lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] [patch] raw_bind should filter received packets


From: Chris Paulson-Ellis
Subject: [lwip-users] [patch] raw_bind should filter received packets
Date: Wed, 06 Jan 2010 18:29:42 +0000
User-agent: Thunderbird 2.0.0.19 (X11/20090220)

I would expect raw_bind to filter the packets passed to the raw_recv callback 
in the same way as udp_bind does to the udp_recv callback and unix bind(2) does 
on a raw(7) socket.

The follow patch makes bound raw pcbs behave in a similar way to bound udp pcbs.

Regards,
Chris.

--- lwip-1.3.2/src/core/raw.c.orig      2009-12-24 15:38:19.000000000 +0000
+++ lwip-1.3.2/src/core/raw.c   2010-01-06 15:43:41.000000000 +0000
@@ -92,7 +92,9 @@
   /* loop through all raw pcbs until the packet is eaten by one */
   /* this allows multiple pcbs to match against the packet by design */
   while ((eaten == 0) && (pcb != NULL)) {
-    if (pcb->protocol == proto) {
+    if ((pcb->protocol == proto) &&
+        ((!ip_addr_isbroadcast(&(iphdr->dest), inp) && 
ip_addr_isany(&pcb->local_ip)) ||
+         ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest)))) {
 #if IP_SOF_BROADCAST_RECV
       /* broadcast filter? */
       if ((pcb->so_options & SOF_BROADCAST) || 
!ip_addr_isbroadcast(&(iphdr->dest), inp))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]