/*
* Create a socket from which to fetch the list of interfaces.
*/
- fd = socket(AF_INET, SOCK_DGRAM, 0);
+ fd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);
if (fd < 0) {
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
- "socket: %s", pcap_strerror(errno));
+ pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE,
+ errno, "socket");
return (-1);
}
* Create a socket from which to fetch the list of interfaces,
* and from which to fetch IPv4 information.
*/
- fd4 = socket(AF_INET, SOCK_DGRAM, 0);
+ fd4 = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);
if (fd4 < 0) {
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
- "socket: %s", pcap_strerror(errno));
+ pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE,
+ errno, "socket: AF_INET");
return (-1);
}
/*
* Create a socket from which to fetch IPv6 information.
*/
- fd6 = socket(AF_INET6, SOCK_DGRAM, 0);
+ fd6 = socket(AF_INET6, SOCK_DGRAM|SOCK_CLOEXEC, 0);
if (fd6 < 0) {
- (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
- "socket: %s", pcap_strerror(errno));
+ pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE,
+ errno, "socket: AF_INET6");
(void)close(fd4);
return (-1);
}
--- /dev/null
- Version: 1.6.1
+%define keepstatic 1
+Name: libpcap
++Version: 1.9.1
+Release: 1
+License: BSD-3-Clause
+Summary: A Library for Network Sniffers
+Url: http://www.tcpdump.org/
+Group: System/Libraries
+Source: %{name}-%{version}.tar.gz
+Source2: baselibs.conf
+Source1001: libpcap.manifest
+BuildRequires: automake
+BuildRequires: bison
+BuildRequires: flex
+BuildRequires: libusb-devel
+
+%description
+libpcap is a library used by packet sniffer programs. It provides an
+interface for them to capture and analyze packets from network devices.
+This package is only needed if you plan to compile or write such a
+program yourself.
+
+%package devel
+Summary: A Library for Network Sniffers
+Group: Development/Libraries/C and C++
+Requires: libpcap = %{version}
+
+%description devel
+libpcap is a library used by packet sniffer programs. It provides an
+interface for them to capture and analyze packets from network devices.
+This package is only needed if you plan to compile or write such a
+program yourself.
+
+%prep
+%setup -q
+cp %{SOURCE1001} .
+
+%build
+pic="pic"
+autoreconf -fiv
+export CFLAGS="%{optflags} -f$pic" CXXFLAGS="%{optflags} -f$pic"
+%configure \
+ --enable-ipv6
+make %{?_smp_mflags} all shared
+
+%install
+%make_install
+
+%docs_package
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%manifest %{name}.manifest
+%defattr(-, root, root)
+%doc LICENSE
+%{_libdir}/*.so.*
+
+%files devel
+%manifest %{name}.manifest
+%defattr(-, root, root)
+%{_includedir}/*
+%{_bindir}/pcap-config
+%{_libdir}/*.so
+%{_libdir}/*.*a
++%{_libdir}/pkgconfig/*.pc
{
struct hci_dev_list_req *dev_list;
struct hci_dev_req *dev_req;
- int i, sock;
+ int sock;
+ unsigned i;
int ret = 0;
-
- sock = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
+
+ sock = socket(AF_BLUETOOTH, SOCK_RAW|SOCK_CLOEXEC, BTPROTO_HCI);
if (sock < 0)
{
- /* if bluetooth is not supported this this is not fatal*/
+ /* if bluetooth is not supported this is not fatal*/
if (errno == EAFNOSUPPORT)
return 0;
- snprintf(err_str, PCAP_ERRBUF_SIZE,
- "Can't open raw Bluetooth socket: %s", strerror(errno));
+ pcap_fmt_errmsg_for_errno(err_str, PCAP_ERRBUF_SIZE,
+ errno, "Can't open raw Bluetooth socket");
return -1;
}
handle->setnonblock_op = pcap_setnonblock_fd;
handle->stats_op = bt_stats_linux;
handlep->dev_id = dev_id;
-
+
/* Create HCI socket */
- handle->fd = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
+ handle->fd = socket(AF_BLUETOOTH, SOCK_RAW|SOCK_CLOEXEC, BTPROTO_HCI);
if (handle->fd < 0) {
- snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
- "Can't create raw socket: %s", strerror(errno));
+ pcap_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
+ errno, "Can't create raw socket");
return PCAP_ERROR;
}
p->snapshot = 96;
memset(p, 0, sizeof(*p));
- p->fd = fd = socket(AF_NIT, SOCK_RAW, NITPROTO_RAW);
+ p->fd = fd = socket(AF_NIT, SOCK_RAW|SOCK_CLOEXEC, NITPROTO_RAW);
if (fd < 0) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
- "socket: %s", pcap_strerror(errno));
+ pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
+ errno, "socket");
goto bad;
}
snit.snit_family = AF_NIT;
* the device in question) can be indicated at open
* time.
*/
- p->fd = fd = open(dev, O_RDWR);
+ p->fd = fd = open(dev, O_RDWR|O_CLOEXEC);
if (fd < 0 && errno == EACCES)
- p->fd = fd = open(dev, O_RDONLY);
+ p->fd = fd = open(dev, O_RDONLY|O_CLOEXEC);
if (fd < 0) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "%s: %s", dev,
- pcap_strerror(errno));
+ if (errno == EACCES)
+ err = PCAP_ERROR_PERM_DENIED;
+ else
+ err = PCAP_ERROR;
+ pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
+ errno, "%s", dev);
goto bad;
}
int snooplen;
struct ifreq ifr;
- fd = socket(PF_RAW, SOCK_RAW, RAWPROTO_SNOOP);
+ fd = socket(PF_RAW, SOCK_RAW|SOCK_CLOEXEC, RAWPROTO_SNOOP);
if (fd < 0) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "snoop socket: %s",
- pcap_strerror(errno));
+ pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
+ errno, "snoop socket");
goto bad;
}
p->fd = fd;