nfctool: Set sniffer buffer large enough to handle MAX_MIU bytes frames
authorThierry Escande <thierry.escande@linux.intel.com>
Mon, 8 Apr 2013 16:55:27 +0000 (18:55 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 11 Apr 2013 11:52:48 +0000 (13:52 +0200)
This fixes the size of the recv buffer for the sniffer. Frames can be
up to 7ff+128+(llcp, seq, and raw headers) bytes.

tools/nfctool/sniffer.c

index 2e89ddc..062925a 100644 (file)
@@ -47,7 +47,7 @@
 #define PCAP_SNAP_LEN 0xFFFF
 #define PCAP_NETWORK 0xF5
 
-#define SNAP_LEN 1024
+#define BUFFER_LEN 0x8FF
 
 static GIOChannel *gio_channel = NULL;
 guint watch = 0;
@@ -251,7 +251,7 @@ static gboolean gio_handler(GIOChannel *channel,
        msg.msg_iov = &iov;
        msg.msg_iovlen = 1;
        iov.iov_base = buffer;
-       iov.iov_len = opts.snap_len;
+       iov.iov_len = BUFFER_LEN;
 
        len = recvmsg(sock, &msg, 0);
        if (len < 0) {
@@ -295,10 +295,7 @@ int sniffer_init(void)
        int err;
        int one = 1;
 
-       if (opts.snap_len < SNAP_LEN)
-               opts.snap_len = SNAP_LEN;
-
-       buffer = g_malloc(opts.snap_len);
+       buffer = g_malloc(BUFFER_LEN);
 
        sock = socket(AF_NFC, SOCK_RAW, NFC_SOCKPROTO_LLCP);