Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_subr.c
Show First 20 Lines • Show All 1,680 Lines • ▼ Show 20 Lines | #ifdef INET | ||||
ip->ip_src = inp->inp_laddr; | ip->ip_src = inp->inp_laddr; | ||||
ip->ip_dst = inp->inp_faddr; | ip->ip_dst = inp->inp_faddr; | ||||
} | } | ||||
#endif /* INET */ | #endif /* INET */ | ||||
th->th_sport = inp->inp_lport; | th->th_sport = inp->inp_lport; | ||||
th->th_dport = inp->inp_fport; | th->th_dport = inp->inp_fport; | ||||
th->th_seq = 0; | th->th_seq = 0; | ||||
th->th_ack = 0; | th->th_ack = 0; | ||||
th->th_x2 = 0; | |||||
th->th_off = 5; | th->th_off = 5; | ||||
th->th_flags = 0; | tcp_set_flags(th, 0); | ||||
th->th_win = 0; | th->th_win = 0; | ||||
th->th_urp = 0; | th->th_urp = 0; | ||||
th->th_sum = 0; /* in_pseudo() is called later for ipv4 */ | th->th_sum = 0; /* in_pseudo() is called later for ipv4 */ | ||||
} | } | ||||
/* | /* | ||||
* Create template to be used to send tcp packets on a connection. | * Create template to be used to send tcp packets on a connection. | ||||
* Allocates an mbuf and fills in a skeletal tcp/ip header. The only | * Allocates an mbuf and fills in a skeletal tcp/ip header. The only | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | #ifdef INET6 | ||||
struct ip6_hdr *ip6; | struct ip6_hdr *ip6; | ||||
int isipv6; | int isipv6; | ||||
#endif /* INET6 */ | #endif /* INET6 */ | ||||
int optlen, tlen, win, ulen; | int optlen, tlen, win, ulen; | ||||
bool incl_opts; | bool incl_opts; | ||||
uint16_t port; | uint16_t port; | ||||
int output_ret; | int output_ret; | ||||
#ifdef INVARIANTS | #ifdef INVARIANTS | ||||
int thflags = th->th_flags; | int thflags = tcp_get_flags(th); | ||||
#endif | #endif | ||||
KASSERT(tp != NULL || m != NULL, ("tcp_respond: tp and m both NULL")); | KASSERT(tp != NULL || m != NULL, ("tcp_respond: tp and m both NULL")); | ||||
NET_EPOCH_ASSERT(); | NET_EPOCH_ASSERT(); | ||||
#ifdef INET6 | #ifdef INET6 | ||||
isipv6 = ((struct ip *)ipgen)->ip_v == (IPV6_VERSION >> 4); | isipv6 = ((struct ip *)ipgen)->ip_v == (IPV6_VERSION >> 4); | ||||
ip6 = ipgen; | ip6 = ipgen; | ||||
▲ Show 20 Lines • Show All 253 Lines • ▼ Show 20 Lines | if (inp != NULL) { | ||||
* Packet is not associated with a socket, so possibly | * Packet is not associated with a socket, so possibly | ||||
* update the label in place. | * update the label in place. | ||||
*/ | */ | ||||
mac_netinet_tcp_reply(m); | mac_netinet_tcp_reply(m); | ||||
} | } | ||||
#endif | #endif | ||||
nth->th_seq = htonl(seq); | nth->th_seq = htonl(seq); | ||||
nth->th_ack = htonl(ack); | nth->th_ack = htonl(ack); | ||||
nth->th_x2 = 0; | |||||
nth->th_off = (sizeof (struct tcphdr) + optlen) >> 2; | nth->th_off = (sizeof (struct tcphdr) + optlen) >> 2; | ||||
nth->th_flags = flags; | tcp_set_flags(nth, flags); | ||||
if (tp != NULL) | if (tp != NULL) | ||||
nth->th_win = htons((u_short) (win >> tp->rcv_scale)); | nth->th_win = htons((u_short) (win >> tp->rcv_scale)); | ||||
else | else | ||||
nth->th_win = htons((u_short)win); | nth->th_win = htons((u_short)win); | ||||
nth->th_urp = 0; | nth->th_urp = 0; | ||||
#if defined(IPSEC_SUPPORT) || defined(TCP_SIGNATURE) | #if defined(IPSEC_SUPPORT) || defined(TCP_SIGNATURE) | ||||
if (to.to_flags & TOF_SIGNATURE) { | if (to.to_flags & TOF_SIGNATURE) { | ||||
▲ Show 20 Lines • Show All 2,026 Lines • ▼ Show 20 Lines | #ifdef INET | ||||
sprintf(sp, "]:%i", ntohs(th->th_dport)); | sprintf(sp, "]:%i", ntohs(th->th_dport)); | ||||
#endif /* INET */ | #endif /* INET */ | ||||
} else { | } else { | ||||
free(s, M_TCPLOG); | free(s, M_TCPLOG); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
sp = s + strlen(s); | sp = s + strlen(s); | ||||
if (th) | if (th) | ||||
sprintf(sp, " tcpflags 0x%b", th->th_flags, PRINT_TH_FLAGS); | sprintf(sp, " tcpflags 0x%b", tcp_get_flags(th), PRINT_TH_FLAGS); | ||||
if (*(s + size - 1) != '\0') | if (*(s + size - 1) != '\0') | ||||
panic("%s: string too long", __func__); | panic("%s: string too long", __func__); | ||||
return (s); | return (s); | ||||
} | } | ||||
/* | /* | ||||
* A subroutine which makes it easy to track TCP state changes with DTrace. | * A subroutine which makes it easy to track TCP state changes with DTrace. | ||||
* This function shouldn't be called for t_state initializations that don't | * This function shouldn't be called for t_state initializations that don't | ||||
▲ Show 20 Lines • Show All 147 Lines • Show Last 20 Lines |