]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
af-packet: get datalink for each socket creation.
authorEric Leblond <eric@regit.org>
Mon, 11 Jun 2012 21:23:32 +0000 (23:23 +0200)
committerVictor Julien <victor@inliniac.net>
Fri, 29 Jun 2012 11:10:02 +0000 (13:10 +0200)
This patch will allow us to use the datalink when computing the filter.
It also fixes a potential issue where an interface data type change
after the interface if going down/up.

src/source-af-packet.c

index 1ce85ef93b3e2f256d4017aadf70349934b776fa..24e6caf1c91c74e8e7cecf1d25e711e3e56fd725 100644 (file)
@@ -844,6 +844,13 @@ static int AFPCreateSocket(AFPThreadVars *ptv, char *devname, int verbose)
     }
 #endif
 
+    ptv->datalink = AFPGetDevLinktype(ptv->socket, ptv->iface);
+    switch (ptv->datalink) {
+        case ARPHRD_PPP:
+        case ARPHRD_ATM:
+            ptv->cooked = 1;
+    }
+
     /* Init is ok */
     ptv->afp_state = AFP_STATE_UP;
     return 0;
@@ -922,12 +929,7 @@ TmEcode ReceiveAFPThreadInit(ThreadVars *tv, void *initdata, void **data) {
         SCReturnInt(TM_ECODE_FAILED);
     }
 
-    ptv->datalink = AFPGetDevLinktype(ptv->socket, ptv->iface);
-    switch (ptv->datalink) {
-        case ARPHRD_PPP:
-        case ARPHRD_ATM:
-            ptv->cooked = 1;
-    }
+
 
 #define T_DATA_SIZE 70000
     ptv->data = SCMalloc(T_DATA_SIZE);