2005-02-27 01:31:44 +03:00
|
|
|
/* $NetBSD: i4b_l3l4.h,v 1.16 2005/02/26 22:39:49 perry Exp $ */
|
2003-09-25 19:16:08 +04:00
|
|
|
|
2001-01-05 15:49:52 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* i4b_l3l4.h - layer 3 / layer 4 interface
|
|
|
|
* ------------------------------------------
|
|
|
|
*
|
2005-02-27 01:31:44 +03:00
|
|
|
* $Id: i4b_l3l4.h,v 1.16 2005/02/26 22:39:49 perry Exp $
|
2001-01-05 15:49:52 +03:00
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*
|
|
|
|
* last edit-date: [Fri Jun 2 14:29:35 2000]
|
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
#ifndef _I4B_L3L4_H_
|
|
|
|
#define _I4B_L3L4_H_
|
|
|
|
|
|
|
|
#define T303VAL (hz*4) /* 4 seconds timeout */
|
|
|
|
#define T305VAL (hz*30) /* 30 seconds timeout */
|
|
|
|
#define T308VAL (hz*4) /* 4 seconds timeout */
|
|
|
|
#define T309VAL (hz*90) /* 90 seconds timeout */
|
|
|
|
#define T310VAL (hz*60) /* 30-120 seconds timeout */
|
|
|
|
#define T313VAL (hz*4) /* 4 seconds timeout */
|
|
|
|
#define T400DEF (hz*10) /* 10 seconds timeout */
|
|
|
|
|
2003-09-25 19:16:08 +04:00
|
|
|
#define MAX_BCHAN 2
|
|
|
|
#define N_CALL_DESC (20*(MAX_BCHAN)) /* XXX: make resizable */
|
2001-01-05 15:49:52 +03:00
|
|
|
|
|
|
|
typedef struct bchan_statistics {
|
|
|
|
int outbytes;
|
|
|
|
int inbytes;
|
|
|
|
} bchan_statistics_t;
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
|
|
* table of things the driver needs to know about the b channel
|
|
|
|
* it is connected to for data transfer
|
|
|
|
*---------------------------------------------------------------------------*/
|
2001-03-24 15:40:29 +03:00
|
|
|
typedef struct i4b_isdn_bchan_linktab {
|
|
|
|
void* l1token;
|
2001-01-05 15:49:52 +03:00
|
|
|
int channel;
|
2002-03-17 12:45:58 +03:00
|
|
|
const struct isdn_l4_bchannel_functions *bchannel_driver;
|
2001-01-05 15:49:52 +03:00
|
|
|
struct ifqueue *tx_queue;
|
|
|
|
struct ifqueue *rx_queue; /* data xfer for NON-HDLC traffic */
|
|
|
|
struct mbuf **rx_mbuf; /* data xfer for HDLC based traffic */
|
|
|
|
} isdn_link_t;
|
|
|
|
|
2002-03-17 23:54:04 +03:00
|
|
|
struct isdn_l4_driver_functions;
|
2002-03-30 14:43:33 +03:00
|
|
|
struct isdn_l3_driver;
|
2001-01-05 15:49:52 +03:00
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
|
|
* this structure describes one call/connection on one B-channel
|
|
|
|
* and all its parameters
|
|
|
|
*---------------------------------------------------------------------------*/
|
2002-03-30 14:15:41 +03:00
|
|
|
typedef struct call_desc
|
2001-01-05 15:49:52 +03:00
|
|
|
{
|
|
|
|
u_int cdid; /* call descriptor id */
|
2003-10-03 20:38:44 +04:00
|
|
|
int isdnif; /* isdn interface number */
|
2002-03-30 14:43:33 +03:00
|
|
|
struct isdn_l3_driver *l3drv;
|
2001-01-05 15:49:52 +03:00
|
|
|
int cr; /* call reference value */
|
|
|
|
|
|
|
|
int crflag; /* call reference flag */
|
|
|
|
#define CRF_ORIG 0 /* originating side */
|
|
|
|
#define CRF_DEST 1 /* destinating side */
|
|
|
|
|
|
|
|
int channelid; /* channel id value */
|
|
|
|
int channelexcl; /* channel exclusive */
|
|
|
|
|
|
|
|
int bprot; /* B channel protocol BPROT_XXX */
|
|
|
|
|
2002-03-17 14:08:31 +03:00
|
|
|
int bchan_driver_index; /* driver to use for B channel */
|
|
|
|
int bchan_driver_unit; /* unit for above driver number */
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2001-01-05 15:49:52 +03:00
|
|
|
cause_t cause_in; /* cause value from NT */
|
|
|
|
cause_t cause_out; /* cause value to NT */
|
|
|
|
|
|
|
|
int call_state; /* from incoming SETUP */
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2001-01-05 15:49:52 +03:00
|
|
|
u_char dst_telno[TELNO_MAX]; /* destination number */
|
|
|
|
u_char src_telno[TELNO_MAX]; /* source number */
|
2002-03-30 10:08:13 +03:00
|
|
|
u_char src_subaddr[SUBADDR_MAX];
|
|
|
|
u_char dest_subaddr[SUBADDR_MAX];
|
2001-01-05 15:49:52 +03:00
|
|
|
|
|
|
|
int scr_ind; /* screening ind for incoming call */
|
|
|
|
int prs_ind; /* presentation ind for incoming call */
|
2002-03-30 10:08:13 +03:00
|
|
|
int type_plan; /* type and plan for incoming number */
|
2005-02-27 01:31:44 +03:00
|
|
|
|
2001-01-05 15:49:52 +03:00
|
|
|
int Q931state; /* Q.931 state for call */
|
|
|
|
int event; /* event to be processed */
|
|
|
|
|
|
|
|
int response; /* setup response type */
|
|
|
|
|
|
|
|
int T303; /* SETUP sent response timeout */
|
|
|
|
int T303_first_to; /* first timeout flag */
|
|
|
|
|
|
|
|
int T305; /* DISC without PROG IND */
|
|
|
|
|
|
|
|
int T308; /* RELEASE sent response timeout*/
|
|
|
|
int T308_first_to; /* first timeout flag */
|
|
|
|
|
|
|
|
int T309; /* data link disconnect timeout */
|
|
|
|
|
|
|
|
int T310; /* CALL PROC received */
|
|
|
|
|
2005-02-27 01:31:44 +03:00
|
|
|
int T313; /* CONNECT sent timeout */
|
2001-01-05 15:49:52 +03:00
|
|
|
|
|
|
|
int T400; /* L4 timeout */
|
|
|
|
|
2002-03-17 23:54:04 +03:00
|
|
|
isdn_link_t *ilt; /* isdn B channel driver/state */
|
|
|
|
const struct isdn_l4_driver_functions *l4_driver; /* layer 4 driver */
|
|
|
|
void *l4_driver_softc; /* layer 4 driver instance */
|
2001-01-05 15:49:52 +03:00
|
|
|
|
|
|
|
int dir; /* outgoing or incoming call */
|
|
|
|
#define DIR_OUTGOING 0
|
|
|
|
#define DIR_INCOMING 1
|
|
|
|
|
|
|
|
int timeout_active; /* idle timeout() active flag */
|
|
|
|
|
|
|
|
struct callout idle_timeout_handle;
|
|
|
|
struct callout T303_callout;
|
|
|
|
struct callout T305_callout;
|
|
|
|
struct callout T308_callout;
|
|
|
|
struct callout T309_callout;
|
|
|
|
struct callout T310_callout;
|
|
|
|
struct callout T313_callout;
|
|
|
|
struct callout T400_callout;
|
|
|
|
int callouts_inited; /* must init before use */
|
|
|
|
|
|
|
|
int idletime_state; /* wait for idle_time begin */
|
|
|
|
#define IST_IDLE 0 /* shorthold mode disabled */
|
|
|
|
#define IST_NONCHK 1 /* in non-checked window */
|
|
|
|
#define IST_CHECK 2 /* in idle check window */
|
|
|
|
#define IST_SAFE 3 /* in safety zone */
|
|
|
|
|
|
|
|
time_t idletimechk_start; /* check idletime window start */
|
|
|
|
time_t connect_time; /* time connect was made */
|
|
|
|
time_t last_active_time; /* last time with activity */
|
|
|
|
|
|
|
|
/* for incoming connections: */
|
|
|
|
time_t max_idle_time; /* max time without activity */
|
|
|
|
|
2005-02-27 01:31:44 +03:00
|
|
|
/* for outgoing connections: */
|
2001-01-05 15:49:52 +03:00
|
|
|
msg_shorthold_t shorthold_data; /* shorthold data to use */
|
|
|
|
|
|
|
|
int aocd_flag; /* AOCD used for unitlength calc*/
|
|
|
|
time_t last_aocd_time; /* last time AOCD received */
|
|
|
|
int units; /* number of AOCD charging units*/
|
|
|
|
int units_type; /* units type: AOCD, AOCE */
|
|
|
|
int cunits; /* calculated units */
|
|
|
|
|
|
|
|
int isdntxdelay; /* isdn tx delay after connect */
|
|
|
|
|
|
|
|
u_char display[DISPLAY_MAX]; /* display information element */
|
2005-02-27 01:31:44 +03:00
|
|
|
char datetime[DATETIME_MAX]; /* date/time information element*/
|
2001-01-05 15:49:52 +03:00
|
|
|
} call_desc_t;
|
|
|
|
|
2002-03-24 23:35:43 +03:00
|
|
|
extern call_desc_t call_desc[];
|
|
|
|
extern int num_call_desc;
|
2001-01-05 15:49:52 +03:00
|
|
|
|
2002-03-17 23:54:04 +03:00
|
|
|
/*
|
|
|
|
* Set of functions layer 4 drivers calls to manipulate the B channel
|
|
|
|
* they are using.
|
|
|
|
*/
|
|
|
|
struct isdn_l4_bchannel_functions {
|
|
|
|
void (*bch_config)(void*, int channel, int bprot, int updown);
|
|
|
|
void (*bch_tx_start)(void*, int channel);
|
2005-02-27 01:31:44 +03:00
|
|
|
void (*bch_stat)(void*, int channel, bchan_statistics_t *bsp);
|
2002-03-17 23:54:04 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Functions a layer 4 application driver exports
|
|
|
|
*/
|
|
|
|
struct isdn_l4_driver_functions {
|
|
|
|
/*
|
|
|
|
* Functions for use by the B channel driver
|
|
|
|
*/
|
|
|
|
void (*bch_rx_data_ready)(void *softc);
|
|
|
|
void (*bch_tx_queue_empty)(void *softc);
|
|
|
|
void (*bch_activity)(void *softc, int rxtx);
|
|
|
|
#define ACT_RX 0
|
|
|
|
#define ACT_TX 1
|
|
|
|
void (*line_connected)(void *softc, void *cde);
|
|
|
|
void (*line_disconnected)(void *softc, void *cde);
|
|
|
|
void (*dial_response)(void *softc, int stat, cause_t cause);
|
|
|
|
void (*updown_ind)(void *softc, int updown);
|
|
|
|
/*
|
|
|
|
* Functions used by the ISDN management system
|
|
|
|
*/
|
|
|
|
void* (*get_softc)(int unit);
|
|
|
|
void (*set_linktab)(void *softc, isdn_link_t *ilt);
|
|
|
|
/*
|
|
|
|
* Optional accounting function
|
|
|
|
*/
|
|
|
|
time_t (*get_idletime)(void* softc);
|
|
|
|
};
|
|
|
|
|
|
|
|
/* global registry of layer 4 drivers */
|
|
|
|
int isdn_l4_driver_attach(const char *name, int units, const struct isdn_l4_driver_functions *driver);
|
|
|
|
int isdn_l4_driver_detatch(const char *name);
|
|
|
|
int isdn_l4_find_driverid(const char *name);
|
|
|
|
const struct isdn_l4_driver_functions *isdn_l4_find_driver(const char *name, int unit);
|
|
|
|
const struct isdn_l4_driver_functions *isdn_l4_get_driver(int driver_id, int unit);
|
|
|
|
|
2001-01-05 15:49:52 +03:00
|
|
|
/* forward decl. */
|
|
|
|
struct isdn_diagnostic_request;
|
|
|
|
struct isdn_dr_prot;
|
|
|
|
|
2002-03-24 23:35:43 +03:00
|
|
|
/*
|
|
|
|
* functions exported by a layer 3 driver to layer 4
|
|
|
|
*/
|
|
|
|
struct isdn_l3_driver_functions {
|
|
|
|
isdn_link_t* (*get_linktab)(void*, int channel);
|
|
|
|
void (*set_l4_driver)(void*, int channel, const struct isdn_l4_driver_functions *l4_driver, void *l4_driver_softc);
|
2005-02-27 01:31:44 +03:00
|
|
|
|
|
|
|
void (*N_CONNECT_REQUEST) (struct call_desc *cd);
|
2002-03-30 14:15:41 +03:00
|
|
|
void (*N_CONNECT_RESPONSE) (struct call_desc *cd, int, int);
|
|
|
|
void (*N_DISCONNECT_REQUEST) (struct call_desc *cd, int);
|
|
|
|
void (*N_ALERT_REQUEST) (struct call_desc *cd);
|
2002-03-24 23:35:43 +03:00
|
|
|
int (*N_DOWNLOAD) (void*, int numprotos, struct isdn_dr_prot *protocols);
|
|
|
|
int (*N_DIAGNOSTICS) (void*, struct isdn_diagnostic_request*);
|
2002-03-30 14:15:41 +03:00
|
|
|
void (*N_MGMT_COMMAND) (struct isdn_l3_driver *, int cmd, void *);
|
2002-03-24 23:35:43 +03:00
|
|
|
};
|
|
|
|
|
2001-01-05 15:49:52 +03:00
|
|
|
/*---------------------------------------------------------------------------*
|
2003-10-03 20:38:44 +04:00
|
|
|
* This structure "describes" one ISDN interface (typically identical
|
|
|
|
* to one controller, but when one controller drives multiple ISDN's,
|
|
|
|
* this is just one of those ISDN's).
|
|
|
|
*
|
|
|
|
* An ISDN can be either a Basic Rate Interface (BRI, 2 B channels)
|
|
|
|
* or a Primary Rate Interface (PRI, 30 B channels).
|
2001-01-05 15:49:52 +03:00
|
|
|
*---------------------------------------------------------------------------*/
|
2002-03-24 23:35:43 +03:00
|
|
|
struct isdn_l3_driver {
|
2002-03-25 15:07:33 +03:00
|
|
|
SLIST_ENTRY(isdn_l3_driver) l3drvq;
|
2002-03-24 23:35:43 +03:00
|
|
|
void* l1_token; /* softc of hardware driver, actually
|
|
|
|
* this is the l2_softc (!!) for
|
|
|
|
* passive cards, and something else
|
|
|
|
* for active cards (maybe actually
|
|
|
|
* the softc there) */
|
2003-10-03 20:38:44 +04:00
|
|
|
int isdnif; /* ISDN id assigned to this */
|
2002-03-24 23:35:43 +03:00
|
|
|
char *devname; /* pointer to autoconf identifier */
|
|
|
|
/* e.g. "isic0" or "daic0 port 2" */
|
|
|
|
char *card_name; /* type of card */
|
2001-01-05 15:49:52 +03:00
|
|
|
|
|
|
|
int protocol; /* D-channel protocol type */
|
|
|
|
|
|
|
|
int dl_est; /* layer 2 established */
|
|
|
|
#define DL_DOWN 0
|
2005-02-27 01:31:44 +03:00
|
|
|
#define DL_UP 1
|
2001-01-05 15:49:52 +03:00
|
|
|
|
2003-10-03 20:38:44 +04:00
|
|
|
int nbch; /* number of B-channels */
|
|
|
|
int *bch_state; /* states of the nbch b channels */
|
|
|
|
#define BCH_ST_FREE 0 /* free to be used, idle */
|
|
|
|
#define BCH_ST_RSVD 1 /* reserved, may become free or used */
|
|
|
|
#define BCH_ST_USED 2 /* in use for data transfer */
|
2001-01-05 15:49:52 +03:00
|
|
|
|
|
|
|
int tei; /* current tei or -1 if invalid */
|
|
|
|
|
|
|
|
/* pointers to functions to be called from L4 */
|
2002-03-24 23:35:43 +03:00
|
|
|
const struct isdn_l3_driver_functions * l3driver;
|
|
|
|
};
|
2001-01-05 15:49:52 +03:00
|
|
|
|
2003-10-03 20:38:44 +04:00
|
|
|
#define NBCH_BRI 2
|
|
|
|
#define NBCH_PRI 30
|
|
|
|
|
2002-03-29 23:29:53 +03:00
|
|
|
void i4b_l4_contr_ev_ind(int controller, int attach);
|
2003-10-03 20:38:44 +04:00
|
|
|
struct isdn_l3_driver * isdn_attach_isdnif(const char *devname,
|
2005-02-27 01:31:44 +03:00
|
|
|
const char *cardname, void *l1_token,
|
2003-10-03 20:38:44 +04:00
|
|
|
const struct isdn_l3_driver_functions * l3driver, int nbch);
|
|
|
|
int isdn_detach_isdnif(struct isdn_l3_driver *);
|
|
|
|
void isdn_isdnif_ready(int isdnif);
|
|
|
|
struct isdn_l3_driver *isdn_find_l3_by_isdnif(int isdnif);
|
|
|
|
int isdn_count_isdnif(int *max_isdnif);
|
2001-01-05 15:49:52 +03:00
|
|
|
|
|
|
|
#endif /* _I4B_Q931_H_ */
|