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_l3l4.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_l3l4.h,v 1.15 2003/10/03 16:38:44 pooka Exp $      */
    2 
    3 /*
    4  * Copyright (c) 1997, 1999 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_l3l4.h - layer 3 / layer 4 interface
   30  *      ------------------------------------------
   31  *
   32  *      $Id: i4b_l3l4.h,v 1.15 2003/10/03 16:38:44 pooka Exp $
   33  *
   34  * $FreeBSD$
   35  *
   36  *      last edit-date: [Fri Jun  2 14:29:35 2000]
   37  *
   38  *---------------------------------------------------------------------------*/
   39 
   40 #ifndef _I4B_L3L4_H_
   41 #define _I4B_L3L4_H_
   42 
   43 #define T303VAL (hz*4)                  /* 4 seconds timeout            */
   44 #define T305VAL (hz*30)                 /* 30 seconds timeout           */
   45 #define T308VAL (hz*4)                  /* 4 seconds timeout            */
   46 #define T309VAL (hz*90)                 /* 90 seconds timeout           */
   47 #define T310VAL (hz*60)                 /* 30-120 seconds timeout       */
   48 #define T313VAL (hz*4)                  /* 4 seconds timeout            */
   49 #define T400DEF (hz*10)                 /* 10 seconds timeout           */
   50 
   51 #define MAX_BCHAN       2
   52 #define N_CALL_DESC     (20*(MAX_BCHAN)) /* XXX: make resizable */
   53 
   54 typedef struct bchan_statistics {
   55         int outbytes;
   56         int inbytes;
   57 } bchan_statistics_t;
   58 
   59 /*---------------------------------------------------------------------------*
   60  * table of things the driver needs to know about the b channel
   61  * it is connected to for data transfer
   62  *---------------------------------------------------------------------------*/
   63 typedef struct i4b_isdn_bchan_linktab {
   64         void* l1token;
   65         int channel;
   66         const struct isdn_l4_bchannel_functions *bchannel_driver;
   67         struct ifqueue *tx_queue;
   68         struct ifqueue *rx_queue;       /* data xfer for NON-HDLC traffic   */
   69         struct mbuf **rx_mbuf;          /* data xfer for HDLC based traffic */
   70 } isdn_link_t;
   71 
   72 struct isdn_l4_driver_functions;
   73 struct isdn_l3_driver;
   74 
   75 /*---------------------------------------------------------------------------*
   76  *      this structure describes one call/connection on one B-channel
   77  *      and all its parameters
   78  *---------------------------------------------------------------------------*/
   79 typedef struct call_desc
   80 {
   81         u_int   cdid;                   /* call descriptor id           */
   82         int     isdnif;                 /* isdn interface number        */
   83         struct isdn_l3_driver *l3drv;
   84         int     cr;                     /* call reference value         */
   85 
   86         int     crflag;                 /* call reference flag          */
   87 #define CRF_ORIG        0               /* originating side             */
   88 #define CRF_DEST        1               /* destinating side             */
   89 
   90         int     channelid;              /* channel id value             */
   91         int     channelexcl;            /* channel exclusive            */
   92 
   93         int     bprot;                  /* B channel protocol BPROT_XXX */
   94 
   95         int     bchan_driver_index;     /* driver to use for B channel  */
   96         int     bchan_driver_unit;      /* unit for above driver number */
   97         
   98         cause_t cause_in;               /* cause value from NT  */
   99         cause_t cause_out;              /* cause value to NT    */
  100 
  101         int     call_state;             /* from incoming SETUP  */
  102         
  103         u_char  dst_telno[TELNO_MAX];   /* destination number   */
  104         u_char  src_telno[TELNO_MAX];   /* source number        */
  105         u_char  src_subaddr[SUBADDR_MAX];
  106         u_char  dest_subaddr[SUBADDR_MAX];
  107 
  108         int     scr_ind;                /* screening ind for incoming call */
  109         int     prs_ind;                /* presentation ind for incoming call */
  110         int     type_plan;              /* type and plan for incoming number */
  111         
  112         int     Q931state;              /* Q.931 state for call */
  113         int     event;                  /* event to be processed */
  114 
  115         int     response;               /* setup response type  */
  116 
  117         int     T303;                   /* SETUP sent response timeout  */
  118         int     T303_first_to;          /* first timeout flag           */
  119 
  120         int     T305;                   /* DISC without PROG IND        */
  121 
  122         int     T308;                   /* RELEASE sent response timeout*/
  123         int     T308_first_to;          /* first timeout flag           */
  124 
  125         int     T309;                   /* data link disconnect timeout */
  126 
  127         int     T310;                   /* CALL PROC received           */
  128 
  129         int     T313;                   /* CONNECT sent timeout         */ 
  130 
  131         int     T400;                   /* L4 timeout */
  132 
  133         isdn_link_t     *ilt;           /* isdn B channel driver/state  */
  134         const struct isdn_l4_driver_functions *l4_driver;               /* layer 4 driver               */
  135         void    *l4_driver_softc;                                       /* layer 4 driver instance      */
  136 
  137         int     dir;                    /* outgoing or incoming call    */
  138 #define DIR_OUTGOING    0
  139 #define DIR_INCOMING    1
  140 
  141         int     timeout_active;         /* idle timeout() active flag   */
  142 
  143         struct  callout idle_timeout_handle;
  144         struct  callout T303_callout;
  145         struct  callout T305_callout;
  146         struct  callout T308_callout;
  147         struct  callout T309_callout;
  148         struct  callout T310_callout;
  149         struct  callout T313_callout;
  150         struct  callout T400_callout;
  151         int     callouts_inited;                /* must init before use */
  152 
  153         int     idletime_state;         /* wait for idle_time begin     */
  154 #define IST_IDLE        0       /* shorthold mode disabled      */
  155 #define IST_NONCHK      1       /* in non-checked window        */
  156 #define IST_CHECK       2       /* in idle check window         */
  157 #define IST_SAFE        3       /* in safety zone               */
  158 
  159         time_t  idletimechk_start;      /* check idletime window start  */
  160         time_t  connect_time;           /* time connect was made        */
  161         time_t  last_active_time;       /* last time with activity      */
  162 
  163                                         /* for incoming connections:    */
  164         time_t  max_idle_time;          /* max time without activity    */
  165 
  166                                         /* for outgoing connections:    */      
  167         msg_shorthold_t shorthold_data; /* shorthold data to use */
  168 
  169         int     aocd_flag;              /* AOCD used for unitlength calc*/
  170         time_t  last_aocd_time;         /* last time AOCD received      */
  171         int     units;                  /* number of AOCD charging units*/
  172         int     units_type;             /* units type: AOCD, AOCE       */
  173         int     cunits;                 /* calculated units             */
  174 
  175         int     isdntxdelay;            /* isdn tx delay after connect  */
  176 
  177         u_char  display[DISPLAY_MAX];   /* display information element  */
  178         char    datetime[DATETIME_MAX]; /* date/time information element*/      
  179 } call_desc_t;
  180 
  181 extern call_desc_t call_desc[];
  182 extern int num_call_desc;
  183 
  184 /*
  185  * Set of functions layer 4 drivers calls to manipulate the B channel
  186  * they are using.
  187  */
  188 struct isdn_l4_bchannel_functions {
  189         void (*bch_config)(void*, int channel, int bprot, int updown);
  190         void (*bch_tx_start)(void*, int channel);
  191         void (*bch_stat)(void*, int channel, bchan_statistics_t *bsp);  
  192 };
  193 
  194 /*
  195  * Functions a layer 4 application driver exports
  196  */
  197 struct isdn_l4_driver_functions {
  198         /*
  199          * Functions for use by the B channel driver
  200          */
  201         void (*bch_rx_data_ready)(void *softc);
  202         void (*bch_tx_queue_empty)(void *softc);
  203         void (*bch_activity)(void *softc, int rxtx);
  204 #define ACT_RX 0
  205 #define ACT_TX 1
  206         void (*line_connected)(void *softc, void *cde);
  207         void (*line_disconnected)(void *softc, void *cde);
  208         void (*dial_response)(void *softc, int stat, cause_t cause);
  209         void (*updown_ind)(void *softc, int updown);
  210         /*
  211          * Functions used by the ISDN management system
  212          */
  213         void* (*get_softc)(int unit);
  214         void (*set_linktab)(void *softc, isdn_link_t *ilt);
  215         /*
  216          * Optional accounting function
  217          */
  218         time_t (*get_idletime)(void* softc);
  219 };
  220 
  221 /* global registry of layer 4 drivers */
  222 int isdn_l4_driver_attach(const char *name, int units, const struct isdn_l4_driver_functions *driver);
  223 int isdn_l4_driver_detatch(const char *name);
  224 int isdn_l4_find_driverid(const char *name);
  225 const struct isdn_l4_driver_functions *isdn_l4_find_driver(const char *name, int unit);
  226 const struct isdn_l4_driver_functions *isdn_l4_get_driver(int driver_id, int unit);
  227 
  228 /* forward decl. */
  229 struct isdn_diagnostic_request;
  230 struct isdn_dr_prot;
  231 
  232 /*
  233  * functions exported by a layer 3 driver to layer 4
  234  */
  235 struct isdn_l3_driver_functions {
  236         isdn_link_t* (*get_linktab)(void*, int channel);
  237         void (*set_l4_driver)(void*, int channel, const struct isdn_l4_driver_functions *l4_driver, void *l4_driver_softc);
  238         
  239         void    (*N_CONNECT_REQUEST)    (struct call_desc *cd); 
  240         void    (*N_CONNECT_RESPONSE)   (struct call_desc *cd, int, int);
  241         void    (*N_DISCONNECT_REQUEST) (struct call_desc *cd, int);
  242         void    (*N_ALERT_REQUEST)      (struct call_desc *cd);
  243         int     (*N_DOWNLOAD)           (void*, int numprotos, struct isdn_dr_prot *protocols);
  244         int     (*N_DIAGNOSTICS)        (void*, struct isdn_diagnostic_request*);
  245         void    (*N_MGMT_COMMAND)       (struct isdn_l3_driver *, int cmd, void *);
  246 };
  247 
  248 /*---------------------------------------------------------------------------*
  249  *      This structure "describes" one ISDN interface (typically identical
  250  *      to one controller, but when one controller drives multiple ISDN's,
  251  *      this is just one of those ISDN's).
  252  *
  253  *      An ISDN can be either a Basic Rate Interface (BRI, 2 B channels)
  254  *      or a Primary Rate Interface (PRI, 30 B channels).
  255  *---------------------------------------------------------------------------*/
  256 struct isdn_l3_driver {
  257         SLIST_ENTRY(isdn_l3_driver) l3drvq;
  258         void*   l1_token;               /* softc of hardware driver, actually
  259                                          * this is the l2_softc (!!) for
  260                                          * passive cards, and something else
  261                                          * for active cards (maybe actually
  262                                          * the softc there) */
  263         int     isdnif;                 /* ISDN id assigned to this */
  264         char *devname;                  /* pointer to autoconf identifier */
  265                                         /* e.g. "isic0" or "daic0 port 2" */
  266         char *card_name;                /* type of card */
  267 
  268         int     protocol;               /* D-channel protocol type */
  269 
  270         int     dl_est;                 /* layer 2 established  */
  271 #define DL_DOWN 0
  272 #define DL_UP   1       
  273 
  274         int     nbch;                   /* number of B-channels */
  275         int     *bch_state;             /* states of the nbch b channels */
  276 #define BCH_ST_FREE     0               /* free to be used, idle */
  277 #define BCH_ST_RSVD     1               /* reserved, may become free or used */
  278 #define BCH_ST_USED     2               /* in use for data transfer */
  279 
  280         int     tei;                    /* current tei or -1 if invalid */
  281 
  282         /* pointers to functions to be called from L4 */
  283         const struct isdn_l3_driver_functions * l3driver;
  284 };
  285 
  286 #define NBCH_BRI 2
  287 #define NBCH_PRI 30
  288 
  289 void i4b_l4_contr_ev_ind(int controller, int attach);
  290 struct isdn_l3_driver * isdn_attach_isdnif(const char *devname,
  291     const char *cardname, void *l1_token, 
  292     const struct isdn_l3_driver_functions * l3driver, int nbch);
  293 int isdn_detach_isdnif(struct isdn_l3_driver *);
  294 void isdn_isdnif_ready(int isdnif);
  295 struct isdn_l3_driver *isdn_find_l3_by_isdnif(int isdnif);
  296 int isdn_count_isdnif(int *max_isdnif);
  297 
  298 #endif /* _I4B_Q931_H_ */

Cache object: 548ee01de09f73eb0188f3163fe9afd1


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