The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/netinet/tcp_debug.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: tcp_debug.c,v 1.21 2005/02/03 23:25:22 perry Exp $     */
    2 
    3 /*
    4  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
    5  * All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  * 3. Neither the name of the project nor the names of its contributors
   16  *    may be used to endorse or promote products derived from this software
   17  *    without specific prior written permission.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
   20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
   23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   29  * SUCH DAMAGE.
   30  */
   31 
   32 /*
   33  * Copyright (c) 1982, 1986, 1993
   34  *      The Regents of the University of California.  All rights reserved.
   35  *
   36  * Redistribution and use in source and binary forms, with or without
   37  * modification, are permitted provided that the following conditions
   38  * are met:
   39  * 1. Redistributions of source code must retain the above copyright
   40  *    notice, this list of conditions and the following disclaimer.
   41  * 2. Redistributions in binary form must reproduce the above copyright
   42  *    notice, this list of conditions and the following disclaimer in the
   43  *    documentation and/or other materials provided with the distribution.
   44  * 3. Neither the name of the University nor the names of its contributors
   45  *    may be used to endorse or promote products derived from this software
   46  *    without specific prior written permission.
   47  *
   48  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   49  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   50  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   51  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   52  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   53  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   54  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   55  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   56  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   57  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   58  * SUCH DAMAGE.
   59  *
   60  *      @(#)tcp_debug.c 8.1 (Berkeley) 6/10/93
   61  */
   62 
   63 #include <sys/cdefs.h>
   64 __KERNEL_RCSID(0, "$NetBSD: tcp_debug.c,v 1.21 2005/02/03 23:25:22 perry Exp $");
   65 
   66 #include "opt_inet.h"
   67 #include "opt_tcp_debug.h"
   68 
   69 /* load symbolic names */
   70 #define PRUREQUESTS
   71 #define TCPSTATES
   72 #define TCPTIMERS
   73 #define TANAMES
   74 
   75 #include <sys/param.h>
   76 #include <sys/systm.h>
   77 #include <sys/mbuf.h>
   78 #include <sys/socket.h>
   79 #include <sys/socketvar.h>
   80 #include <sys/protosw.h>
   81 #include <sys/errno.h>
   82 
   83 #include <net/route.h>
   84 #include <net/if.h>
   85 
   86 #include <netinet/in.h>
   87 #include <netinet/in_systm.h>
   88 #include <netinet/ip.h>
   89 #include <netinet/in_pcb.h>
   90 #include <netinet/ip_var.h>
   91 
   92 #ifdef INET6
   93 #ifndef INET
   94 #include <netinet/in.h>
   95 #endif
   96 #include <netinet/ip6.h>
   97 #endif
   98 
   99 #include <netinet/tcp.h>
  100 #include <netinet/tcp_fsm.h>
  101 #include <netinet/tcp_seq.h>
  102 #include <netinet/tcp_timer.h>
  103 #include <netinet/tcp_var.h>
  104 #include <netinet/tcpip.h>
  105 #include <netinet/tcp_debug.h>
  106 
  107 struct  tcp_debug tcp_debug[TCP_NDEBUG];
  108 int     tcp_debx;
  109 int     tcpconsdebug = 0;
  110 /*
  111  * Tcp debug routines
  112  */
  113 void
  114 tcp_trace(short act, short ostate, struct tcpcb *tp, struct mbuf *m, int req)
  115 {
  116         tcp_seq seq, ack;
  117         int len, flags;
  118         struct tcphdr *th;
  119         struct tcp_debug *td = &tcp_debug[tcp_debx++];
  120 
  121         if (tcp_debx == TCP_NDEBUG)
  122                 tcp_debx = 0;
  123         td->td_time = iptime();
  124         td->td_act = act;
  125         td->td_ostate = ostate;
  126         td->td_tcb = (caddr_t)tp;
  127         if (tp)
  128                 td->td_cb = *tp;
  129         else
  130                 bzero((caddr_t)&td->td_cb, sizeof (*tp));
  131         td->td_family = tp->t_family;
  132         bzero((caddr_t)&td->td_ti, sizeof (td->td_ti));
  133 #ifdef INET6
  134         bzero((caddr_t)&td->td_ti6, sizeof (td->td_ti6));
  135 #endif
  136         th = NULL;
  137         if (m) {
  138                 struct ip *ip;
  139                 ip = mtod(m, struct ip *);
  140                 switch (ip->ip_v) {
  141                 case 4:
  142                         if (m->m_len < sizeof(td->td_ti))
  143                                 break;
  144                         bcopy(mtod(m, caddr_t), &td->td_ti, sizeof(td->td_ti));
  145                         th = (struct tcphdr *)((caddr_t)&td->td_ti + sizeof(struct ip));
  146                         break;
  147 #ifdef INET6
  148                 case 6:
  149                         if (m->m_len < sizeof(td->td_ti6))
  150                                 break;
  151                         bcopy(mtod(m, caddr_t), &td->td_ti6,
  152                                 sizeof(td->td_ti6));
  153                         th = (struct tcphdr *)((caddr_t)&td->td_ti6 + sizeof(struct ip6_hdr));
  154                         break;
  155 #endif
  156                 }
  157         }
  158         td->td_req = req;
  159         if (tcpconsdebug == 0)
  160                 return;
  161         if (tp)
  162                 printf("%p %s:", tp, tcpstates[ostate]);
  163         else
  164                 printf("???????? ");
  165         printf("%s ", tanames[act]);
  166         switch (act) {
  167 
  168         case TA_INPUT:
  169         case TA_OUTPUT:
  170         case TA_DROP:
  171                 if (th == 0)
  172                         break;
  173                 seq = th->th_seq;
  174                 ack = th->th_ack;
  175                 len = m->m_pkthdr.len;
  176                 if (act == TA_OUTPUT) {
  177                         seq = ntohl(seq);
  178                         ack = ntohl(ack);
  179                         len = ntohs((u_int16_t)len);
  180                 }
  181                 if (act == TA_OUTPUT)
  182                         len -= sizeof (struct tcphdr);
  183                 if (len)
  184                         printf("[%x..%x)", seq, seq+len);
  185                 else
  186                         printf("%x", seq);
  187                 printf("@%x, urp=%x", ack, th->th_urp);
  188                 flags = th->th_flags;
  189                 if (flags) {
  190 #ifndef lint
  191                         char *cp = "<";
  192 #define pf(f) { if (th->th_flags&__CONCAT(TH_,f)) { printf("%s%s", cp, "f"); cp = ","; } }
  193                         pf(SYN); pf(ACK); pf(FIN); pf(RST); pf(PUSH); pf(URG);
  194 #endif
  195                         printf(">");
  196                 }
  197                 break;
  198 
  199         case TA_USER:
  200                 printf("%s", prurequests[req&0xff]);
  201                 if ((req & 0xff) == PRU_SLOWTIMO)
  202                         printf("<%s>", tcptimers[req>>8]);
  203                 break;
  204         }
  205         if (tp)
  206                 printf(" -> %s", tcpstates[tp->t_state]);
  207         /* print out internal state of tp !?! */
  208         printf("\n");
  209         if (tp == 0)
  210                 return;
  211         printf("\trcv_(nxt,wnd,up) (%x,%lx,%x) snd_(una,nxt,max) (%x,%x,%x)\n",
  212             tp->rcv_nxt, tp->rcv_wnd, tp->rcv_up, tp->snd_una, tp->snd_nxt,
  213             tp->snd_max);
  214         printf("\tsnd_(wl1,wl2,wnd) (%x,%x,%lx)\n",
  215             tp->snd_wl1, tp->snd_wl2, tp->snd_wnd);
  216 }

Cache object: 683c0d91ea145e9d3231b16065d4f9b9


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.