libnet: avoid failing setting up filter with e1000 like cardnames
authorRoni Häcki <roni.haecki@inf.ethz.ch>
Mon, 18 Sep 2017 14:00:53 +0000 (16:00 +0200)
committerRoni Häcki <roni.haecki@inf.ethz.ch>
Mon, 18 Sep 2017 14:00:53 +0000 (16:00 +0200)
e1000 cardname was of the form e1000:vendor:bus:device:function ..
where other cardnames were simply in the form of the name itself.

Signed-off-by: Roni Häcki <roni.haecki@inf.ethz.ch>

lib/net/net_filter.c

index 34dde6d..1ed167b 100644 (file)
@@ -148,7 +148,20 @@ errval_t net_filter_init(struct net_filter_state** st,
     tmp->filters_mac.start = NULL;
     tmp->filters_mac.num_ele = 0;
 
-    err = connect_to_net_filter(tmp, cardname);
+    // cardname are of the form name:vendor:device:bus:function ..
+    int end = 0;
+    for (; end < strlen(cardname); end++) {
+        if (cardname[end] == ':') {
+            break;
+        }
+    }
+
+    char name[64];
+    strncpy(name, cardname, end);
+    name[end] = '\0';
+
+    printf("cardname %s \n", name);
+    err = connect_to_net_filter(tmp, name);
     *st = tmp;
     return err;
 }