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/netisdn/i4b_l2.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: i4b_l2.h,v 1.9 2004/02/13 18:02:05 wiz Exp $ */
    2 
    3 /*
    4  * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
    5  *
    6  * Redistribution and use in source and binary forms, with or without
    7  * modification, are permitted provided that the following conditions
    8  * are met:
    9  * 1. Redistributions of source code must retain the above copyright
   10  *    notice, this list of conditions and the following disclaimer.
   11  * 2. Redistributions in binary form must reproduce the above copyright
   12  *    notice, this list of conditions and the following disclaimer in the
   13  *    documentation and/or other materials provided with the distribution.
   14  *
   15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   25  * SUCH DAMAGE.
   26  *
   27  *---------------------------------------------------------------------------
   28  *
   29  *      i4b_l2.h - ISDN layer 2 (Q.921) definitions
   30  *      ---------------------------------------------
   31  *
   32  *      $Id: i4b_l2.h,v 1.9 2004/02/13 18:02:05 wiz Exp $ 
   33  *
   34  * $FreeBSD$
   35  *
   36  *      last edit-date: [Sat Mar 18 10:28:22 2000]
   37  *
   38  *---------------------------------------------------------------------------*/
   39 
   40 #ifndef _I4B_L2_H_
   41 #define _I4B_L2_H_
   42 
   43 typedef struct l2_softc {
   44         const struct isdn_layer1_isdnif_driver * driver;
   45         void*   l1_token;
   46         struct isdn_l3_driver *drv;
   47 
   48         int     Q921_state;     /* state according to Q.921 */
   49 
   50         u_char  last_ril;       /* last reference number from TEI management */
   51         u_char  last_rih;
   52 
   53         int     tei_valid;      /* tei is valid flag */
   54 #define TEI_INVALID     0
   55 #define TEI_VALID       1       
   56         int     tei;            /* tei, if tei flag valid */
   57 
   58         int     ph_active;      /* Layer 1 active flag */
   59 #define PH_INACTIVE     0       /* layer 1 inactive */
   60 #define PH_ACTIVEPEND   1       /* already tried to activate */
   61 #define PH_ACTIVE       2       /* layer 1 active */
   62 
   63         int     T200;           /* Multiframe timeout timer */
   64         int     T201;           /* min time between TEI ID check */
   65         int     T202;           /* min time between TEI ID Req messages */
   66         int     N202;           /* TEI ID Req tx counter */
   67         void(*T202func)(void *);/* function to be called when T202 expires */
   68         int     T203;           /* max line idle time */
   69         struct  callout T200_callout;
   70         struct  callout T202_callout;
   71         struct  callout T203_callout;
   72         struct  callout IFQU_callout;   
   73 
   74 /*
   75  * i4b_iframe.c, i4b_i_frame_queued_up(): value of IFQU_DLY
   76  * some experimentation Gary did showed a minimal value of (hz/20) was
   77  * possible to let this work, Gary suggested using (hz/10) but i settled
   78  * down to using (hz/5) for now (-hm).
   79  */
   80 #define IFQU_DLY (hz/5)         /* reschedule I-FRAME-QUEUED-UP 0.2 sec */
   81 
   82         int     vr;             /* receive sequence frame counter */
   83         int     vs;             /* transmit sequence frame counter */
   84         int     va;             /* acknowledge sequence frame counter */
   85 
   86         int     ack_pend;       /* acknowledge pending */
   87         int     rej_excpt;      /* reject exception */
   88         int     peer_busy;      /* peer receiver busy */
   89         int     own_busy;       /* own receiver busy */
   90         int     l3initiated;    /* layer 3 initiated */
   91 
   92         int     bchan_state[2];
   93 
   94         struct ifqueue i_queue; /* queue of outgoing i frames */
   95 #define IQUEUE_MAXLEN   20
   96 
   97         /* this implementation only supports a k-value of 1 !!! */
   98         struct mbuf *ua_frame;  /* last unacked frame */
   99         int     ua_num;         /* last unacked frame number */
  100 #define UA_EMPTY (-1)           /* ua_frame is unused   */      
  101 
  102         int     rxd_CR;         /* received Command Response bit */
  103         int     rxd_PF;         /* received Poll/Final bit */
  104         int     rxd_NR;         /* received N(R) field */
  105         int     RC;             /* Retry Counter */
  106 
  107         int     iframe_sent;    /* check if i frame acked by another i frame */
  108         
  109         int (*postfsmfunc)(struct isdn_l3_driver *drv);/* function to be called at fsm exit */
  110         struct isdn_l3_driver *postfsmarg;      /* argument for above function */
  111 
  112         /* statistics */
  113 
  114         lapdstat_t      stat;   /* lapd protocol statistics */
  115 
  116 } l2_softc_t;
  117 
  118 /* Q.912 system parameters (Q.921 03/93 pp 43) */
  119 
  120 #define MAX_K_VALUE     1       /* BRI - # of outstanding frames        */
  121 
  122 #define N200    3               /* max no of retransmissions */
  123 #define N201DEF 260             /* max no of octetts in information field */
  124 #define N202DEF 3               /* max no of TEI ID Request message transmissions */
  125 
  126 #define T200DEF (hz*1)          /* default T200 timer value = 1 second  */
  127 #define T201DEF T200DEF         /* default T201 timer value = T200DEF   */
  128 #define T202DEF (hz*2)          /* default T202 timer value = 2 seconds */
  129 #define T203DEF (hz*10)         /* default T203 timer value = 10 seconds*/
  130 
  131 /* modulo 128 operations */
  132 
  133 #define M128INC(v)      (v)++;          \
  134                         if((v)>127)     \
  135                         {               \
  136                                 v = 0;  \
  137                         }
  138                         
  139 #define M128DEC(v)      (v)--;          \
  140                         if((v)<0)       \
  141                         {               \
  142                                 v = 127;\
  143                         }
  144                         
  145 /* P-bit values */
  146 
  147 typedef enum {
  148         P0,
  149         P1
  150 } pbit_t;
  151 
  152 /* F-bit values */
  153 
  154 typedef enum {
  155         F0,
  156         F1
  157 } fbit_t;
  158 
  159 /* CR-bit values to NT */
  160 
  161 typedef enum {
  162         CR_CMD_TO_NT,
  163         CR_RSP_TO_NT
  164 } crbit_to_nt_t;
  165 
  166 /* CR-bit values from NT */
  167 
  168 typedef enum {
  169         CR_RSP_FROM_NT,
  170         CR_CMD_FROM_NT
  171 } crbit_from_nt_t;
  172 
  173 /* address field - octett 2 */
  174 
  175 #define OFF_SAPI        0       /* SAPI offset, HDLC flag is eaten by L1 */
  176 #define SAPI_CCP        0       /* SAPI = 0 - call control procedures */
  177 #define SAPI_X25        16      /* SAPI = 16 - X.25 packet procedures */
  178 #define SAPI_L2M        63      /* SAPI = 63 - Layer 2 management procedures */
  179 
  180 /* extract and insert macros for SAPI octett */
  181 
  182 #define GETSAPI(octett)         (((octett) >> 2) & 0x3f)
  183 #define PUTSAPI(sapi,cr,octett) ((octett) = (((sapi << 2) & 0xfc) | ((cr & 0x01) << 1)))
  184 #define GETCR(octett)           (((octett) >> 1) & 0x01)
  185 #define GETEA(octett)           ((octett) & 0x01)
  186 
  187 /* address field - octett 3 */
  188 
  189 #define OFF_TEI         1       /* TEI offset */
  190 #define GETTEI(octett) (((octett) >> 1) & 0x7f)
  191 #define PUTTEI(tei, octett) ((octett) = ((((tei) << 1) & 0xfe)) | 0x01) 
  192 #define GROUP_TEI       127     /* broadcast TEI for LME */
  193 
  194 /* control field - octett 4 */
  195 
  196 #define OFF_CNTL        2       /* 1st byte of control field */
  197 
  198 /* S frames */
  199 
  200 #define S_FRAME_LEN     4       /* length of a U-frame */
  201 #define OFF_SRCR        2       /* 1st byte of control field,   */
  202                                 /* R-commands and R-responses   */
  203 #define OFF_SNR         3       /* 2nd byte of control field, N(R) and PF */
  204 #define SPFBIT          0x01    /* poll/final bit mask */
  205 #define SPBITSET        SPFBIT
  206 #define SFBITSET        SPFBIT
  207 #define GETSNR(octett) (((octett) >> 1) & 0x7f)
  208 #define GETSPF(octett) ((octett) & SPFBIT)
  209 #define RR              0x01    /* RR and bit 0 set */
  210 #define RNR             0x05    /* RNR and bit 0 set */
  211 #define REJ             0x09    /* REJ and bit 0 set */
  212 
  213 /* U frames */
  214 
  215 #define UI_HDR_LEN      3       /* length of UI header in front of L3 frame */
  216 #define U_FRAME_LEN     3       /* length of a U-frame */
  217 #define UPFBIT          0x10    /* poll/final bit mask */
  218 #define UPBITSET        UPFBIT
  219 #define UFBITSET        UPFBIT
  220 #define GETUPF(octett) (((octett) >> 4) & 0x01)
  221 
  222 /* commands/responses with pf bit set to 0 */
  223 
  224 #define SABME           0x6f
  225 #define DM              0x0f
  226 #define UI              0x03
  227 #define DISC            0x43
  228 #define UA              0x63
  229 #define FRMR            0x87
  230 #define XID             0xaf
  231 
  232 /* control field - octett 3 */
  233 
  234 #define OFF_MEI         3       /* 2nd byte of control field */
  235 
  236 /* control field - octett 4,5 */
  237 
  238 #define OFF_RIL         4       /* Ri low byte */
  239 #define OFF_RIH         5       /* Ri high byte */
  240 
  241 /* control field - octett 6 */
  242 
  243 #define OFF_MT          6       /* Message Type */
  244 #define OFF_AI          7       /* Action Indicator  */
  245 #define GET_TEIFROMAI(octett) (((octett) >> 1) & 0x7f)
  246 
  247 /* I frame */
  248 
  249 #define I_HDR_LEN       4       /* length of I header in front of L3 frame */
  250 #define OFF_INS         2       /* transmit sequence number */
  251 #define OFF_INR         3       /* receive sequence number */
  252 #define IPFBIT          0x01    /* poll/final bit mask */
  253 #define IPBITSET        0x01
  254 #define GETINR(octett)  (((octett) >> 1) & 0x7f)
  255 #define GETINS(octett)  (((octett) >> 1) & 0x7f)
  256 #define GETIP(octett)   ((octett) & IPFBIT)
  257 
  258 /* structure of a TEI management frame */
  259 
  260 #define TEI_MGMT_FRM_LEN   8            /* frame length */
  261 #define TEIM_SAPIO      0x00            /* SAPI, CR, EA */
  262 #define TEIM_TEIO       0x01            /* TEI, EA */
  263 #define TEIM_UIO        0x02            /* frame type = UI = 0x03 */
  264 #define TEIM_MEIO       0x03            /* management entity id = 0x0f */
  265 #define         MEI     0x0f    
  266 #define TEIM_RILO       0x04            /* reference number, low  */
  267 #define TEIM_RIHO       0x05            /* reference number, high */
  268 #define TEIM_MTO        0x06            /* message type */
  269 #define         MT_ID_REQEST    0x01
  270 #define         MT_ID_ASSIGN    0x02
  271 #define         MT_ID_DENY      0x03
  272 #define         MT_ID_CHK_REQ   0x04
  273 #define         MT_ID_CHK_RSP   0x05
  274 #define         MT_ID_REMOVE    0x06
  275 #define         MT_ID_VERIFY    0x07
  276 #define TEIM_AIO        0x07            /* action indicator */
  277 
  278 /* i4b_mdl_error_ind codes */
  279 
  280 enum MDL_ERROR_CODES {
  281         MDL_ERR_A,
  282         MDL_ERR_B,
  283         MDL_ERR_C,
  284         MDL_ERR_D,
  285         MDL_ERR_E,
  286         MDL_ERR_F,
  287         MDL_ERR_G,
  288         MDL_ERR_H,
  289         MDL_ERR_I,
  290         MDL_ERR_J,
  291         MDL_ERR_K,
  292         MDL_ERR_L,
  293         MDL_ERR_M,
  294         MDL_ERR_N,
  295         MDL_ERR_O,
  296         MDL_ERR_MAX     
  297 };
  298 
  299 /* forward decl */
  300 struct isdn_l3_driver;
  301 extern void i4b_acknowledge_pending ( l2_softc_t *l2sc );
  302 extern struct mbuf * i4b_build_s_frame ( l2_softc_t *l2sc, crbit_to_nt_t crbit, pbit_t pbit, u_char type );
  303 extern struct mbuf * i4b_build_u_frame ( l2_softc_t *l2sc, crbit_to_nt_t crbit, pbit_t pbit, u_char type );
  304 extern void i4b_clear_exception_conditions ( l2_softc_t *l2sc );
  305 extern int i4b_dl_data_req ( l2_softc_t*, struct isdn_l3_driver *drv, struct mbuf *m );
  306 extern int i4b_dl_establish_req ( l2_softc_t*, struct isdn_l3_driver *drv );
  307 extern int i4b_dl_release_req ( l2_softc_t*, struct isdn_l3_driver *drv );
  308 extern int i4b_dl_unit_data_req ( l2_softc_t*, struct isdn_l3_driver *drv, struct mbuf *m );
  309 extern void i4b_enquiry_response ( l2_softc_t *l2sc );
  310 extern void i4b_establish_data_link ( l2_softc_t *l2sc );
  311 extern void i4b_invoke_retransmission ( l2_softc_t *l2sc, int nr );
  312 extern void i4b_i_frame_queued_up ( l2_softc_t *l2sc );
  313 extern void i4b_l1_activate ( l2_softc_t *l2sc );
  314 extern int i4b_l2_nr_ok ( int nr, int va, int vs );
  315 extern void i4b_make_rand_ri ( l2_softc_t *l2sc );
  316 extern void i4b_mdl_assign_ind ( l2_softc_t *l2sc );
  317 extern void i4b_mdl_error_ind ( l2_softc_t *l2sc, char *where, int errorcode );
  318 extern void i4b_next_l2state ( l2_softc_t *l2sc, struct isdn_l3_driver *drv, int event );
  319 extern void i4b_nr_error_recovery ( l2_softc_t *l2sc );
  320 extern int i4b_ph_activate_ind ( l2_softc_t* );
  321 extern int i4b_ph_deactivate_ind ( l2_softc_t* );
  322 extern void i4b_print_frame ( int len, u_char *buf );
  323 extern char *i4b_print_l2state ( l2_softc_t *l2sc );
  324 extern void i4b_print_l2var ( l2_softc_t *l2sc );
  325 extern void i4b_rxd_ack(l2_softc_t *l2sc, struct isdn_l3_driver *drv, int nr);
  326 extern void i4b_rxd_i_frame ( l2_softc_t *, struct isdn_l3_driver *drv, struct mbuf *m );
  327 extern void i4b_rxd_s_frame ( l2_softc_t *, struct isdn_l3_driver *drv, struct mbuf *m );
  328 extern void i4b_rxd_u_frame ( l2_softc_t *, struct isdn_l3_driver *drv, struct mbuf *m );
  329 extern void i4b_T200_restart ( l2_softc_t *l2sc );
  330 extern void i4b_T200_start ( l2_softc_t *l2sc );
  331 extern void i4b_T200_stop ( l2_softc_t *l2sc );
  332 extern void i4b_T202_start ( l2_softc_t *l2sc );
  333 extern void i4b_T202_stop ( l2_softc_t *l2sc );
  334 extern void i4b_T203_restart ( l2_softc_t *l2sc );
  335 extern void i4b_T203_start ( l2_softc_t *l2sc );
  336 extern void i4b_T203_stop ( l2_softc_t *l2sc );
  337 extern void i4b_tei_assign ( l2_softc_t *l2sc );
  338 extern void i4b_tei_chkresp ( l2_softc_t *l2sc );
  339 extern void i4b_tei_rxframe ( l2_softc_t *, struct isdn_l3_driver *, struct mbuf *m );
  340 extern void i4b_tei_verify ( l2_softc_t *l2sc );
  341 extern void i4b_transmit_enquire ( l2_softc_t *l2sc );
  342 extern void i4b_tx_disc ( l2_softc_t *l2sc, pbit_t pbit );
  343 extern void i4b_tx_dm ( l2_softc_t *l2sc, fbit_t fbit );
  344 extern void i4b_tx_frmr ( l2_softc_t *l2sc, fbit_t fbit );
  345 extern void i4b_tx_rej_response ( l2_softc_t *l2sc, fbit_t fbit );
  346 extern void i4b_tx_rnr_command ( l2_softc_t *l2sc, pbit_t pbit );
  347 extern void i4b_tx_rnr_response ( l2_softc_t *l2sc, fbit_t fbit );
  348 extern void i4b_tx_rr_command ( l2_softc_t *l2sc, pbit_t pbit );
  349 extern void i4b_tx_rr_response ( l2_softc_t *l2sc, fbit_t fbit );
  350 extern void i4b_tx_sabme ( l2_softc_t *l2sc, pbit_t pbit );
  351 extern void i4b_tx_ua ( l2_softc_t *l2sc, fbit_t fbit );
  352 
  353 struct isdn_l3_driver;
  354 extern int i4b_l2_channel_get_state(struct isdn_l3_driver *drv, int b_chanid);
  355 extern void i4b_l2_channel_set_state(struct isdn_l3_driver *drv, int b_chanid, int state);
  356 extern int i4b_mdl_status_ind ( struct isdn_l3_driver *drv, int status, int parm);
  357 extern int i4b_dl_release_ind ( struct isdn_l3_driver *drv );
  358 extern int i4b_dl_establish_ind ( struct isdn_l3_driver *drv );
  359 extern int i4b_dl_release_cnf ( struct isdn_l3_driver *drv );
  360 extern int i4b_dl_establish_cnf ( struct isdn_l3_driver *drv );
  361 extern int i4b_dl_unit_data_ind ( struct isdn_l3_driver *drv, struct mbuf *m );
  362 extern int i4b_dl_data_ind ( struct isdn_l3_driver *drv, struct mbuf *m );
  363 int i4b_mdl_command_req(struct isdn_l3_driver *drv, int, void *);
  364 void * isdn_find_softc_by_isdnif(int isdnif);
  365 extern int isdn_bchan_silence __P(( unsigned char *data, int len ));
  366 
  367 #endif /* _I4B_L2_H_ */

Cache object: 82fc72e093e6df3904593422476afc54


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