173 |
#if UDP_DEBUG |
#if UDP_DEBUG |
174 |
udp_debug_print(udphdr); |
udp_debug_print(udphdr); |
175 |
#endif /* UDP_DEBUG */ |
#endif /* UDP_DEBUG */ |
176 |
|
|
177 |
/* Demultiplex packet. First, go for a perfect match. */ |
/* Iterate through the UDP pcb list for a fully matching pcb */ |
178 |
for(pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) { |
for(pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) { |
179 |
DEBUGF(UDP_DEBUG, ("udp_input: pcb local port %d (dgram %d)\n", |
DEBUGF(UDP_DEBUG, ("udp_input: pcb local port %u, dgram dest port %u)\n", |
180 |
pcb->local_port, ntohs(udphdr->dest))); |
pcb->local_port, ntohs(udphdr->dest))); |
181 |
|
DEBUGF(UDP_DEBUG, (" pcb remote ip: %d.%d.%d.%d, dgram src: %d.%d.%d.%d,\n", |
182 |
|
ip4_addr1(&pcb->remote_ip), ip4_addr2(&pcb->remote_ip), |
183 |
|
ip4_addr3(&pcb->remote_ip), ip4_addr4(&pcb->remote_ip), |
184 |
|
ip4_addr1(&iphdr->src), ip4_addr2(&iphdr->src), |
185 |
|
ip4_addr3(&iphdr->src), ip4_addr4(&iphdr->src))); |
186 |
|
DEBUGF(UDP_DEBUG, (" pcb local ip: %d.%d.%d.%d, dgram dest: %d.%d.%d.%d\n", |
187 |
|
ip4_addr1(&pcb->local_ip), ip4_addr2(&pcb->local_ip), |
188 |
|
ip4_addr3(&pcb->local_ip), ip4_addr4(&pcb->local_ip), |
189 |
|
ip4_addr1(&iphdr->dest), ip4_addr2(&iphdr->dest), |
190 |
|
ip4_addr3(&iphdr->dest), ip4_addr4(&iphdr->dest))); |
191 |
|
|
192 |
|
/* Do both local and remote addresses match? */ |
193 |
if(pcb->remote_port == src && |
if(pcb->remote_port == src && |
194 |
pcb->local_port == dest && |
pcb->local_port == dest && |
195 |
(ip_addr_isany(&pcb->remote_ip) || |
(ip_addr_isany(&pcb->remote_ip) || |
199 |
break; |
break; |
200 |
} |
} |
201 |
} |
} |
202 |
|
/* no fully matching pcb found? */ |
203 |
if(pcb == NULL) { |
if(pcb == NULL) { |
204 |
|
/* Iterate through the UDP pcb list for a pcb that matches |
205 |
|
the local address. */ |
206 |
for(pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) { |
for(pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) { |
207 |
DEBUGF(UDP_DEBUG, ("udp_input: pcb local port %d (dgram %d)\n", |
DEBUGF(UDP_DEBUG, ("udp_input: pcb local port %d (dgram %d)\n", |
208 |
pcb->local_port, dest)); |
pcb->local_port, dest)); |