]> The Tcpdump Group git mirrors - tcpdump/blobdiff - netdissect.h
Skip the LLC and SNAP headers with -x.
[tcpdump] / netdissect.h
index e0a0205d94dbc08560c138cbad2c2963b6cb7421..f4de98cd2726f32ed3355d94151151eb97fa6f5f 100644 (file)
@@ -115,6 +115,7 @@ struct netdissect_options {
   int ndo_dlt;                  /* if != -1, ask libpcap for the DLT it names*/
   int ndo_jflag;                /* packet time stamp source */
   int ndo_pflag;                /* don't go promiscuous */
+  int ndo_immediate;            /* use immediate mode */
 
   int ndo_Cflag;                /* rotate dump files after this many bytes */
   int ndo_Cflag_count;      /* Keep track of which file number we're writing */
@@ -257,9 +258,22 @@ struct netdissect_options {
  * "l" isn't so large that "ndo->ndo_snapend - (l)" underflows.
  *
  * The check is for <= rather than < because "l" might be 0.
+ *
+ * We cast the pointers to uintptr_t to make sure that the compiler
+ * doesn't optimize away any of these tests (which it is allowed to
+ * do, as adding an integer to, or subtracting an integer from, a
+ * pointer assumes that the pointer is a pointer to an element of an
+ * array and that the result of the addition or subtraction yields a
+ * pointer to another member of the array, so that, for example, if
+ * you subtract a positive integer from a pointer, the result is
+ * guaranteed to be less than the original pointer value). See
+ *
+ *     http://www.kb.cert.org/vuls/id/162289
  */
-#define ND_TTEST2(var, l) (ndo->ndo_snapend - (l) <= ndo->ndo_snapend && \
-                       (const u_char *)&(var) <= ndo->ndo_snapend - (l))
+#define ND_TTEST2(var, l) \
+  ((l) >= 0 && \
+       ((uintptr_t)ndo->ndo_snapend - (l) <= (uintptr_t)ndo->ndo_snapend && \
+         (uintptr_t)&(var) <= (uintptr_t)ndo->ndo_snapend - (l)))
 
 /* True if "var" was captured */
 #define ND_TTEST(var) ND_TTEST2(var, sizeof(var))
@@ -345,11 +359,11 @@ extern const char *dnnum_string(netdissect_options *, u_short);
 
 #include <pcap.h>
 
-typedef u_int (*if_ndo_printer)(struct netdissect_options *ndo,
+extern char *q922_string(netdissect_options *ndo, const u_char *, u_int);
+
+typedef u_int (*if_printer)(struct netdissect_options *ndo,
                                const struct pcap_pkthdr *, const u_char *);
-typedef u_int (*if_printer)(const struct pcap_pkthdr *, const u_char *);
 
-extern if_ndo_printer lookup_ndo_printer(int);
 extern if_printer lookup_printer(int);
 
 extern void eap_print(netdissect_options *,const u_char *, u_int);
@@ -373,10 +387,10 @@ extern void rrcp_print(netdissect_options *,const u_char *, u_int);
 extern void loopback_print(netdissect_options *, const u_char *, const u_int);
 extern void carp_print(netdissect_options *, const u_char *, u_int, int);
 
-extern void ether_print(netdissect_options *,
-                        const u_char *, u_int, u_int,
-                        void (*)(netdissect_options *, const u_char *),
-                        const u_char *);
+extern u_int ether_print(netdissect_options *,
+                         const u_char *, u_int, u_int,
+                         void (*)(netdissect_options *, const u_char *),
+                         const u_char *);
 
 extern u_int ether_if_print(netdissect_options *,
                             const struct pcap_pkthdr *,const u_char *);
@@ -440,14 +454,15 @@ extern u_int token_print(netdissect_options *, const u_char *, u_int, u_int);
 extern u_int token_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
 extern void vqp_print(netdissect_options *, register const u_char *, register u_int);
 extern void zephyr_print(netdissect_options *, const u_char *, int);
-extern void fddi_print(netdissect_options *, const u_char *, u_int, u_int);
+extern u_int fddi_print(netdissect_options *, const u_char *, u_int, u_int);
 extern u_int fddi_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
 extern void mpcp_print(netdissect_options *, const u_char *, u_int);
 extern void rpki_rtr_print(netdissect_options *, const u_char *, u_int);
 extern u_int sll_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
 extern void dccp_print(netdissect_options *, const u_char *, const u_char *, u_int);
-extern int llc_print(netdissect_options *, const u_char *, u_int, u_int, const u_char *, const u_char *, u_short *);
-extern int snap_print(netdissect_options *, const u_char *, u_int, u_int, u_int);
+extern int llc_print(netdissect_options *, const u_char *, u_int, u_int, const u_char *, const u_char *);
+extern int snap_print(netdissect_options *, const u_char *, u_int, u_int,
+       const u_char *, const u_char *, u_int);
 extern void eigrp_print(netdissect_options *, const u_char *, u_int);
 extern void stp_print(netdissect_options *, const u_char *, u_int);
 extern void l2tp_print(netdissect_options *, const u_char *, u_int);
@@ -478,7 +493,7 @@ extern u_int atm_if_print(netdissect_options *, const struct pcap_pkthdr *, cons
 extern void vtp_print(netdissect_options *, const u_char *, u_int);
 extern int mptcp_print(netdissect_options *, const u_char *, u_int, u_char);
 extern void ntp_print(netdissect_options *, const u_char *, u_int);
-extern void cnfp_print(netdissect_options *, const u_char *, const u_char *);
+extern void cnfp_print(netdissect_options *, const u_char *);
 extern void dvmrp_print(netdissect_options *, const u_char *, u_int);
 extern void egp_print(netdissect_options *, const u_char *, u_int);
 extern u_int enc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
@@ -614,4 +629,6 @@ extern int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo,
 extern void geonet_print(netdissect_options *ndo,const u_char *eth_hdr,const u_char *geo_pck, u_int len);
 extern void calm_fast_print(netdissect_options *ndo,const u_char *eth_hdr,const u_char *calm_pck, u_int len);
 
+extern netdissect_options *gndo;
+
 #endif  /* netdissect_h */