| version 1.17, 1995/06/04 05:07:20 |
version 1.18, 1995/06/12 00:48:06 |
| 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 = &udb; |
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)); |
| Line 77 static struct mbuf *udp_saveopt __P((cad |
|
| Line 77 static struct mbuf *udp_saveopt __P((cad |
|
| void |
void |
| udp_init() |
udp_init() |
| { |
{ |
| udb.inp_next = udb.inp_prev = &udb; |
|
| |
in_pcbinit(&udbtable); |
| } |
} |
| |
|
| void |
void |
| Line 183 udp_input(m, iphlen) |
|
| Line 184 udp_input(m, iphlen) |
|
| * (Algorithm copied from raw_intr().) |
* (Algorithm copied from raw_intr().) |
| */ |
*/ |
| last = NULL; |
last = NULL; |
| for (inp = udb.inp_next; inp != &udb; inp = inp->inp_next) { |
for (inp = udbtable.inpt_list.lh_first; inp != 0; |
| |
inp = inp->inp_list.le_next) { |
| if (inp->inp_lport != uh->uh_dport) |
if (inp->inp_lport != uh->uh_dport) |
| continue; |
continue; |
| if (inp->inp_laddr.s_addr != INADDR_ANY) { |
if (inp->inp_laddr.s_addr != INADDR_ANY) { |
| Line 245 udp_input(m, iphlen) |
|
| Line 247 udp_input(m, iphlen) |
|
| * Locate pcb for datagram. |
* Locate pcb for datagram. |
| */ |
*/ |
| inp = udp_last_inpcb; |
inp = udp_last_inpcb; |
| if (inp->inp_lport != uh->uh_dport || |
if (inp == 0 || |
| |
inp->inp_lport != uh->uh_dport || |
| inp->inp_fport != uh->uh_sport || |
inp->inp_fport != uh->uh_sport || |
| inp->inp_faddr.s_addr != ip->ip_src.s_addr || |
inp->inp_faddr.s_addr != ip->ip_src.s_addr || |
| inp->inp_laddr.s_addr != ip->ip_dst.s_addr) { |
inp->inp_laddr.s_addr != ip->ip_dst.s_addr) { |
| inp = in_pcblookup(&udb, ip->ip_src, uh->uh_sport, |
|
| ip->ip_dst, uh->uh_dport, INPLOOKUP_WILDCARD); |
|
| if (inp) |
|
| udp_last_inpcb = inp; |
|
| udpstat.udpps_pcbcachemiss++; |
udpstat.udpps_pcbcachemiss++; |
| } |
inp = in_pcblookup(&udbtable, ip->ip_src, uh->uh_sport, |
| if (inp == 0) { |
ip->ip_dst, uh->uh_dport, INPLOOKUP_WILDCARD); |
| udpstat.udps_noport++; |
if (inp == 0) { |
| if (m->m_flags & (M_BCAST | M_MCAST)) { |
udpstat.udps_noport++; |
| udpstat.udps_noportbcast++; |
if (m->m_flags & (M_BCAST | M_MCAST)) { |
| goto bad; |
udpstat.udps_noportbcast++; |
| |
goto bad; |
| |
} |
| |
*ip = save_ip; |
| |
ip->ip_len += iphlen; |
| |
icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PORT, 0, 0); |
| |
return; |
| } |
} |
| *ip = save_ip; |
udp_last_inpcb = inp; |
| ip->ip_len += iphlen; |
|
| icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PORT, 0, 0); |
|
| return; |
|
| } |
} |
| |
|
| /* |
/* |
| Line 364 udp_ctlinput(cmd, sa, ip) |
|
| Line 366 udp_ctlinput(cmd, sa, ip) |
|
| register struct udphdr *uh; |
register struct udphdr *uh; |
| extern struct in_addr zeroin_addr; |
extern struct in_addr zeroin_addr; |
| extern u_char inetctlerrmap[]; |
extern u_char inetctlerrmap[]; |
| |
void (*notify) __P((struct inpcb *, int)) = udp_notify; |
| |
|
| if (!PRC_IS_REDIRECT(cmd) && |
if (PRC_IS_REDIRECT(cmd)) |
| ((unsigned)cmd >= PRC_NCMDS || inetctlerrmap[cmd] == 0)) |
notify = in_rtchange; |
| |
else if (cmd == PRC_HOSTDEAD) |
| |
; |
| |
else if ((unsigned)cmd >= PRC_NCMDS || inetctlerrmap[cmd] == 0) |
| return; |
return; |
| if (ip) { |
else if (ip) { |
| uh = (struct udphdr *)((caddr_t)ip + (ip->ip_hl << 2)); |
uh = (struct udphdr *)((caddr_t)ip + (ip->ip_hl << 2)); |
| in_pcbnotify(&udb, sa, uh->uh_dport, ip->ip_src, uh->uh_sport, |
in_pcbnotify(&udbtable, sa, uh->uh_dport, ip->ip_src, |
| cmd, udp_notify); |
uh->uh_sport, cmd, notify); |
| } else |
return; |
| in_pcbnotify(&udb, sa, 0, zeroin_addr, 0, cmd, udp_notify); |
} |
| |
in_pcbnotifyall(&udbtable, sa, cmd, notify); |
| } |
} |
| |
|
| int |
int |
| Line 498 udp_usrreq(so, req, m, addr, control) |
|
| Line 505 udp_usrreq(so, req, m, addr, control) |
|
| break; |
break; |
| } |
} |
| s = splnet(); |
s = splnet(); |
| error = in_pcballoc(so, &udb); |
error = in_pcballoc(so, &udbtable); |
| splx(s); |
splx(s); |
| if (error) |
if (error) |
| break; |
break; |
|
|
| int s = splnet(); |
int s = splnet(); |
| |
|
| if (inp == udp_last_inpcb) |
if (inp == udp_last_inpcb) |
| udp_last_inpcb = &udb; |
udp_last_inpcb = 0; |
| in_pcbdetach(inp); |
in_pcbdetach(inp); |
| splx(s); |
splx(s); |
| } |
} |