[BACK]Return to i4b_l3l4.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / netisdn

File: [cvs.NetBSD.org] / src / sys / netisdn / Attic / i4b_l3l4.h (download)

Revision 1.17, Sat Dec 10 23:51:50 2005 UTC (18 years, 4 months ago) by elad
Branch: MAIN
CVS Tags: yamt-x86pmap-base4, yamt-x86pmap-base3, yamt-x86pmap-base2, yamt-x86pmap-base, yamt-x86pmap, yamt-uio_vmspace-base5, yamt-uio_vmspace, yamt-splraiseipl-base5, yamt-splraiseipl-base4, yamt-splraiseipl-base3, yamt-splraiseipl-base2, yamt-splraiseipl-base, yamt-splraiseipl, yamt-pf42-baseX, yamt-pf42-base4, yamt-pf42-base3, yamt-pf42-base2, yamt-pf42-base, yamt-pf42, yamt-pdpolicy-base9, yamt-pdpolicy-base8, yamt-pdpolicy-base7, yamt-pdpolicy-base6, yamt-pdpolicy-base5, yamt-pdpolicy-base4, yamt-pdpolicy-base3, yamt-pdpolicy-base2, yamt-pdpolicy-base, yamt-pdpolicy, yamt-pagecache-tag8, yamt-pagecache-base9, yamt-pagecache-base8, yamt-pagecache-base7, yamt-pagecache-base6, yamt-pagecache-base5, yamt-pagecache-base4, yamt-pagecache-base3, yamt-pagecache-base2, yamt-pagecache-base, yamt-pagecache, yamt-nfs-mp-base9, yamt-nfs-mp-base8, yamt-nfs-mp-base7, yamt-nfs-mp-base6, yamt-nfs-mp-base5, yamt-nfs-mp-base4, yamt-nfs-mp-base3, yamt-nfs-mp-base2, yamt-nfs-mp-base11, yamt-nfs-mp-base10, yamt-nfs-mp-base, yamt-nfs-mp, yamt-lazymbuf-base15, yamt-lazymbuf-base14, yamt-kmem-base3, yamt-kmem-base2, yamt-kmem-base, yamt-kmem, yamt-idlelwp-base8, yamt-idlelwp, wrstuden-revivesa-base-4, wrstuden-revivesa-base-3, wrstuden-revivesa-base-2, wrstuden-revivesa-base-1, wrstuden-revivesa-base, wrstuden-revivesa, wrstuden-fixsa-newbase, wrstuden-fixsa-base-1, wrstuden-fixsa-base, wrstuden-fixsa, vmlocking2-base3, vmlocking2-base2, vmlocking2-base1, vmlocking2, vmlocking-nbase, vmlocking-base, vmlocking, uebayasi-xip-base4, uebayasi-xip-base3, uebayasi-xip-base2, uebayasi-xip-base1, uebayasi-xip-base, uebayasi-xip, tls-maxphys-base-20171202, tls-maxphys-base, tls-maxphys, tls-earlyentropy-base, tls-earlyentropy, thorpej-atomic-base, thorpej-atomic, simonb-wapbl-nbase, simonb-wapbl-base, simonb-wapbl, simonb-timecounters-base, simonb-timecounters, simonb-timcounters-final, rpaulo-netinet-merge-pcb-base, rpaulo-netinet-merge-pcb, rmind-uvmplock-nbase, rmind-uvmplock-base, rmind-uvmplock, rmind-smpnet-nbase, rmind-smpnet-base, rmind-smpnet, riastradh-xf86-video-intel-2-7-1-pre-2-21-15, riastradh-drm2-base3, riastradh-drm2-base2, riastradh-drm2-base1, riastradh-drm2-base, riastradh-drm2, reinoud-bufcleanup-nbase, reinoud-bufcleanup-base, reinoud-bufcleanup, prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, post-newlock2-merge, phil-wifi-base, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, pgoyette-compat-base, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, peter-altq-base, peter-altq, perseant-stdc-iso10646-base, perseant-stdc-iso10646, nick-nhusb-base-20170825, nick-nhusb-base-20170204, nick-nhusb-base-20161204, nick-nhusb-base-20161004, nick-nhusb-base-20160907, nick-nhusb-base-20160529, nick-nhusb-base-20160422, nick-nhusb-base-20160319, nick-nhusb-base-20151226, nick-nhusb-base-20150921, nick-nhusb-base-20150606, nick-nhusb-base-20150406, nick-nhusb-base, nick-nhusb, nick-net80211-sync-base, nick-net80211-sync, nick-hppapmap-base4, nick-hppapmap-base3, nick-hppapmap-base2, nick-hppapmap-base, nick-hppapmap, nick-csl-alignment-base5, nick-csl-alignment-base, nick-csl-alignment, newlock2-nbase, newlock2-base, newlock2, netbsd-8-base, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, netbsd-7-nhusb-base-20170116, netbsd-7-nhusb-base, netbsd-7-nhusb, netbsd-7-base, netbsd-7-2-RELEASE, netbsd-7-1-RELEASE, netbsd-7-1-RC2, netbsd-7-1-RC1, netbsd-7-1-2-RELEASE, netbsd-7-1-1-RELEASE, netbsd-7-1, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE, netbsd-7-0, netbsd-7, netbsd-6-base, netbsd-6-1-RELEASE, netbsd-6-1-RC4, netbsd-6-1-RC3, netbsd-6-1-RC2, netbsd-6-1-RC1, netbsd-6-1-5-RELEASE, netbsd-6-1-4-RELEASE, netbsd-6-1-3-RELEASE, netbsd-6-1-2-RELEASE, netbsd-6-1-1-RELEASE, netbsd-6-1, netbsd-6-0-RELEASE, netbsd-6-0-RC2, netbsd-6-0-RC1, netbsd-6-0-6-RELEASE, netbsd-6-0-5-RELEASE, netbsd-6-0-4-RELEASE, netbsd-6-0-3-RELEASE, netbsd-6-0-2-RELEASE, netbsd-6-0-1-RELEASE, netbsd-6-0, netbsd-6, netbsd-5-base, netbsd-5-2-RELEASE, netbsd-5-2-RC1, netbsd-5-2-3-RELEASE, netbsd-5-2-2-RELEASE, netbsd-5-2-1-RELEASE, netbsd-5-2, netbsd-5-1-RELEASE, netbsd-5-1-RC4, netbsd-5-1-RC3, netbsd-5-1-RC2, netbsd-5-1-RC1, netbsd-5-1-5-RELEASE, netbsd-5-1-4-RELEASE, netbsd-5-1-3-RELEASE, netbsd-5-1-2-RELEASE, netbsd-5-1-1-RELEASE, netbsd-5-1, netbsd-5-0-RELEASE, netbsd-5-0-RC4, netbsd-5-0-RC3, netbsd-5-0-RC2, netbsd-5-0-RC1, netbsd-5-0-2-RELEASE, netbsd-5-0-1-RELEASE, netbsd-5-0, netbsd-5, netbsd-4-base, netbsd-4-0-RELEASE, netbsd-4-0-RC5, netbsd-4-0-RC4, netbsd-4-0-RC3, netbsd-4-0-RC2, netbsd-4-0-RC1, netbsd-4-0-1-RELEASE, netbsd-4-0, netbsd-4, mjf-ufs-trans-base, mjf-ufs-trans, mjf-devfs2-base, mjf-devfs2, mjf-devfs-base, mjf-devfs, matt-premerge-20091211, matt-nb8-mediatek-base, matt-nb8-mediatek, matt-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus, matt-nb5-pq3-base, matt-nb5-pq3, matt-nb5-mips64-u2-k2-k4-k7-k8-k9, matt-nb5-mips64-u1-k1-k5, matt-nb5-mips64-premerge-20101231, matt-nb5-mips64-premerge-20091211, matt-nb5-mips64-k15, matt-nb5-mips64, matt-nb4-mips64-k7-u2a-k9b, matt-nb4-arm-base, matt-nb4-arm, matt-mips64-premerge-20101231, matt-mips64-base2, matt-mips64-base, matt-mips64, matt-armv6-prevmlocking, matt-armv6-nbase, matt-armv6-base, matt-armv6, localcount-20160914, ktrace-lwp-base, khorben-n900, keiichi-mipv6-nbase, keiichi-mipv6-base, keiichi-mipv6, jymxensuspend-base, jym-xensuspend-nbase, jym-xensuspend-base, jym-xensuspend, jruoho-x86intr-base, jruoho-x86intr, jmcneill-usbmp-pre-base2, jmcneill-usbmp-base9, jmcneill-usbmp-base8, jmcneill-usbmp-base7, jmcneill-usbmp-base6, jmcneill-usbmp-base5, jmcneill-usbmp-base4, jmcneill-usbmp-base3, jmcneill-usbmp-base2, jmcneill-usbmp-base10, jmcneill-usbmp-base, jmcneill-usbmp, jmcneill-pm-base, jmcneill-pm, jmcneill-base, jmcneill-audiomp3-base, jmcneill-audiomp3, jdolecek-ncq-base, jdolecek-ncq, hpcarm-cleanup-nbase, hpcarm-cleanup-base, hpcarm-cleanup, haad-nbase2, haad-dm-base2, haad-dm-base1, haad-dm-base, haad-dm, gdamore-uart-base, gdamore-uart, elad-kernelauth-base, elad-kernelauth, cube-autoconf-base, cube-autoconf, cherry-xenmp-base, cherry-xenmp, chap-midi-nbase, chap-midi-base, chap-midi, bouyer-xeni386-nbase, bouyer-xeni386-merge1, bouyer-xeni386-base, bouyer-xeni386, bouyer-xenamd64-base2, bouyer-xenamd64-base, bouyer-xenamd64, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan, bouyer-quota2-nbase, bouyer-quota2-base, bouyer-quota2, agc-symver-base, agc-symver, ad-socklock-base1, ad-audiomp2-base, ad-audiomp2, ad-audiomp-base, ad-audiomp, abandoned-netbsd-4-base, abandoned-netbsd-4
Branch point for: phil-wifi, pgoyette-compat
Changes since 1.16: +5 -5 lines

Multiple inclusion protection, as suggested by christos@ on tech-kern@
few days ago.

/*	$NetBSD: i4b_l3l4.h,v 1.17 2005/12/10 23:51:50 elad Exp $	*/

/*
 * 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
 *	------------------------------------------
 *
 *	$Id: i4b_l3l4.h,v 1.17 2005/12/10 23:51:50 elad Exp $
 *
 * $FreeBSD$
 *
 *	last edit-date: [Fri Jun  2 14:29:35 2000]
 *
 *---------------------------------------------------------------------------*/

#ifndef _NETISDN_I4B_L3L4_H_
#define _NETISDN_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		*/

#define MAX_BCHAN	2
#define N_CALL_DESC	(20*(MAX_BCHAN)) /* XXX: make resizable */

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
 *---------------------------------------------------------------------------*/
typedef struct i4b_isdn_bchan_linktab {
	void* l1token;
	int channel;
	const struct isdn_l4_bchannel_functions *bchannel_driver;
	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;

struct isdn_l4_driver_functions;
struct isdn_l3_driver;

/*---------------------------------------------------------------------------*
 *	this structure describes one call/connection on one B-channel
 *	and all its parameters
 *---------------------------------------------------------------------------*/
typedef struct call_desc
{
	u_int	cdid;			/* call descriptor id		*/
	int	isdnif;			/* isdn interface number	*/
	struct isdn_l3_driver *l3drv;
	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 */

	int	bchan_driver_index;	/* driver to use for B channel	*/
	int	bchan_driver_unit;	/* unit for above driver number	*/

	cause_t	cause_in;		/* cause value from NT	*/
	cause_t	cause_out;		/* cause value to NT	*/

	int	call_state;		/* from incoming SETUP	*/

	u_char	dst_telno[TELNO_MAX];	/* destination number	*/
	u_char	src_telno[TELNO_MAX];	/* source number	*/
	u_char	src_subaddr[SUBADDR_MAX];
	u_char	dest_subaddr[SUBADDR_MAX];

	int	scr_ind;		/* screening ind for incoming call */
	int	prs_ind;		/* presentation ind for incoming call */
	int	type_plan;		/* type and plan for incoming number */

	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		*/

	int	T313;			/* CONNECT sent timeout		*/

	int	T400;			/* L4 timeout */

	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	*/

	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	*/

					/* for outgoing connections:	*/
	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	*/
	char	datetime[DATETIME_MAX];	/* date/time information element*/
} call_desc_t;

extern call_desc_t call_desc[];
extern int num_call_desc;

/*
 * 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);
	void (*bch_stat)(void*, int channel, bchan_statistics_t *bsp);
};

/*
 * 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);

/* forward decl. */
struct isdn_diagnostic_request;
struct isdn_dr_prot;

/*
 * 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);

	void	(*N_CONNECT_REQUEST)	(struct call_desc *cd);
	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);
	int     (*N_DOWNLOAD)		(void*, int numprotos, struct isdn_dr_prot *protocols);
	int     (*N_DIAGNOSTICS)	(void*, struct isdn_diagnostic_request*);
	void	(*N_MGMT_COMMAND)	(struct isdn_l3_driver *, int cmd, void *);
};

/*---------------------------------------------------------------------------*
 *	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).
 *---------------------------------------------------------------------------*/
struct isdn_l3_driver {
	SLIST_ENTRY(isdn_l3_driver) l3drvq;
	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) */
	int	isdnif;			/* ISDN id assigned to this */
	char *devname;			/* pointer to autoconf identifier */
					/* e.g. "isic0" or "daic0 port 2" */
	char *card_name;		/* type of card */

	int	protocol;		/* D-channel protocol type */

	int	dl_est;			/* layer 2 established	*/
#define DL_DOWN	0
#define DL_UP	1

	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 */

	int	tei;			/* current tei or -1 if invalid */

	/* pointers to functions to be called from L4 */
	const struct isdn_l3_driver_functions * l3driver;
};

#define NBCH_BRI 2
#define NBCH_PRI 30

void i4b_l4_contr_ev_ind(int controller, int attach);
struct isdn_l3_driver * isdn_attach_isdnif(const char *devname,
    const char *cardname, void *l1_token,
    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);

#endif /* !_NETISDN_I4B_Q931_H_ */