tcpdump mailing list archives

[PATCH 2/2] Debug: pcap-linux.c: fprintf() values related to req.tp_frame_size.


From: julm+tcpdump () savines alpes fr eu org
Date: Wed, 23 Mar 2011 04:47:58 +0100

From: Julien Moutinho <julm () savines alpes fr eu org>

---
 pcap-linux.c |   33 +++++++++++++++++++++++++++++++--
 1 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/pcap-linux.c b/pcap-linux.c
index 1542fad..c896584 100644
--- a/pcap-linux.c
+++ b/pcap-linux.c
@@ -1429,6 +1429,7 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata)
                        (struct sockaddr *) &from, &fromlen);
 #endif /* defined(HAVE_PACKET_AUXDATA) && defined(HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI) */
        } while (packet_len == -1 && errno == EINTR);
+       fprintf(stdout, "packet_len(recvmsg)=%d\n", packet_len);
 
        /* Check if an error occured */
 
@@ -1592,6 +1593,8 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata)
         * filter to the kernel.
         */
 
+       fprintf(stderr, "packet_len=%d\n", packet_len);
+       fflush(stderr);
        caplen = packet_len;
        if (caplen > handle->snapshot)
                caplen = handle->snapshot;
@@ -3144,6 +3147,8 @@ prepare_tpacket_socket(pcap_t *handle)
 
        /* Reserve space for VLAN tag reconstruction */
        val = VLAN_TAG_LEN;
+       fprintf(stderr, "tp_reserve(set) = %d (%lu)\n", val, sizeof(val));
+       fflush(stderr);
        if (setsockopt(handle->fd, SOL_PACKET, PACKET_RESERVE, &val,
                       sizeof(val)) < 0) {
                snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
@@ -3231,8 +3236,22 @@ create_ring(pcap_t *handle, int *status)
        macoff = netoff - maclen;
        req.tp_frame_size = TPACKET_ALIGN(macoff + handle->snapshot);
        req.tp_frame_nr = handle->opt.buffer_size/req.tp_frame_size;
-
-       /* compute the minumum block size that will handle this frame. 
+       
+       fprintf(stderr, "req.tp_frame_size = %d (not aligned = %d)\n", req.tp_frame_size, macoff + handle->snapshot);
+       fprintf(stderr, " sk_type = %d\n", sk_type);
+       fprintf(stderr, " sizeof(struct sockaddr_ll) = %lu\n", sizeof(struct sockaddr_ll));
+       fprintf(stderr, " maclen = %d\n", maclen);
+       fprintf(stderr, " tp_hdrlen = %d\n", tp_hdrlen);
+       fprintf(stderr, " tp_reserve = %d\n", tp_reserve);
+       fprintf(stderr, " netoff = %d\n", netoff);
+       fprintf(stderr, " macoff = %d\n", macoff);
+       fprintf(stderr, " handle->snapshot = %d\n", handle->snapshot);
+       fprintf(stderr, " handle->offset = %d\n", handle->offset);
+       fprintf(stderr, " handle->linktype = %d\n", handle->linktype);
+       fprintf(stderr, " handle->cc = %d\n", handle->cc);
+       fflush(stderr);
+
+       /* compute the minimum block size that will handle this frame.
         * The block has to be page size aligned. 
         * The max block size allowed by the kernel is arch-dependent and 
         * it's not explicitly checked here. */
@@ -3668,6 +3687,9 @@ pcap_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback,
                        tp_snaplen = h.h2->tp_snaplen;
                        tp_sec     = h.h2->tp_sec;
                        tp_usec    = h.h2->tp_nsec / 1000;
+                       fprintf(stderr, "h.h2->tp_mac = %d\n", h.h2->tp_mac);
+                       fprintf(stderr, "h.h2->tp_net = %d\n", h.h2->tp_net);
+                       fflush(stderr);
                        break;
 #endif
                default:
@@ -3735,6 +3757,10 @@ pcap_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback,
                pcaphdr.ts.tv_usec = tp_usec;
                pcaphdr.caplen = tp_snaplen;
                pcaphdr.len = tp_len;
+               fprintf(stderr, "tp_mac = %d\n", tp_mac);
+               fprintf(stderr, "tp_snaplen = %d\n", tp_snaplen);
+               fprintf(stderr, "tp_len = %d\n", tp_len);
+               fflush(stderr);
 
                /* if required build in place the sll header*/
                if (handle->md.cooked) {
@@ -3808,6 +3834,9 @@ pcap_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback,
                 */
                if (pcaphdr.caplen > handle->snapshot)
                        pcaphdr.caplen = handle->snapshot;
+               fprintf(stderr, "pcaphdr.caplen = %d\n", pcaphdr.caplen);
+               fprintf(stderr, "handle->snapshot = %d\n", handle->snapshot);
+               fflush(stderr);
 
                /* pass the packet to the user */
                pkts++;
-- 
1.7.2.3

-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.


Current thread: