| version 1.24.2.1, 1996/02/02 06:13:02 |
version 1.25, 1995/11/21 01:07:46 |
| Line 68 int udpcksum = 0; /* XXX */ |
|
| Line 68 int udpcksum = 0; /* XXX */ |
|
| #endif |
#endif |
| |
|
| struct sockaddr_in udp_in = { sizeof(udp_in), AF_INET }; |
struct sockaddr_in udp_in = { sizeof(udp_in), AF_INET }; |
| |
struct inpcb *udp_last_inpcb = 0; |
| |
|
| static void udp_detach __P((struct inpcb *)); |
static void udp_detach __P((struct inpcb *)); |
| static void udp_notify __P((struct inpcb *, int)); |
static void udp_notify __P((struct inpcb *, int)); |
| static struct mbuf *udp_saveopt __P((caddr_t, int, int)); |
static struct mbuf *udp_saveopt __P((caddr_t, int, int)); |
| |
|
| #ifndef UDBHASHSIZE |
|
| #define UDBHASHSIZE 128 |
|
| #endif |
|
| int udbhashsize = UDBHASHSIZE; |
|
| |
|
| void |
void |
| udp_init() |
udp_init() |
| { |
{ |
| |
|
| in_pcbinit(&udbtable, udbhashsize); |
in_pcbinit(&udbtable); |
| } |
} |
| |
|
| void |
void |
| Line 146 udp_input(m, iphlen) |
|
| Line 142 udp_input(m, iphlen) |
|
| * Checksum extended UDP header and data. |
* Checksum extended UDP header and data. |
| */ |
*/ |
| if (udpcksum && uh->uh_sum) { |
if (udpcksum && uh->uh_sum) { |
| ((struct ipovly *)ip)->ih_next = 0; |
bzero(((struct ipovly *)ip)->ih_x1, |
| ((struct ipovly *)ip)->ih_prev = 0; |
sizeof ((struct ipovly *)ip)->ih_x1); |
| ((struct ipovly *)ip)->ih_x1 = 0; |
|
| ((struct ipovly *)ip)->ih_len = uh->uh_ulen; |
((struct ipovly *)ip)->ih_len = uh->uh_ulen; |
| if (uh->uh_sum = in_cksum(m, len + sizeof (struct ip))) { |
if (uh->uh_sum = in_cksum(m, len + sizeof (struct ip))) { |
| udpstat.udps_badsum++; |
udpstat.udps_badsum++; |
| Line 251 udp_input(m, iphlen) |
|
| Line 246 udp_input(m, iphlen) |
|
| /* |
/* |
| * Locate pcb for datagram. |
* Locate pcb for datagram. |
| */ |
*/ |
| inp = in_pcbhashlookup(&udbtable, ip->ip_src, uh->uh_sport, |
inp = udp_last_inpcb; |
| ip->ip_dst, uh->uh_dport); |
if (inp == 0 || |
| if (inp == 0) { |
inp->inp_lport != uh->uh_dport || |
| ++udpstat.udps_pcbhashmiss; |
inp->inp_fport != uh->uh_sport || |
| |
inp->inp_faddr.s_addr != ip->ip_src.s_addr || |
| |
inp->inp_laddr.s_addr != ip->ip_dst.s_addr) { |
| |
udpstat.udpps_pcbcachemiss++; |
| inp = in_pcblookup(&udbtable, ip->ip_src, uh->uh_sport, |
inp = in_pcblookup(&udbtable, ip->ip_src, uh->uh_sport, |
| ip->ip_dst, uh->uh_dport, INPLOOKUP_WILDCARD); |
ip->ip_dst, uh->uh_dport, INPLOOKUP_WILDCARD); |
| if (inp == 0) { |
if (inp == 0) { |
| Line 268 udp_input(m, iphlen) |
|
| Line 266 udp_input(m, iphlen) |
|
| icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PORT, 0, 0); |
icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PORT, 0, 0); |
| return; |
return; |
| } |
} |
| |
udp_last_inpcb = inp; |
| } |
} |
| |
|
| /* |
/* |
| Line 437 udp_output(inp, m, addr, control) |
|
| Line 436 udp_output(inp, m, addr, control) |
|
| * and addresses and length put into network format. |
* and addresses and length put into network format. |
| */ |
*/ |
| ui = mtod(m, struct udpiphdr *); |
ui = mtod(m, struct udpiphdr *); |
| ui->ui_next = ui->ui_prev = 0; |
bzero(ui->ui_x1, sizeof ui->ui_x1); |
| ui->ui_x1 = 0; |
|
| ui->ui_pr = IPPROTO_UDP; |
ui->ui_pr = IPPROTO_UDP; |
| ui->ui_len = htons((u_int16_t)len + sizeof (struct udphdr)); |
ui->ui_len = htons((u_int16_t)len + sizeof (struct udphdr)); |
| ui->ui_src = inp->inp_laddr; |
ui->ui_src = inp->inp_laddr; |
|
|
| { |
{ |
| int s = splsoftnet(); |
int s = splsoftnet(); |
| |
|
| |
if (inp == udp_last_inpcb) |
| |
udp_last_inpcb = 0; |
| in_pcbdetach(inp); |
in_pcbdetach(inp); |
| splx(s); |
splx(s); |
| } |
} |