*/
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.212 2004-11-06 22:57:28 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.213 2004-12-15 00:25:08 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
/* XXX */
#ifdef PCAP_FDDIPAD
-int pcap_fddipad = PCAP_FDDIPAD;
-#else
-int pcap_fddipad;
+static int pcap_fddipad;
#endif
/* VARARGS */
/* NOTREACHED */
}
-static void init_linktype(int);
+static void init_linktype(pcap_t *);
static int alloc_reg(void);
static void free_reg(int);
/*
* We divy out chunks of memory rather than call malloc each time so
* we don't have to worry about leaking memory. It's probably
- * not a big deal if all this memory was wasted but it this ever
+ * not a big deal if all this memory was wasted but if this ever
* goes into a library that would probably not be a good idea.
+ *
+ * XXX - this *is* in a library....
*/
#define NCHUNKS 16
#define CHUNK0SIZE 1024
}
lex_init(buf ? buf : "");
- init_linktype(pcap_datalink(p));
+ init_linktype(p);
(void)pcap_parse();
if (n_errors)
static int linktype;
static void
-init_linktype(type)
- int type;
+init_linktype(p)
+ pcap_t *p;
{
- linktype = type;
+ linktype = pcap_datalink(p);
+#ifdef PCAP_FDDIPAD
+ pcap_fddipad = p->fddipad;
+#endif
/*
* Assume it's not raw ATM with a pseudo-header, for now.
orig_nl = -1;
orig_nl_nosnap = -1;
- switch (type) {
+ switch (linktype) {
case DLT_ARCNET:
off_linktype = 2;
*/
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/pcap-bpf.c,v 1.83 2004-12-14 23:55:30 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/pcap-bpf.c,v 1.84 2004-12-15 00:25:09 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#define bhp ((struct bpf_hdr *)bp)
ep = bp + cc;
#ifdef PCAP_FDDIPAD
- if (pc->linktype == DLT_FDDI)
- pad = pcap_fddipad;
- else
- pad = 0;
+ pad = p->fddipad;
#endif
while (bp < ep) {
register int caplen, hdrlen;
*
#ifdef PCAP_FDDIPAD
* Note: the filter code was generated assuming
- * that pcap_fddipad was the amount of padding
+ * 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.
v = DLT_CHDLC;
break;
}
+#endif
+#ifdef PCAP_FDDIPAD
+ if (v == DLT_FDDI)
+ p->fddipad = PCAP_FDDIPAD:
+ else
+ p->fddipad = 0;
#endif
p->linktype = v;
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.65 2004-10-19 07:06:12 guy Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.66 2004-12-15 00:25:09 guy Exp $ (LBL)
*/
#ifndef pcap_int_h
int break_loop; /* flag set to force break from packet-reading loop */
+#ifdef PCAP_FDDIPAD
+ int fddipad;
+#endif
+
struct pcap_sf sf;
struct pcap_md md;
char *pcap_win32strerror(void);
#endif
-/* XXX */
-extern int pcap_fddipad;
-
int install_bpf_program(pcap_t *, struct bpf_program *);
int pcap_strcasecmp(const char *, const char *);
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/pcap-pf.c,v 1.89 2004-12-15 00:05:48 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/pcap-pf.c,v 1.90 2004-12-15 00:25:09 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
*/
n = 0;
#ifdef PCAP_FDDIPAD
- if (pc->linktype == DLT_FDDI)
- pad = pcap_fddipad;
- else
- pad = 0;
+ pad = p->fddipad;
#endif
while (cc > 0) {
/*
*
#ifdef PCAP_FDDIPAD
* Note: the filter code was generated assuming
- * that pcap_fddipad was the amount of padding
+ * 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.
}
/* set truncation */
#ifdef PCAP_FDDIPAD
- if (p->linktype == DLT_FDDI)
+ if (p->linktype == DLT_FDDI) {
+ p->fddipad = PCAP_FDDIPAD:
+
/* packetfilter includes the padding in the snapshot */
- snaplen += pcap_fddipad;
+ snaplen += PCAP_FDDIPAD;
+ } else
+ p->fddipad = 0;
#endif
if (ioctl(p->fd, EIOCTRUNCATE, (caddr_t)&snaplen) < 0) {
snprintf(ebuf, PCAP_ERRBUF_SIZE, "EIOCTRUNCATE: %s",
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.115 2004-12-09 19:03:37 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/savefile.c,v 1.116 2004-12-15 00:25:09 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
p->sf.version_major = hdr.version_major;
p->sf.version_minor = hdr.version_minor;
#ifdef PCAP_FDDIPAD
- /* XXX padding only needed for kernel fcode */
- pcap_fddipad = 0;
+ /* Padding only needed for live capture fcode */
+ p->fddipad = 0;
#endif
/*