--- libaitio/src/bpf.c 2013/06/25 10:58:22 1.1.2.11 +++ libaitio/src/bpf.c 2013/06/25 16:42:41 1.1.2.12 @@ -122,24 +122,13 @@ io_etherOpen(const char *csIface, int flags, int whdr, return -1; } - if (ioctl(eth, BIOCIMMEDIATE, &n) == -1) { - LOGERR; - close(eth); - return -1; - } - if (whdr && ioctl(eth, BIOCSHDRCMPLT, &n) == -1) { - LOGERR; - close(eth); - return -1; - } - if (!zcbuf) { if (ioctl(eth, BIOCGBLEN, &n) == -1) { LOGERR; close(eth); return -1; } else - n = (buflen && *buflen) ? MIN(n, *buflen) : n; + n = (buflen && *buflen) ? *buflen : n; if (ioctl(eth, BIOCSBLEN, &n) == -1) { LOGERR; close(eth); @@ -160,7 +149,7 @@ io_etherOpen(const char *csIface, int flags, int whdr, close(eth); return -1; } else - n = (buflen && *buflen) ? MIN(n, *buflen) : n; + n = (buflen && *buflen) ? *buflen : n; if (!(*zcbuf = allocZCbuf(n))) { close(eth); return -1; @@ -173,6 +162,17 @@ io_etherOpen(const char *csIface, int flags, int whdr, if (buflen && *buflen) *buflen = n; #endif + } + + if (ioctl(eth, BIOCIMMEDIATE, &n) == -1) { + LOGERR; + close(eth); + return -1; + } + if (whdr && ioctl(eth, BIOCSHDRCMPLT, &n) == -1) { + LOGERR; + close(eth); + return -1; } if (csIface)