]> The Tcpdump Group git mirrors - tcpdump/blobdiff - netdissect.h
Add CAP_FCNTL and use cap_fcntls_limit().
[tcpdump] / netdissect.h
index bbf355fc22b7ab89b12a21eb7f9138a6876ba89a..515d839d733b1bcd7f2a0d668218bbdb374ac623 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 */
@@ -124,7 +125,9 @@ struct netdissect_options {
   int ndo_Wflag;          /* recycle output files after this number of files */
   int ndo_WflagChars;
   int ndo_Hflag;               /* dissect 802.11s draft mesh standard */
+  int ndo_packet_number;       /* print a packet number in the beginning of line */
   int ndo_suppress_default_print; /* don't use default_print() for unknown packet types */
+  int ndo_tstamp_precision;   /* requested time stamp precision */
   const char *ndo_dltname;
 
   char *ndo_espsecret;
@@ -154,14 +157,18 @@ struct netdissect_options {
   /* pointer to void function to output stuff */
   void (*ndo_default_print)(netdissect_options *,
                      register const u_char *bp, register u_int length);
+
+  /* pointer to function to print ^T output */
   void (*ndo_info)(netdissect_options *, int verbose);
 
+  /* pointer to function to do regular output */
   int  (*ndo_printf)(netdissect_options *,
                     const char *fmt, ...)
 #ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
                     __attribute__ ((format (printf, 2, 3)))
 #endif
                     ;
+  /* pointer to function to output errors */
   void (*ndo_error)(netdissect_options *,
                    const char *fmt, ...)
 #ifdef __ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS
@@ -171,6 +178,7 @@ struct netdissect_options {
                     __attribute__ ((format (printf, 2, 3)))
 #endif /* __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS */
                     ;
+  /* pointer to function to output warnings */
   void (*ndo_warning)(netdissect_options *,
                      const char *fmt, ...)
 #ifdef __ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS
@@ -207,12 +215,26 @@ struct netdissect_options {
  * Maximum snapshot length.  This should be enough to capture the full
  * packet on most network interfaces.
  *
- * XXX - could it be larger?  If so, should it?  Some applications might
- * use the snapshot length in a savefile header to control the size of
- * the buffer they allocate, so a size of, say, 2^31-1 might not work
- * well.
+ *
+ * Somewhat arbitrary, but chosen to be:
+ *
+ *    1) big enough for maximum-size Linux loopback packets (65549)
+ *       and some USB packets captured with USBPcap:
+ *
+ *           http://desowin.org/usbpcap/
+ *
+ *       (> 131072, < 262144)
+ *
+ * and
+ *
+ *    2) small enough not to cause attempts to allocate huge amounts of
+ *       memory; some applications might use the snapshot length in a
+ *       savefile header to control the size of the buffer they allocate,
+ *       so a size of, say, 2^31-1 might not work well.
+ *
+ * XXX - does it need to be bigger still?
  */
-#define MAXIMUM_SNAPLEN        65535
+#define MAXIMUM_SNAPLEN        262144
 
 /*
  * The default snapshot length is the maximum.
@@ -252,16 +274,22 @@ struct netdissect_options {
 #define ND_PRINT(STUFF) (*ndo->ndo_printf)STUFF
 #define ND_DEFAULTPRINT(ap, length) (*ndo->ndo_default_print)(ndo, ap, length)
 
-#if 0
-extern void ts_print(netdissect_options *ipdo,
-                    const struct timeval *);
-extern void relts_print(int);
-#endif
+extern void ts_print(netdissect_options *, const struct timeval *);
+extern void relts_print(netdissect_options *, int);
 
-extern int fn_print(const u_char *, const u_char *);
-extern int fn_printn(const u_char *, u_int, const u_char *);
+extern int fn_print(netdissect_options *, const u_char *, const u_char *);
+extern int fn_printn(netdissect_options *, const u_char *, u_int, const u_char *);
+extern int fn_printzp(netdissect_options *, const u_char *, u_int, const u_char *);
 extern const char *tok2str(const struct tok *, const char *, int);
 
+/*
+ * Flags for txtproto_print().
+ */
+#define RESP_CODE_SECOND_TOKEN 0x00000001      /* response code is second token in response line */
+
+extern void txtproto_print(netdissect_options *, const u_char *, u_int,
+    const char *, const char **, u_int);
+
 #if 0
 extern char *read_infile(netdissect_options *, char *);
 extern char *copy_argv(netdissect_options *, char **);
@@ -278,8 +306,8 @@ extern char *copy_argv(netdissect_options *, char **);
 #define ND_ISGRAPH(c)  ((c) > 0x20 && (c) <= 0x7E)
 #define ND_TOASCII(c)  ((c) & 0x7F)
 
-extern void safeputchar(int);
-extern void safeputs(const char *, int);
+extern void safeputchar(netdissect_options *, const u_char);
+extern void safeputs(netdissect_options *, const u_char *, const u_int);
 
 #ifdef LBL_ALIGN
 /*
@@ -310,8 +338,6 @@ extern int unaligned_memcmp(const void *, const void *, size_t);
        (((n) != 1) ? "s" : "")
 
 #if 0
-extern const char *isonsap_string(netdissect_options *, const u_char *);
-extern const char *protoid_string(netdissect_options *, const u_char *);
 extern const char *dnname_string(netdissect_options *, u_short);
 extern const char *dnnum_string(netdissect_options *, u_short);
 #endif
@@ -320,6 +346,8 @@ extern const char *dnnum_string(netdissect_options *, u_short);
 
 #include <pcap.h>
 
+extern char *q922_string(netdissect_options *ndo, const u_char *, u_int);
+
 typedef u_int (*if_ndo_printer)(struct netdissect_options *ndo,
                                const struct pcap_pkthdr *, const u_char *);
 typedef u_int (*if_printer)(const struct pcap_pkthdr *, const u_char *);
@@ -365,6 +393,7 @@ extern int ethertype_print(netdissect_options *,u_short, const u_char *,
                             u_int, u_int);
 
 extern int print_unknown_data(netdissect_options *,const u_char *, const char *,int);
+extern void ascii_print(netdissect_options *, const u_char *, u_int);
 extern void hex_print_with_offset(netdissect_options *, const char *ident, const u_char *cp,
                                  u_int, u_int);
 extern void hex_print(netdissect_options *,const char *ident, const u_char *cp,u_int);
@@ -452,7 +481,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 *);
@@ -498,48 +527,47 @@ extern u_int juniper_frelay_print(netdissect_options *, const struct pcap_pkthdr
 extern u_int juniper_chdlc_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
 extern void snmp_print(netdissect_options *, const u_char *, u_int);
 extern void rx_print(netdissect_options *, register const u_char *, int, int, int, u_char *);
+extern void nfsreply_print(netdissect_options *, const u_char *, u_int, const u_char *);
+extern void nfsreply_print_noaddr(netdissect_options *, const u_char *, u_int, const u_char *);
+extern void nfsreq_print_noaddr(netdissect_options *, const u_char *, u_int, const u_char *);
+extern void sip_print(netdissect_options *, const u_char *, u_int);
+extern void syslog_print(netdissect_options *, const u_char *, u_int);
+extern void lwres_print(netdissect_options *, const u_char *, u_int);
+extern void cfm_print(netdissect_options *, const u_char *, u_int);
+extern void nbt_tcp_print(netdissect_options *, const u_char *, int);
+extern void nbt_udp137_print(netdissect_options *, const u_char *, int);
+extern void nbt_udp138_print(netdissect_options *, const u_char *, int);
+extern void smb_tcp_print(netdissect_options *, const u_char *, int);
+extern void netbeui_print(netdissect_options *, u_short, const u_char *, int);
+extern void ipx_netbios_print(netdissect_options *, const u_char *, u_int);
+extern void print_data(netdissect_options *, const unsigned char *, int);
+extern void decnet_print(netdissect_options *, const u_char *, u_int, u_int);
+extern void tcp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
+extern void ospf_print(netdissect_options *, const u_char *, u_int, const u_char *);
+extern int ospf_print_te_lsa(netdissect_options *, const uint8_t *, u_int);
+extern int ospf_print_grace_lsa(netdissect_options *, const uint8_t *, u_int);
+extern u_int ppp_print(netdissect_options *, register const u_char *, u_int);
+extern u_int ppp_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int ppp_hdlc_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int ppp_bsdos_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern void lldp_print(netdissect_options *, const u_char *, u_int);
+extern void rsvp_print(netdissect_options *, const u_char *, u_int);
+extern void timed_print(netdissect_options *, const u_char *);
+extern void m3ua_print(netdissect_options *, const u_char *, const u_int);
+extern void aoe_print(netdissect_options *, const u_char *, const u_int);
+extern void ftp_print(netdissect_options *, const u_char *, u_int);
+extern void http_print(netdissect_options *, const u_char *, u_int);
+extern void rtsp_print(netdissect_options *, const u_char *, u_int);
+extern void smtp_print(netdissect_options *, const u_char *, u_int);
+extern void geneve_print(netdissect_options *, const u_char *, u_int);
 
 /* stuff that has not yet been rototiled */
 
 #if 0
 extern void ascii_print(netdissect_options *,u_int);
-extern void decnet_print(netdissect_options *,const u_char *,
-                        u_int, u_int);
 extern void default_print(netdissect_options *,const u_char *, u_int);
-
-extern void ieee802_11_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
-extern const char *linkaddr_string(netdissect_options *ndo,
-                                  const u_char *ep, const unsigned int len);
-extern void nfsreply_print(netdissect_options *,const u_char *,
-                          u_int, const u_char *);
-extern void nfsreq_print(netdissect_options *,const u_char *,
-                        u_int, const u_char *);
-extern void ospf_print(netdissect_options *,const u_char *,
-                      u_int, const u_char *);
-extern void ppp_print(netdissect_options *,
-                     register const u_char *, u_int);
-
-extern void ppp_if_print(u_char *,const struct pcap_pkthdr *, const u_char *);
-extern void ppp_hdlc_if_print(u_char *,
-                             const struct pcap_pkthdr *, const u_char *);
-extern void ppp_bsdos_if_print(u_char *,
-                              const struct pcap_pkthdr *, const u_char *);
-
-extern void tcp_print(netdissect_options *,const u_char *, u_int,
-                     const u_char *, int);
-extern void timed_print(netdissect_options *,const u_char *, u_int);
-extern void netbeui_print(netdissect_options *,u_short,
-                         const u_char *, int);
-extern void ipx_netbios_print(netdissect_options *,const u_char *, u_int);
-extern void nbt_tcp_print(netdissect_options *,const u_char *, int);
-extern void nbt_udp137_print(netdissect_options *,
-                            const u_char *data, int);
-extern void nbt_udp138_print(netdissect_options *,
-                            const u_char *data, int);
 extern char *smb_errstr(netdissect_options *,int, int);
-extern const char *nt_errstr(netdissect_options *, u_int32_t);
-extern void print_data(netdissect_options *,const unsigned char *, int);
-extern void lwres_print(netdissect_options *,const u_char *, u_int);
+extern const char *nt_errstr(netdissect_options *, uint32_t);
 #endif
 
 extern u_int ipnet_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
@@ -547,9 +575,13 @@ extern u_int ppi_if_print(netdissect_options *,const struct pcap_pkthdr *, const
 extern u_int nflog_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
 extern u_int ieee802_15_4_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
 extern u_int pktap_if_print(netdissect_options *,const struct pcap_pkthdr *, const u_char *);
+extern u_int ieee802_11_radio_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int ieee802_11_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int ieee802_11_radio_avs_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
+extern u_int prism_if_print(netdissect_options *, const struct pcap_pkthdr *, const u_char *);
 
-#ifdef INET6
 extern void ip6_print(netdissect_options *,const u_char *, u_int);
+#ifdef INET6
 extern int frag6_print(netdissect_options *, const u_char *, const u_char *);
 extern int rt6_print(netdissect_options *, const u_char *, const u_char *);
 extern int hbhopt_print(netdissect_options *, const u_char *);
@@ -558,17 +590,18 @@ extern void ripng_print(netdissect_options *, const u_char *, unsigned int);
 extern int mobility_print(netdissect_options *, const u_char *, const u_char *);
 extern void dhcp6_print(netdissect_options *, const u_char *, u_int);
 extern void ospf6_print(netdissect_options *, const u_char *, u_int);
+extern void babel_print(netdissect_options *, const u_char *, u_int);
 #endif /*INET6*/
 
 #if 0
 struct cksum_vec {
-       const u_int8_t  *ptr;
+       const uint8_t   *ptr;
        int             len;
 };
-extern u_int16_t in_cksum(const struct cksum_vec *, int);
-extern u_int16_t in_cksum_shouldbe(u_int16_t, u_int16_t);
+extern uint16_t in_cksum(const struct cksum_vec *, int);
+extern uint16_t in_cksum_shouldbe(uint16_t, uint16_t);
 #endif
-extern int nextproto4_cksum(netdissect_options *ndo, const struct ip *, const u_int8_t *, u_int, u_int, u_int);
+extern int nextproto4_cksum(netdissect_options *ndo, const struct ip *, const uint8_t *, u_int, u_int, u_int);
 extern int decode_prefix4(netdissect_options *ndo, const u_char *, u_int, char *, u_int);
 #ifdef INET6
 extern int decode_prefix6(netdissect_options *ndo, const u_char *, u_int, char *, u_int);