libnet: adding hardware filter for udp ping test
authorRoni Häcki <roni.haecki@inf.ethz.ch>
Thu, 20 Apr 2017 15:24:30 +0000 (17:24 +0200)
committerRoni Häcki <roni.haecki@inf.ethz.ch>
Thu, 20 Apr 2017 15:24:30 +0000 (17:24 +0200)
Signed-off-by: Roni Häcki <roni.haecki@inf.ethz.ch>

lib/net/test/udp_ping.c

index d12c6ed..9e20705 100644 (file)
@@ -193,9 +193,16 @@ int main(int argc, char *argv[])
 
     debug_printf("PING pcb created.\n");
 
-    udp_recv(ping_pcb, ping_recv, NULL);
     udp_bind(ping_pcb, IP_ADDR_ANY, UDP_ECHOSERVER_PORT);
 
+    udp_recv(ping_pcb, ping_recv, NULL);
+
+    err = networking_install_ip_filter(false, (ip_addr_t*) IP_ADDR_ANY, 
+                                       0, UDP_ECHOSERVER_PORT);    
+    if (err_is_fail(err)) {
+        USER_PANIC("Adding filter failed %s \n", err_getstring(err));
+    }
+
     sys_timeout(PING_DELAY, ping_timeout, ping_pcb);