Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet6/udp6_usrreq.c
Show First 20 Lines • Show All 697 Lines • ▼ Show 20 Lines | udp6_output(struct socket *so, int flags_arg, struct mbuf *m, | ||||
u_int32_t ulen, plen; | u_int32_t ulen, plen; | ||||
uint16_t cscov; | uint16_t cscov; | ||||
u_short fport; | u_short fport; | ||||
uint8_t nxt, unlock_inp, unlock_udbinfo; | uint8_t nxt, unlock_inp, unlock_udbinfo; | ||||
/* addr6 has been validated in udp6_send(). */ | /* addr6 has been validated in udp6_send(). */ | ||||
sin6 = (struct sockaddr_in6 *)addr6; | sin6 = (struct sockaddr_in6 *)addr6; | ||||
/* | |||||
* In contrast to to IPv4 we do not validate the max. packet length | |||||
* here due to IPv6 Jumbograms (RFC2675). | |||||
*/ | |||||
scope_ambiguous = 0; | scope_ambiguous = 0; | ||||
if (sin6) { | if (sin6) { | ||||
/* Protect *addr6 from overwrites. */ | /* Protect *addr6 from overwrites. */ | ||||
tmp = *sin6; | tmp = *sin6; | ||||
sin6 = &tmp; | sin6 = &tmp; | ||||
/* | /* | ||||
* Application should provide a proper zone ID or the use of | * Application should provide a proper zone ID or the use of | ||||
▲ Show 20 Lines • Show All 167 Lines • ▼ Show 20 Lines | if (sin6) { | ||||
faddr = &inp->in6p_faddr; | faddr = &inp->in6p_faddr; | ||||
fport = inp->inp_fport; | fport = inp->inp_fport; | ||||
} | } | ||||
ulen = m->m_pkthdr.len; | ulen = m->m_pkthdr.len; | ||||
plen = sizeof(struct udphdr) + ulen; | plen = sizeof(struct udphdr) + ulen; | ||||
hlen = sizeof(struct ip6_hdr); | hlen = sizeof(struct ip6_hdr); | ||||
if (plen > IPV6_MAXPACKET) { | |||||
error = EMSGSIZE; | |||||
goto release; | |||||
} | |||||
/* | /* | ||||
* Calculate data length and get a mbuf | * Calculate data length and get a mbuf | ||||
* for UDP and IP6 headers. | * for UDP and IP6 headers. | ||||
*/ | */ | ||||
M_PREPEND(m, hlen + sizeof(struct udphdr), M_NOWAIT); | M_PREPEND(m, hlen + sizeof(struct udphdr), M_NOWAIT); | ||||
if (m == NULL) { | if (m == NULL) { | ||||
error = ENOBUFS; | error = ENOBUFS; | ||||
goto release; | goto release; | ||||
Show All 14 Lines | if (nxt == IPPROTO_UDPLITE) { | ||||
if (cscov >= plen) | if (cscov >= plen) | ||||
cscov = 0; | cscov = 0; | ||||
udp6->uh_ulen = htons(cscov); | udp6->uh_ulen = htons(cscov); | ||||
/* | /* | ||||
* For UDP-Lite, checksum coverage length of zero means | * For UDP-Lite, checksum coverage length of zero means | ||||
* the entire UDPLite packet is covered by the checksum. | * the entire UDPLite packet is covered by the checksum. | ||||
*/ | */ | ||||
cscov_partial = (cscov == 0) ? 0 : 1; | cscov_partial = (cscov == 0) ? 0 : 1; | ||||
} else if (plen <= 0xffff) | } else | ||||
udp6->uh_ulen = htons((u_short)plen); | udp6->uh_ulen = htons((u_short)plen); | ||||
else | |||||
udp6->uh_ulen = 0; | |||||
udp6->uh_sum = 0; | udp6->uh_sum = 0; | ||||
ip6 = mtod(m, struct ip6_hdr *); | ip6 = mtod(m, struct ip6_hdr *); | ||||
ip6->ip6_flow = inp->inp_flow & IPV6_FLOWINFO_MASK; | ip6->ip6_flow = inp->inp_flow & IPV6_FLOWINFO_MASK; | ||||
ip6->ip6_vfc &= ~IPV6_VERSION_MASK; | ip6->ip6_vfc &= ~IPV6_VERSION_MASK; | ||||
ip6->ip6_vfc |= IPV6_VERSION; | ip6->ip6_vfc |= IPV6_VERSION; | ||||
ip6->ip6_plen = htons((u_short)plen); | ip6->ip6_plen = htons((u_short)plen); | ||||
ip6->ip6_nxt = nxt; | ip6->ip6_nxt = nxt; | ||||
▲ Show 20 Lines • Show All 445 Lines • Show Last 20 Lines |