]> The Tcpdump Group git mirrors - libpcap/blobdiff - gencode.c
Add to the beginning a note from Rick Jones that 11i (11.11) and later
[libpcap] / gencode.c
index d37f9841db9a2cbe19cd1a412026408e322e8fa3..535f4a64b262997527dd831a3485f7a6cdbd399e 100644 (file)
--- a/gencode.c
+++ b/gencode.c
@@ -21,7 +21,7 @@
  */
 #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.216 2005-01-12 09:02:55 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -33,7 +33,6 @@ static const char rcsid[] _U_ =
 #else /* WIN32 */
 #include <sys/types.h>
 #include <sys/socket.h>
-#include <sys/time.h>
 #endif /* WIN32 */
 
 /*
@@ -59,6 +58,10 @@ static const char rcsid[] _U_ =
 #include <setjmp.h>
 #include <stdarg.h>
 
+#ifdef MSDOS
+#include "pcap-dos.h"
+#endif
+
 #include "pcap-int.h"
 
 #include "ethertype.h"
@@ -102,9 +105,7 @@ static u_int        orig_linktype = -1U, orig_nl = -1U, orig_nl_nosnap = -1U;
 
 /* XXX */
 #ifdef PCAP_FDDIPAD
-int    pcap_fddipad = PCAP_FDDIPAD;
-#else
-int    pcap_fddipad;
+static int     pcap_fddipad;
 #endif
 
 /* VARARGS */
@@ -123,7 +124,7 @@ bpf_error(const char *fmt, ...)
        /* NOTREACHED */
 }
 
-static void init_linktype(int);
+static void init_linktype(pcap_t *);
 
 static int alloc_reg(void);
 static void free_reg(int);
@@ -133,8 +134,10 @@ static struct block *root;
 /*
  * 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
@@ -341,7 +344,7 @@ pcap_compile(pcap_t *p, struct bpf_program *program,
        }
 
        lex_init(buf ? buf : "");
-       init_linktype(pcap_datalink(p));
+       init_linktype(p);
        (void)pcap_parse();
 
        if (n_errors)
@@ -679,10 +682,13 @@ static u_int off_nl_nosnap;
 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.
@@ -699,7 +705,7 @@ init_linktype(type)
        orig_nl = -1;
        orig_nl_nosnap = -1;
 
-       switch (type) {
+       switch (linktype) {
 
        case DLT_ARCNET:
                off_linktype = 2;
@@ -1017,6 +1023,12 @@ init_linktype(type)
                off_nl_nosnap = PFLOG_HDRLEN;
                return;
 
+        case DLT_JUNIPER_MLPPP:
+                off_linktype = 4;
+               off_nl = 4;
+               off_nl_nosnap = -1;
+                break;
+
        case DLT_JUNIPER_ATM1:
                off_linktype = 4; /* in reality variable between 4-8 */
                off_nl = 4;
@@ -1816,6 +1828,7 @@ gen_linktype(proto)
                /*NOTREACHED*/
                break;
 
+        case DLT_JUNIPER_MLPPP:
        case DLT_JUNIPER_ATM1:
        case DLT_JUNIPER_ATM2:
                /* just lets verify the magic number for now -
@@ -5112,6 +5125,7 @@ gen_inbound(dir)
                }
                break;
 
+        case DLT_JUNIPER_MLPPP:
        case DLT_JUNIPER_ATM1:
        case DLT_JUNIPER_ATM2:
                /* juniper flags (including direction) are stored