1: /*
   2:  * Copyright (c) 1982, 1986 Regents of the University of California.
   3:  * All rights reserved.
   4:  *
   5:  * Redistribution and use in source and binary forms are permitted
   6:  * provided that this notice is preserved and that due credit is given
   7:  * to the University of California at Berkeley. The name of the University
   8:  * may not be used to endorse or promote products derived from this
   9:  * software without specific prior written permission. This software
  10:  * is provided ``as is'' without express or implied warranty.
  11:  *
  12:  *	@(#)tcp_debug.c	7.2.1 (2.11BSD) 1995/10/11
  13:  */
  14: 
  15: #ifdef  TCPDEBUG
  16: #define TCPTIMERS
  17: #define TANAMES
  18: #define PRUREQUESTS
  19: #define TCPSTATES
  20: #endif
  21: 
  22: #include "param.h"
  23: #include "systm.h"
  24: #include "mbuf.h"
  25: #include "socket.h"
  26: #include "socketvar.h"
  27: #include "protosw.h"
  28: #include "errno.h"
  29: 
  30: #include "../net/route.h"
  31: #include "../net/if.h"
  32: 
  33: #include "domain.h"
  34: #include "in.h"
  35: #include "in_pcb.h"
  36: #include "in_systm.h"
  37: #include "ip.h"
  38: #include "ip_var.h"
  39: #include "tcp.h"
  40: #include "tcp_fsm.h"
  41: #include "tcp_seq.h"
  42: #include "tcp_timer.h"
  43: #include "tcp_var.h"
  44: #include "tcpip.h"
  45: #include "tcp_debug.h"
  46: 
  47: #ifdef  TCPDEBUG
  48: int tcpconsdebug = 0;
  49: #endif
  50: 
  51: /*
  52:  * Tcp debug routines
  53:  */
  54: tcp_trace(act, ostate, tp, ti, req)
  55:     short act, ostate;
  56:     struct tcpcb *tp;
  57:     struct tcpiphdr *ti;
  58:     int req;
  59: {
  60:     tcp_seq seq, ack;
  61:     int len, flags;
  62:     struct tcp_debug *td = &tcp_debug[tcp_debx++];
  63: 
  64:     if (tcp_debx == TCP_NDEBUG)
  65:         tcp_debx = 0;
  66:     td->td_time = iptime();
  67:     td->td_act = act;
  68:     td->td_ostate = ostate;
  69:     td->td_tcb = (caddr_t)tp;
  70:     if (tp)
  71:         td->td_cb = *tp;
  72:     else
  73:         bzero((caddr_t)&td->td_cb, sizeof (*tp));
  74:     if (ti)
  75:         td->td_ti = *ti;
  76:     else
  77:         bzero((caddr_t)&td->td_ti, sizeof (*ti));
  78:     td->td_req = req;
  79: #ifdef  TCPDEBUG
  80:     if (tcpconsdebug == 0)
  81:         return;
  82:     if (tp)
  83:         printf("%x %s:", tp, tcpstates[ostate]);
  84:     else
  85:         printf("???????? ");
  86:     printf("%s ", tanames[act]);
  87:     switch (act) {
  88: 
  89:     case TA_INPUT:
  90:     case TA_OUTPUT:
  91:     case TA_DROP:
  92:         if (ti == 0)
  93:             break;
  94:         seq = ti->ti_seq;
  95:         ack = ti->ti_ack;
  96:         len = ti->ti_len;
  97:         if (act == TA_OUTPUT) {
  98:             seq = ntohl(seq);
  99:             ack = ntohl(ack);
 100:             len = ntohs((u_short)len);
 101:         }
 102:         if (act == TA_OUTPUT)
 103:             len -= sizeof (struct tcphdr);
 104:         if (len)
 105:             printf("[%X..%X)", seq, seq+len);
 106:         else
 107:             printf("%X", seq);
 108:         printf("@%X, urp=%X", ack, ti->ti_urp);
 109:         flags = ti->ti_flags;
 110:         if (flags) {
 111: #ifndef lint
 112:             char *cp = "<";
 113: #define pf(f) { if (ti->ti_flags&TH_/**/f) { printf("%s%s", cp, "f"); cp = ","; } }
 114:             pf(SYN); pf(ACK); pf(FIN); pf(RST); pf(PUSH); pf(URG);
 115: #endif
 116:             printf(">");
 117:         }
 118:         break;
 119: 
 120:     case TA_USER:
 121:         printf("%s", prurequests[req&0xff]);
 122:         if ((req & 0xff) == PRU_SLOWTIMO)
 123:             printf("<%s>", tcptimers[req>>8]);
 124:         break;
 125:     }
 126:     if (tp)
 127:         printf(" -> %s", tcpstates[tp->t_state]);
 128:     /* print out internal state of tp !?! */
 129:     printf("\n");
 130:     if (tp == 0)
 131:         return;
 132:     printf("\trcv_(nxt,wnd,up) (%X,%x,%x) snd_(una,nxt,max) (%X,%X,%X)\n",
 133:         tp->rcv_nxt, tp->rcv_wnd, tp->rcv_up, tp->snd_una, tp->snd_nxt,
 134:         tp->snd_max);
 135:     printf("\tsnd_(wl1,wl2,wnd) (%X,%X,%x)\n",
 136:         tp->snd_wl1, tp->snd_wl2, tp->snd_wnd);
 137: #endif /* TCPDEBUG */
 138: }

Defined functions

tcp_trace defined in line 54; never used

Defined variables

tcpconsdebug defined in line 48; used 1 times
  • in line 80

Defined macros

PRUREQUESTS defined in line 18; never used
TANAMES defined in line 17; never used
TCPSTATES defined in line 19; never used
TCPTIMERS defined in line 16; never used
pf defined in line 113; used 6 times
  • in line 114(6)
Last modified: 1995-10-12
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3428
Valid CSS Valid XHTML 1.0 Strict