Watt-32 tcp/ip  2.2 dev-rel.10
Data Structures | Enumerations | Functions | Variables
pcdbug.c File Reference

Go to the source code of this file.

Data Structures

struct  token
 
struct  pcap_file_header
 
struct  pcap_pkt_header
 
struct  model_info
 

Enumerations

enum  ncp_codes {
  CONFREQ = 1,
  CONFACK = 2,
  CONFNAK = 3,
  CONFREJ = 4,
  TERMREQ = 5,
  TERMACK = 6,
  CODEREJ = 7,
  PROTREJ = 8,
  ECHOREQ = 9,
  ECHOREP = 10,
  DISCARD = 11
}
 
enum  lcp_options {
  LCP_RESERVED = 0,
  LCP_MRU = 1,
  LCP_ASYNCMAP = 2,
  LCP_AUTHPROTO = 3,
  LCP_QUALPROTO = 4,
  LCP_MAGICNUM = 5,
  LCP_PCOMP = 7,
  LCP_ACFCOMP = 8,
  LCP_CALLBACK = 13
}
 
enum  ipcp_options {
  IPCP_RESERVED = 0,
  IPCP_ADDRS = 1,
  IPCP_COMPRTYPE = 2,
  IPCP_ADDR = 3,
  IPCP_MS_DNS1 = 129,
  IPCP_MS_WINS1 = 130,
  IPCP_MS_DNS2 = 131,
  IPCP_MS_WINS2 = 132
}
 

Functions

const char * tcpStateName (UINT state)
 
void dbug_init (void)
 
static void dbug_exit (void)
 Print ARP-cache and statistics counters to one of the debug-files. More...
 
static void dbug_close (void)
 
static void dump_ip_opt (const void *opt, int len)
 
static void dump_tcp_opt (const void *opt, int len, DWORD ack)
 
static DWORD dump_data (const void *data, UINT datalen)
 
static int udp_dump (const _udp_Socket *sock, const in_Header *ip)
 
static int tcp_dump (const _tcp_Socket *sock, const in_Header *ip)
 
static unsigned dns_dump (const BYTE *, unsigned, unsigned)
 
static const BYTE * dns_resource (const BYTE *, const BYTE *, const BYTE *)
 
static const BYTE * dns_labels (const BYTE *, const BYTE *, const BYTE *)
 
static int write_pcap_header (void)
 
static int write_pcap_packet (const void *pkt, BOOL out)
 
static unsigned ccp_dump (const BYTE *bp)
 
static unsigned lcp_dump (const BYTE *bp)
 
static unsigned ipcp_dump (const BYTE *bp)
 
static void print_cpu_info (void)
 
static void (W32_CALL *prev_hook)(const char *
 
static int udp6_dump (const _udp_Socket *sock, const in6_Header *ip)
 
BOOL dbug_file (void)
 
void dbug_open (void)
 
static __inline BOOL MAC_is_mcast (const void *addr)
 
static __inline BOOL MAC_is_bcast (const void *addr)
 
static __inline BOOL is_looped (const in_Header *ip)
 
static __inline BOOL match_link_destination (const void *addr)
 
static __inline BOOL match_arp_rarp (const arp_Header *arp)
 
static __inline BOOL match_ip4_dest (const in_Header *ip)
 
static __inline BOOL match_ip6_dest (const in6_Header *ip)
 
static __inline const char * do_check_sum (WORD value, const void *p, int len)
 
static __inline const char * link_protocol (WORD type)
 
static __inline const char * ip4_protocol (BYTE prot)
 
static const char * type_of_service (BYTE tos)
 
static __inline const char * RTT_str (DWORD rtt, DWORD now)
 
static __inline const char * arp_opcode (WORD code)
 
static void dump_addr_port (const char *proto, const void *sock, const in_Header *ip)
 
static __inline void ip6_addr_type (char *ret, const void *addr)
 
static void dump_addr6_port (const char *proto, const void *sock, const in6_Header *ip)
 
static void link_head_dump (const union link_Packet *pkt)
 
static int arp_dump (const arp_Header *arp)
 
static int rarp_dump (const rarp_Header *rarp)
 
static void ip4_dump (const in_Header *ip)
 
static int ip4_orig_dump (const in_Header *this_ip, const in_Header *orig_ip, int icmp_len)
 
static int icmp4_dump (const in_Header *ip)
 
static int igmp0_dump (const IGMPv0_packet *igmp, WORD len)
 
static int igmp1_dump (const IGMPv1_packet *igmp, WORD len)
 
static int igmp2_dump (const IGMPv2_packet *igmp, WORD len)
 
static int igmp3_dump (const IGMPv3_packet *igmp, WORD len)
 
static int igmp_dump (const in_Header *ip)
 
static void sctp_dump_params (const BYTE *p, int len)
 
static void sctp_dump_init (const struct sctp_Initiation *init, const BYTE *chunk_end)
 
static int sctp_dump (const in_Header *ip4, const in6_Header *ip6)
 
static unsigned ip4_payload_dump (const void *sock, const in_Header *ip)
 
static const char * ip6_next_hdr (BYTE nxt)
 
const char * icmp6_options (const BYTE *opt, int tot_len)
 
static int icmp6_dump (const in6_Header *ip)
 
static int ip6_header_dump (const in6_Header *ip)
 
static unsigned ip6_payload_dump (const void *sock, const in6_Header *ip)
 
static const char * tok2str (const struct token *lp, const char *fmt, int v)
 
static const char * pppoe_get_tag (const BYTE *tag)
 
const char * pppoe_get_code (WORD code)
 
static __inline int pppoe_head_dump (const struct pppoe_Packet *pppoe, const char *proto)
 
static int pppoe_disc_dump (const struct pppoe_Packet *pppoe)
 
static int pppoe_sess_dump (const void *sock, const struct pppoe_Packet *pppoe)
 
static const char * udp_tcp_checksum (const in_Header *ip, const udp_Header *udp, const tcp_Header *tcp)
 
static const char * udp_checksum (const in6_Header *ip, const udp_Header *udp)
 
static const char * tcp_checksum (const in6_Header *ip, const tcp_Header *tcp)
 
static BOOL is_dns_packet (WORD src_port, WORD dst_port)
 
static BOOL dbug_filter (void)
 
static const char * pcdbug_driver_ver (void)
 
static const char * pcdbug_api_ver (void)
 
static void print_driver_info (void)
 
static void dbug_dump (const void *sock, const in_Header *ip, const char *fname, unsigned line, BOOL out)
 
static void trace_xmit_pkt (const void *sock, const in_Header *ip, const char *fname, unsigned line)
 
static void trace_recv_pkt (const void *sock, const in_Header *ip, const char *fname, unsigned line)
 
static void set_debug_file (const char *value)
 
static void set_debug_mode (const char *value)
 
static void set_debug_filter (const char *value)
 
static void set_debug_proto (const char *value)
 
static void W32_CALL dbug_cfg_parse (const char *name, const char *value)
 
static int flush_ods (void)
 
int MS_CDECL dbug_printf (const char *format,...)
 
int dbug_write (const char *buf)
 
int dbug_putc (int c)
 
int db_write_raw (const char *buf)
 
void dbug_flush (void)
 
static __inline const char * dns_query (WORD type)
 
static const char * i486_model (int model)
 
static const char * i586_model (int model)
 
static const char * Cx86_model (int type)
 
static const char * i686_model (int model)
 
static const char * AMD_model (int type, int model)
 
static const char * get_model (const char *vendor, int type, int model)
 

Variables

DebugProc debug_xmit = NULL
 
DebugProc debug_recv = NULL
 
static const char *static jmp_buf dbg_jmp = NULL
 
static char dbg_name [MAX_PATHLEN+1] = "WATTCP.DBG"
 
static BOOL dbg_linebuf = FALSE
 
static BOOL pcap_mode = FALSE
 
static DWORD now
 
static BOOL outbound
 
static BOOL in_dbug_dump
 
static BOOL use_gzip
 
static BOOL use_ods = FALSE
 
static char ip4_src [20]
 
static char ip4_dst [20]
 
union {
   FILE *   stream
 
   void *   gz_stream
 
dbg_file
 
static int frag_status
 
static char ip6_src [50]
 
static char ip6_dst [50]
 
struct {
   char   MAC
 
   char   ARP
 
   char   RARP
 
   char   IP
 
   char   BCAST
 
   char   MCAST
 
   char   LOOP
 
   char   NONE
 
filter = { 1,1,1,1,1,1,0,0 }
 
struct {
   char   MAC
 
   char   LLC
 
   char   ARP
 
   char   RARP
 
   char   IP
 
   char   UDP
 
   char   TCP
 
   char   ICMP
 
   char   IGMP
 
   char   SCTP
 
debug = { 0,0,1,1,1,1,1,1,1,1 }
 
BOOL dbg_mode_all = 1
 These are public so they can be set by application if running without a config-file. More...
 
BOOL dbg_print_stat = 1
 
BOOL dbg_dns_details = 1
 
static DWORD bytes_raw = 0UL
 
static const struct search_list sctp_chunks []
 
static const struct search_list sctp_params []
 
struct token ppp_type2str []
 
static char ods_buf [4000]
 
static char * ods_ptr = ods_buf
 
static const char * dns_opcodes [16]
 Debug of DNS (udp) records. More...
 
static const char * dns_responses [16]
 
static const struct token ncp_code2str []
 
static const struct token lcp_option2str []
 
static const struct token ipcp_option2str []
 
static const struct token lcpauth2str []
 
static const struct token lcpqual2str []
 
static const struct token lcpchap2str []
 

Detailed Description

Watt-32 protocol debugger. Writes to `debug.file' specified in config-file. File may be stdout/stderr/nul.

Most functions are prefixed with `dbug_'. And variables with `dbg_'.

Definition in file pcdbug.c.

Function Documentation

static void dbug_exit ( void  )
static

Print ARP-cache and statistics counters to one of the debug-files.

Called from tcp_shutdown() after DHCP_release() and _tcp_abort() but before _eth_release() is called. pkt-drop counters are not reliable once _eth_release() has been called.

Definition at line 2895 of file pcdbug.c.

References _watt_assert_buf, _watt_cbroke, and _watt_fatal_error.

static int icmp4_dump ( const in_Header ip)
static
Todo:
Handle debugging of these

Definition at line 877 of file pcdbug.c.

References _inet_ntoa().

static __inline BOOL match_ip6_dest ( const in6_Header ip)
static
Todo:
needs work

Definition at line 388 of file pcdbug.c.

Variable Documentation

BOOL dbg_mode_all = 1

These are public so they can be set by application if running without a config-file.

Todo:
make them static.

Definition at line 190 of file pcdbug.c.

const char* dns_opcodes[16]
static
Initial value:
= {
"standard",
"inverse",
"server status",
"op 3??",
"op 4??",
"update",
"op 6??",
"op 7??",
"op 8??",
"op 9??",
"op 10??",
"op 11??",
"op 12??",
"op 13??",
"op 14??",
"op 15??"
}

Debug of DNS (udp) records.

Author
Mike Borella mike_.nosp@m.bore.nosp@m.lla@m.nosp@m.w.3c.nosp@m.om.co.nosp@m.m

Changed for Watt-32 and pcdbug.c by G.Vanem 1998 gvane.nosp@m.m@ya.nosp@m.hoo.n.nosp@m.o

Todo:
parse the SRV resource record (RFC 2052)

Definition at line 2954 of file pcdbug.c.

const char* dns_responses[16]
static
Initial value:
= {
"no error",
"format error",
"server error",
"NXDOMAIN",
"not implemented",
"service refused",
"resp 6??",
"resp 7??",
"resp 8??",
"resp 9??",
"resp 10??",
"resp 11??",
"resp 12??",
"resp 13??",
"resp 14??",
"resp 15??"
}

Definition at line 2973 of file pcdbug.c.

const struct token ipcp_option2str[]
static
Initial value:
= {
{ IPCP_RESERVED, "reserved" },
{ IPCP_ADDRS, "Addrs" },
{ IPCP_COMPRTYPE,"Compr" },
{ IPCP_ADDR, "Addr" },
{ IPCP_MS_DNS1, "DNS1" },
{ IPCP_MS_WINS1, "Wins1" },
{ IPCP_MS_DNS2, "DNS2" },
{ IPCP_MS_WINS2, "Win2" },
{ 0, NULL }
}

Definition at line 3378 of file pcdbug.c.

const struct token lcp_option2str[]
static
Initial value:
= {
{ LCP_RESERVED, "reserved" },
{ LCP_MRU, "MRU" },
{ LCP_ASYNCMAP, "AsyncMap" },
{ LCP_AUTHPROTO,"AUTH" },
{ LCP_QUALPROTO,"QUAL" },
{ LCP_MAGICNUM, "MAGIC" },
{ LCP_PCOMP, "PCOMP" },
{ LCP_ACFCOMP, "ACFcomp" },
{ LCP_CALLBACK, "CallBack" },
{ 0, NULL }
}

Definition at line 3365 of file pcdbug.c.

const struct token lcpauth2str[]
static
Initial value:
= {
{ 0xc023, "PAP" },
{ 0xc223, "CHAP" },
{ 0, NULL }
}

Definition at line 3390 of file pcdbug.c.

const struct token lcpchap2str[]
static
Initial value:
= {
{ 0x05, "MD5" },
{ 0x80, "MS" },
{ 0, NULL }
}

Definition at line 3401 of file pcdbug.c.

const struct token lcpqual2str[]
static
Initial value:
= {
{ 0xc025, "LQR" },
{ 0, NULL }
}

Definition at line 3396 of file pcdbug.c.

const struct token ncp_code2str[]
static
Initial value:
= {
{ CONFREQ, "ConfReq" },
{ CONFACK, "ConfAck" },
{ CONFNAK, "ConfNak" },
{ CONFREJ, "ConfRej" },
{ TERMREQ, "TermReq" },
{ TERMACK, "TermAck" },
{ CODEREJ, "CodeRej" },
{ PROTREJ, "ProtRej" },
{ ECHOREQ, "EchoReq" },
{ ECHOREP, "EchoRep" },
{ DISCARD, "Discard" },
{ 0, NULL }
}

Definition at line 3350 of file pcdbug.c.

struct token ppp_type2str[]
Initial value:
= {
{ PPP_IP, "IP" },
{ PPP_IPV6, "IP6" },
{ PPP_IPX, "IPX" },
{ PPP_VJC, "VJC" },
{ PPP_VJNC, "VJNC" },
{ PPP_IPCP, "IPCP" },
{ PPP_IPXCP, "IPXCP" },
{ PPP_LCP, "LCP" },
{ PPP_LQR, "LQR" },
{ PPP_CCP, "CCP" },
{ PPP_PAP, "PAP" },
{ PPP_CHAP, "CHAP" },
{ PPP_CBCP, "CBCP" },
{ PPP_COMP, "COMP" },
{ 0, NULL }
}

Definition at line 1468 of file pcdbug.c.

const struct search_list sctp_chunks[]
static
Initial value:
= {
{ SCTP_DATA, "DATA" },
{ SCTP_INITIATION, "INIT" },
{ SCTP_INITIATION_ACK, "INIT-ACK" },
{ SCTP_SELECTIVE_ACK, "SACK" },
{ SCTP_HEARTBEAT_REQUEST, "HB REQ" },
{ SCTP_HEARTBEAT_ACK, "HB ACK" },
{ SCTP_ABORT_ASSOCIATION, "ABORT" },
{ SCTP_SHUTDOWN, "SHUTDOWN" },
{ SCTP_SHUTDOWN_ACK, "SHUTDOWN ACK" },
{ SCTP_OPERATION_ERR, "OP ERR" },
{ SCTP_COOKIE_ECHO, "COOKIE ECHO" },
{ SCTP_COOKIE_ACK, "COOKIE ACK" },
{ SCTP_ECN_ECHO, "ECN ECHO" },
{ SCTP_ECN_CWR, "ECN CWR" },
{ SCTP_SHUTDOWN_COMPLETE, "SHUTDOWN COMPLETE" },
{ SCTP_FORWARD_CUM_TSN, "FOR CUM TSN" },
{ SCTP_RELIABLE_CNTL, "REL CTRL" },
{ SCTP_RELIABLE_CNTL_ACK, "REL CTRL ACK" },
{ SCTP_ASCONF_ACK_CHUNK_ID, "ASCONF ACK CHUNK ID" },
{ SCTP_PKTDROP_CHUNK_ID, "PKTDROP CHUNK ID" },
{ SCTP_STREAM_RESET_CHUNK_ID, "STREAM RESET_CHUNK ID" },
{ SCTP_IETF_EXT, "IETF EXT" }
}

Definition at line 1052 of file pcdbug.c.

const struct search_list sctp_params[]
static
Initial value:
= {
{ SCTP_IPV4_PARAM_TYPE, "IPV4 PARAM TYPE" },
{ SCTP_IPV6_PARAM_TYPE, "IPV6 PARAM TYPE" },
{ SCTP_RESPONDER_COOKIE, "RESPONDER COOKIE" },
{ SCTP_UNRECOG_PARAM, "UNRECOG_PARAM" },
{ SCTP_COOKIE_PRESERVE, "COOKIE PRESERVE" },
{ SCTP_HOSTNAME_VIA_DNS, "HOSTNAME VIA_DNS" },
{ SCTP_RESTRICT_ADDR_TO, "RESTRICT ADDR_TO" },
{ SCTP_ECN_I_CAN_DO_ECN, "I CAN DO ECN" },
{ SCTP_OPERATION_SUCCEED, "OPERATION SUCCEED" },
{ SCTP_ERROR_NOT_EXECUTED, "ERROR NOT EXECUTED" },
{ SCTP_UNRELIABLE_STRM, "UNRELIABLE STRM" },
{ SCTP_ADD_IP_ADDRESS, "ADD IP ADDRESS" },
{ SCTP_DEL_IP_ADDRESS, "DEL IP ADDRESS" },
{ SCTP_STRM_FLOW_LIMIT, "STRM FLOW LIMIT" },
{ SCTP_PARTIAL_CSUM, "PARTIAL CSUM" },
{ SCTP_ERROR_CAUSE_TLV, "ERROR CAUSE TLV" },
{ SCTP_MIT_STACK_NAME, "MIT STACK NAME" },
{ SCTP_SETADDRESS_PRIMARY, "SETADDRESS PRIMARY" },
{ SCTP_RANDOM_PARAM, "RANDOM PARAM" },
{ SCTP_AUTH_CHUNK, "AUTH CHUNK" },
{ SCTP_REQ_HMAC_ALGO, "REQ HMAC ALGO" },
{ SCTP_SUPPORTED_EXT, "SUPPORTED EXT" }
}

Definition at line 1077 of file pcdbug.c.