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/netiso/tp_pcb.h

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: tp_pcb.h,v 1.22 2007/12/20 19:53:35 dyoung Exp $       */
    2 
    3 /*-
    4  * Copyright (c) 1991, 1993
    5  *      The Regents of the University of California.  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 University 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 REGENTS 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 REGENTS 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  *      @(#)tp_pcb.h    8.2 (Berkeley) 9/22/94
   32  */
   33 
   34 /***********************************************************
   35                 Copyright IBM Corporation 1987
   36 
   37                       All Rights Reserved
   38 
   39 Permission to use, copy, modify, and distribute this software and its
   40 documentation for any purpose and without fee is hereby granted,
   41 provided that the above copyright notice appear in all copies and that
   42 both that copyright notice and this permission notice appear in
   43 supporting documentation, and that the name of IBM not be
   44 used in advertising or publicity pertaining to distribution of the
   45 software without specific, written prior permission.
   46 
   47 IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
   48 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
   49 IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
   50 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
   51 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
   52 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
   53 SOFTWARE.
   54 
   55 ******************************************************************/
   56 
   57 /*
   58  * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
   59  */
   60 /*
   61  * This file defines the transport protocol control block (tpcb). and a bunch
   62  * of #define values that are used in the tpcb.
   63  */
   64 
   65 #ifndef  _NETISO_TP_PCB_H_
   66 #define  _NETISO_TP_PCB_H_
   67 
   68 #include <netiso/tp_param.h>
   69 #include <netiso/tp_timer.h>
   70 #include <netiso/tp_user.h>
   71 #ifndef sblock
   72 #include <sys/socketvar.h>
   73 #endif                          /* sblock */
   74 
   75 /*
   76  * NOTE: the code depends on REF_CLOSED > REF_OPEN > the rest, and on
   77  * REF_FREE being zero
   78  *
   79  * Possible improvement: think about merging the tp_ref w/ the tpcb and doing a
   80  * search through the tpcb list, from tpb. This would slow down lookup during
   81  * data transfer It would be a little nicer also to have something based on
   82  * the clock (like top n bits of the reference is part of the clock, to
   83  * minimize the likelihood  of reuse after a crash) also, need to keep the
   84  * timer servicing part to a minimum (although the cost of this is probably
   85  * independent of whether the timers are in the pcb or in an array.. Last,
   86  * would have to make the number of timers a function of the amount of mbufs
   87  * available, plus some for the frozen references.
   88  *
   89  * Possible improvement: Might not need the ref_state stuff either... REF_FREE
   90  * could correspond to tp_state == CLOSED or nonexistend tpcb, REF_OPEN to
   91  * tp_state anywhere from AK_WAIT or CR_SENT to CLOSING REF_OPENING could
   92  * correspond to LISTENING, because that's the way it's used, not because the
   93  * correspondence is exact. REF_CLOSED could correspond to REFWAIT
   94  */
   95 #define REF_FROZEN 3            /* has ref timer only */
   96 #define REF_OPEN 2              /* has timers, possibly active */
   97 #define REF_OPENING 1           /* in use (has a pcb) but no timers */
   98 #define REF_FREE 0              /* free to reallocate */
   99 
  100 #define TM_NTIMERS              6
  101 struct iso_addr;
  102 struct sockaddr;
  103 struct socket;
  104 struct tp_pcb;
  105 struct inpcb;
  106 
  107 struct tp_ref {
  108         struct tp_pcb  *tpr_pcb;/* back ptr to PCB */
  109 };
  110 
  111 /* PER system stuff (one static structure instead of a bunch of names) */
  112 struct tp_refinfo {
  113         struct tp_ref  *tpr_base;
  114         int             tpr_size;
  115         int             tpr_maxopen;
  116         int             tpr_numopen;
  117 };
  118 
  119 struct nl_protosw {
  120         int             nlp_afamily;    /* address family */
  121         void            (*nlp_putnetaddr)       /* puts addresses in nl pcb */
  122                                 (void *, struct sockaddr *, int);
  123         void            (*nlp_getnetaddr)       /* gets addresses from nl pcb */
  124                                 (void *, struct mbuf *, int);
  125         int             (*nlp_cmpnetaddr)       /* compares address in pcb */
  126                                 (void *, struct sockaddr *, int);
  127                                                 /* with sockaddr */
  128         void            (*nlp_putsufx)          /* puts transport suffixes in */
  129                                 (void *, void *, int, int);
  130                                                 /* nl pcb */
  131         void            (*nlp_getsufx)          /* gets transport suffixes */
  132                                 (void *, u_short *, void *, int);
  133                                                 /* from nl pcb */
  134         void            (*nlp_recycle_suffix)   /* clears suffix from nl pcb */
  135                                 (void *);
  136         int             (*nlp_mtu)              /* figures out mtu based on */
  137                                 (void *);       /* nl used */
  138         int             (*nlp_pcbbind)          /* bind to pcb for net level */
  139                                 (void *, struct mbuf *, struct lwp *);
  140         int             (*nlp_pcbconn)          /* connect for net level */
  141                                 (void *, struct mbuf *, struct lwp *);
  142         void            (*nlp_pcbdisc)          /* disconnect net level */
  143                                 (void *);
  144         void            (*nlp_pcbdetach)        /* detach net level pcb */
  145                                 (void *);
  146         int             (*nlp_pcballoc)         /* allocate a net level pcb */
  147                                 (struct socket *, void *);
  148         int             (*nlp_output)           /* prepare a packet to give */
  149                                 (struct mbuf *, ...); /* to nl */
  150         int             (*nlp_dgoutput)         /* prepare a packet to give */
  151                                 (struct mbuf *, ...); /*to nl*/
  152         int             (*nlp_ctloutput)        /* hook for network set/get */
  153                                 (int, int, void *, struct mbuf *);
  154                                                 /* options */
  155         void *          nlp_pcblist;    /* list of xx_pcb's for connections */
  156 };
  157 
  158 
  159 struct tp_pcb {
  160         struct tp_pcb  *tp_next;
  161         struct tp_pcb  *tp_prev;
  162         struct tp_pcb  *tp_nextlisten;  /* chain all listeners */
  163         struct socket  *tp_sock;/* back ptr */
  164         u_short         tp_state;       /* state of fsm */
  165         short           tp_retrans;     /* # times can still retrans */
  166         void *          tp_npcb;/* to lower layer pcb */
  167         struct nl_protosw *tp_nlproto;  /* lower-layer dependent routines */
  168         struct route    *tp_routep;     /* obtain mtu; inside npcb */
  169 
  170 
  171         RefNum          tp_lref;/* local reference */
  172         RefNum          tp_fref;/* foreign reference */
  173 
  174         u_int           tp_seqmask;     /* mask for seq space */
  175         u_int           tp_seqbit;      /* bit for seq number wraparound */
  176         u_int           tp_seqhalf;     /* half the seq space */
  177 
  178         struct mbuf    *tp_ucddata;     /* user connect/disconnect data */
  179 
  180         /* credit & sequencing info for SENDING */
  181         u_short         tp_fcredit;     /* current remote credit in # packets */
  182         u_short         tp_maxfcredit;  /* max remote credit in # packets */
  183         u_short         tp_dupacks;     /* intuit packet loss before rxt timo */
  184         u_long          tp_cong_win;    /* congestion window in bytes. see
  185                                          * profuse comments in TCP code */
  186         u_long          tp_ssthresh;    /* cong_win threshold for slow start
  187                                          * exponential to linear switch */
  188         SeqNum          tp_snduna;      /* seq # of lowest unacked DT */
  189         SeqNum          tp_sndnew;      /* seq # of lowest unsent DT  */
  190         SeqNum          tp_sndnum;      /* next seq # to be assigned */
  191         SeqNum          tp_sndnxt;      /* what to do next; poss. rxt */
  192         struct mbuf    *tp_sndnxt_m;    /* packet corres. to sndnxt */
  193         int             tp_Nwindow;     /* for perf. measurement */
  194 
  195         /* credit & sequencing info for RECEIVING */
  196         SeqNum          tp_rcvnxt;      /* next DT seq # expect to recv */
  197         SeqNum          tp_sent_lcdt;   /* cdt according to last ack sent */
  198         SeqNum          tp_sent_uwe;    /* uwe according to last ack sent */
  199         SeqNum          tp_sent_rcvnxt; /* rcvnxt according to last ack sent
  200                                          * needed for perf measurements only */
  201         u_short         tp_lcredit;     /* current local credit in # packets */
  202         u_short         tp_maxlcredit;  /* needed for reassembly queue */
  203         struct mbuf   **tp_rsyq;/* unacked stuff recvd out of order */
  204         int             tp_rsycnt;      /* number of packets "" "" "" ""    */
  205         u_long          tp_rhiwat;      /* remember original RCVBUF size */
  206 
  207         /* receiver congestion state stuff ...  */
  208         u_int           tp_win_recv;
  209 
  210         /* receive window as a scaled int (8 bit fraction part) */
  211 
  212         struct cong_sample {
  213                 ushort          cs_size;        /* current window size */
  214                 ushort          cs_received;    /* PDUs received in this
  215                                                  * sample */
  216                 ushort          cs_ce_set;      /* PDUs received in this
  217                                                  * sample with CE bit set */
  218         }               tp_cong_sample;
  219 
  220 
  221         /* parameters per-connection controllable by user */
  222         struct tp_conn_param _tp_param;
  223 
  224 #define tp_Nretrans _tp_param.p_Nretrans
  225 #define tp_dr_ticks _tp_param.p_dr_ticks
  226 #define tp_cc_ticks _tp_param.p_cc_ticks
  227 #define tp_dt_ticks _tp_param.p_dt_ticks
  228 #define tp_xpd_ticks _tp_param.p_x_ticks
  229 #define tp_cr_ticks _tp_param.p_cr_ticks
  230 #define tp_keepalive_ticks _tp_param.p_keepalive_ticks
  231 #define tp_sendack_ticks _tp_param.p_sendack_ticks
  232 #define tp_refer_ticks _tp_param.p_ref_ticks
  233 #define tp_inact_ticks _tp_param.p_inact_ticks
  234 #define tp_xtd_format _tp_param.p_xtd_format
  235 #define tp_xpd_service _tp_param.p_xpd_service
  236 #define tp_ack_strat _tp_param.p_ack_strat
  237 #define tp_rx_strat _tp_param.p_rx_strat
  238 #define tp_use_checksum _tp_param.p_use_checksum
  239 #define tp_use_efc _tp_param.p_use_efc
  240 #define tp_use_nxpd _tp_param.p_use_nxpd
  241 #define tp_use_rcc _tp_param.p_use_rcc
  242 #define tp_tpdusize _tp_param.p_tpdusize
  243 #define tp_class _tp_param.p_class
  244 #define tp_winsize _tp_param.p_winsize
  245 #define tp_no_disc_indications _tp_param.p_no_disc_indications
  246 #define tp_dont_change_params _tp_param.p_dont_change_params
  247 #define tp_netservice _tp_param.p_netservice
  248 #define tp_version _tp_param.p_version
  249 #define tp_ptpdusize _tp_param.p_ptpdusize
  250 
  251         int             tp_l_tpdusize;
  252         /*
  253          * whereas tp_tpdusize is log2(the negotiated max size) l_tpdusize is
  254          * the size we'll use when sending, in # chars
  255          */
  256 
  257         int             tp_rtv; /* max round-trip time variance */
  258         int             tp_rtt; /* smoothed round-trip time */
  259         SeqNum          tp_rttseq;      /* packet being timed */
  260         int             tp_rttemit;     /* when emitted, in ticks */
  261         int             tp_idle;/* last activity, in ticks */
  262         short           tp_rxtcur;      /* current retransmit value */
  263         short           tp_rxtshift;    /* log(2) of rexmt exp. backoff */
  264         u_char          tp_cebit_off;   /* real DEC bit algorithms not in use */
  265         u_char          tp_oktonagle;   /* Last unsent pckt may be append to */
  266         u_char          tp_flags;       /* values: */
  267 #define TPF_NLQOS_PDN           TPFLAG_NLQOS_PDN
  268 #define TPF_PEER_ON_SAMENET     TPFLAG_PEER_ON_SAMENET
  269 #define TPF_GENERAL_ADDR        TPFLAG_GENERAL_ADDR
  270 #define TPF_DELACK                      0x8
  271 #define TPF_ACKNOW                      0x10
  272 
  273 #define PEER_IS_LOCAL(t)        (((t)->tp_flags & TPF_PEER_ON_SAME_NET) != 0)
  274 #define USES_PDN(t)                     (((t)->tp_flags & TPF_NLQOS_PDN) != 0)
  275 
  276 
  277         unsigned
  278                         tp_sendfcc:1,   /* shall next ack include FCC
  279                                          * parameter? */
  280                         tp_trace:1,     /* is this pcb being traced? (not
  281                                          * used yet) */
  282                         tp_perf_on:1,   /* 0/1 -> performance measuring on  */
  283                         tp_reneged:1,   /* have we reneged on cdt since last
  284                                          * ack? */
  285                         tp_decbit:3,    /* dec bit was set, we're in reneg
  286                                          * mode  */
  287                         tp_notdetached:1;       /* Call tp_detach before
  288                                                  * freeing XXXXXXX */
  289 
  290 #ifdef TP_PERF_MEAS
  291         /* performance stats - see tp_stat.h */
  292         struct tp_pmeas *tp_p_meas;
  293 #endif                          /* TP_PERF_MEAS */
  294 
  295         /* addressing */
  296         u_short         tp_domain;      /* domain (INET, ISO) */
  297         /*
  298          * for compatibility with the *old* way and with INET, be sure that
  299          * that lsuffix and fsuffix are aligned to a short addr. having them
  300          * follow the u_short *suffixlen should suffice (choke)
  301          */
  302         u_short         tp_fsuffixlen;  /* foreign suffix */
  303         char            tp_fsuffix[MAX_TSAP_SEL_LEN];
  304         u_short         tp_lsuffixlen;  /* local suffix */
  305         char            tp_lsuffix[MAX_TSAP_SEL_LEN];
  306 #define SHORT_LSUFXP(tpcb) ((short *)((tpcb)->tp_lsuffix))
  307 #define SHORT_FSUFXP(tpcb) ((short *)((tpcb)->tp_fsuffix))
  308 
  309         /* Timer stuff */
  310         u_char          tp_vers;/* protocol version */
  311         u_char          tp_peer_acktime;        /* used for DT retrans time */
  312         u_char          tp_refstate;    /* values REF_FROZEN, etc. above */
  313         struct tp_pcb  *tp_fasttimeo;   /* limit pcbs to examine */
  314         u_int           tp_timer[TM_NTIMERS];   /* C timers */
  315 
  316         struct sockbuf  tp_Xsnd;                /* for expedited data */
  317 #if 0
  318         struct sockbuf  tp_Xrcv;                /* for expedited data */
  319 #else
  320 #define tp_Xrcv tp_sock->so_rcv
  321 #endif
  322         SeqNum          tp_Xsndnxt;     /* next XPD seq # to send */
  323         SeqNum          tp_Xuna;/* seq # of unacked XPD */
  324         SeqNum          tp_Xrcvnxt;     /* next XPD seq # expect to recv */
  325 
  326         /* AK subsequencing */
  327         u_short         tp_s_subseq;    /* next subseq to send */
  328         u_short         tp_r_subseq;    /* highest recv subseq */
  329 
  330 };
  331 
  332 extern  u_int   tp_start_win;
  333 
  334 #define ROUND(scaled_int) (((scaled_int) >> 8) + (((scaled_int) & 0x80) ? 1:0))
  335 
  336 /* to round off a scaled int with an 8 bit fraction part */
  337 
  338 #define CONG_INIT_SAMPLE(pcb) \
  339         pcb->tp_cong_sample.cs_received = \
  340     pcb->tp_cong_sample.cs_ce_set = 0; \
  341     pcb->tp_cong_sample.cs_size = max(pcb->tp_lcredit, 1) << 1;
  342 
  343 #define CONG_UPDATE_SAMPLE(pcb, ce_bit) \
  344     pcb->tp_cong_sample.cs_received++; \
  345     if (ce_bit) { \
  346         pcb->tp_cong_sample.cs_ce_set++; \
  347     } \
  348     if (pcb->tp_cong_sample.cs_size <= pcb->tp_cong_sample.cs_received) { \
  349         if ((pcb->tp_cong_sample.cs_ce_set << 1) >=  \
  350                     pcb->tp_cong_sample.cs_size ) { \
  351             pcb->tp_win_recv -= pcb->tp_win_recv >> 3; /* multiply by .875 */ \
  352             pcb->tp_win_recv = max(1 << 8, pcb->tp_win_recv); \
  353         } \
  354         else { \
  355             pcb->tp_win_recv += (1 << 8); /* add one to the scaled int */ \
  356         } \
  357         pcb->tp_lcredit = ROUND(pcb->tp_win_recv); \
  358         CONG_INIT_SAMPLE(pcb); \
  359     }
  360 
  361 #ifdef _KERNEL
  362 extern struct tp_refinfo tp_refinfo;
  363 extern struct tp_ref *tp_ref;
  364 extern struct tp_param tp_param;
  365 extern struct nl_protosw nl_protosw[];
  366 extern struct tp_pcb *tp_listeners;
  367 extern struct tp_pcb *tp_ftimeolist;
  368 #endif
  369 
  370 #define sototpcb(so)    ((struct tp_pcb *)(so->so_pcb))
  371 #define sototpref(so)   ((sototpcb(so)->tp_ref))
  372 #define tpcbtoso(tp)    ((struct socket *)((tp)->tp_sock))
  373 #define tpcbtoref(tp)   ((struct tp_ref *)((tp)->tp_ref))
  374 
  375 #endif /* !_NETISO_TP_PCB_H_ */

Cache object: 716cba4e71e637874e4923f5cde0fef8


[ 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.