Deleted Added
full compact
27c27
< "@(#) $Header: /tcpdump/master/libpcap/pcap-pf.c,v 1.79.2.5 2003/11/22 00:32:55 guy Exp $ (LBL)";
---
> "@(#) $Header: /tcpdump/master/libpcap/pcap-pf.c,v 1.91 2005/02/26 21:58:06 guy Exp $ (LBL)";
132,135c132
< if (pc->linktype == DLT_FDDI)
< pad = pcap_fddipad;
< else
< pad = 0;
---
> pad = p->fddipad;
185,188d181
< #ifdef PCAP_FDDIPAD
< p += pad;
< buflen -= pad;
< #endif
197a191,198
> *
> #ifdef PCAP_FDDIPAD
> * Note: the filter code was generated assuming
> * that p->fddipad was the amount of padding
> * before the header, as that's what's required
> * in the kernel, so we run the filter before
> * skipping that padding.
> #endif
208a210,213
> #ifdef PCAP_FDDIPAD
> p += pad;
> buflen -= pad;
> #endif
222a228,241
> pcap_inject_pf(pcap_t *p, const void *buf, size_t size)
> {
> int ret;
>
> ret = write(p->fd, buf, size);
> if (ret == -1) {
> snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "send: %s",
> pcap_strerror(errno));
> return (-1);
> }
> return (ret);
> }
>
> static int
268,275c287,293
< static void
< pcap_close_pf(pcap_t *p)
< {
< if (p->buffer != NULL)
< free(p->buffer);
< if (p->fd >= 0)
< close(p->fd);
< }
---
> /*
> * We include the OS's <net/bpf.h>, not our "pcap-bpf.h", so we probably
> * don't get DLT_DOCSIS defined.
> */
> #ifndef DLT_DOCSIS
> #define DLT_DOCSIS 143
> #endif
294d311
<
295a313,325
> * Initially try a read/write open (to allow the inject
> * method to work). If that fails due to permission
> * issues, fall back to read-only. This allows a
> * non-root user to be granted specific access to pcap
> * capabilities via file permissions.
> *
> * XXX - we should have an API that has a flag that
> * controls whether to open read-only or read-write,
> * so that denial of permission to send (or inability
> * to send, if sending packets isn't supported on
> * the device in question) can be indicated at open
> * time.
> *
301c331,333
< p->fd = pfopen(device, O_RDONLY);
---
> p->fd = pfopen(device, O_RDWR);
> if (p->fd == -1 && errno == EACCES)
> p->fd = pfopen(device, O_RDONLY);
342a375,393
> /*
> * This is (presumably) a real Ethernet capture; give it a
> * link-layer-type list with DLT_EN10MB and DLT_DOCSIS, so
> * that an application can let you choose it, in case you're
> * capturing DOCSIS traffic that a Cisco Cable Modem
> * Termination System is putting out onto an Ethernet (it
> * doesn't put an Ethernet header onto the wire, it puts raw
> * DOCSIS frames out on the wire inside the low-level
> * Ethernet framing).
> */
> p->dlt_list = (u_int *) malloc(sizeof(u_int) * 2);
> /*
> * If that fails, just leave the list empty.
> */
> if (p->dlt_list != NULL) {
> p->dlt_list[0] = DLT_EN10MB;
> p->dlt_list[1] = DLT_DOCSIS;
> p->dlt_count = 2;
> }
399c450,452
< if (p->linktype == DLT_FDDI)
---
> if (p->linktype == DLT_FDDI) {
> p->fddipad = PCAP_FDDIPAD:
>
401c454,456
< snaplen += pcap_fddipad;
---
> snaplen += PCAP_FDDIPAD;
> } else
> p->fddipad = 0;
442a498
> p->inject_op = pcap_inject_pf;
448c504
< p->close_op = pcap_close_pf;
---
> p->close_op = pcap_close_common;
453a510,514
> /*
> * Get rid of any link-layer type list we allocated.
> */
> if (p->dlt_list != NULL)
> free(p->dlt_list);
508a570,579
>
> /*
> * Discard any previously-received packets,
> * as they might have passed whatever filter
> * was formerly in effect, but might not pass
> * this filter (BIOCSETF discards packets buffered
> * in the kernel, so you can lose packets in any
> * case).
> */
> p->cc = 0;