Annotation of 43BSDTahoe/sys/netns/spp_debug.c, revision 1.1.1.1

1.1       root        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 the above copyright notice and this paragraph are
                      7:  * duplicated in all such forms and that any documentation,
                      8:  * advertising materials, and other materials related to such
                      9:  * distribution and use acknowledge that the software was developed
                     10:  * by the University of California, Berkeley.  The name of the
                     11:  * University may not be used to endorse or promote products derived
                     12:  * from this software without specific prior written permission.
                     13:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
                     14:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
                     15:  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     16:  *
                     17:  *     @(#)spp_debug.c 7.5 (Berkeley) 6/29/88
                     18:  */
                     19: 
                     20: #include "param.h"
                     21: #include "systm.h"
                     22: #include "mbuf.h"
                     23: #include "socket.h"
                     24: #include "socketvar.h"
                     25: #include "protosw.h"
                     26: #include "errno.h"
                     27: 
                     28: #include "../net/route.h"
                     29: #include "../net/if.h"
                     30: #include "../netinet/tcp_fsm.h"
                     31: 
                     32: #include "ns.h"
                     33: #include "ns_pcb.h"
                     34: #include "idp.h"
                     35: #include "idp_var.h"
                     36: #include "sp.h"
                     37: #include "spidp.h"
                     38: #define SPPTIMERS
                     39: #include "spp_timer.h"
                     40: #include "spp_var.h"
                     41: #define        SANAMES
                     42: #include "spp_debug.h"
                     43: 
                     44: int    sppconsdebug = 0;
                     45: /*
                     46:  * spp debug routines
                     47:  */
                     48: spp_trace(act, ostate, sp, si, req)
                     49:        short act;
                     50:        u_char ostate;
                     51:        struct sppcb *sp;
                     52:        struct spidp *si;
                     53:        int req;
                     54: {
                     55: #ifdef INET
                     56:        u_short seq, ack, len, alo;
                     57:        unsigned long iptime();
                     58:        int flags;
                     59:        struct spp_debug *sd = &spp_debug[spp_debx++];
                     60:        extern char *prurequests[];
                     61:        extern char *sanames[];
                     62:        extern char *tcpstates[];
                     63:        extern char *spptimers[];
                     64: 
                     65:        if (spp_debx == SPP_NDEBUG)
                     66:                spp_debx = 0;
                     67:        sd->sd_time = iptime();
                     68:        sd->sd_act = act;
                     69:        sd->sd_ostate = ostate;
                     70:        sd->sd_cb = (caddr_t)sp;
                     71:        if (sp)
                     72:                sd->sd_sp = *sp;
                     73:        else
                     74:                bzero((caddr_t)&sd->sd_sp, sizeof (*sp));
                     75:        if (si)
                     76:                sd->sd_si = *si;
                     77:        else
                     78:                bzero((caddr_t)&sd->sd_si, sizeof (*si));
                     79:        sd->sd_req = req;
                     80:        if (sppconsdebug == 0)
                     81:                return;
                     82:        if (ostate >= TCP_NSTATES) ostate = 0;
                     83:        if (act >= SA_DROP) act = SA_DROP;
                     84:        if (sp)
                     85:                printf("%x %s:", sp, tcpstates[ostate]);
                     86:        else
                     87:                printf("???????? ");
                     88:        printf("%s ", sanames[act]);
                     89:        switch (act) {
                     90: 
                     91:        case SA_RESPOND:
                     92:        case SA_INPUT:
                     93:        case SA_OUTPUT:
                     94:        case SA_DROP:
                     95:                if (si == 0)
                     96:                        break;
                     97:                seq = si->si_seq;
                     98:                ack = si->si_ack;
                     99:                alo = si->si_alo;
                    100:                len = si->si_len;
                    101:                if (act == SA_OUTPUT) {
                    102:                        seq = ntohs(seq);
                    103:                        ack = ntohs(ack);
                    104:                        alo = ntohs(alo);
                    105:                        len = ntohs(len);
                    106:                }
                    107: #ifndef lint
                    108: #define p1(f)  { printf("%s = %x, ", "f", f); }
                    109:                p1(seq); p1(ack); p1(alo); p1(len);
                    110: #endif
                    111:                flags = si->si_cc;
                    112:                if (flags) {
                    113:                        char *cp = "<";
                    114: #ifndef lint
                    115: #define pf(f) { if (flags&SP_/**/f) { printf("%s%s", cp, "f"); cp = ","; } }
                    116:                        pf(SP); pf(SA); pf(OB); pf(EM);
                    117: #else
                    118:                        cp = cp;
                    119: #endif
                    120:                        printf(">");
                    121:                }
                    122: #ifndef lint
                    123: #define p2(f)  { printf("%s = %x, ", "f", si->si_/**/f); }
                    124:                p2(sid);p2(did);p2(dt);p2(pt);
                    125: #endif
                    126:                ns_printhost(&si->si_sna);
                    127:                ns_printhost(&si->si_dna);
                    128: 
                    129:                if (act==SA_RESPOND) {
                    130:                        printf("idp_len = %x, ",
                    131:                                ((struct idp *)si)->idp_len);
                    132:                }
                    133:                break;
                    134: 
                    135:        case SA_USER:
                    136:                printf("%s", prurequests[req&0xff]);
                    137:                if ((req & 0xff) == PRU_SLOWTIMO)
                    138:                        printf("<%s>", spptimers[req>>8]);
                    139:                break;
                    140:        }
                    141:        if (sp)
                    142:                printf(" -> %s", tcpstates[sp->s_state]);
                    143:        /* print out internal state of sp !?! */
                    144:        printf("\n");
                    145:        if (sp == 0)
                    146:                return;
                    147: #ifndef lint
                    148: #define p3(f)  { printf("%s = %x, ", "f", sp->s_/**/f); }
                    149:        printf("\t"); p3(rack);p3(ralo);p3(smax);p3(flags); printf("\n");
                    150: #endif
                    151: #endif
                    152: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.