1: /*
   2:  * Copyright (c) 1984, 1985, 1986, 1987 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:  *      @(#)spp_debug.c	7.4 (Berkeley) 3/12/88
  13:  */
  14: 
  15: #include "param.h"
  16: #ifdef  NS
  17: #include "systm.h"
  18: #include "mbuf.h"
  19: #include "socket.h"
  20: #include "socketvar.h"
  21: #include "protosw.h"
  22: #include "errno.h"
  23: 
  24: #include "../net/route.h"
  25: #include "../net/if.h"
  26: #include "../netinet/tcp_fsm.h"
  27: 
  28: #include "ns.h"
  29: #include "ns_pcb.h"
  30: #include "idp.h"
  31: #include "idp_var.h"
  32: #include "sp.h"
  33: #include "spidp.h"
  34: #define SPPTIMERS
  35: #include "spp_timer.h"
  36: #include "spp_var.h"
  37: #define SANAMES
  38: #include "spp_debug.h"
  39: 
  40: int sppconsdebug = 0;
  41: /*
  42:  * spp debug routines
  43:  */
  44: spp_trace(act, ostate, sp, si, req)
  45:     short act;
  46:     u_char ostate;
  47:     struct sppcb *sp;
  48:     struct spidp *si;
  49:     int req;
  50: {
  51: #ifdef INET
  52:     u_short seq, ack, len, alo;
  53:     u_long iptime();
  54:     int flags;
  55:     struct spp_debug *sd = &spp_debug[spp_debx++];
  56:     extern char *prurequests[];
  57:     extern char *sanames[];
  58:     extern char *tcpstates[];
  59:     extern char *spptimers[];
  60: 
  61:     if (spp_debx == SPP_NDEBUG)
  62:         spp_debx = 0;
  63:     sd->sd_time = iptime();
  64:     sd->sd_act = act;
  65:     sd->sd_ostate = ostate;
  66:     sd->sd_cb = (caddr_t)sp;
  67:     if (sp)
  68:         sd->sd_sp = *sp;
  69:     else
  70:         bzero((caddr_t)&sd->sd_sp, sizeof (*sp));
  71:     if (si)
  72:         sd->sd_si = *si;
  73:     else
  74:         bzero((caddr_t)&sd->sd_si, sizeof (*si));
  75:     sd->sd_req = req;
  76:     if (sppconsdebug == 0)
  77:         return;
  78:     if (ostate >= TCP_NSTATES) ostate = 0;
  79:     if (act >= SA_DROP) act = SA_DROP;
  80:     if (sp)
  81:         printf("%x %s:", sp, tcpstates[ostate]);
  82:     else
  83:         printf("???????? ");
  84:     printf("%s ", sanames[act]);
  85:     switch (act) {
  86: 
  87:     case SA_RESPOND:
  88:     case SA_INPUT:
  89:     case SA_OUTPUT:
  90:     case SA_DROP:
  91:         if (si == 0)
  92:             break;
  93:         seq = si->si_seq;
  94:         ack = si->si_ack;
  95:         alo = si->si_alo;
  96:         len = si->si_len;
  97:         if (act == SA_OUTPUT) {
  98:             seq = ntohs(seq);
  99:             ack = ntohs(ack);
 100:             alo = ntohs(alo);
 101:             len = ntohs(len);
 102:         }
 103: #ifndef lint
 104: #define p1(f)  { printf("%s = %x, ", "f", f); }
 105:         p1(seq); p1(ack); p1(alo); p1(len);
 106: #endif
 107:         flags = si->si_cc;
 108:         if (flags) {
 109:             char *cp = "<";
 110: #ifndef lint
 111: #define pf(f) { if (flags&SP_/**/f) { printf("%s%s", cp, "f"); cp = ","; } }
 112:             pf(SP); pf(SA); pf(OB); pf(EM);
 113: #else
 114:             cp = cp;
 115: #endif
 116:             printf(">");
 117:         }
 118: #ifndef lint
 119: #define p2(f)  { printf("%s = %x, ", "f", si->si_/**/f); }
 120:         p2(sid);p2(did);p2(dt);p2(pt);
 121: #endif
 122:         ns_printhost(&si->si_sna);
 123:         ns_printhost(&si->si_dna);
 124: 
 125:         if (act==SA_RESPOND) {
 126:             printf("idp_len = %x, ",
 127:                 ((struct idp *)si)->idp_len);
 128:         }
 129:         break;
 130: 
 131:     case SA_USER:
 132:         printf("%s", prurequests[req&0xff]);
 133:         if ((req & 0xff) == PRU_SLOWTIMO)
 134:             printf("<%s>", spptimers[req>>8]);
 135:         break;
 136:     }
 137:     if (sp)
 138:         printf(" -> %s", tcpstates[sp->s_state]);
 139:     /* print out internal state of sp !?! */
 140:     printf("\n");
 141:     if (sp == 0)
 142:         return;
 143: #ifndef lint
 144: #define p3(f)  { printf("%s = %x, ", "f", sp->s_/**/f); }
 145:     printf("\t"); p3(rack);p3(ralo);p3(smax);p3(flags); printf("\n");
 146: #endif
 147: #endif
 148: }
 149: #endif

Defined functions

spp_trace defined in line 44; never used

Defined variables

sppconsdebug defined in line 40; used 1 times
  • in line 76

Defined macros

SANAMES defined in line 37; never used
SPPTIMERS defined in line 34; never used
p1 defined in line 104; used 4 times
  • in line 105(4)
p2 defined in line 119; used 4 times
  • in line 120(4)
p3 defined in line 144; used 4 times
  • in line 145(4)
pf defined in line 111; used 4 times
  • in line 112(4)
Last modified: 1988-04-29
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3283
Valid CSS Valid XHTML 1.0 Strict