]> The Tcpdump Group git mirrors - libpcap/commitdiff
From Patrick McHardy: Convert pcap-linux to use recvmsg() as preparation
authorguy <guy>
Wed, 6 Aug 2008 07:40:20 +0000 (07:40 +0000)
committerguy <guy>
Wed, 6 Aug 2008 07:40:20 +0000 (07:40 +0000)
for using PACKET_AUXDATA cmsgs.

CREDITS
pcap-linux.c

diff --git a/CREDITS b/CREDITS
index 796caf4e832a650a37499d28e15c93092d43ba2b..29009963ca774712f9dfe1558a1948e2b36d094b 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -84,8 +84,9 @@ Additional people who have contributed patches:
        Olaf Kirch                      <okir at caldera dot de>
        Ollie Wild                      <aaw at users dot sourceforge dot net>
        Onno van der Linden             <onno at simplex dot nl>
        Olaf Kirch                      <okir at caldera dot de>
        Ollie Wild                      <aaw at users dot sourceforge dot net>
        Onno van der Linden             <onno at simplex dot nl>
-       Patrick Marie                   <mycroft at virgaria dot org>
        Paolo Abeni                     <paolo dot abeni at email dot it>
        Paolo Abeni                     <paolo dot abeni at email dot it>
+       Patrick Marie                   <mycroft at virgaria dot org>
+       Patrick McHardy                 <kaber at trash not net>
        Paul Mundt                      <lethal at linux-sh dot org>
        Pavel Kankovsky                 <kan at dcit dot cz>
        Pawel Pokrywka                  <publicpp at gmail dot com>
        Paul Mundt                      <lethal at linux-sh dot org>
        Pavel Kankovsky                 <kan at dcit dot cz>
        Pawel Pokrywka                  <publicpp at gmail dot com>
index 8e3142713c8c78fac307d292887b519b03d84e5d..bef5c437858d300e6215615571b6213f344dc782 100644 (file)
@@ -34,7 +34,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.129.2.21 2008-07-01 08:04:03 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.129.2.22 2008-08-06 07:40:20 guy Exp $ (LBL)";
 #endif
 
 /*
 #endif
 
 /*
@@ -625,10 +625,10 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata)
 #else
        struct sockaddr         from;
 #endif
 #else
        struct sockaddr         from;
 #endif
-       socklen_t               fromlen;
        int                     packet_len, caplen;
        struct pcap_pkthdr      pcap_header;
        int                     packet_len, caplen;
        struct pcap_pkthdr      pcap_header;
-
+       struct iovec            iov;
+       struct msghdr           msg;
 #ifdef HAVE_PF_PACKET_SOCKETS
        /*
         * If this is a cooked device, leave extra room for a
 #ifdef HAVE_PF_PACKET_SOCKETS
        /*
         * If this is a cooked device, leave extra room for a
@@ -662,6 +662,18 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata)
         * get notified of "network down" events.
         */
        bp = handle->buffer + handle->offset;
         * get notified of "network down" events.
         */
        bp = handle->buffer + handle->offset;
+
+       msg.msg_name            = &from;
+       msg.msg_namelen         = sizeof(from);
+       msg.msg_iov             = &iov;
+       msg.msg_iovlen          = 1;
+       msg.msg_control         = NULL;
+       msg.msg_controllen      = 0;
+       msg.msg_flags           = 0;
+
+       iov.iov_len             = handle->bufsize - offset;
+       iov.iov_base            = bp + offset;
+
        do {
                /*
                 * Has "pcap_breakloop()" been called?
        do {
                /*
                 * Has "pcap_breakloop()" been called?
@@ -675,11 +687,8 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata)
                        handle->break_loop = 0;
                        return -2;
                }
                        handle->break_loop = 0;
                        return -2;
                }
-               fromlen = sizeof(from);
-               packet_len = recvfrom(
-                       handle->fd, bp + offset,
-                       handle->bufsize - offset, MSG_TRUNC,
-                       (struct sockaddr *) &from, &fromlen);
+
+               packet_len = recvmsg(handle->fd, &msg, MSG_TRUNC);
        } while (packet_len == -1 && (errno == EINTR || errno == ENETDOWN));
 
        /* Check if an error occured */
        } while (packet_len == -1 && (errno == EINTR || errno == ENETDOWN));
 
        /* Check if an error occured */