version 1.134, 2005/03/11 06:16:16 |
version 1.134.2.4, 2005/05/06 08:40:21 |
Line 146 int udpcksum = 1; |
|
Line 146 int udpcksum = 1; |
|
#else |
#else |
int udpcksum = 0; /* XXX */ |
int udpcksum = 0; /* XXX */ |
#endif |
#endif |
int udp_do_loopback_cksum = 0; |
|
|
|
struct inpcbtable udbtable; |
struct inpcbtable udbtable; |
struct udpstat udpstat; |
struct udpstat udpstat; |
Line 1080 udp_output(struct mbuf *m, ...) |
|
Line 1079 udp_output(struct mbuf *m, ...) |
|
/* |
/* |
* XXX Cache pseudo-header checksum part for |
* XXX Cache pseudo-header checksum part for |
* XXX "connected" UDP sockets. |
* XXX "connected" UDP sockets. |
* Maybe skip checksums on loopback interfaces. |
|
*/ |
*/ |
ui->ui_sum = in_cksum_phdr(ui->ui_src.s_addr, |
ui->ui_sum = in_cksum_phdr(ui->ui_src.s_addr, |
ui->ui_dst.s_addr, htons((u_int16_t)len + |
ui->ui_dst.s_addr, htons((u_int16_t)len + |
sizeof(struct udphdr) + IPPROTO_UDP)); |
sizeof(struct udphdr) + IPPROTO_UDP)); |
if (__predict_true(ro->ro_rt == NULL || |
m->m_pkthdr.csum_flags = M_CSUM_UDPv4; |
!(ro->ro_rt->rt_ifp->if_flags & |
|
IFF_LOOPBACK) || |
|
udp_do_loopback_cksum)) |
|
m->m_pkthdr.csum_flags = M_CSUM_UDPv4; |
|
else |
|
m->m_pkthdr.csum_flags = 0; |
|
m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum); |
m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum); |
} else |
} else |
ui->ui_sum = 0; |
ui->ui_sum = 0; |
Line 1365 udp4_espinudp(m, off, src, so) |
|
Line 1357 udp4_espinudp(m, off, src, so) |
|
size_t iphdrlen; |
size_t iphdrlen; |
struct ip *ip; |
struct ip *ip; |
struct mbuf *n; |
struct mbuf *n; |
|
struct m_tag *tag; |
|
struct udphdr *udphdr; |
|
u_int16_t sport, dport; |
|
|
/* |
/* |
* Collapse the mbuf chain if the first mbuf is too short |
* Collapse the mbuf chain if the first mbuf is too short |
Line 1415 udp4_espinudp(m, off, src, so) |
|
Line 1410 udp4_espinudp(m, off, src, so) |
|
} |
} |
|
|
/* |
/* |
|
* Get the UDP ports. They are handled in network |
|
* order everywhere in IPSEC_NAT_T code. |
|
*/ |
|
udphdr = (struct udphdr *)(data - skip); |
|
sport = udphdr->uh_sport; |
|
dport = udphdr->uh_dport; |
|
|
|
/* |
* Remove the UDP header (and possibly the non ESP marker) |
* Remove the UDP header (and possibly the non ESP marker) |
* IP header lendth is iphdrlen |
* IP header lendth is iphdrlen |
* Before: |
* Before: |
Line 1447 udp4_espinudp(m, off, src, so) |
|
Line 1450 udp4_espinudp(m, off, src, so) |
|
return 0; |
return 0; |
} |
} |
|
|
|
/* |
|
* Add a PACKET_TAG_IPSEC_NAT_T_PORT tag to remember |
|
* the source UDP port. This is required if we want |
|
* to select the right SPD for multiple hosts behind |
|
* same NAT |
|
*/ |
|
if ((tag = m_tag_get(PACKET_TAG_IPSEC_NAT_T_PORTS, |
|
sizeof(sport) + sizeof(dport), M_DONTWAIT)) == NULL) { |
|
printf("udp4_espinudp: m_tag_get failed\n"); |
|
m_freem(n); |
|
return 0; |
|
} |
|
((u_int16_t *)(tag + 1))[0] = sport; |
|
((u_int16_t *)(tag + 1))[1] = dport; |
|
m_tag_prepend(n, tag); |
|
|
esp4_input(n, iphdrlen); |
esp4_input(n, iphdrlen); |
|
|
/* We handled it, it shoudln't be handled by UDP */ |
/* We handled it, it shoudln't be handled by UDP */ |