Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy am I getting extra bits in my recv() calls with libnfqueue?
    primarykey
    data
    text
    <p>I'm having problems with the following code. I receive my data with no problems, however that data is loaded with extraneous bits! For example, the following code grabs all traffic directed to it from nfqueue, and prints out each byte followed by a newline. </p> <p>At first the data is exactly what I'd expect, but then there are lines that have seeming 4 bytes on them!</p> <pre><code>int main(int argc, char** argv) { int fd; ssize_t rv; char buf[4096]; struct nfq_handle* h; struct nfq_q_handle* qh; h = nfq_open(); if (!h) { fprintf(stderr, "error during nfq_open()\n"); exit(1); } if (nfq_unbind_pf(h, AF_INET) &lt; 0) { fprintf(stderr, "error during nfq_unbind_pf()\n"); exit(1); } if (nfq_bind_pf(h, AF_INET) &lt; 0) { fprintf(stderr, "error during nfq_bind_pf()\n"); exit(1); } printf("Binding to queue 0...\n"); qh = nfq_create_queue(h, 0, &amp;cb, NULL); if (!qh) { fprintf(stderr, "error during nfq_create_queue()\n"); exit(1); } printf("Copying packets...\n"); if (nfq_set_mode(qh, NFQNL_COPY_PACKET, 0xffff) &lt; 0) { fprintf(stderr, "error during nfq_set_mode()\n"); exit(1); } fd = nfq_fd(h); memset(buf, 0, 4096); while ((rv = recv(fd, buf, sizeof(buf), 0)) &amp;&amp; rv &gt;= 0) { for (int i = 0; i &lt; rv; i++) printf("%02x\n", *(buf+i)); printf("\n\n"); nfq_handle_packet(h, buf, rv); } nfq_destroy_queue(qh); nfq_close(h); } </code></pre> <p>Output:</p> <pre><code>... 50 10 39 08 48 ffffffa4 00 00 ... </code></pre> <p>I couldn't find anything on the internet, or in bug trackers similar to this problem. Where can I begin to diagnose it? Why are there all these extra bits in my data? How can I fix it?</p> <p>I did a comparison with the output from tcpdump, and they aren't appearing there either.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload