FreeBSD/sys/netinet/toecore.c
/*
 * General purpose check to see if a 4-tuple is in use by the kernel.  If a TCP
 * header (presumably for an incoming SYN) is also provided, an existing 4-tuple
 * in TIME_WAIT may be assassinated freeing it up for re-use.
 *
 * Note that the TCP header must have been run through tcp_fields_to_host() or
 * equivalent.
 */
General purpose check to see if a 4-tuple is in use by the kernel.  If a TCP
header (presumably for an incoming SYN) is also provided, an existing 4-tuple
in TIME_WAIT may be assassinated freeing it up for re-use.

Note that the TCP header must have been run through tcp_fields_to_host() or
equivalent.
General purpose check to see if a 4 - tuple is in use by the kernel . If a TCP header ( presumably for an incoming SYN ) is also provided an existing 4 - tuple in TIME_WAIT may be assassinated freeing it up for re - use . Note that the TCP header must have been run through tcp_fields_to_host () or equivalent .
int
toe_4tuple_check(struct in_conninfo *inc, struct tcphdr *th, struct ifnet *ifp)
{
	struct inpcb *inp;
	if (inc->inc_flags & INC_ISIPV6) {
		inp = in6_pcblookup(&V_tcbinfo, &inc->inc6_faddr,
		    inc->inc_fport, &inc->inc6_laddr, inc->inc_lport,
		    INPLOOKUP_WLOCKPCB, ifp);
	} else {
		inp = in_pcblookup(&V_tcbinfo, inc->inc_faddr, inc->inc_fport,
		    inc->inc_laddr, inc->inc_lport, INPLOOKUP_WLOCKPCB, ifp);
	}
	if (inp != NULL) {
		INP_WLOCK_ASSERT(inp);
		if ((inp->inp_flags & INP_TIMEWAIT) && th != NULL) {
			INP_INFO_RLOCK_ASSERT(&V_tcbinfo); 
			if (!tcp_twcheck(inp, NULL, th, NULL, 0))
				return (EADDRINUSE);
		} else {
			INP_WUNLOCK(inp);
			return (EADDRINUSE);
		}
	}
	return (0);
}
int toe_4tuple_check ( struct in_conninfo * inc , struct tcphdr * th , struct ifnet * ifp ) { struct inpcb * inp ; if ( inc -> inc_flags & INC_ISIPV6 ) { inp = in6_pcblookup ( & V_tcbinfo , & inc -> inc6_faddr , inc -> inc_fport , & inc -> inc6_laddr , inc -> inc_lport , INPLOOKUP_WLOCKPCB , ifp ) ; } else { inp = in_pcblookup ( & V_tcbinfo , inc -> inc_faddr , inc -> inc_fport , inc -> inc_laddr , inc -> inc_lport , INPLOOKUP_WLOCKPCB , ifp ) ; } if ( inp != NULL ) { INP_WLOCK_ASSERT ( inp ) ; if ( ( inp -> inp_flags & INP_TIMEWAIT ) && th != NULL ) { INP_INFO_RLOCK_ASSERT ( & V_tcbinfo ) ; if ( ! tcp_twcheck ( inp , NULL , th , NULL , 0 ) ) return ( EADDRINUSE ) ; } else { INP_WUNLOCK ( inp ) ; return ( EADDRINUSE ) ; } } return ( 0 ) ; }
General purpose check to see if a 4-tuple is in use by the kernel.
General purpose check to see if a 4 - tuple is in use by the kernel .
/* for twcheck */