Annotation of Net2/netns/spp_debug.c, revision 1.1.1.2

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, with or without
                      6:  * modification, are permitted provided that the following conditions
                      7:  * are met:
                      8:  * 1. Redistributions of source code must retain the above copyright
                      9:  *    notice, this list of conditions and the following disclaimer.
                     10:  * 2. Redistributions in binary form must reproduce the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer in the
                     12:  *    documentation and/or other materials provided with the distribution.
                     13:  * 3. All advertising materials mentioning features or use of this software
                     14:  *    must display the following acknowledgement:
                     15:  *     This product includes software developed by the University of
                     16:  *     California, Berkeley and its contributors.
                     17:  * 4. Neither the name of the University nor the names of its contributors
                     18:  *    may be used to endorse or promote products derived from this software
                     19:  *    without specific prior written permission.
                     20:  *
                     21:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     22:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     23:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     24:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     25:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     26:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     27:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     28:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     29:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     30:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     31:  * SUCH DAMAGE.
                     32:  *
1.1.1.2 ! root       33:  *     from: @(#)spp_debug.c   7.7 (Berkeley) 6/28/90
        !            34:  *     spp_debug.c,v 1.2 1993/05/20 04:36:06 cgd Exp
1.1       root       35:  */
                     36: 
                     37: #include "param.h"
                     38: #include "systm.h"
                     39: #include "mbuf.h"
                     40: #include "socket.h"
                     41: #include "socketvar.h"
                     42: #include "protosw.h"
                     43: #include "errno.h"
                     44: 
                     45: #include "../net/route.h"
                     46: #include "../net/if.h"
                     47: #include "../netinet/tcp_fsm.h"
                     48: 
                     49: #include "ns.h"
                     50: #include "ns_pcb.h"
                     51: #include "idp.h"
                     52: #include "idp_var.h"
                     53: #include "sp.h"
                     54: #include "spidp.h"
                     55: #define SPPTIMERS
                     56: #include "spp_timer.h"
                     57: #include "spp_var.h"
                     58: #define        SANAMES
                     59: #include "spp_debug.h"
                     60: 
                     61: int    sppconsdebug = 0;
                     62: /*
                     63:  * spp debug routines
                     64:  */
                     65: spp_trace(act, ostate, sp, si, req)
                     66:        short act;
                     67:        u_char ostate;
                     68:        struct sppcb *sp;
                     69:        struct spidp *si;
                     70:        int req;
                     71: {
                     72: #ifdef INET
                     73: #ifdef TCPDEBUG
                     74:        u_short seq, ack, len, alo;
                     75:        unsigned long iptime();
                     76:        int flags;
                     77:        struct spp_debug *sd = &spp_debug[spp_debx++];
                     78:        extern char *prurequests[];
                     79:        extern char *sanames[];
                     80:        extern char *tcpstates[];
                     81:        extern char *spptimers[];
                     82: 
                     83:        if (spp_debx == SPP_NDEBUG)
                     84:                spp_debx = 0;
                     85:        sd->sd_time = iptime();
                     86:        sd->sd_act = act;
                     87:        sd->sd_ostate = ostate;
                     88:        sd->sd_cb = (caddr_t)sp;
                     89:        if (sp)
                     90:                sd->sd_sp = *sp;
                     91:        else
                     92:                bzero((caddr_t)&sd->sd_sp, sizeof (*sp));
                     93:        if (si)
                     94:                sd->sd_si = *si;
                     95:        else
                     96:                bzero((caddr_t)&sd->sd_si, sizeof (*si));
                     97:        sd->sd_req = req;
                     98:        if (sppconsdebug == 0)
                     99:                return;
                    100:        if (ostate >= TCP_NSTATES) ostate = 0;
                    101:        if (act >= SA_DROP) act = SA_DROP;
                    102:        if (sp)
                    103:                printf("%x %s:", sp, tcpstates[ostate]);
                    104:        else
                    105:                printf("???????? ");
                    106:        printf("%s ", sanames[act]);
                    107:        switch (act) {
                    108: 
                    109:        case SA_RESPOND:
                    110:        case SA_INPUT:
                    111:        case SA_OUTPUT:
                    112:        case SA_DROP:
                    113:                if (si == 0)
                    114:                        break;
                    115:                seq = si->si_seq;
                    116:                ack = si->si_ack;
                    117:                alo = si->si_alo;
                    118:                len = si->si_len;
                    119:                if (act == SA_OUTPUT) {
                    120:                        seq = ntohs(seq);
                    121:                        ack = ntohs(ack);
                    122:                        alo = ntohs(alo);
                    123:                        len = ntohs(len);
                    124:                }
                    125: #ifndef lint
                    126: #define p1(f)  { printf("%s = %x, ", "f", f); }
                    127:                p1(seq); p1(ack); p1(alo); p1(len);
                    128: #endif
                    129:                flags = si->si_cc;
                    130:                if (flags) {
                    131:                        char *cp = "<";
                    132: #ifndef lint
                    133: #define pf(f) { if (flags&SP_/**/f) { printf("%s%s", cp, "f"); cp = ","; } }
                    134:                        pf(SP); pf(SA); pf(OB); pf(EM);
                    135: #else
                    136:                        cp = cp;
                    137: #endif
                    138:                        printf(">");
                    139:                }
                    140: #ifndef lint
                    141: #define p2(f)  { printf("%s = %x, ", "f", si->si_/**/f); }
                    142:                p2(sid);p2(did);p2(dt);p2(pt);
                    143: #endif
                    144:                ns_printhost(&si->si_sna);
                    145:                ns_printhost(&si->si_dna);
                    146: 
                    147:                if (act==SA_RESPOND) {
                    148:                        printf("idp_len = %x, ",
                    149:                                ((struct idp *)si)->idp_len);
                    150:                }
                    151:                break;
                    152: 
                    153:        case SA_USER:
                    154:                printf("%s", prurequests[req&0xff]);
                    155:                if ((req & 0xff) == PRU_SLOWTIMO)
                    156:                        printf("<%s>", spptimers[req>>8]);
                    157:                break;
                    158:        }
                    159:        if (sp)
                    160:                printf(" -> %s", tcpstates[sp->s_state]);
                    161:        /* print out internal state of sp !?! */
                    162:        printf("\n");
                    163:        if (sp == 0)
                    164:                return;
                    165: #ifndef lint
                    166: #define p3(f)  { printf("%s = %x, ", "f", sp->s_/**/f); }
                    167:        printf("\t"); p3(rack);p3(ralo);p3(smax);p3(flags); printf("\n");
                    168: #endif
                    169: #endif
                    170: #endif
                    171: }

unix.superglobalmegacorp.com

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