#include <netinet/tcp.h>
#include <netinet/tcpip.h>
-#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
/*
* loop through each snapshot in the chunk
+ *
+ * This assumes that a single buffer of packets will have
+ * <= INT_MAX packets, so the packet count doesn't overflow.
*/
n = 0;
ep = bp + cc;
if (caplen > p->snapshot)
caplen = p->snapshot;
- if (bpf_filter(p->fcode.bf_insns, cp, nlp->nh_pktlen, caplen)) {
+ if (pcap_filter(p->fcode.bf_insns, cp, nlp->nh_pktlen, caplen)) {
struct pcap_pkthdr h;
h.ts = ntp->nh_timestamp;
h.len = nlp->nh_pktlen;
}
static int
-pcap_inject_snit(pcap_t *p, const void *buf, size_t size)
+pcap_inject_snit(pcap_t *p, const void *buf, int size)
{
struct strbuf ctl, data;
if (fd < 0 && errno == EACCES)
p->fd = fd = open(dev, O_RDONLY);
if (fd < 0) {
- if (errno == EACCES)
+ if (errno == EACCES) {
err = PCAP_ERROR_PERM_DENIED;
- else
+ snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ "Attempt to open %s failed with EACCES - root privileges may be required",
+ dev);
+ } else {
err = PCAP_ERROR;
- pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
- errno, "%s", dev);
+ pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
+ errno, "%s", dev);
+ }
goto bad;
}
{
pcap_t *p;
- p = pcap_create_common(ebuf, sizeof (struct pcap_snit));
+ p = PCAP_CREATE_COMMON(ebuf, struct pcap_snit);
if (p == NULL)
return (NULL);
return (1);
}
+static int
+get_if_flags(const char *name _U_, bpf_u_int32 *flags _U_, char *errbuf _U_)
+{
+ /*
+ * Nothing we can do.
+ * XXX - is there a way to find out whether an adapter has
+ * something plugged into it?
+ */
+ return (0);
+}
+
int
pcap_platform_finddevs(pcap_if_list_t *devlistp, char *errbuf)
{
- return (pcap_findalldevs_interfaces(devlistp, errbuf, can_be_bound));
+ return (pcap_findalldevs_interfaces(devlistp, errbuf, can_be_bound,
+ get_if_flags));
}
/*