aboutsummaryrefslogtreecommitdiff
path: root/sys/i4b/layer4
diff options
context:
space:
mode:
Diffstat (limited to 'sys/i4b/layer4')
-rw-r--r--sys/i4b/layer4/i4b_i4bdrv.c865
-rw-r--r--sys/i4b/layer4/i4b_l4.c1097
-rw-r--r--sys/i4b/layer4/i4b_l4.h73
-rw-r--r--sys/i4b/layer4/i4b_l4mgmt.c436
-rw-r--r--sys/i4b/layer4/i4b_l4timer.c88
5 files changed, 0 insertions, 2559 deletions
diff --git a/sys/i4b/layer4/i4b_i4bdrv.c b/sys/i4b/layer4/i4b_i4bdrv.c
deleted file mode 100644
index ef73ce162be1..000000000000
--- a/sys/i4b/layer4/i4b_i4bdrv.c
+++ /dev/null
@@ -1,865 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 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_i4bdrv.c - i4b userland interface driver
- * --------------------------------------------
- * last edit-date: [Sun Aug 11 12:42:46 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/ioccom.h>
-#include <sys/malloc.h>
-#include <sys/uio.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/conf.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/selinfo.h>
-#include <net/if.h>
-
-#include <i4b/include/i4b_debug.h>
-#include <i4b/include/i4b_ioctl.h>
-#include <i4b/include/i4b_cause.h>
-
-#include <i4b/include/i4b_l3l4.h>
-#include <i4b/include/i4b_mbuf.h>
-#include <i4b/include/i4b_global.h>
-
-#include <i4b/layer4/i4b_l4.h>
-
-#include <sys/poll.h>
-
-struct selinfo select_rd_info;
-
-static struct ifqueue i4b_rdqueue;
-static int openflag = 0;
-static int selflag = 0;
-static int readflag = 0;
-
-static d_open_t i4bopen;
-static d_close_t i4bclose;
-static d_read_t i4bread;
-static d_ioctl_t i4bioctl;
-static d_poll_t i4bpoll;
-
-
-static struct cdevsw i4b_cdevsw = {
- .d_version = D_VERSION,
- .d_flags = D_NEEDGIANT,
- .d_open = i4bopen,
- .d_close = i4bclose,
- .d_read = i4bread,
- .d_ioctl = i4bioctl,
- .d_poll = i4bpoll,
- .d_name = "i4b",
-};
-
-static void i4battach(void *);
-PSEUDO_SET(i4battach, i4b_i4bdrv);
-
-/*---------------------------------------------------------------------------*
- * interface attach routine
- *---------------------------------------------------------------------------*/
-static void
-i4battach(void *dummy)
-{
- printf("i4b: ISDN call control device attached\n");
-
- i4b_rdqueue.ifq_maxlen = IFQ_MAXLEN;
-
- if(!mtx_initialized(&i4b_rdqueue.ifq_mtx))
- mtx_init(&i4b_rdqueue.ifq_mtx, "i4b_rdqueue", NULL, MTX_DEF);
-
- make_dev(&i4b_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "i4b");
-}
-
-/*---------------------------------------------------------------------------*
- * i4bopen - device driver open routine
- *---------------------------------------------------------------------------*/
-static int
-i4bopen(struct cdev *dev, int flag, int fmt, struct thread *td)
-{
- int x;
-
- if(minor(dev))
- return(ENXIO);
-
- if(openflag)
- return(EBUSY);
-
- x = splimp();
- openflag = 1;
- i4b_l4_daemon_attached();
- splx(x);
-
- return(0);
-}
-
-/*---------------------------------------------------------------------------*
- * i4bclose - device driver close routine
- *---------------------------------------------------------------------------*/
-static int
-i4bclose(struct cdev *dev, int flag, int fmt, struct thread *td)
-{
- int x = splimp();
- openflag = 0;
- i4b_l4_daemon_detached();
- i4b_Dcleanifq(&i4b_rdqueue);
- splx(x);
- return(0);
-}
-
-/*---------------------------------------------------------------------------*
- * i4bread - device driver read routine
- *---------------------------------------------------------------------------*/
-static int
-i4bread(struct cdev *dev, struct uio *uio, int ioflag)
-{
- struct mbuf *m;
- int x;
- int error = 0;
-
- if(minor(dev))
- return(ENODEV);
-
- x = splimp();
- IF_LOCK(&i4b_rdqueue);
- while(IF_QEMPTY(&i4b_rdqueue))
- {
- readflag = 1;
-
- error = msleep( &i4b_rdqueue, &i4b_rdqueue.ifq_mtx,
- (PZERO + 1) | PCATCH, "bird", 0);
-
- if (error != 0) {
- IF_UNLOCK(&i4b_rdqueue);
- splx(x);
- return error;
- }
- }
-
- _IF_DEQUEUE(&i4b_rdqueue, m);
- IF_UNLOCK(&i4b_rdqueue);
-
- splx(x);
-
- if(m && m->m_len)
- error = uiomove(m->m_data, m->m_len, uio);
- else
- error = EIO;
-
- if(m)
- i4b_Dfreembuf(m);
-
- return(error);
-}
-
-/*---------------------------------------------------------------------------*
- * i4bioctl - device driver ioctl routine
- *---------------------------------------------------------------------------*/
-static int
-i4bioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
-{
- call_desc_t *cd;
- int error = 0;
-
- if(minor(dev))
- return(ENODEV);
-
- switch(cmd)
- {
- /* cdid request, reserve cd and return cdid */
-
- case I4B_CDID_REQ:
- {
- msg_cdid_req_t *mir;
- mir = (msg_cdid_req_t *)data;
- cd = reserve_cd();
- mir->cdid = cd->cdid;
- break;
- }
-
- /* connect request, dial out to remote */
-
- case I4B_CONNECT_REQ:
- {
- msg_connect_req_t *mcr;
- mcr = (msg_connect_req_t *)data; /* setup ptr */
-
- if((cd = cd_by_cdid(mcr->cdid)) == NULL)/* get cd */
- {
- NDBGL4(L4_ERR, "I4B_CONNECT_REQ ioctl, cdid not found!");
- error = EINVAL;
- break;
- }
-
- /* prevent dialling on leased lines */
- if(ctrl_desc[mcr->controller].protocol == PROTOCOL_D64S)
- {
- SET_CAUSE_TYPE(cd->cause_in, CAUSET_I4B);
- SET_CAUSE_VAL(cd->cause_in, CAUSE_I4B_LLDIAL);
- i4b_l4_disconnect_ind(cd);
- freecd_by_cd(cd);
- break;
- }
-
- cd->controller = mcr->controller; /* fill cd */
- cd->bprot = mcr->bprot;
- cd->bcap = mcr->bcap;
- cd->driver = mcr->driver;
- cd->driver_unit = mcr->driver_unit;
- cd->cr = get_rand_cr(ctrl_desc[cd->controller].unit);
-
- cd->shorthold_data.shorthold_algorithm = mcr->shorthold_data.shorthold_algorithm;
- cd->shorthold_data.unitlen_time = mcr->shorthold_data.unitlen_time;
- cd->shorthold_data.idle_time = mcr->shorthold_data.idle_time;
- cd->shorthold_data.earlyhup_time = mcr->shorthold_data.earlyhup_time;
-
- cd->last_aocd_time = 0;
- if(mcr->unitlen_method == ULEN_METHOD_DYNAMIC)
- cd->aocd_flag = 1;
- else
- cd->aocd_flag = 0;
-
- cd->cunits = 0;
-
- cd->max_idle_time = 0; /* this is outgoing */
-
- cd->dir = DIR_OUTGOING;
-
- NDBGL4(L4_TIMO, "I4B_CONNECT_REQ times, algorithm=%ld unitlen=%ld idle=%ld earlyhup=%ld",
- (long)cd->shorthold_data.shorthold_algorithm, (long)cd->shorthold_data.unitlen_time,
- (long)cd->shorthold_data.idle_time, (long)cd->shorthold_data.earlyhup_time);
-
- strcpy(cd->dst_telno, mcr->dst_telno);
- strcpy(cd->src_telno, mcr->src_telno);
-
- strcpy(cd->dst_subaddr, mcr->dst_subaddr);
- strcpy(cd->src_subaddr, mcr->src_subaddr);
-
- if(mcr->keypad[0] != '\0')
- strcpy(cd->keypad, mcr->keypad);
- else
- cd->keypad[0] = '\0';
-
- cd->display[0] = '\0';
-
- SET_CAUSE_TYPE(cd->cause_in, CAUSET_I4B);
- SET_CAUSE_VAL(cd->cause_in, CAUSE_I4B_NORMAL);
-
- switch(mcr->channel)
- {
- case CHAN_B1:
- case CHAN_B2:
- if(ctrl_desc[mcr->controller].bch_state[mcr->channel] != BCH_ST_FREE)
- SET_CAUSE_VAL(cd->cause_in, CAUSE_I4B_NOCHAN);
- break;
-
- case CHAN_ANY:
- {
- int i;
- for (i = 0;
- i < ctrl_desc[mcr->controller].nbch &&
- ctrl_desc[mcr->controller].bch_state[i] != BCH_ST_FREE;
- i++);
- if (i == ctrl_desc[mcr->controller].nbch)
- SET_CAUSE_VAL(cd->cause_in, CAUSE_I4B_NOCHAN);
- /* else mcr->channel = i; XXX */
- }
- break;
-
- default:
- SET_CAUSE_VAL(cd->cause_in, CAUSE_I4B_NOCHAN);
- break;
- }
-
- cd->channelid = mcr->channel;
-
- cd->isdntxdelay = mcr->txdelay;
-
- /* check whether we have a pointer. Seems like */
- /* this should be adequate. GJ 19.09.97 */
- if(ctrl_desc[cd->controller].N_CONNECT_REQUEST == NULL)
-/*XXX*/ SET_CAUSE_VAL(cd->cause_in, CAUSE_I4B_NOCHAN);
-
- if((GET_CAUSE_VAL(cd->cause_in)) != CAUSE_I4B_NORMAL)
- {
- i4b_l4_disconnect_ind(cd);
- freecd_by_cd(cd);
- }
- else
- {
- (*ctrl_desc[cd->controller].N_CONNECT_REQUEST)(mcr->cdid);
- }
- break;
- }
-
- /* connect response, accept/reject/ignore incoming call */
-
- case I4B_CONNECT_RESP:
- {
- msg_connect_resp_t *mcrsp;
-
- mcrsp = (msg_connect_resp_t *)data;
-
- if((cd = cd_by_cdid(mcrsp->cdid)) == NULL)/* get cd */
- {
- NDBGL4(L4_ERR, "I4B_CONNECT_RESP ioctl, cdid not found!");
- error = EINVAL;
- break;
- }
-
- T400_stop(cd);
-
- cd->driver = mcrsp->driver;
- cd->driver_unit = mcrsp->driver_unit;
- cd->max_idle_time = mcrsp->max_idle_time;
-
- cd->shorthold_data.shorthold_algorithm = SHA_FIXU;
- cd->shorthold_data.unitlen_time = 0; /* this is incoming */
- cd->shorthold_data.idle_time = 0;
- cd->shorthold_data.earlyhup_time = 0;
-
- cd->isdntxdelay = mcrsp->txdelay;
-
- NDBGL4(L4_TIMO, "I4B_CONNECT_RESP max_idle_time set to %ld seconds", (long)cd->max_idle_time);
-
- (*ctrl_desc[cd->controller].N_CONNECT_RESPONSE)(mcrsp->cdid, mcrsp->response, mcrsp->cause);
- break;
- }
-
- /* disconnect request, actively terminate connection */
-
- case I4B_DISCONNECT_REQ:
- {
- msg_discon_req_t *mdr;
-
- mdr = (msg_discon_req_t *)data;
-
- if((cd = cd_by_cdid(mdr->cdid)) == NULL)/* get cd */
- {
- NDBGL4(L4_ERR, "I4B_DISCONNECT_REQ ioctl, cdid not found!");
- error = EINVAL;
- break;
- }
-
- /* preset causes with our cause */
- cd->cause_in = cd->cause_out = mdr->cause;
-
- (*ctrl_desc[cd->controller].N_DISCONNECT_REQUEST)(mdr->cdid, mdr->cause);
- break;
- }
-
- /* controller info request */
-
- case I4B_CTRL_INFO_REQ:
- {
- msg_ctrl_info_req_t *mcir;
-
- mcir = (msg_ctrl_info_req_t *)data;
- mcir->ncontroller = nctrl;
-
- if(mcir->controller > nctrl)
- {
- mcir->ctrl_type = -1;
- mcir->card_type = -1;
- }
- else
- {
- mcir->ctrl_type =
- ctrl_desc[mcir->controller].ctrl_type;
- mcir->card_type =
- ctrl_desc[mcir->controller].card_type;
- mcir->nbch =
- ctrl_desc[mcir->controller].nbch;
-
- if(ctrl_desc[mcir->controller].ctrl_type == CTRL_PASSIVE)
- mcir->tei = ctrl_desc[mcir->controller].tei;
- else
- mcir->tei = -1;
- }
- break;
- }
-
- /* dial response */
-
- case I4B_DIALOUT_RESP:
- {
- drvr_link_t *dlt = NULL;
- msg_dialout_resp_t *mdrsp;
-
- mdrsp = (msg_dialout_resp_t *)data;
-
- switch(mdrsp->driver)
- {
-#if defined(NI4BIPR) && (NI4BIPR > 0)
- case BDRV_IPR:
- dlt = ipr_ret_linktab(mdrsp->driver_unit);
- break;
-#endif
-
-#if defined(NI4BISPPP) && (NI4BISPPP > 0)
- case BDRV_ISPPP:
- dlt = i4bisppp_ret_linktab(mdrsp->driver_unit);
- break;
-#endif
-
-#if defined(NI4BTEL) && (NI4BTEL > 0)
- case BDRV_TEL:
- dlt = tel_ret_linktab(mdrsp->driver_unit);
- break;
-#endif
-
-#if defined(NIBC) && NIBC > 0
- case BDRV_IBC:
- dlt = ibc_ret_linktab(mdrsp->driver_unit);
- break;
-#endif
-
-#if defined(NI4BING) && (NI4BING > 0)
- case BDRV_ING:
- dlt = ing_ret_linktab(mdrsp->driver_unit);
- break;
-#endif
- }
-
- if(dlt != NULL)
- (*dlt->dial_response)(mdrsp->driver_unit, mdrsp->stat, mdrsp->cause);
- break;
- }
-
- /* update timeout value */
-
- case I4B_TIMEOUT_UPD:
- {
- msg_timeout_upd_t *mtu;
- int x;
-
- mtu = (msg_timeout_upd_t *)data;
-
- NDBGL4(L4_TIMO, "I4B_TIMEOUT_UPD ioctl, alg %d, unit %d, idle %d, early %d!",
- mtu->shorthold_data.shorthold_algorithm, mtu->shorthold_data.unitlen_time,
- mtu->shorthold_data.idle_time, mtu->shorthold_data.earlyhup_time);
-
- if((cd = cd_by_cdid(mtu->cdid)) == NULL)/* get cd */
- {
- NDBGL4(L4_ERR, "I4B_TIMEOUT_UPD ioctl, cdid not found!");
- error = EINVAL;
- break;
- }
-
- switch( mtu->shorthold_data.shorthold_algorithm )
- {
- case SHA_FIXU:
- /*
- * For this algorithm unitlen_time,
- * idle_time and earlyhup_time are used.
- */
-
- if(!(mtu->shorthold_data.unitlen_time >= 0 &&
- mtu->shorthold_data.idle_time >= 0 &&
- mtu->shorthold_data.earlyhup_time >= 0))
- {
- NDBGL4(L4_ERR, "I4B_TIMEOUT_UPD ioctl, invalid args for fix unit algorithm!");
- error = EINVAL;
- }
- break;
-
- case SHA_VARU:
- /*
- * For this algorithm unitlen_time and
- * idle_time are used. both must be
- * positive integers. earlyhup_time is
- * not used and must be 0.
- */
-
- if(!(mtu->shorthold_data.unitlen_time > 0 &&
- mtu->shorthold_data.idle_time >= 0 &&
- mtu->shorthold_data.earlyhup_time == 0))
- {
- NDBGL4(L4_ERR, "I4B_TIMEOUT_UPD ioctl, invalid args for var unit algorithm!");
- error = EINVAL;
- }
- break;
-
- default:
- NDBGL4(L4_ERR, "I4B_TIMEOUT_UPD ioctl, invalid algorithm!");
- error = EINVAL;
- break;
- }
-
- /*
- * any error set above requires us to break
- * out of the outer switch
- */
- if(error != 0)
- break;
-
- x = SPLI4B();
- cd->shorthold_data.shorthold_algorithm = mtu->shorthold_data.shorthold_algorithm;
- cd->shorthold_data.unitlen_time = mtu->shorthold_data.unitlen_time;
- cd->shorthold_data.idle_time = mtu->shorthold_data.idle_time;
- cd->shorthold_data.earlyhup_time = mtu->shorthold_data.earlyhup_time;
- splx(x);
- break;
- }
-
- /* soft enable/disable interface */
-
- case I4B_UPDOWN_IND:
- {
- msg_updown_ind_t *mui;
-
- mui = (msg_updown_ind_t *)data;
-
-#if defined(NI4BIPR) && (NI4BIPR > 0)
- if(mui->driver == BDRV_IPR)
- {
- drvr_link_t *dlt;
- dlt = ipr_ret_linktab(mui->driver_unit);
- (*dlt->updown_ind)(mui->driver_unit, mui->updown);
- }
-#endif
- break;
- }
-
- /* send ALERT request */
-
- case I4B_ALERT_REQ:
- {
- msg_alert_req_t *mar;
-
- mar = (msg_alert_req_t *)data;
-
- if((cd = cd_by_cdid(mar->cdid)) == NULL)
- {
- NDBGL4(L4_ERR, "I4B_ALERT_REQ ioctl, cdid not found!");
- error = EINVAL;
- break;
- }
-
- T400_stop(cd);
-
- (*ctrl_desc[cd->controller].N_ALERT_REQUEST)(mar->cdid);
-
- break;
- }
-
- /* version/release number request */
-
- case I4B_VR_REQ:
- {
- msg_vr_req_t *mvr;
-
- mvr = (msg_vr_req_t *)data;
-
- mvr->version = VERSION;
- mvr->release = REL;
- mvr->step = STEP;
- break;
- }
-
- /* set D-channel protocol for a controller */
-
- case I4B_PROT_IND:
- {
- msg_prot_ind_t *mpi;
-
- mpi = (msg_prot_ind_t *)data;
-
- ctrl_desc[mpi->controller].protocol = mpi->protocol;
-
- break;
- }
-
- /* Download request */
-
- case I4B_CTRL_DOWNLOAD:
- {
- struct isdn_dr_prot *prots = NULL, *prots2 = NULL;
- struct isdn_download_request *r =
- (struct isdn_download_request*)data;
- int i;
-
- if (r->controller < 0 || r->controller >= nctrl)
- {
- error = ENODEV;
- goto download_done;
- }
-
- if(!ctrl_desc[r->controller].N_DOWNLOAD)
- {
- error = ENODEV;
- goto download_done;
- }
-
- prots = malloc(r->numprotos * sizeof(struct isdn_dr_prot),
- M_DEVBUF, M_WAITOK);
-
- prots2 = malloc(r->numprotos * sizeof(struct isdn_dr_prot),
- M_DEVBUF, M_WAITOK);
-
- if(!prots || !prots2)
- {
- error = ENOMEM;
- goto download_done;
- }
-
- copyin(r->protocols, prots, r->numprotos * sizeof(struct isdn_dr_prot));
-
- for(i = 0; i < r->numprotos; i++)
- {
- prots2[i].microcode = malloc(prots[i].bytecount, M_DEVBUF, M_WAITOK);
- copyin(prots[i].microcode, prots2[i].microcode, prots[i].bytecount);
- prots2[i].bytecount = prots[i].bytecount;
- }
-
- error = ctrl_desc[r->controller].N_DOWNLOAD(
- ctrl_desc[r->controller].unit,
- r->numprotos, prots2);
-
-download_done:
- if(prots2)
- {
- for(i = 0; i < r->numprotos; i++)
- {
- if(prots2[i].microcode)
- {
- free(prots2[i].microcode, M_DEVBUF);
- }
- }
- free(prots2, M_DEVBUF);
- }
-
- if(prots)
- {
- free(prots, M_DEVBUF);
- }
- break;
- }
-
- /* Diagnostic request */
-
- case I4B_ACTIVE_DIAGNOSTIC:
- {
- struct isdn_diagnostic_request req, *r =
- (struct isdn_diagnostic_request*)data;
-
- req.in_param = req.out_param = NULL;
- if (r->controller < 0 || r->controller >= nctrl)
- {
- error = ENODEV;
- goto diag_done;
- }
-
- if(!ctrl_desc[r->controller].N_DIAGNOSTICS)
- {
- error = ENODEV;
- goto diag_done;
- }
-
- memcpy(&req, r, sizeof(req));
-
- if(req.in_param_len)
- {
- /* XXX arbitrary limit */
- if (req.in_param_len >
- I4B_ACTIVE_DIAGNOSTIC_MAXPARAMLEN) {
- error = EINVAL;
- goto diag_done;
- }
-
- req.in_param = malloc(r->in_param_len, M_DEVBUF, M_WAITOK);
-
- if(!req.in_param)
- {
- error = ENOMEM;
- goto diag_done;
- }
- error = copyin(r->in_param, req.in_param, req.in_param_len);
- if (error)
- goto diag_done;
- }
-
- if(req.out_param_len)
- {
- req.out_param = malloc(r->out_param_len, M_DEVBUF, M_WAITOK);
-
- if(!req.out_param)
- {
- error = ENOMEM;
- goto diag_done;
- }
- }
-
- error = ctrl_desc[r->controller].N_DIAGNOSTICS(r->controller, &req);
-
- if(!error && req.out_param_len)
- error = copyout(req.out_param, r->out_param, req.out_param_len);
-
-diag_done:
- if(req.in_param)
- free(req.in_param, M_DEVBUF);
-
- if(req.out_param)
- free(req.out_param, M_DEVBUF);
-
- break;
- }
-
- /* default */
-
- default:
- error = ENOTTY;
- break;
- }
-
- return(error);
-}
-
-/*---------------------------------------------------------------------------*
- * i4bpoll - device driver poll routine
- *---------------------------------------------------------------------------*/
-static int
-i4bpoll(struct cdev *dev, int events, struct thread *td)
-{
- int x;
-
- if(minor(dev))
- return(ENODEV);
-
- if((events & POLLIN) || (events & POLLRDNORM))
- {
- if(!IF_QEMPTY(&i4b_rdqueue))
- return(1);
-
- x = splimp();
- selrecord(td, &select_rd_info);
- selflag = 1;
- splx(x);
- return(0);
- }
- else if((events & POLLOUT) || (events & POLLWRNORM))
- {
- return(1);
- }
-
- return(0);
-}
-
-/*---------------------------------------------------------------------------*
- * i4bputqueue - put message into queue to userland
- *---------------------------------------------------------------------------*/
-void
-i4bputqueue(struct mbuf *m)
-{
- int x;
-
- if(!openflag)
- {
- i4b_Dfreembuf(m);
- return;
- }
-
- x = splimp();
-
- IF_LOCK(&i4b_rdqueue);
- if(_IF_QFULL(&i4b_rdqueue))
- {
- struct mbuf *m1;
- _IF_DEQUEUE(&i4b_rdqueue, m1);
- i4b_Dfreembuf(m1);
- NDBGL4(L4_ERR, "ERROR, queue full, removing entry!");
- }
-
- _IF_ENQUEUE(&i4b_rdqueue, m);
- IF_UNLOCK(&i4b_rdqueue);
-
- splx(x);
-
- if(readflag)
- {
- readflag = 0;
- wakeup( &i4b_rdqueue);
- }
-
- if(selflag)
- {
- selflag = 0;
- selwakeuppri(&select_rd_info, I4BPRI);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * i4bputqueue_hipri - put message into front of queue to userland
- *---------------------------------------------------------------------------*/
-void
-i4bputqueue_hipri(struct mbuf *m)
-{
- int x;
-
- if(!openflag)
- {
- i4b_Dfreembuf(m);
- return;
- }
-
- x = splimp();
-
- IF_LOCK(&i4b_rdqueue);
- if(_IF_QFULL(&i4b_rdqueue))
- {
- struct mbuf *m1;
- _IF_DEQUEUE(&i4b_rdqueue, m1);
- i4b_Dfreembuf(m1);
- NDBGL4(L4_ERR, "ERROR, queue full, removing entry!");
- }
-
- _IF_PREPEND(&i4b_rdqueue, m);
- IF_UNLOCK(&i4b_rdqueue);
-
- splx(x);
-
- if(readflag)
- {
- readflag = 0;
- wakeup( &i4b_rdqueue);
- }
-
- if(selflag)
- {
- selflag = 0;
- selwakeuppri(&select_rd_info, I4BPRI);
- }
-}
diff --git a/sys/i4b/layer4/i4b_l4.c b/sys/i4b/layer4/i4b_l4.c
deleted file mode 100644
index 9ca64e2a845c..000000000000
--- a/sys/i4b/layer4/i4b_l4.c
+++ /dev/null
@@ -1,1097 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 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_l4.c - kernel interface to userland
- * -----------------------------------------
- * last edit-date: [Sun Aug 11 12:43:14 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include "opt_i4b.h"
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-
-#include <i4b/include/i4b_debug.h>
-#include <i4b/include/i4b_ioctl.h>
-#include <i4b/include/i4b_cause.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_l3l4.h>
-#include <i4b/include/i4b_mbuf.h>
-#include <i4b/layer4/i4b_l4.h>
-
-unsigned int i4b_l4_debug = L4_DEBUG_DEFAULT;
-
-struct ctrl_type_desc ctrl_types[CTRL_NUMTYPES] = { { NULL, NULL} };
-
-static int i4b_link_bchandrvr(call_desc_t *cd);
-static void i4b_unlink_bchandrvr(call_desc_t *cd);
-static void i4b_l4_setup_timeout(call_desc_t *cd);
-static void i4b_idle_check_fix_unit(call_desc_t *cd);
-static void i4b_idle_check_var_unit(call_desc_t *cd);
-static void i4b_l4_setup_timeout_fix_unit(call_desc_t *cd);
-static void i4b_l4_setup_timeout_var_unit(call_desc_t *cd);
-static time_t i4b_get_idletime(call_desc_t *cd);
-
-#if defined(NI4BISPPP) && (NI4BISPPP > 0)
-extern time_t i4bisppp_idletime(int);
-#endif
-
-/*---------------------------------------------------------------------------*
- * send MSG_PDEACT_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_pdeact(int controller, int numactive)
-{
- struct mbuf *m;
- int i;
- call_desc_t *cd;
-
- for(i=0; i < N_CALL_DESC; i++)
- {
- if((call_desc[i].cdid != CDID_UNUSED) &&
- (ctrl_desc[call_desc[i].controller].ctrl_type == CTRL_PASSIVE) &&
- (ctrl_desc[call_desc[i].controller].unit == controller))
- {
- cd = &call_desc[i];
-
- if(cd->timeout_active)
- {
- STOP_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd);
- }
-
- if(cd->dlt != NULL)
- {
- (*cd->dlt->line_disconnected)(cd->driver_unit, (void *)cd);
- i4b_unlink_bchandrvr(cd);
- }
-
- if((cd->channelid >= 0) & (cd->channelid < ctrl_desc[cd->controller].nbch))
- {
- ctrl_desc[cd->controller].bch_state[cd->channelid] = BCH_ST_FREE;
- }
-
- cd->cdid = CDID_UNUSED;
- }
- }
-
- if((m = i4b_Dgetmbuf(sizeof(msg_pdeact_ind_t))) != NULL)
- {
- msg_pdeact_ind_t *md = (msg_pdeact_ind_t *)m->m_data;
-
- md->header.type = MSG_PDEACT_IND;
- md->header.cdid = -1;
-
- md->controller = controller;
- md->numactive = numactive;
-
- i4bputqueue_hipri(m); /* URGENT !!! */
- }
-}
-
-/*---------------------------------------------------------------------------*
- * send MSG_L12STAT_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_l12stat(int controller, int layer, int state)
-{
- struct mbuf *m;
-
- if((m = i4b_Dgetmbuf(sizeof(msg_l12stat_ind_t))) != NULL)
- {
- msg_l12stat_ind_t *md = (msg_l12stat_ind_t *)m->m_data;
-
- md->header.type = MSG_L12STAT_IND;
- md->header.cdid = -1;
-
- md->controller = controller;
- md->layer = layer;
- md->state = state;
-
- i4bputqueue(m);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * send MSG_TEIASG_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_teiasg(int controller, int tei)
-{
- struct mbuf *m;
-
- if((m = i4b_Dgetmbuf(sizeof(msg_teiasg_ind_t))) != NULL)
- {
- msg_teiasg_ind_t *md = (msg_teiasg_ind_t *)m->m_data;
-
- md->header.type = MSG_TEIASG_IND;
- md->header.cdid = -1;
-
- md->controller = controller;
- md->tei = ctrl_desc[controller].tei;
-
- i4bputqueue(m);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * send MSG_DIALOUT_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_dialout(int driver, int driver_unit)
-{
- struct mbuf *m;
-
- if((m = i4b_Dgetmbuf(sizeof(msg_dialout_ind_t))) != NULL)
- {
- msg_dialout_ind_t *md = (msg_dialout_ind_t *)m->m_data;
-
- md->header.type = MSG_DIALOUT_IND;
- md->header.cdid = -1;
-
- md->driver = driver;
- md->driver_unit = driver_unit;
-
- i4bputqueue(m);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * send MSG_DIALOUTNUMBER_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_dialoutnumber(int driver, int driver_unit, int cmdlen, char *cmd)
-{
- struct mbuf *m;
-
- if((m = i4b_Dgetmbuf(sizeof(msg_dialoutnumber_ind_t))) != NULL)
- {
- msg_dialoutnumber_ind_t *md = (msg_dialoutnumber_ind_t *)m->m_data;
- int i;
-
- md->header.type = MSG_DIALOUTNUMBER_IND;
- md->header.cdid = -1;
-
- md->driver = driver;
- md->driver_unit = driver_unit;
-
- for (i = 0; i < cmdlen; i++)
- if (cmd[i] == '*')
- break;
-
- /* XXX: TELNO_MAX is _with_ tailing '\0', so max is actually TELNO_MAX - 1 */
- md->cmdlen = (i < TELNO_MAX - 1 ? i : TELNO_MAX - 1);
- /* skip the (first) '*' */
- md->subaddrlen = (cmdlen - i - 1 < SUBADDR_MAX - 1 ? cmdlen - i - 1 : SUBADDR_MAX - 1);
-
- bcopy(cmd, md->cmd, md->cmdlen);
- if (md->subaddrlen != -1)
- bcopy(cmd+i+1, md->subaddr, md->subaddrlen);
-
- NDBGL4(L4_TIMO, "cmd[%d]=%s, subaddr[%d]=%s", md->cmdlen, md->cmd, md->subaddrlen, md->subaddr);
- i4bputqueue(m);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * send MSG_KEYPAD_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_keypad(int driver, int driver_unit, int cmdlen, char *cmd)
-{
- struct mbuf *m;
-
- if((m = i4b_Dgetmbuf(sizeof(msg_keypad_ind_t))) != NULL)
- {
- msg_keypad_ind_t *md = (msg_keypad_ind_t *)m->m_data;
-
- md->header.type = MSG_KEYPAD_IND;
- md->header.cdid = -1;
-
- md->driver = driver;
- md->driver_unit = driver_unit;
-
- if(cmdlen > KEYPAD_MAX)
- cmdlen = KEYPAD_MAX;
-
- md->cmdlen = cmdlen;
- bcopy(cmd, md->cmd, cmdlen);
- i4bputqueue(m);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * send MSG_NEGOTIATION_COMPL message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_negcomplete(call_desc_t *cd)
-{
- struct mbuf *m;
-
- if((m = i4b_Dgetmbuf(sizeof(msg_negcomplete_ind_t))) != NULL)
- {
- msg_negcomplete_ind_t *md = (msg_negcomplete_ind_t *)m->m_data;
-
- md->header.type = MSG_NEGCOMP_IND;
- md->header.cdid = cd->cdid;
-
- i4bputqueue(m);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * send MSG_IFSTATE_CHANGED_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_ifstate_changed(call_desc_t *cd, int new_state)
-{
- struct mbuf *m;
-
- if((m = i4b_Dgetmbuf(sizeof(msg_ifstatechg_ind_t))) != NULL)
- {
- msg_ifstatechg_ind_t *md = (msg_ifstatechg_ind_t *)m->m_data;
-
- md->header.type = MSG_IFSTATE_CHANGED_IND;
- md->header.cdid = cd->cdid;
- md->state = new_state;
-
- i4bputqueue(m);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * send MSG_DRVRDISC_REQ message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_drvrdisc(int driver, int driver_unit)
-{
- struct mbuf *m;
-
- if((m = i4b_Dgetmbuf(sizeof(msg_drvrdisc_req_t))) != NULL)
- {
- msg_drvrdisc_req_t *md = (msg_drvrdisc_req_t *)m->m_data;
-
- md->header.type = MSG_DRVRDISC_REQ;
- md->header.cdid = -1;
-
- md->driver = driver;
- md->driver_unit = driver_unit;
-
- i4bputqueue(m);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * send MSG_ACCT_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_accounting(int driver, int driver_unit, int accttype, int ioutbytes,
- int iinbytes, int ro, int ri, int outbytes, int inbytes)
-{
- struct mbuf *m;
-
- if((m = i4b_Dgetmbuf(sizeof(msg_accounting_ind_t))) != NULL)
- {
- msg_accounting_ind_t *md = (msg_accounting_ind_t *)m->m_data;
-
- md->header.type = MSG_ACCT_IND;
- md->header.cdid = -1;
-
- md->driver = driver;
- md->driver_unit = driver_unit;
-
- md->accttype = accttype;
- md->ioutbytes = ioutbytes;
- md->iinbytes = iinbytes;
- md->outbps = ro;
- md->inbps = ri;
- md->outbytes = outbytes;
- md->inbytes = inbytes;
-
- i4bputqueue(m);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * send MSG_CONNECT_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_connect_ind(call_desc_t *cd)
-{
- struct mbuf *m;
-
- if((m = i4b_Dgetmbuf(sizeof(msg_connect_ind_t))) != NULL)
- {
- msg_connect_ind_t *mp = (msg_connect_ind_t *)m->m_data;
-
- mp->header.type = MSG_CONNECT_IND;
- mp->header.cdid = cd->cdid;
-
- mp->controller = cd->controller;
- mp->channel = cd->channelid;
- mp->bprot = cd->bprot;
- mp->bcap = cd->bcap;
-
- cd->dir = DIR_INCOMING;
-
- if(strlen(cd->dst_telno) > 0)
- strcpy(mp->dst_telno, cd->dst_telno);
- else
- strcpy(mp->dst_telno, TELNO_EMPTY);
-
- if(strlen(cd->dst_subaddr) > 0)
- strcpy(mp->dst_subaddr, cd->dst_subaddr);
- else
- strcpy(mp->dst_subaddr, TELNO_EMPTY);
-
- if(strlen(cd->src_telno) > 0)
- strcpy(mp->src_telno, cd->src_telno);
- else
- strcpy(mp->src_telno, TELNO_EMPTY);
-
- if(strlen(cd->src_subaddr) > 0)
- strcpy(mp->src_subaddr, cd->src_subaddr);
- else
- strcpy(mp->src_subaddr, TELNO_EMPTY);
-
- mp->src_ton = cd->src_ton;
- mp->dst_ton = cd->dst_ton;
-
- strcpy(mp->display, cd->display);
-
- mp->scr_ind = cd->scr_ind;
- mp->prs_ind = cd->prs_ind;
-
- T400_start(cd);
-
- i4bputqueue(m);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * send MSG_CONNECT_ACTIVE_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_connect_active_ind(call_desc_t *cd)
-{
- int s;
- struct mbuf *m;
-
- s = SPLI4B();
-
- cd->last_active_time = cd->connect_time = SECOND;
-
- NDBGL4(L4_TIMO, "last_active/connect_time=%ld", (long)cd->connect_time);
-
- i4b_link_bchandrvr(cd);
-
- (*cd->dlt->line_connected)(cd->driver_unit, (void *)cd);
-
- i4b_l4_setup_timeout(cd);
-
- splx(s);
-
- if((m = i4b_Dgetmbuf(sizeof(msg_connect_active_ind_t))) != NULL)
- {
- msg_connect_active_ind_t *mp = (msg_connect_active_ind_t *)m->m_data;
-
- mp->header.type = MSG_CONNECT_ACTIVE_IND;
- mp->header.cdid = cd->cdid;
- mp->controller = cd->controller;
- mp->channel = cd->channelid;
- if(cd->datetime[0] != '\0')
- strcpy(mp->datetime, cd->datetime);
- else
- mp->datetime[0] = '\0';
- i4bputqueue(m);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * send MSG_DISCONNECT_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_disconnect_ind(call_desc_t *cd)
-{
- struct mbuf *m;
-
- if(cd->timeout_active)
- STOP_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd);
-
- if(cd->dlt != NULL)
- {
- (*cd->dlt->line_disconnected)(cd->driver_unit, (void *)cd);
- i4b_unlink_bchandrvr(cd);
- }
-
- if((cd->channelid >= 0) && (cd->channelid < ctrl_desc[cd->controller].nbch))
- {
- ctrl_desc[cd->controller].bch_state[cd->channelid] = BCH_ST_FREE;
- }
- else
- {
- /* no error, might be hunting call for callback */
- NDBGL4(L4_MSG, "channel free not valid but %d!", cd->channelid);
- }
-
- if((m = i4b_Dgetmbuf(sizeof(msg_disconnect_ind_t))) != NULL)
- {
- msg_disconnect_ind_t *mp = (msg_disconnect_ind_t *)m->m_data;
-
- mp->header.type = MSG_DISCONNECT_IND;
- mp->header.cdid = cd->cdid;
- mp->cause = cd->cause_in;
-
- i4bputqueue(m);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * send MSG_IDLE_TIMEOUT_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_idle_timeout_ind(call_desc_t *cd)
-{
- struct mbuf *m;
-
- if((m = i4b_Dgetmbuf(sizeof(msg_idle_timeout_ind_t))) != NULL)
- {
- msg_idle_timeout_ind_t *mp = (msg_idle_timeout_ind_t *)m->m_data;
-
- mp->header.type = MSG_IDLE_TIMEOUT_IND;
- mp->header.cdid = cd->cdid;
-
- i4bputqueue(m);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * send MSG_CHARGING_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_charging_ind(call_desc_t *cd)
-{
- struct mbuf *m;
-
- if((m = i4b_Dgetmbuf(sizeof(msg_charging_ind_t))) != NULL)
- {
- msg_charging_ind_t *mp = (msg_charging_ind_t *)m->m_data;
-
- mp->header.type = MSG_CHARGING_IND;
- mp->header.cdid = cd->cdid;
- mp->units_type = cd->units_type;
-
-/*XXX*/ if(mp->units_type == CHARGE_CALC)
- mp->units = cd->cunits;
- else
- mp->units = cd->units;
-
- i4bputqueue(m);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * send MSG_STATUS_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_status_ind(call_desc_t *cd)
-{
-}
-
-/*---------------------------------------------------------------------------*
- * send MSG_ALERT_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_alert_ind(call_desc_t *cd)
-{
- struct mbuf *m;
-
- if((m = i4b_Dgetmbuf(sizeof(msg_alert_ind_t))) != NULL)
- {
- msg_alert_ind_t *mp = (msg_alert_ind_t *)m->m_data;
-
- mp->header.type = MSG_ALERT_IND;
- mp->header.cdid = cd->cdid;
-
- i4bputqueue(m);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * send MSG_INFO_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_info_ind(call_desc_t *cd)
-{
-}
-
-/*---------------------------------------------------------------------------*
- * send MSG_INFO_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_proceeding_ind(call_desc_t *cd)
-{
- struct mbuf *m;
-
- if((m = i4b_Dgetmbuf(sizeof(msg_proceeding_ind_t))) != NULL)
- {
- msg_proceeding_ind_t *mp = (msg_proceeding_ind_t *)m->m_data;
-
- mp->header.type = MSG_PROCEEDING_IND;
- mp->header.cdid = cd->cdid;
- mp->controller = cd->controller;
- mp->channel = cd->channelid;
- i4bputqueue(m);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * send MSG_PACKET_IND message to userland
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_packet_ind(int driver, int driver_unit, int dir, struct mbuf *pkt)
-{
- struct mbuf *m;
- int len = pkt->m_pkthdr.len;
- unsigned char *ip = pkt->m_data;
-
- if((m = i4b_Dgetmbuf(sizeof(msg_packet_ind_t))) != NULL)
- {
- msg_packet_ind_t *mp = (msg_packet_ind_t *)m->m_data;
-
- mp->header.type = MSG_PACKET_IND;
- mp->header.cdid = -1;
- mp->driver = driver;
- mp->driver_unit = driver_unit;
- mp->direction = dir;
- memcpy(mp->pktdata, ip,
- len <MAX_PACKET_LOG ? len : MAX_PACKET_LOG);
- i4bputqueue(m);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * link a driver(unit) to a B-channel(controller,unit,channel)
- *---------------------------------------------------------------------------*/
-static int
-i4b_link_bchandrvr(call_desc_t *cd)
-{
- int t = ctrl_desc[cd->controller].ctrl_type;
-
- if(t < 0 || t >= CTRL_NUMTYPES || ctrl_types[t].get_linktab == NULL)
- {
- cd->ilt = NULL;
- }
- else
- {
- cd->ilt = ctrl_types[t].get_linktab(
- ctrl_desc[cd->controller].unit,
- cd->channelid);
- }
-
- switch(cd->driver)
- {
-#if defined(NI4BRBCH) && (NI4BRBCH > 0)
- case BDRV_RBCH:
- cd->dlt = rbch_ret_linktab(cd->driver_unit);
- break;
-#endif
-
-#if defined(NI4BTEL) && (NI4BTEL > 0)
- case BDRV_TEL:
- cd->dlt = tel_ret_linktab(cd->driver_unit);
- break;
-#endif
-
-#if defined(NI4BIPR) && (NI4BIPR > 0)
- case BDRV_IPR:
- cd->dlt = ipr_ret_linktab(cd->driver_unit);
- break;
-#endif
-
-#if defined(NI4BISPPP) && (NI4BISPPP > 0)
- case BDRV_ISPPP:
- cd->dlt = i4bisppp_ret_linktab(cd->driver_unit);
- break;
-#endif
-
-#if defined(NIBC) && NIBC > 0
- case BDRV_IBC:
- cd->dlt = ibc_ret_linktab(cd->driver_unit);
- break;
-#endif
-
-#if defined(NI4BING) && (NI4BING > 0)
- case BDRV_ING:
- cd->dlt = ing_ret_linktab(cd->driver_unit);
- break;
-#endif
-
- default:
- cd->dlt = NULL;
- break;
- }
-
- if(cd->dlt == NULL || cd->ilt == NULL)
- return(-1);
-
- if(t >= 0 && t < CTRL_NUMTYPES && ctrl_types[t].set_linktab != NULL)
- {
- ctrl_types[t].set_linktab(
- ctrl_desc[cd->controller].unit,
- cd->channelid,
- cd->dlt);
- }
-
- switch(cd->driver)
- {
-#if defined(NI4BRBCH) && (NI4BRBCH > 0)
- case BDRV_RBCH:
- rbch_set_linktab(cd->driver_unit, cd->ilt);
- break;
-#endif
-
-#if defined(NI4BTEL) && (NI4BTEL > 0)
- case BDRV_TEL:
- tel_set_linktab(cd->driver_unit, cd->ilt);
- break;
-#endif
-
-#if defined(NI4BIPR) && (NI4BIPR > 0)
- case BDRV_IPR:
- ipr_set_linktab(cd->driver_unit, cd->ilt);
- break;
-#endif
-
-#if defined(NI4BISPPP) && (NI4BISPPP > 0)
- case BDRV_ISPPP:
- i4bisppp_set_linktab(cd->driver_unit, cd->ilt);
- break;
-#endif
-
-#if defined(NIBC) && NIBC > 0
- case BDRV_IBC:
- ibc_set_linktab(cd->driver_unit, cd->ilt);
- break;
-#endif
-
-#if defined(NI4BING) && (NI4BING > 0)
- case BDRV_ING:
- ing_set_linktab(cd->driver_unit, cd->ilt);
- break;
-#endif
-
- default:
- return(0);
- break;
- }
-
- /* activate B channel */
-
- (*cd->ilt->bch_config)(cd->ilt->unit, cd->ilt->channel, cd->bprot, 1);
-
- return(0);
-}
-
-/*---------------------------------------------------------------------------*
- * unlink a driver(unit) from a B-channel(controller,unit,channel)
- *---------------------------------------------------------------------------*/
-static void
-i4b_unlink_bchandrvr(call_desc_t *cd)
-{
- int t = ctrl_desc[cd->controller].ctrl_type;
-
- if(t < 0 || t >= CTRL_NUMTYPES || ctrl_types[t].get_linktab == NULL)
- {
- cd->ilt = NULL;
- return;
- }
- else
- {
- cd->ilt = ctrl_types[t].get_linktab(
- ctrl_desc[cd->controller].unit,
- cd->channelid);
- }
-
- /* deactivate B channel */
-
- (*cd->ilt->bch_config)(cd->ilt->unit, cd->ilt->channel, cd->bprot, 0);
-}
-
-/*---------------------------------------------------------------------------
-
- How shorthold mode works for OUTGOING connections
- =================================================
-
- |<---- unchecked-window ------->|<-checkwindow->|<-safetywindow>|
-
-idletime_state: IST_NONCHK IST_CHECK IST_SAFE
-
- | | | |
- time>>+-------------------------------+---------------+---------------+-...
- | | | |
- | |<--idle_time-->|<--earlyhup--->|
- |<-----------------------unitlen------------------------------->|
-
-
- unitlen - specifies the time a charging unit lasts
- idle_time - specifies the thime the line must be idle at the
- end of the unit to be elected for hangup
- earlyhup - is the beginning of a timing safety zone before the
- next charging unit starts
-
- The algorithm works as follows: lets assume the unitlen is 100
- secons, idle_time is 40 seconds and earlyhup is 10 seconds.
- The line then must be idle 50 seconds after the begin of the
- current unit and it must then be quiet for 40 seconds. if it
- has been quiet for this 40 seconds, the line is closed 10
- seconds before the next charging unit starts. In case there was
- any traffic within the idle_time, the line is not closed.
- It does not matter whether there was any traffic between second
- 0 and second 50 or not.
-
-
- How shorthold mode works for INCOMING connections
- =================================================
-
- it is just possible to specify a maximum idle time for incoming
- connections, after this time of no activity on the line the line
- is closed.
-
----------------------------------------------------------------------------*/
-
-static time_t
-i4b_get_idletime(call_desc_t *cd)
-{
- switch (cd->driver) {
-#if defined(NI4BISPPP) && (NI4BISPPP > 0)
- case BDRV_ISPPP:
- return i4bisppp_idletime(cd->driver_unit);
- break;
-#endif
- default:
- return cd->last_active_time;
- break;
- }
-}
-/*---------------------------------------------------------------------------*
- * B channel idle check timeout setup
- *---------------------------------------------------------------------------*/
-static void
-i4b_l4_setup_timeout(call_desc_t *cd)
-{
- NDBGL4(L4_TIMO, "%ld: direction %d, shorthold algorithm %d",
- (long)SECOND, cd->dir, cd->shorthold_data.shorthold_algorithm);
-
- cd->timeout_active = 0;
- cd->idletime_state = IST_IDLE;
-
- if((cd->dir == DIR_INCOMING) && (cd->max_idle_time > 0))
- {
- /* incoming call: simple max idletime check */
-
- START_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd, hz/2);
- cd->timeout_active = 1;
- NDBGL4(L4_TIMO, "%ld: incoming-call, setup max_idle_time to %ld", (long)SECOND, (long)cd->max_idle_time);
- }
- else if((cd->dir == DIR_OUTGOING) && (cd->shorthold_data.idle_time > 0))
- {
- switch( cd->shorthold_data.shorthold_algorithm )
- {
- default: /* fall into the old fix algorithm */
- case SHA_FIXU:
- i4b_l4_setup_timeout_fix_unit( cd );
- break;
-
- case SHA_VARU:
- i4b_l4_setup_timeout_var_unit( cd );
- break;
- }
- }
- else
- {
- NDBGL4(L4_TIMO, "no idle_timeout configured");
- }
-}
-
-/*---------------------------------------------------------------------------*
- * fixed unit algorithm B channel idle check timeout setup
- *---------------------------------------------------------------------------*/
-static void
-i4b_l4_setup_timeout_fix_unit(call_desc_t *cd)
-{
- /* outgoing call */
-
- if((cd->shorthold_data.idle_time > 0) && (cd->shorthold_data.unitlen_time == 0))
- {
- /* outgoing call: simple max idletime check */
-
- START_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd, hz/2);
- cd->timeout_active = 1;
- NDBGL4(L4_TIMO, "%ld: outgoing-call, setup idle_time to %ld",
- (long)SECOND, (long)cd->shorthold_data.idle_time);
- }
- else if((cd->shorthold_data.unitlen_time > 0) && (cd->shorthold_data.unitlen_time > (cd->shorthold_data.idle_time + cd->shorthold_data.earlyhup_time)))
- {
- /* outgoing call: full shorthold mode check */
-
- START_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd, hz*(cd->shorthold_data.unitlen_time - (cd->shorthold_data.idle_time + cd->shorthold_data.earlyhup_time)));
- cd->timeout_active = 1;
- cd->idletime_state = IST_NONCHK;
- NDBGL4(L4_TIMO, "%ld: outgoing-call, start %ld sec nocheck window",
- (long)SECOND, (long)(cd->shorthold_data.unitlen_time - (cd->shorthold_data.idle_time + cd->shorthold_data.earlyhup_time)));
-
- if(cd->aocd_flag == 0)
- {
- cd->units_type = CHARGE_CALC;
- cd->cunits++;
- i4b_l4_charging_ind(cd);
- }
- }
- else
- {
- /* parms somehow got wrong .. */
-
- NDBGL4(L4_ERR, "%ld: ERROR: idletime[%ld]+earlyhup[%ld] > unitlength[%ld]!",
- (long)SECOND, (long)cd->shorthold_data.idle_time, (long)cd->shorthold_data.earlyhup_time, (long)cd->shorthold_data.unitlen_time);
- }
-}
-
-/*---------------------------------------------------------------------------*
- * variable unit algorithm B channel idle check timeout setup
- *---------------------------------------------------------------------------*/
-static void
-i4b_l4_setup_timeout_var_unit(call_desc_t *cd)
-{
- /* outgoing call: variable unit idletime check */
-
- /*
- * start checking for an idle connect one second before the end of the unit.
- * The one second takes into account of rounding due to the driver only
- * using the seconds and not the uSeconds of the current time
- */
- cd->idletime_state = IST_CHECK; /* move directly to the checking state */
-
- START_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd, hz * (cd->shorthold_data.unitlen_time - 1) );
- cd->timeout_active = 1;
- NDBGL4(L4_TIMO, "%ld: outgoing-call, var idle time - setup to %ld",
- (long)SECOND, (long)cd->shorthold_data.unitlen_time);
-}
-
-
-/*---------------------------------------------------------------------------*
- * B channel idle check timeout function
- *---------------------------------------------------------------------------*/
-void
-i4b_idle_check(call_desc_t *cd)
-{
- int s;
-
- if(cd->cdid == CDID_UNUSED)
- return;
-
- s = SPLI4B();
-
- /* failsafe */
-
- if(cd->timeout_active == 0)
- {
- NDBGL4(L4_ERR, "ERROR: timeout_active == 0 !!!");
- }
- else
- {
- cd->timeout_active = 0;
- }
-
- /* incoming connections, simple idletime check */
-
- if(cd->dir == DIR_INCOMING)
- {
- if((i4b_get_idletime(cd) + cd->max_idle_time) <= SECOND)
- {
- NDBGL4(L4_TIMO, "%ld: incoming-call, line idle timeout, disconnecting!", (long)SECOND);
- (*ctrl_desc[cd->controller].N_DISCONNECT_REQUEST)(cd->cdid,
- (CAUSET_I4B << 8) | CAUSE_I4B_NORMAL);
- i4b_l4_idle_timeout_ind(cd);
- }
- else
- {
- NDBGL4(L4_TIMO, "%ld: incoming-call, activity, last_active=%ld, max_idle=%ld", (long)SECOND, (long)i4b_get_idletime(cd), (long)cd->max_idle_time);
-
- START_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd, hz/2);
- cd->timeout_active = 1;
- }
- }
-
- /* outgoing connections */
-
- else if(cd->dir == DIR_OUTGOING)
- {
- switch( cd->shorthold_data.shorthold_algorithm )
- {
- case SHA_FIXU:
- i4b_idle_check_fix_unit( cd );
- break;
- case SHA_VARU:
- i4b_idle_check_var_unit( cd );
- break;
- default:
- NDBGL4(L4_TIMO, "%ld: bad value for shorthold_algorithm of %d",
- (long)SECOND, cd->shorthold_data.shorthold_algorithm);
- i4b_idle_check_fix_unit( cd );
- break;
- }
- }
- splx(s);
-}
-
-/*---------------------------------------------------------------------------*
- * fixed unit algorithm B channel idle check timeout function
- *---------------------------------------------------------------------------*/
-static void
-i4b_idle_check_fix_unit(call_desc_t *cd)
-{
-
- /* simple idletime calculation */
-
- if((cd->shorthold_data.idle_time > 0) && (cd->shorthold_data.unitlen_time == 0))
- {
- if((i4b_get_idletime(cd) + cd->shorthold_data.idle_time) <= SECOND)
- {
- NDBGL4(L4_TIMO, "%ld: outgoing-call-st, idle timeout, disconnecting!", (long)SECOND);
- (*ctrl_desc[cd->controller].N_DISCONNECT_REQUEST)(cd->cdid, (CAUSET_I4B << 8) | CAUSE_I4B_NORMAL);
- i4b_l4_idle_timeout_ind(cd);
- }
- else
- {
- NDBGL4(L4_TIMO, "%ld: outgoing-call-st, activity, last_active=%ld, max_idle=%ld",
- (long)SECOND, (long)i4b_get_idletime(cd), (long)cd->shorthold_data.idle_time);
- START_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd, hz/2);
- cd->timeout_active = 1;
- }
- }
-
- /* full shorthold mode calculation */
-
- else if((cd->shorthold_data.unitlen_time > 0)
- && (cd->shorthold_data.unitlen_time > (cd->shorthold_data.idle_time + cd->shorthold_data.earlyhup_time)))
- {
- switch(cd->idletime_state)
- {
-
- case IST_NONCHK: /* end of non-check time */
-
- START_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd, hz*(cd->shorthold_data.idle_time));
- cd->idletimechk_start = SECOND;
- cd->idletime_state = IST_CHECK;
- cd->timeout_active = 1;
- NDBGL4(L4_TIMO, "%ld: outgoing-call, idletime check window reached!", (long)SECOND);
- break;
-
- case IST_CHECK: /* end of idletime chk */
- if((i4b_get_idletime(cd) > cd->idletimechk_start) &&
- (i4b_get_idletime(cd) <= SECOND))
- { /* activity detected */
- START_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd, hz*(cd->shorthold_data.earlyhup_time));
- cd->timeout_active = 1;
- cd->idletime_state = IST_SAFE;
- NDBGL4(L4_TIMO, "%ld: outgoing-call, activity at %ld, wait earlyhup-end", (long)SECOND, (long)i4b_get_idletime(cd));
- }
- else
- { /* no activity, hangup */
- NDBGL4(L4_TIMO, "%ld: outgoing-call, idle timeout, last activity at %ld", (long)SECOND, (long)i4b_get_idletime(cd));
- (*ctrl_desc[cd->controller].N_DISCONNECT_REQUEST)(cd->cdid, (CAUSET_I4B << 8) | CAUSE_I4B_NORMAL);
- i4b_l4_idle_timeout_ind(cd);
- cd->idletime_state = IST_IDLE;
- }
- break;
-
- case IST_SAFE: /* end of earlyhup time */
-
- START_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd, hz*(cd->shorthold_data.unitlen_time - (cd->shorthold_data.idle_time+cd->shorthold_data.earlyhup_time)));
- cd->timeout_active = 1;
- cd->idletime_state = IST_NONCHK;
-
- if(cd->aocd_flag == 0)
- {
- cd->units_type = CHARGE_CALC;
- cd->cunits++;
- i4b_l4_charging_ind(cd);
- }
-
- NDBGL4(L4_TIMO, "%ld: outgoing-call, earlyhup end, wait for idletime start", (long)SECOND);
- break;
-
- default:
- NDBGL4(L4_ERR, "outgoing-call: invalid idletime_state value!");
- cd->idletime_state = IST_IDLE;
- break;
- }
- }
-}
-
-/*---------------------------------------------------------------------------*
- * variable unit algorithm B channel idle check timeout function
- *---------------------------------------------------------------------------*/
-static void
-i4b_idle_check_var_unit(call_desc_t *cd)
-{
- switch(cd->idletime_state)
- {
-
- /* see if there has been any activity within the last idle_time seconds */
- case IST_CHECK:
- if( i4b_get_idletime(cd) > (SECOND - cd->shorthold_data.idle_time))
- { /* activity detected */
- /* check again in one second */
- cd->idle_timeout_handle =
- START_TIMER (cd->idle_timeout_handle, i4b_idle_check, cd, hz);
- cd->timeout_active = 1;
- cd->idletime_state = IST_CHECK;
- NDBGL4(L4_TIMO, "%ld: outgoing-call, var idle timeout - activity at %ld, continuing", (long)SECOND, (long)i4b_get_idletime(cd));
- }
- else
- { /* no activity, hangup */
- NDBGL4(L4_TIMO, "%ld: outgoing-call, var idle timeout - last activity at %ld", (long)SECOND, (long)i4b_get_idletime(cd));
- (*ctrl_desc[cd->controller].N_DISCONNECT_REQUEST)(cd->cdid, (CAUSET_I4B << 8) | CAUSE_I4B_NORMAL);
- i4b_l4_idle_timeout_ind(cd);
- cd->idletime_state = IST_IDLE;
- }
- break;
-
- default:
- NDBGL4(L4_ERR, "outgoing-call: var idle timeout invalid idletime_state value!");
- cd->idletime_state = IST_IDLE;
- break;
- }
-}
diff --git a/sys/i4b/layer4/i4b_l4.h b/sys/i4b/layer4/i4b_l4.h
deleted file mode 100644
index b02d9ac7c97a..000000000000
--- a/sys/i4b/layer4/i4b_l4.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*-
- * Copyright (c) 1997, 2001 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_l4.h - kernel interface to userland header file
- * ---------------------------------------------------
- *
- * $FreeBSD$
- *
- * last edit-date: [Thu Oct 18 10:11:51 2001]
- *
- *---------------------------------------------------------------------------*/
-
-#ifndef _I4B_L4_H_
-#define _I4B_L4_H_
-
-extern void i4bputqueue ( struct mbuf *m );
-extern void i4bputqueue_hipri(struct mbuf *m);
-extern void i4b_l4_accounting(int, int, int, int, int, int, int, int, int);
-extern void i4b_l4_alert_ind ( call_desc_t *cd );
-extern void i4b_l4_charging_ind( call_desc_t *cd );
-extern void i4b_l4_connect_active_ind ( call_desc_t *cd );
-extern void i4b_l4_connect_ind ( call_desc_t *cd );
-extern void i4b_l4_daemon_attached(void);
-extern void i4b_l4_daemon_detached(void);
-extern void i4b_l4_dialout( int driver, int driver_unit );
-extern void i4b_l4_dialoutnumber(int driver, int driver_unit, int cmdlen, char *cmd);
-extern void i4b_l4_keypad(int driver, int driver_unit, int cmdlen, char *cmd);
-extern void i4b_l4_disconnect_ind ( call_desc_t *cd );
-extern void i4b_l4_drvrdisc (int driver, int driver_unit );
-extern void i4b_l4_negcomplete( call_desc_t *cd );
-extern void i4b_l4_ifstate_changed( call_desc_t *cd, int new_state );
-extern void i4b_l4_idle_timeout_ind( call_desc_t *cd );
-extern void i4b_l4_info_ind ( call_desc_t *cd );
-extern void i4b_l4_packet_ind(int, int, int, struct mbuf *pkt);
-extern void i4b_l4_l12stat(int controller, int layer, int state);
-extern void i4b_l4_pdeact(int controller, int numactive);
-extern void i4b_l4_teiasg(int controller, int tei);
-extern void i4b_l4_status_ind ( call_desc_t *cd );
-extern void i4b_l4_proceeding_ind ( call_desc_t *cd );
-extern void i4b_idle_check(call_desc_t *cdp);
-extern call_desc_t * cd_by_cdid ( unsigned int cdid );
-extern call_desc_t * cd_by_unitcr ( int unit, int cr, int crf );
-extern void freecd_by_cd ( call_desc_t *cd );
-extern unsigned char get_rand_cr ( int unit );
-extern call_desc_t * reserve_cd ( void );
-extern void T400_start ( call_desc_t *cd );
-extern void T400_stop ( call_desc_t *cd );
-
-#endif /* _I4B_L4_H_ */
diff --git a/sys/i4b/layer4/i4b_l4mgmt.c b/sys/i4b/layer4/i4b_l4mgmt.c
deleted file mode 100644
index 1f3e9e3ca94d..000000000000
--- a/sys/i4b/layer4/i4b_l4mgmt.c
+++ /dev/null
@@ -1,436 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 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_l4mgmt.c - layer 4 calldescriptor management utilites
- * -----------------------------------------------------------
- * last edit-date: [Sun Aug 11 12:42:01 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/mbuf.h>
-
-#include <i4b/include/i4b_debug.h>
-#include <i4b/include/i4b_ioctl.h>
-
-#include <i4b/include/i4b_l3l4.h>
-#include <i4b/include/i4b_global.h>
-
-#include <i4b/layer4/i4b_l4.h>
-
-call_desc_t call_desc[N_CALL_DESC]; /* call descriptor array */
-
-static unsigned int get_cdid(void);
-
-int nctrl; /* number of attached controllers */
-
-void i4b_init_callout(call_desc_t *);
-
-/*---------------------------------------------------------------------------*
- * return a new unique call descriptor id
- * --------------------------------------
- * returns a new calldescriptor id which is used to uniquely identyfy
- * a single call in the communication between kernel and userland.
- * this cdid is then used to associate a calldescriptor with an id.
- *---------------------------------------------------------------------------*/
-static unsigned int
-get_cdid(void)
-{
- static unsigned int cdid_count = 0;
- int i;
- int x;
-
- x = SPLI4B();
-
- /* get next id */
-
- cdid_count++;
-
-again:
- if(cdid_count == CDID_UNUSED) /* zero is invalid */
- cdid_count++;
- else if(cdid_count > CDID_MAX) /* wraparound ? */
- cdid_count = 1;
-
- /* check if id already in use */
-
- for(i=0; i < N_CALL_DESC; i++)
- {
- if(call_desc[i].cdid == cdid_count)
- {
- cdid_count++;
- goto again;
- }
- }
-
- splx(x);
-
- return(cdid_count);
-}
-
-/*---------------------------------------------------------------------------*
- * reserve a calldescriptor for later usage
- * ----------------------------------------
- * searches the calldescriptor array until an unused
- * descriptor is found, gets a new calldescriptor id
- * and reserves it by putting the id into the cdid field.
- * returns pointer to the calldescriptor.
- *---------------------------------------------------------------------------*/
-call_desc_t *
-reserve_cd(void)
-{
- call_desc_t *cd;
- int x;
- int i;
-
- x = SPLI4B();
-
- cd = NULL;
-
- for(i=0; i < N_CALL_DESC; i++)
- {
- if(call_desc[i].cdid == CDID_UNUSED)
- {
- bzero(&call_desc[i], sizeof(call_desc_t)); /* clear it */
- call_desc[i].cdid = get_cdid(); /* fill in new cdid */
- cd = &(call_desc[i]); /* get pointer to descriptor */
- NDBGL4(L4_MSG, "found free cd - index=%d cdid=%u",
- i, call_desc[i].cdid);
- break;
- }
- }
-
- splx(x);
-
- if(cd == NULL)
- panic("reserve_cd: no free call descriptor available!");
-
- i4b_init_callout(cd);
-
- return(cd);
-}
-
-/*---------------------------------------------------------------------------*
- * free a calldescriptor
- * ---------------------
- * free an unused calldescriptor by giving address of calldescriptor
- * and writing a 0 into the cdid field marking it as unused.
- *---------------------------------------------------------------------------*/
-void
-freecd_by_cd(call_desc_t *cd)
-{
- int i;
- int x = SPLI4B();
-
- for(i=0; i < N_CALL_DESC; i++)
- {
- if( (call_desc[i].cdid != CDID_UNUSED) &&
- (&(call_desc[i]) == cd) )
- {
- NDBGL4(L4_MSG, "releasing cd - index=%d cdid=%u cr=%d",
- i, call_desc[i].cdid, cd->cr);
- call_desc[i].cdid = CDID_UNUSED;
- break;
- }
- }
-
- if(i == N_CALL_DESC)
- panic("freecd_by_cd: ERROR, cd not found, cr = %d\n", cd->cr);
-
- splx(x);
-}
-
-/*---------------------------------------------------------------------------*
- * return pointer to calldescriptor by giving the calldescriptor id
- * ----------------------------------------------------------------
- * lookup a calldescriptor in the calldescriptor array by looking
- * at the cdid field. return pointer to calldescriptor if found,
- * else return NULL if not found.
- *---------------------------------------------------------------------------*/
-call_desc_t *
-cd_by_cdid(unsigned int cdid)
-{
- int i;
-
- for(i=0; i < N_CALL_DESC; i++)
- {
- if(call_desc[i].cdid == cdid)
- {
- NDBGL4(L4_MSG, "found cdid - index=%d cdid=%u cr=%d",
- i, call_desc[i].cdid, call_desc[i].cr);
-
- i4b_init_callout(&call_desc[i]);
-
- return(&(call_desc[i]));
- }
- }
- return(NULL);
-}
-
-/*---------------------------------------------------------------------------*
- * search calldescriptor
- * ---------------------
- * This routine searches for the calldescriptor for a passive controller
- * given by unit number, callreference and callreference flag.
- * It returns a pointer to the calldescriptor if found, else a NULL.
- *---------------------------------------------------------------------------*/
-call_desc_t *
-cd_by_unitcr(int unit, int cr, int crf)
-{
- int i;
-
- for(i=0; i < N_CALL_DESC; i++)
- {
- if((call_desc[i].cdid != CDID_UNUSED) &&
- (ctrl_desc[call_desc[i].controller].ctrl_type == CTRL_PASSIVE) &&
- (ctrl_desc[call_desc[i].controller].unit == unit) &&
- (call_desc[i].cr == cr) &&
- (call_desc[i].crflag == crf) )
- {
- NDBGL4(L4_MSG, "found cd, index=%d cdid=%u cr=%d",
- i, call_desc[i].cdid, call_desc[i].cr);
-
- i4b_init_callout(&call_desc[i]);
-
- return(&(call_desc[i]));
- }
- }
- return(NULL);
-}
-
-/*---------------------------------------------------------------------------*
- * generate 7 bit "random" number used for outgoing Call Reference
- *---------------------------------------------------------------------------*/
-unsigned char
-get_rand_cr(int unit)
-{
- register int i, j;
- static u_char val, retval;
- static int called = 42;
-
- val += ++called;
-
- for(i=0; i < 50 ; i++, val++)
- {
- int found = 1;
-
-#ifdef RANDOMDEV
- read_random((char *)&val, sizeof(val));
-#else
- val = (u_char)random();
-#endif /* RANDOMDEV */
-
- retval = val & 0x7f;
-
- if(retval == 0 || retval == 0x7f)
- continue;
-
- for(j=0; j < N_CALL_DESC; j++)
- {
- if( (call_desc[j].cdid != CDID_UNUSED) &&
- (call_desc[j].cr == retval) )
- {
- found = 0;
- break;
- }
- }
-
- if(found)
- return(retval);
- }
- return(0); /* XXX */
-}
-
-/*---------------------------------------------------------------------------*
- * initialize the callout handles for FreeBSD
- *---------------------------------------------------------------------------*/
-void
-i4b_init_callout(call_desc_t *cd)
-{
- if(cd->callouts_inited == 0)
- {
- callout_handle_init(&cd->idle_timeout_handle);
- callout_handle_init(&cd->T303_callout);
- callout_handle_init(&cd->T305_callout);
- callout_handle_init(&cd->T308_callout);
- callout_handle_init(&cd->T309_callout);
- callout_handle_init(&cd->T310_callout);
- callout_handle_init(&cd->T313_callout);
- callout_handle_init(&cd->T400_callout);
- cd->callouts_inited = 1;
- }
-}
-
-/*---------------------------------------------------------------------------*
- * daemon is attached
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_daemon_attached(void)
-{
- int i;
-
- int x = SPLI4B();
-
- for(i=0; i < nctrl; i++)
- {
-/*XXX*/ if(*ctrl_desc[i].N_MGMT_COMMAND &&
- (ctrl_desc[i].ctrl_type == CTRL_PASSIVE ||
- ctrl_desc[i].ctrl_type == CTRL_CAPIMGR))
- {
- NDBGL4(L4_MSG, "CMR_DOPEN sent to unit %d", ctrl_desc[i].unit);
- (*ctrl_desc[i].N_MGMT_COMMAND)(ctrl_desc[i].unit, CMR_DOPEN, 0);
- }
- }
- splx(x);
-}
-
-/*---------------------------------------------------------------------------*
- * daemon is detached
- *---------------------------------------------------------------------------*/
-void
-i4b_l4_daemon_detached(void)
-{
- int i;
-
- int x = SPLI4B();
-
- for(i=0; i < nctrl; i++)
- {
-/*XXX*/ if(*ctrl_desc[i].N_MGMT_COMMAND &&
- (ctrl_desc[i].ctrl_type == CTRL_PASSIVE ||
- ctrl_desc[i].ctrl_type == CTRL_CAPIMGR))
- {
- NDBGL4(L4_MSG, "CMR_DCLOSE sent to unit %d", ctrl_desc[i].unit);
- (*ctrl_desc[i].N_MGMT_COMMAND)(ctrl_desc[i].unit, CMR_DCLOSE, 0);
- }
- }
- splx(x);
-}
-
-#ifdef I4B_CD_DEBUG_PRINT
-
-extern char *print_l3state(call_desc_t *cd);
-
-void i4b_print_cdp(call_desc_t *cdp);
-void i4b_print_cdx(int index);
-void i4b_print_cda(void);
-void i4b_print_cdaa(void);
-
-/*---------------------------------------------------------------------------*
- * print a call descriptor by cd-pointer
- *---------------------------------------------------------------------------*/
-void
-i4b_print_cdp(call_desc_t *cdp)
-{
- if((cdp > &(call_desc[N_CALL_DESC])) || (cdp < &(call_desc[0])))
- {
- printf("i4b_print_cd: cdp out of range!\n");
- return;
- }
-
- printf("i4b_print_cd: printing call descriptor %d at 0x%lx:\n", cdp - (&(call_desc[0])), (unsigned long)cdp);
-
- printf(" cdid = %d\n", cdp->cdid);
- printf(" controller = %d (u=%d, dl=%d, b1=%d, b2=%d)\n",
- cdp->controller,
- ctrl_desc[cdp->controller].unit,
- ctrl_desc[cdp->controller].dl_est,
- ctrl_desc[cdp->controller].bch_state[CHAN_B1],
- ctrl_desc[cdp->controller].bch_state[CHAN_B2]);
- printf(" cr = 0x%02x\n", cdp->cr);
- printf(" crflag = %d\n", cdp->crflag);
- printf(" channelid = %d\n", cdp->channelid);
- printf(" bprot = %d\n", cdp->bprot);
- printf(" bcap = %d\n", cdp->bcap);
- printf(" driver = %d\n", cdp->driver);
- printf(" driver_unit = %d\n", cdp->driver_unit);
- printf(" call_state = %d\n", cdp->call_state);
- printf(" Q931state = %s\n", print_l3state(cdp));
- printf(" event = %d\n", cdp->event);
- printf(" response = %d\n", cdp->response);
- printf(" T303 = %d\n", cdp->T303);
- printf("T303_first_to = %d\n", cdp->T303_first_to);
- printf(" T305 = %d\n", cdp->T305);
- printf(" T308 = %d\n", cdp->T308);
- printf("T308_first_to = %d\n", cdp->T308_first_to);
- printf(" T309 = %d\n", cdp->T309);
- printf(" T310 = %d\n", cdp->T310);
- printf(" T313 = %d\n", cdp->T313);
- printf(" T400 = %d\n", cdp->T400);
- printf(" dir = %s\n", cdp->dir == DIR_OUTGOING ? "out" : "in");
-}
-
-/*---------------------------------------------------------------------------*
- * print a call descriptor by index
- *---------------------------------------------------------------------------*/
-void
-i4b_print_cdx(int index)
-{
- if(index >= N_CALL_DESC)
- {
- printf("i4b_print_cdx: index %d >= N_CALL_DESC %d\n", index, N_CALL_DESC);
- return;
- }
- i4b_print_cdp(&(call_desc[index]));
-}
-
-/*---------------------------------------------------------------------------*
- * print all call descriptors
- *---------------------------------------------------------------------------*/
-void
-i4b_print_cda(void)
-{
- int i;
-
- for(i=0; i < N_CALL_DESC; i++)
- {
- i4b_print_cdp(&(call_desc[i]));
- }
-}
-
-/*---------------------------------------------------------------------------*
- * print all active call descriptors
- *---------------------------------------------------------------------------*/
-void
-i4b_print_cdaa(void)
-{
- int i;
-
- for(i=0; i < N_CALL_DESC; i++)
- {
- if(call_desc[i].cdid != CDID_UNUSED)
- {
- i4b_print_cdp(&(call_desc[i]));
- }
- }
-}
-
-#endif /* I4B_CD_DEBUG_PRINT */
diff --git a/sys/i4b/layer4/i4b_l4timer.c b/sys/i4b/layer4/i4b_l4timer.c
deleted file mode 100644
index 90d564db5b02..000000000000
--- a/sys/i4b/layer4/i4b_l4timer.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*-
- * Copyright (c) 1997, 2002 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_l4timer.c - timer and timeout handling for layer 4
- * --------------------------------------------------------
- * last edit-date: [Sat Mar 9 19:49:13 2002]
- *
- *---------------------------------------------------------------------------*/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-
-#include <i4b/include/i4b_debug.h>
-#include <i4b/include/i4b_ioctl.h>
-
-#include <i4b/include/i4b_global.h>
-#include <i4b/include/i4b_l3l4.h>
-
-#include <i4b/layer4/i4b_l4.h>
-
-/*---------------------------------------------------------------------------*
- * timer T400 timeout function
- *---------------------------------------------------------------------------*/
-static void
-T400_timeout(call_desc_t *cd)
-{
- NDBGL4(L4_ERR, "cr = %d", cd->cr);
-}
-
-/*---------------------------------------------------------------------------*
- * timer T400 start
- *---------------------------------------------------------------------------*/
-void
-T400_start(call_desc_t *cd)
-{
- if (cd->T400 == TIMER_ACTIVE)
- return;
-
- NDBGL4(L4_MSG, "cr = %d", cd->cr);
- cd->T400 = TIMER_ACTIVE;
-
- START_TIMER(cd->T400_callout, T400_timeout, cd, T400DEF);
-}
-
-/*---------------------------------------------------------------------------*
- * timer T400 stop
- *---------------------------------------------------------------------------*/
-void
-T400_stop(call_desc_t *cd)
-{
- CRIT_VAR;
- CRIT_BEG;
-
- if(cd->T400 == TIMER_ACTIVE)
- {
- STOP_TIMER(cd->T400_callout, T400_timeout, cd);
- cd->T400 = TIMER_IDLE;
- }
- CRIT_END;
- NDBGL4(L4_MSG, "cr = %d", cd->cr);
-}