PUD: check downlink header fields in correct order
authorFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 19 Apr 2012 07:32:16 +0000 (09:32 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 19 Apr 2012 10:08:04 +0000 (12:08 +0200)
The length field comes before the IPv6 flag.

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/pud/src/pud.c

index 8c1a13d..c354f80 100644 (file)
@@ -191,14 +191,6 @@ static void packetReceivedFromDownlink(int skfd, void *data __attribute__ ((unus
                                continue;
                        }
 
-                       ipv6 = getUplinkMessageIPv6(&msg->header);
-                       if (unlikely(ipv6 && (olsr_cnf->ip_version != AF_INET6))) {
-                               pudError(false, "Received wrong IPv6 status (%s) in %s,"
-                                               " ignoring message.", (ipv6 ? "true" : "false"),
-                                               __func__);
-                               continue;
-                       }
-
                        olsrMessageLength = getUplinkMessageLength(&msg->header);
                        uplinkMessageLength = olsrMessageLength + sizeof(UplinkHeader);
 
@@ -209,6 +201,14 @@ static void packetReceivedFromDownlink(int skfd, void *data __attribute__ ((unus
                                break;
                        }
 
+                       ipv6 = getUplinkMessageIPv6(&msg->header);
+                       if (unlikely(ipv6 && (olsr_cnf->ip_version != AF_INET6))) {
+                               pudError(false, "Received wrong IPv6 status (%s) in %s,"
+                                               " ignoring message.", (ipv6 ? "true" : "false"),
+                                               __func__);
+                               continue;
+                       }
+
                        olsrMessage = &msg->msg.olsrMessage;
 
                        /* we now have a position update (olsrMessage) of a certain length