BSD 4_3_Net_2 release
[unix-history] / usr / src / usr.sbin / trsp / trsp.c
index 43d60ba..f4ba04c 100644 (file)
@@ -2,19 +2,33 @@
  * Copyright (c) 1985 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1985 Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted provided
- * that: (1) source distributions retain this entire copyright notice and
- * comment, and (2) distributions including binaries display the following
- * acknowledgement:  ``This product includes software developed by the
- * University of California, Berkeley and its contributors'' in the
- * documentation or other materials provided with the distribution and in
- * all advertising materials mentioning features or use of this software.
- * Neither the name of the University nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
@@ -24,9 +38,10 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)trsp.c     6.7 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)trsp.c     6.8 (Berkeley) 3/2/91";
 #endif /* not lint */
 
 #endif /* not lint */
 
+#include <sys/cdefs.h>
 #include <sys/param.h>
 #include <sys/socket.h>
 #include <sys/socketvar.h>
 #include <sys/param.h>
 #include <sys/socket.h>
 #include <sys/socketvar.h>
@@ -42,13 +57,13 @@ static char sccsid[] = "@(#)trsp.c  6.7 (Berkeley) 6/1/90";
 #include <netinet/tcp_timer.h>
 
 #include <netns/ns.h>
 #include <netinet/tcp_timer.h>
 
 #include <netns/ns.h>
-#include <netns/ns_pcb.h>
-#include <netns/idp.h>
-#include <netns/idp_var.h>
 #include <netns/sp.h>
 #include <netns/sp.h>
+#include <netns/idp.h>
 #include <netns/spidp.h>
 #include <netns/spp_timer.h>
 #include <netns/spp_var.h>
 #include <netns/spidp.h>
 #include <netns/spp_timer.h>
 #include <netns/spp_var.h>
+#include <netns/ns_pcb.h>
+#include <netns/idp_var.h>
 #define SANAMES
 #include <netns/spp_debug.h>
 
 #define SANAMES
 #include <netns/spp_debug.h>
 
@@ -293,19 +308,36 @@ spp_trace(act, ostate, asp, sp, si, req)
                                ns_printhost(&si->si_dna);
                        }
                        printf("\n\t");
                                ns_printhost(&si->si_dna);
                        }
                        printf("\n\t");
-#define p1(f)  { printf("%s = %x, ", "f", f); }
-                       p1(seq); p1(ack); p1(alo); p1(len);
+#define p1(name, f) { \
+       printf("%s = %x, ", name, f); \
+ }
+                       p1("seq", seq);
+                       p1("ack", ack);
+                       p1("alo", alo);
+                       p1("len", len);
                        flags = si->si_cc;
                        printf("flags=%x", flags);
                        flags = si->si_cc;
                        printf("flags=%x", flags);
+#define pf(name, f) { \
+       if (flags & f) { \
+               printf("%s%s", cp, name); \
+               cp = ","; \
+       } \
+}
                        if (flags) {
                                char *cp = "<";
                        if (flags) {
                                char *cp = "<";
-#define pf(f) { if (flags&f) { printf("%s%s", cp, "f"); cp = ","; } }
-                               pf(SP_SP); pf(SP_SA); pf(SP_OB); pf(SP_EM);
+                               pf("SP_SP", SP_SP);
+                               pf("SP_SA", SP_SA);
+                               pf("SP_OB", SP_OB);
+                               pf("SP_EM", SP_EM);
                                printf(">");
                        }
                        printf(", ");
                                printf(">");
                        }
                        printf(", ");
-#define p2(f)  { printf("%s = %x, ", "f", si->si_/**/f); }
-                       p2(sid);p2(did);p2(dt);
+#define p2(name, f) { \
+       printf("%s = %x, ", name, f); \
+}
+                       p2("sid", si->si_sid);
+                       p2("did", si->si_did);
+                       p2("dt", si->si_dt);
                        printf("\n\tsna=");
                        ns_printhost(&si->si_sna);
                        printf("\tdna=");
                        printf("\n\tsna=");
                        ns_printhost(&si->si_sna);
                        printf("\tdna=");
@@ -323,21 +355,39 @@ spp_trace(act, ostate, asp, sp, si, req)
        printf("\n");
        if (sp == 0)
                return;
        printf("\n");
        if (sp == 0)
                return;
-#define p3(f)  { printf("%s = %x, ", "f", sp->s_/**/f); }
-       if(sflag) {
-               printf("\t"); p3(rack); p3(ralo); p3(smax); p3(snxt); p3(flags);
+#define p3(name, f)  { \
+       printf("%s = %x, ", name, f); \
+}
+       if (sflag) {
+               printf("\t");
+               p3("rack", sp->s_rack);
+               p3("ralo", sp->s_ralo);
+               p3("smax", sp->s_smax);
+               p3("snxt", sp->s_snxt);
+               p3("flags", sp->s_flags);
 #undef pf
 #undef pf
-#define pf(f) { if (flags&SF_/**/f) { printf("%s%s", cp, "f"); cp = ","; } }
+#define pf(name, f) { \
+       if (flags & f) { \
+               printf("%s%s", cp, name); \
+               cp = ","; \
+       } \
+}
                flags = sp->s_flags;
                if (flags || sp->s_oobflags) {
                        char *cp = "<";
                flags = sp->s_flags;
                if (flags || sp->s_oobflags) {
                        char *cp = "<";
-                       pf(ACKNOW); pf(DELACK); pf(HI); pf(HO);
-                       pf(PI); pf(WIN); pf(RXT); pf(RVD);
+                       pf("ACKNOW", SF_ACKNOW);
+                       pf("DELACK", SF_DELACK);
+                       pf("HI", SF_HI);
+                       pf("HO", SF_HO);
+                       pf("PI", SF_PI);
+                       pf("WIN", SF_WIN);
+                       pf("RXT", SF_RXT);
+                       pf("RVD", SF_RVD);
                        flags = sp->s_oobflags;
                        flags = sp->s_oobflags;
-                       pf(SOOB); pf(IOOB);
+                       pf("SOOB", SF_SOOB);
+                       pf("IOOB", SF_IOOB);
                        printf(">");
                }
                        printf(">");
                }
-
        }
        /* print out timers? */
        if (tflag) {
        }
        /* print out timers? */
        if (tflag) {
@@ -345,7 +395,9 @@ spp_trace(act, ostate, asp, sp, si, req)
                register int i;
 
                printf("\n\tTIMERS: ");
                register int i;
 
                printf("\n\tTIMERS: ");
-               p3(idle); p3(force); p3(rtseq);
+               p3("idle", sp->s_idle);
+               p3("force", sp->s_force);
+               p3("rtseq", sp->s_rtseq);
                for (i = 0; i < TCPT_NTIMERS; i++) {
                        if (sp->s_timer[i] == 0)
                                continue;
                for (i = 0; i < TCPT_NTIMERS; i++) {
                        if (sp->s_timer[i] == 0)
                                continue;