update to libpcap-1.1.1

OBS-URL: https://build.opensuse.org/package/show/Base:System/libpcap?expand=0&rev=11
This commit is contained in:
Petr Uzel 2010-04-06 09:03:49 +00:00 committed by Git OBS Bridge
parent 3e70428eec
commit 015963765c
8 changed files with 38 additions and 233 deletions

View File

@ -1,161 +0,0 @@
From 8fa17a5a554aaeb85d3ec4118b45a31f1efd6808 Mon Sep 17 00:00:00 2001
From: guy <guy>
Date: Wed, 19 Nov 2008 08:20:39 +0000
Subject: [PATCH] Fix the handling of the "any" device, including making it reject
attempts to open it in monitor mode.
---
pcap-linux.c | 68 +++++++++++++++++++++++++++++++++++----------------------
1 files changed, 42 insertions(+), 26 deletions(-)
Index: libpcap-1.0.0/pcap-linux.c
===================================================================
--- libpcap-1.0.0.orig/pcap-linux.c
+++ libpcap-1.0.0/pcap-linux.c
@@ -297,6 +297,12 @@ pcap_create(const char *device, char *eb
{
pcap_t *handle;
+ /*
+ * A null device name is equivalent to the "any" device.
+ */
+ if (device == NULL)
+ device = "any";
+
#ifdef HAVE_DAG_API
if (strstr(device, "dag")) {
return dag_create(device, ebuf);
@@ -338,10 +344,9 @@ pcap_can_set_rfmon_linux(pcap_t *p)
struct iwreq ireq;
#endif
- if (p->opt.source == NULL) {
+ if (strcmp(p->opt.source, "any") == 0) {
/*
- * This is equivalent to the "any" device, and we don't
- * support monitor mode on it.
+ * Monitor mode makes no sense on the "any" device.
*/
return 0;
}
@@ -518,12 +523,11 @@ pcap_activate_linux(pcap_t *handle)
handle->stats_op = pcap_stats_linux;
/*
- * NULL and "any" are special devices which give us the hint to
- * monitor all devices.
+ * The "any" device is a special device which causes us not
+ * to bind to a particular device and thus to look at all
+ * devices.
*/
- if (!device || strcmp(device, "any") == 0) {
- device = NULL;
- handle->md.device = strdup("any");
+ if (strcmp(device, "any") == 0) {
if (handle->opt.promisc) {
handle->opt.promisc = 0;
/* Just a warning. */
@@ -531,10 +535,9 @@ pcap_activate_linux(pcap_t *handle)
"Promiscuous mode not supported on the \"any\" device");
status = PCAP_WARNING_PROMISC_NOTSUP;
}
+ }
- } else
- handle->md.device = strdup(device);
-
+ handle->md.device = strdup(device);
if (handle->md.device == NULL) {
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "strdup: %s",
pcap_strerror(errno) );
@@ -1680,19 +1683,21 @@ static int
activate_new(pcap_t *handle)
{
#ifdef HAVE_PF_PACKET_SOCKETS
+ const char *device = handle->opt.source;
+ int is_any_device = (strcmp(device, "any") == 0);
int sock_fd = -1, arptype, val;
int err = 0;
struct packet_mreq mr;
- const char* device = handle->opt.source;
/*
- * Open a socket with protocol family packet. If a device is
- * given we try to open it in raw mode otherwise we use
- * the cooked interface.
- */
- sock_fd = device ?
- socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))
- : socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_ALL));
+ * Open a socket with protocol family packet. If the
+ * "any" device was specified, we open a SOCK_DGRAM
+ * socket for the cooked interface, otherwise we first
+ * try a SOCK_RAW socket for the raw interface.
+ */
+ sock_fd = is_any_device ?
+ socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_ALL)) :
+ socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
if (sock_fd == -1) {
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "socket: %s",
@@ -1727,7 +1732,7 @@ activate_new(pcap_t *handle)
* to cooked mode if we have an unknown interface type
* or a type we know doesn't work well in raw mode.
*/
- if (device) {
+ if (!is_any_device) {
/* Assume for now we don't need cooked mode. */
handle->md.cooked = 0;
@@ -1845,15 +1850,23 @@ activate_new(pcap_t *handle)
handle->linktype = DLT_EN10MB;
} else {
/*
- * This is cooked mode.
+ * The "any" device.
+ */
+ if (handle->opt.rfmon) {
+ /*
+ * It doesn't support monitor mode.
+ */
+ return PCAP_ERROR_RFMON_NOTSUP;
+ }
+
+ /*
+ * It uses cooked mode.
*/
handle->md.cooked = 1;
handle->linktype = DLT_LINUX_SLL;
/*
* We're not bound to a device.
- * XXX - true? Or true only if we're using
- * the "any" device?
* For now, we're using this as an indication
* that we can't transmit; stop doing that only
* if we figure out how to transmit in cooked
@@ -1878,10 +1891,13 @@ activate_new(pcap_t *handle)
/*
* Hmm, how can we set promiscuous mode on all interfaces?
- * I am not sure if that is possible at all.
+ * I am not sure if that is possible at all. For now, we
+ * silently ignore attempts to turn promiscuous mode on
+ * for the "any" device (so you don't have to explicitly
+ * disable it in programs such as tcpdump).
*/
- if (device && handle->opt.promisc) {
+ if (!is_any_device && handle->opt.promisc) {
memset(&mr, 0, sizeof(mr));
mr.mr_ifindex = handle->md.ifindex;
mr.mr_type = PACKET_MR_PROMISC;
@@ -3144,7 +3160,7 @@ activate_old(pcap_t *handle)
/* Bind to the given device */
- if (!device) {
+ if (strcmp(device, "any") == 0) {
strncpy(handle->errbuf, "pcap_activate: The \"any\" device isn't supported on 2.0[.x]-kernel systems",
PCAP_ERRBUF_SIZE);
return PCAP_ERROR;

View File

@ -1,46 +0,0 @@
From 3866e8312346839a7b6d1ddb521c4a0a8033dd5f Mon Sep 17 00:00:00 2001
From: Guy Harris <gharris@steve.local>
Date: Thu, 19 Mar 2009 09:37:03 -0700
Subject: [PATCH] From Roman Francoise: rename the USB-sniffing devices to "usbmonN", so
as not to collide with the "usbN" names for USB-based networking
devices.
Index: libpcap-1.0.0/inet.c
===================================================================
--- libpcap-1.0.0.orig/inet.c
+++ libpcap-1.0.0/inet.c
@@ -669,7 +669,7 @@ pcap_lookupnet(device, netp, maskp, errb
|| strstr(device, "bluetooth") != NULL
#endif
#ifdef PCAP_SUPPORT_USB
- || strstr(device, "usb") != NULL
+ || strstr(device, "usbmon") != NULL
#endif
) {
*netp = *maskp = 0;
Index: libpcap-1.0.0/pcap-linux.c
===================================================================
--- libpcap-1.0.0.orig/pcap-linux.c
+++ libpcap-1.0.0/pcap-linux.c
@@ -322,7 +322,7 @@ pcap_create(const char *device, char *eb
#endif
#ifdef PCAP_SUPPORT_USB
- if (strstr(device, "usb")) {
+ if (strstr(device, "usbmon")) {
return usb_create(device, ebuf);
}
#endif
Index: libpcap-1.0.0/pcap-usb-linux.c
===================================================================
--- libpcap-1.0.0.orig/pcap-usb-linux.c
+++ libpcap-1.0.0/pcap-usb-linux.c
@@ -61,7 +61,7 @@ static const char rcsid[] _U_ =
#include <sys/ioctl.h>
#include <sys/mman.h>
-#define USB_IFACE "usb"
+#define USB_IFACE "usbmon"
#define USB_TEXT_DIR "/sys/kernel/debug/usbmon"
#define USB_BUS_DIR "/proc/bus/usb"
#define USB_LINE_LEN 4096

View File

@ -1,6 +1,8 @@
--- pcap-linux.c
+++ pcap-linux.c
@@ -1752,6 +1752,9 @@
Index: pcap-linux.c
===================================================================
--- pcap-linux.c.orig 2010-04-06 10:17:29.000000000 +0200
+++ pcap-linux.c 2010-04-06 10:17:51.000000000 +0200
@@ -2865,6 +2865,9 @@ activate_new(pcap_t *handle)
else
return 0; /* try old mechanism */
}
@ -9,4 +11,4 @@
+ handle->linktype = DLT_EN10MB;
} else {
/*
* This is cooked mode.
* The "any" device.

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c0a590014eb2ac2367eda2cadcc1d4285d7e5054609f8f3aa17cfc057bd7a3ec
size 423995

3
libpcap-1.1.1.tar.bz2 Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:74bb03dbc639910cc1daa98c280d91c47b17dc5e7e86b74cc6daa3d1345a5d2e
size 467578

View File

@ -1,3 +1,20 @@
-------------------------------------------------------------------
Tue Apr 6 08:19:41 UTC 2010 - puzel@novell.com
- update to libpcap-1.1.1
- notable changes :
- Add SocketCAN capture support
- Add Myricom SNF API support
- Update Endace DAG and ERF support
- Support monitor mode on mac80211 devices on Linux
- Fix USB memory-mapped capturing on Linux
- On Linux, scan /sys/class/net for devices if we have it
- Add limited support for reading pcap-ng files
- see /usr/share/doc/packages/libpcap1/CHANGES for
full list of changes
- drop fix-any-interface-handling.patch (fixed upstream)
- drop fix-usb-nic.patch (fixed upstream)
-------------------------------------------------------------------
Tue Jan 26 22:11:20 CET 2010 - jengelh@medozas.de

View File

@ -1,5 +1,5 @@
#
# spec file for package libpcap (Version 1.0.0)
# spec file for package libpcap (Version 1.1.1)
#
# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
@ -19,7 +19,7 @@
Name: libpcap
Version: 1.0.0
Version: 1.1.1
Release: 8
Group: System/Libraries
License: BSD3c(or similar) ; BSD4c(or similar)
@ -27,18 +27,17 @@ Url: http://www.tcpdump.org/
Summary: A Library for Network Sniffers
Source: %{name}-%{version}.tar.bz2
Source2: baselibs.conf
Patch0: %{name}-%{version}-filter-fix.patch
Patch1: %{name}-%{version}-fcode.patch
Patch2: %{name}-%{version}-pcap-bpf.patch
Patch3: %{name}-%{version}-ppp.patch
Patch4: %{name}-%{version}-s390.patch
Patch5: %{name}-%{version}-man.patch
Patch6: %{name}-%{version}-mac_syntax.patch
Patch7: fix-any-interface-handling.patch
#PATCH-FIX-UPSTREAM fix-usb-nic.patch bnc455774 petr.uzel@suse.cz
Patch8: fix-usb-nic.patch
Patch0: libpcap-1.0.0-filter-fix.patch
Patch1: libpcap-1.0.0-fcode.patch
Patch2: libpcap-1.0.0-pcap-bpf.patch
Patch3: libpcap-1.0.0-ppp.patch
Patch4: libpcap-1.0.0-s390.patch
Patch5: libpcap-1.0.0-man.patch
Patch6: libpcap-1.0.0-mac_syntax.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: bison bluez-devel flex
BuildRequires: bison
BuildRequires: bluez-devel
BuildRequires: flex
%description
libpcap is a library used by packet sniffer programs. It provides an
@ -132,8 +131,6 @@ Authors:
%patch4
%patch5
%patch6
%patch7 -p1
%patch8 -p1
%build
%ifarch %sparc
@ -149,10 +146,6 @@ make %{?_smp_mflags} all shared
%install
mkdir -p $RPM_BUILD_ROOT%{_bindir}
make DESTDIR=$RPM_BUILD_ROOT install install-shared
# create symlinks
ln -s %{name}.so.%{version} $RPM_BUILD_ROOT%{_libdir}/%{name}.so.1.0
ln -s %{name}.so.%{version} $RPM_BUILD_ROOT%{_libdir}/%{name}.so.1
ln -s %{name}.so.%{version} $RPM_BUILD_ROOT%{_libdir}/%{name}.so
%clean
rm -rf $RPM_BUILD_ROOT

0
ready Normal file
View File