From: Eric Leblond Date: Mon, 11 Jun 2012 21:23:32 +0000 (+0200) Subject: af-packet: get datalink for each socket creation. X-Git-Tag: suricata-1.3rc1~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c85ee1e3f64e8319ad3b7cc305d56071c100ad28;p=thirdparty%2Fsuricata.git af-packet: get datalink for each socket creation. 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. --- diff --git a/src/source-af-packet.c b/src/source-af-packet.c index 1ce85ef93b..24e6caf1c9 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -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);