summaryrefslogtreecommitdiffstats
path: root/sys/i4b/driver
diff options
context:
space:
mode:
authorhm <hm@FreeBSD.org>1999-08-06 14:05:10 +0000
committerhm <hm@FreeBSD.org>1999-08-06 14:05:10 +0000
commitc318ffb377724b7eab997d3ddd7f16e229f18e4d (patch)
tree4dd20754e94db3bc400654765c985e981925a884 /sys/i4b/driver
parent29c67703e3751c283a1bdfe7764effe015c13b83 (diff)
downloadFreeBSD-src-c318ffb377724b7eab997d3ddd7f16e229f18e4d.zip
FreeBSD-src-c318ffb377724b7eab997d3ddd7f16e229f18e4d.tar.gz
updating isdn4bsd to beta version 0.83
Diffstat (limited to 'sys/i4b/driver')
-rw-r--r--sys/i4b/driver/i4b_bsdi_ibc.c559
-rw-r--r--sys/i4b/driver/i4b_ctl.c57
-rw-r--r--sys/i4b/driver/i4b_ipr.c20
-rw-r--r--sys/i4b/driver/i4b_isppp.c43
-rw-r--r--sys/i4b/driver/i4b_rbch.c120
-rw-r--r--sys/i4b/driver/i4b_tel.c34
-rw-r--r--sys/i4b/driver/i4b_trace.c22
7 files changed, 784 insertions, 71 deletions
diff --git a/sys/i4b/driver/i4b_bsdi_ibc.c b/sys/i4b/driver/i4b_bsdi_ibc.c
new file mode 100644
index 0000000..9168815
--- /dev/null
+++ b/sys/i4b/driver/i4b_bsdi_ibc.c
@@ -0,0 +1,559 @@
+/*
+ * Copyright (c) 1998, 1999 Bert Driehuis. All rights reserved.
+ *
+ * Copyright (c) 1997, 1998 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_bsdi_ibc.c - isdn4bsd kernel BSD/OS point to point driver
+ * -------------------------------------------------------------
+ *
+ * $Id: i4b_bsdi_ibc.c,v 1.1 1999/04/23 08:35:07 hm Exp $
+ *
+ * last edit-date: [Fri Apr 23 10:27:57 1999]
+ *
+ *---------------------------------------------------------------------------*/
+
+#include "ibc.h"
+
+#if NIBC > 0
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/mbuf.h>
+#include <sys/socket.h>
+#include <sys/errno.h>
+#include <sys/ioccom.h>
+#include <sys/ttycom.h>
+#include <sys/sockio.h>
+#include <sys/kernel.h>
+#include <sys/protosw.h>
+
+#include <net/if.h>
+#include <net/if_types.h>
+#include <net/if_p2p.h>
+#include <net/netisr.h>
+#include <net/route.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+
+#include <i4b/i4b_ioctl.h>
+#include <i4b/i4b_cause.h>
+#include <i4b/include/i4b_global.h>
+#include <i4b/include/i4b_mbuf.h>
+#include <i4b/include/i4b_l3l4.h>
+#include <i4b/layer4/i4b_l4.h>
+
+#define IFP2UNIT(ifp) (ifp)->if_unit
+
+#define IOCTL_CMD_T u_long
+
+void ibcattach(void *);
+
+#define IBCACCT 1 /* enable accounting messages */
+#define IBCACCTINTVL 2 /* accounting msg interval in secs */
+
+#define PPP_HDRLEN 4 /* 4 octets PPP header length */
+
+struct ibc_softc {
+ struct p2pcom sc_p2pcom;
+
+ int sc_state; /* state of the interface */
+ call_desc_t *sc_cdp; /* ptr to call descriptor */
+
+#ifdef IBCACCT
+ int sc_iinb; /* isdn driver # of inbytes */
+ int sc_ioutb; /* isdn driver # of outbytes */
+ int sc_inb; /* # of bytes rx'd */
+ int sc_outb; /* # of bytes tx'd */
+ int sc_linb; /* last # of bytes rx'd */
+ int sc_loutb; /* last # of bytes tx'd */
+ int sc_fn; /* flag, first null acct */
+#endif
+} ibc_softc[NIBC];
+
+static void ibc_init_linktab(int unit);
+
+static int ibc_start(struct ifnet *ifp);
+
+static int ibc_watchdog(int unit);
+static int ibc_mdmctl(struct p2pcom *pp, int flag);
+static int ibc_getmdm(struct p2pcom *pp, caddr_t arg);
+
+/* initialized by L4 */
+
+static drvr_link_t ibc_drvr_linktab[NIBC];
+static isdn_link_t *isdn_ibc_lt[NIBC];
+
+enum ibc_states {
+ ST_IDLE, /* initialized, ready, idle */
+ ST_DIALING, /* dialling out to remote */
+ ST_CONNECTED, /* connected to remote */
+};
+
+int ibcdebug = 0; /* Use bpatch to set this for debug printf's */
+#define DBG(x) if (ibcdebug) printf x
+
+/*===========================================================================*
+ * DEVICE DRIVER ROUTINES
+ *===========================================================================*/
+
+/*---------------------------------------------------------------------------*
+ * interface attach routine at kernel boot time
+ *---------------------------------------------------------------------------*/
+void
+ibcattach(void *dummy)
+{
+ struct ibc_softc *sc = ibc_softc;
+ struct ifnet *ifp;
+ int i;
+
+#ifndef HACK_NO_PSEUDO_ATTACH_MSG
+ printf("ibc: %d ISDN ibc device(s) attached\n",
+ NIBC);
+#endif
+
+ for(i = 0; i < NIBC; sc++, i++) {
+ ibc_init_linktab(i);
+
+ sc->sc_p2pcom.p2p_mdmctl = ibc_mdmctl;
+ sc->sc_p2pcom.p2p_getmdm = ibc_getmdm;
+ sc->sc_state = ST_IDLE;
+ ifp = &sc->sc_p2pcom.p2p_if;
+ ifp->if_name = "ibc";
+ ifp->if_next = NULL;
+ ifp->if_unit = i;
+ ifp->if_mtu = 1500 /*XXX*/;
+ ifp->if_baudrate = 64000;
+ ifp->if_flags = IFF_SIMPLEX | IFF_POINTOPOINT;
+ ifp->if_type = IFT_ISDNBASIC;
+ ifp->if_start = ibc_start;
+ ifp->if_output = 0;
+ ifp->if_ioctl = p2p_ioctl;
+
+ ifp->if_hdrlen = 0;
+ ifp->if_addrlen = 0;
+ ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
+
+ ifp->if_ipackets = 0;
+ ifp->if_ierrors = 0;
+ ifp->if_opackets = 0;
+ ifp->if_oerrors = 0;
+ ifp->if_collisions = 0;
+ ifp->if_ibytes = 0;
+ ifp->if_obytes = 0;
+ ifp->if_imcasts = 0;
+ ifp->if_omcasts = 0;
+ ifp->if_iqdrops = 0;
+ ifp->if_noproto = 0;
+#if IBCACCT
+ ifp->if_timer = 0;
+ ifp->if_watchdog = ibc_watchdog;
+ sc->sc_iinb = 0;
+ sc->sc_ioutb = 0;
+ sc->sc_inb = 0;
+ sc->sc_outb = 0;
+ sc->sc_linb = 0;
+ sc->sc_loutb = 0;
+ sc->sc_fn = 1;
+#endif
+ if_attach(ifp);
+ p2p_attach(&sc->sc_p2pcom);
+ }
+}
+
+static struct mbuf *
+p2p_dequeue(struct p2pcom *pp)
+{
+ struct ifqueue *ifq;
+ struct mbuf *m;
+
+ ifq = &pp->p2p_isnd;
+ m = ifq->ifq_head;
+ if (m == 0) {
+ ifq = &pp->p2p_if.if_snd;
+ m = ifq->ifq_head;
+ }
+ if (m == 0)
+ return 0;
+ IF_DEQUEUE(ifq, m);
+ return m;
+}
+
+/*---------------------------------------------------------------------------*
+ * start output to ISDN B-channel
+ *---------------------------------------------------------------------------*/
+static int
+ibc_start(struct ifnet *ifp)
+{
+ int unit = IFP2UNIT(ifp);
+ struct ibc_softc *sc = (struct ibc_softc *)&ibc_softc[unit];
+ struct p2pcom *pp = &sc->sc_p2pcom;
+ struct mbuf *m;
+ int s;
+
+ if(sc->sc_state != ST_CONNECTED) {
+ DBG(("ibc%d: ibc_start called with sc_state=%d\n",
+ unit, sc->sc_state));
+ return 0;
+ }
+
+ s = SPLI4B();
+
+ if (IF_QFULL(isdn_ibc_lt[unit]->tx_queue)) {
+ splx(s);
+ return 0;
+ }
+
+ m = p2p_dequeue(pp);
+ if (m == NULL) {
+ splx(s);
+ return 0;
+ }
+
+ do {
+ microtime(&ifp->if_lastchange);
+
+ IF_ENQUEUE(isdn_ibc_lt[unit]->tx_queue, m);
+
+ ifp->if_obytes += m->m_pkthdr.len;
+ sc->sc_outb += m->m_pkthdr.len;
+ ifp->if_opackets++;
+ } while (!IF_QFULL(isdn_ibc_lt[unit]->tx_queue) &&
+ (m = p2p_dequeue(pp)) != NULL);
+ isdn_ibc_lt[unit]->bch_tx_start(isdn_ibc_lt[unit]->unit,
+ isdn_ibc_lt[unit]->channel);
+ splx(s);
+ return 0;
+}
+
+#ifdef IBCACCT
+/*---------------------------------------------------------------------------*
+ * watchdog routine
+ *---------------------------------------------------------------------------*/
+static int
+ibc_watchdog(int unit)
+{
+ struct ibc_softc *sc = &ibc_softc[unit];
+ struct ifnet *ifp = &sc->sc_p2pcom.p2p_if;
+ bchan_statistics_t bs;
+
+ (*isdn_ibc_lt[unit]->bch_stat)
+ (isdn_ibc_lt[unit]->unit, isdn_ibc_lt[unit]->channel, &bs);
+
+ sc->sc_ioutb += bs.outbytes;
+ sc->sc_iinb += bs.inbytes;
+
+ if((sc->sc_iinb != sc->sc_linb) || (sc->sc_ioutb != sc->sc_loutb) || sc->sc_fn)
+ {
+ int ri = (sc->sc_iinb - sc->sc_linb)/IBCACCTINTVL;
+ int ro = (sc->sc_ioutb - sc->sc_loutb)/IBCACCTINTVL;
+
+ if((sc->sc_iinb == sc->sc_linb) && (sc->sc_ioutb == sc->sc_loutb))
+ sc->sc_fn = 0;
+ else
+ sc->sc_fn = 1;
+
+ sc->sc_linb = sc->sc_iinb;
+ sc->sc_loutb = sc->sc_ioutb;
+
+ i4b_l4_accounting(BDRV_IBC, unit, ACCT_DURING,
+ sc->sc_ioutb, sc->sc_iinb, ro, ri, sc->sc_outb, sc->sc_inb);
+ }
+ ifp->if_timer = IBCACCTINTVL;
+ return 0;
+}
+#endif /* IBCACCT */
+
+/*
+ *===========================================================================*
+ * P2P layer interface routines
+ *===========================================================================*
+ */
+
+#if 0
+/*---------------------------------------------------------------------------*
+ * PPP interface phase change
+ *---------------------------------------------------------------------------*
+ */
+static void
+ibc_state_changed(struct sppp *sp, int new_state)
+{
+ struct ibc_softc *sc = (struct ibc_softc *)sp;
+
+ i4b_l4_ifstate_changed(sc->sc_cdp, new_state);
+}
+
+/*---------------------------------------------------------------------------*
+ * PPP control protocol negotiation complete (run ip-up script now)
+ *---------------------------------------------------------------------------*
+ */
+static void
+ibc_negotiation_complete(struct sppp *sp)
+{
+ struct ibc_softc *sc = (struct ibc_softc *)sp;
+
+ i4b_l4_negcomplete(sc->sc_cdp);
+}
+#endif
+
+/*===========================================================================*
+ * ISDN INTERFACE ROUTINES
+ *===========================================================================*/
+
+/*---------------------------------------------------------------------------*
+ * this routine is called from L4 handler at connect time
+ *---------------------------------------------------------------------------*/
+static void
+ibc_connect(int unit, void *cdp)
+{
+ struct ibc_softc *sc = &ibc_softc[unit];
+ struct ifnet *ifp = &sc->sc_p2pcom.p2p_if;
+ int s;
+
+ DBG(("ibc%d: ibc_connect\n", unit));
+
+ s = splimp();
+
+ sc->sc_cdp = (call_desc_t *)cdp;
+ sc->sc_state = ST_CONNECTED;
+
+#if IBCACCT
+ sc->sc_iinb = 0;
+ sc->sc_ioutb = 0;
+ sc->sc_inb = 0;
+ sc->sc_outb = 0;
+ sc->sc_linb = 0;
+ sc->sc_loutb = 0;
+ ifp->if_timer = IBCACCTINTVL;
+#endif
+
+ splx(s);
+ if (sc->sc_p2pcom.p2p_modem)
+ (*sc->sc_p2pcom.p2p_modem)(&sc->sc_p2pcom, 1);
+
+ /* This is a lie... PPP is just starting to negociate :-) */
+ i4b_l4_negcomplete(sc->sc_cdp);
+}
+
+/*---------------------------------------------------------------------------*
+ * this routine is called from L4 handler at disconnect time
+ *---------------------------------------------------------------------------*/
+static void
+ibc_disconnect(int unit, void *cdp)
+{
+ call_desc_t *cd = (call_desc_t *)cdp;
+ struct ibc_softc *sc = &ibc_softc[unit];
+ struct ifnet *ifp = &sc->sc_p2pcom.p2p_if;
+ int s;
+
+ DBG(("ibc%d: ibc_disconnect\n", unit));
+
+ s = splimp();
+
+ /* new stuff to check that the active channel is being closed */
+ if (cd != sc->sc_cdp)
+ {
+ DBG(("ibc_disconnect: ibc%d channel%d not active\n",
+ cd->driver_unit, cd->channelid));
+ splx(s);
+ return;
+ }
+
+#if IBCACCT
+ ifp->if_timer = 0;
+#endif
+
+ i4b_l4_accounting(BDRV_IBC, unit, ACCT_FINAL,
+ sc->sc_ioutb, sc->sc_iinb, 0, 0, sc->sc_outb, sc->sc_inb);
+
+ if (sc->sc_state == ST_CONNECTED)
+ {
+ sc->sc_cdp = (call_desc_t *)0;
+ sc->sc_state = ST_IDLE;
+ if (sc->sc_p2pcom.p2p_modem)
+ (*sc->sc_p2pcom.p2p_modem)(&sc->sc_p2pcom, 0);
+ }
+
+ splx(s);
+}
+
+/*---------------------------------------------------------------------------*
+ * this routine is used to give a feedback from userland demon
+ * in case of dial problems
+ *---------------------------------------------------------------------------*/
+static void
+ibc_dialresponse(int unit, int status)
+{
+ DBG(("ibc%d: ibc_dialresponse %d\n", unit, status));
+/* struct ibc_softc *sc = &ibc_softc[unit]; */
+}
+
+/*---------------------------------------------------------------------------*
+ * interface up/down
+ *---------------------------------------------------------------------------*/
+static void
+ibc_updown(int unit, int updown)
+{
+ DBG(("ibc%d: ibc_updown %d\n", unit, updown));
+ /* could probably do something useful here */
+}
+
+/*---------------------------------------------------------------------------*
+ * this routine is called from the HSCX interrupt handler
+ * when a new frame (mbuf) has been received and was put on
+ * the rx queue.
+ *---------------------------------------------------------------------------*/
+static void
+ibc_rx_data_rdy(int unit)
+{
+ struct ibc_softc *sc = &ibc_softc[unit];
+ struct ifnet *ifp = &sc->sc_p2pcom.p2p_if;
+ struct mbuf *m, *m0;
+ char *buf;
+ int s;
+
+ if((m = *isdn_ibc_lt[unit]->rx_mbuf) == NULL)
+ return;
+
+ microtime(&ifp->if_lastchange);
+ ifp->if_ipackets++;
+
+ /* Walk the mbuf chain */
+ s = splimp();
+ for (m0 = m; m != 0; m = m->m_next) {
+ if (m->m_len == 0)
+ continue;
+ ifp->if_ibytes += m->m_len;
+#if IBCACCT
+ sc->sc_inb += m->m_len;
+#endif
+ buf = mtod(m, caddr_t);
+ if ((*sc->sc_p2pcom.p2p_hdrinput)(
+ &sc->sc_p2pcom, buf, m->m_len) >= 0)
+ (*sc->sc_p2pcom.p2p_input)(&sc->sc_p2pcom, 0);
+ }
+ splx(s);
+ m_freem(m0);
+}
+
+/*---------------------------------------------------------------------------*
+ * this routine is called from the HSCX interrupt handler
+ * when the last frame has been sent out and there is no
+ * further frame (mbuf) in the tx queue.
+ *---------------------------------------------------------------------------*/
+static void
+ibc_tx_queue_empty(int unit)
+{
+ ibc_start(&ibc_softc[unit].sc_p2pcom.p2p_if);
+}
+
+/*---------------------------------------------------------------------------*
+ * this routine is called from the HSCX interrupt handler
+ * each time a packet is received or transmitted. It should
+ * be used to implement an activity timeout mechanism.
+ *---------------------------------------------------------------------------*/
+static void
+ibc_activity(int unit, int rxtx)
+{
+ ibc_softc[unit].sc_cdp->last_active_time = SECOND;
+}
+
+/*---------------------------------------------------------------------------*
+ * return this drivers linktab address
+ *---------------------------------------------------------------------------*/
+drvr_link_t *
+ibc_ret_linktab(int unit)
+{
+ return(&ibc_drvr_linktab[unit]);
+}
+
+/*---------------------------------------------------------------------------*
+ * setup the isdn_ibc_lt for this driver
+ *---------------------------------------------------------------------------*/
+void
+ibc_set_linktab(int unit, isdn_link_t *ilt)
+{
+ isdn_ibc_lt[unit] = ilt;
+}
+
+/*---------------------------------------------------------------------------*
+ * initialize this drivers linktab
+ *---------------------------------------------------------------------------*/
+static void
+ibc_init_linktab(int unit)
+{
+ ibc_drvr_linktab[unit].unit = unit;
+ ibc_drvr_linktab[unit].bch_rx_data_ready = ibc_rx_data_rdy;
+ ibc_drvr_linktab[unit].bch_tx_queue_empty = ibc_tx_queue_empty;
+ ibc_drvr_linktab[unit].bch_activity = ibc_activity;
+ ibc_drvr_linktab[unit].line_connected = ibc_connect;
+ ibc_drvr_linktab[unit].line_disconnected = ibc_disconnect;
+ ibc_drvr_linktab[unit].dial_response = ibc_dialresponse;
+ ibc_drvr_linktab[unit].updown_ind = ibc_updown;
+}
+
+/*===========================================================================*/
+
+static int
+ibc_mdmctl(pp, flag)
+ struct p2pcom *pp;
+ int flag;
+{
+ register struct ifnet *ifp = &pp->p2p_if;
+ struct ibc_softc *sc = (struct ibc_softc *)&ibc_softc[ifp->if_unit];
+
+ DBG(("ibc%d: ibc_mdmctl called flags=%d\n", IFP2UNIT(ifp), flag));
+
+ if (flag == 1 && sc->sc_state == ST_IDLE) {
+ sc->sc_state = ST_DIALING;
+ i4b_l4_dialout(BDRV_IBC, IFP2UNIT(ifp));
+ } else if (flag == 0 && sc->sc_state != ST_IDLE) {
+ sc->sc_state = ST_IDLE;
+ i4b_l4_drvrdisc(BDRV_IBC, IFP2UNIT(ifp));
+ }
+ return 0;
+}
+
+static int
+ibc_getmdm(pp, arg)
+ struct p2pcom *pp;
+ caddr_t arg;
+{
+ register struct ifnet *ifp = &pp->p2p_if;
+ struct ibc_softc *sc = (struct ibc_softc *)&ibc_softc[ifp->if_unit];
+
+ if (sc->sc_state == ST_CONNECTED)
+ *(int *)arg = TIOCM_CAR;
+ else
+ *(int *)arg = 0;
+ return 0;
+
+ DBG(("ibc%d: ibc_getmdm called ret=%d\n", IFP2UNIT(ifp), *(int *)arg));
+}
+#endif
diff --git a/sys/i4b/driver/i4b_ctl.c b/sys/i4b/driver/i4b_ctl.c
index aac6f50..3ad68a0 100644
--- a/sys/i4b/driver/i4b_ctl.c
+++ b/sys/i4b/driver/i4b_ctl.c
@@ -27,9 +27,9 @@
* i4b_ctl.c - i4b system control port driver
* ------------------------------------------
*
- * $Id: i4b_ctl.c,v 1.4 1999/05/20 10:08:56 hm Exp $
+ * $Id: i4b_ctl.c,v 1.25 1999/06/08 08:13:00 hm Exp $
*
- * last edit-date: [Mon Apr 26 11:16:28 1999]
+ * last edit-date: [Tue Jun 8 09:27:15 1999]
*
*---------------------------------------------------------------------------*/
@@ -83,6 +83,7 @@
#include <i4b/include/i4b_global.h>
#include <i4b/include/i4b_mbuf.h>
#include <i4b/layer1/i4b_l1.h>
+#include <i4b/layer2/i4b_l2.h>
static int openflag = 0;
@@ -99,6 +100,8 @@ static d_poll_t i4bctlpoll;
#endif
#define CDEV_MAJOR 55
+
+#if defined (__FreeBSD_version) && __FreeBSD_version >= 400006
static struct cdevsw i4bctl_cdevsw = {
/* open */ i4bctlopen,
/* close */ i4bctlclose,
@@ -120,6 +123,12 @@ static struct cdevsw i4bctl_cdevsw = {
/* maxio */ 0,
/* bmaj */ -1
};
+#else
+static struct cdevsw i4bctl_cdevsw =
+ { i4bctlopen, i4bctlclose, noread, nowrite,
+ i4bctlioctl, nostop, nullreset, nodevtotty,
+ POLLFIELD, nommap, NULL, "i4bctl", NULL, -1 };
+#endif
static void i4bctlattach(void *);
PSEUDO_SET(i4bctlattach, i4b_i4bctldrv);
@@ -150,8 +159,12 @@ int i4bctlioctl __P((dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
static void
i4bctlinit(void *unused)
{
-
- cdevsw_add(&i4bctl_cdevsw);
+#if defined (__FreeBSD_version) && __FreeBSD_version >= 400006
+ cdevsw_add(&i4bctl_cdevsw);
+#else
+ dev_t dev = makedev(CDEV_MAJOR, 0);
+ cdevsw_add(&dev, &i4bctl_cdevsw, NULL);
+#endif
}
SYSINIT(i4bctldev, SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR, &i4bctlinit, NULL);
@@ -332,6 +345,42 @@ i4bctlioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
break;
}
+ case I4B_CTL_GET_LAPDSTAT:
+ {
+ l2stat_t *l2s;
+ l2_softc_t *sc;
+ l2s = (l2stat_t *)data;
+
+ if( l2s->unit < 0 || l2s->unit > ISIC_MAXUNIT)
+ {
+ error = EINVAL;
+ break;
+ }
+
+ sc = &l2_softc[l2s->unit];
+
+ bcopy(&sc->stat, &l2s->lapdstat, sizeof(lapdstat_t));
+ break;
+ }
+
+ case I4B_CTL_CLR_LAPDSTAT:
+ {
+ int *up;
+ l2_softc_t *sc;
+ up = (int *)data;
+
+ if( *up < 0 || *up > ISIC_MAXUNIT)
+ {
+ error = EINVAL;
+ break;
+ }
+
+ sc = &l2_softc[*up];
+
+ bzero(&sc->stat, sizeof(lapdstat_t));
+ break;
+ }
+
default:
error = ENOTTY;
break;
diff --git a/sys/i4b/driver/i4b_ipr.c b/sys/i4b/driver/i4b_ipr.c
index 5415dda..b2ac7d0 100644
--- a/sys/i4b/driver/i4b_ipr.c
+++ b/sys/i4b/driver/i4b_ipr.c
@@ -27,9 +27,9 @@
* i4b_ipr.c - isdn4bsd IP over raw HDLC ISDN network driver
* ---------------------------------------------------------
*
- * $Id: i4b_ipr.c,v 1.4 1999/05/20 10:08:58 hm Exp $
+ * $Id: i4b_ipr.c,v 1.53 1999/07/22 18:30:15 hm Exp $
*
- * last edit-date: [Thu May 6 10:09:20 1999]
+ * last edit-date: [Thu Jul 22 19:46:53 1999]
*
*---------------------------------------------------------------------------*
*
@@ -110,8 +110,12 @@
/* undef to uncompress in the mbuf itself */
#endif /* IPR_VJ */
+#if defined(__FreeBSD_version) && __FreeBSD_version >= 400008
#include "bpf.h"
-#if NBPF > 0
+#else
+#include "bpfilter.h"
+#endif
+#if NBPFILTER > 0 || NBPF > 0
#include <sys/time.h>
#include <net/bpf.h>
#endif
@@ -350,7 +354,7 @@ i4biprattach()
if_attach(&sc->sc_if);
-#if NBPF > 0
+#if NBPFILTER > 0 || NBPF > 0
#ifdef __FreeBSD__
bpfattach(&sc->sc_if, DLT_NULL, sizeof(u_int));
#else
@@ -994,7 +998,7 @@ error:
sc->sc_inb += m->m_pkthdr.len;
#endif
-#if NBPF > 0
+#if NBPFILTER > 0 || NBPF > 0
if(sc->sc_if.if_bpf)
{
/* prepend the address family as a four byte field */
@@ -1010,7 +1014,7 @@ error:
bpf_mtap(sc->sc_if.if_bpf, &mm);
#endif
}
-#endif /* NBPF > 0 */
+#endif /* NBPFILTER > 0 || NBPF > 0 */
if(IF_QFULL(&ipintrq))
{
@@ -1062,7 +1066,7 @@ ipr_tx_queue_empty(int unit)
microtime(&sc->sc_if.if_lastchange);
-#if NBPF > 0
+#if NBPFILTER > 0 || NBPF > 0
if(sc->sc_if.if_bpf)
{
/* prepend the address family as a four byte field */
@@ -1079,7 +1083,7 @@ ipr_tx_queue_empty(int unit)
bpf_mtap(sc->sc_if.if_bpf, &mm);
#endif
}
-#endif /* NBPF */
+#endif /* NBPFILTER */
#if I4BIPRACCT
sc->sc_outb += m->m_pkthdr.len; /* size before compression */
diff --git a/sys/i4b/driver/i4b_isppp.c b/sys/i4b/driver/i4b_isppp.c
index eef0997..a2911d8 100644
--- a/sys/i4b/driver/i4b_isppp.c
+++ b/sys/i4b/driver/i4b_isppp.c
@@ -34,9 +34,9 @@
* the "cx" driver for Cronyx's HDLC-in-hardware device). This driver
* is only the glue between sppp and i4b.
*
- * $Id: i4b_isppp.c,v 1.3 1999/05/20 10:09:01 hm Exp $
+ * $Id: i4b_isppp.c,v 1.34 1999/07/24 13:21:42 hm Exp $
*
- * last edit-date: [Sun May 2 10:52:57 1999]
+ * last edit-date: [Sat Jul 24 15:23:04 1999]
*
*---------------------------------------------------------------------------*/
@@ -63,19 +63,27 @@
#include <net/if_types.h>
#include <net/netisr.h>
#include <net/route.h>
-#if defined(__FreeBSD__)
-#include <net/if_sppp.h>
-#else
-#include <i4b/sppp/if_sppp.h>
-#endif
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/in_var.h>
#include <netinet/ip.h>
-#include "bpf.h"
-#if NBPF > 0
+#include <net/slcompress.h>
+
+#if defined(__FreeBSD__) || defined(__OpenBSD__)
+#include <net/if_sppp.h>
+#else
+#include <i4b/sppp/if_sppp.h>
+#endif
+
+
+#if defined(__FreeBSD_version) && __FreeBSD_version >= 400008
+#include "bpf.h"
+#else
+#include "bpfilter.h"
+#endif
+#if NBPFILTER > 0 || NBPF > 0
#include <sys/time.h>
#include <net/bpf.h>
#endif
@@ -222,8 +230,11 @@ i4bispppattach(void)
int i;
#ifndef HACK_NO_PSEUDO_ATTACH_MSG
- printf("i4bisppp: %d ISDN SyncPPP device(s) attached\n",
- NI4BISPPP);
+#ifdef SPPP_VJ
+ printf("i4bisppp: %d ISDN SyncPPP device(s) attached (VJ header compression)\n", NI4BISPPP);
+#else
+ printf("i4bisppp: %d ISDN SyncPPP device(s) attached\n", NI4BISPPP);
+#endif
#endif
for(i = 0; i < NI4BISPPP; sc++, i++) {
@@ -290,7 +301,7 @@ i4bispppattach(void)
sppp_attach(&sc->sc_if);
if_attach(&sc->sc_if);
-#if NBPF > 0
+#if NBPFILTER > 0 || NBPF > 0
#ifdef __FreeBSD__
bpfattach(&sc->sc_if, DLT_PPP, PPP_HDRLEN);
CALLOUT_INIT(&sc->sc_ch);
@@ -361,7 +372,7 @@ i4bisppp_start(struct ifnet *ifp)
while ((m = sppp_dequeue(&sc->sc_if)) != NULL)
{
-#if NBPF > 0
+#if NBPFILTER > 0 || NBPF > 0
#ifdef __FreeBSD__
if (ifp->if_bpf)
bpf_mtap(ifp, m);
@@ -371,7 +382,7 @@ i4bisppp_start(struct ifnet *ifp)
if (ifp->if_bpf)
bpf_mtap(ifp->if_bpf, m);
#endif
-#endif /* NBPF > 0 */
+#endif /* NBPFILTER > 0 || NBPF > 0 */
microtime(&ifp->if_lastchange);
@@ -654,7 +665,7 @@ i4bisppp_rx_data_rdy(int unit)
printf("i4bisppp_rx_data_ready: received packet!\n");
#endif
-#if NBPF > 0
+#if NBPFILTER > 0 || NBPF > 0
#ifdef __FreeBSD__
if(sc->sc_if.if_bpf)
@@ -666,7 +677,7 @@ i4bisppp_rx_data_rdy(int unit)
bpf_mtap(sc->sc_if.if_bpf, m);
#endif
-#endif /* NBPF > 0 */
+#endif /* NBPFILTER > 0 || NBPF > 0 */
s = splimp();
diff --git a/sys/i4b/driver/i4b_rbch.c b/sys/i4b/driver/i4b_rbch.c
index e4a5e61..1179b35 100644
--- a/sys/i4b/driver/i4b_rbch.c
+++ b/sys/i4b/driver/i4b_rbch.c
@@ -27,9 +27,9 @@
* i4b_rbch.c - device driver for raw B channel data
* ---------------------------------------------------
*
- * $Id: i4b_rbch.c,v 1.3 1999/05/20 10:09:02 hm Exp $
+ * $Id: i4b_rbch.c,v 1.36 1999/07/19 14:03:33 hm Exp $
*
- * last edit-date: [Thu May 6 13:40:22 1999]
+ * last edit-date: [Fri Jul 9 09:37:02 1999]
*
*---------------------------------------------------------------------------*/
@@ -49,7 +49,7 @@
#include <sys/proc.h>
#include <sys/tty.h>
-#ifdef __NetBSD__
+#if defined (__NetBSD__) || defined (__OpenBSD__)
extern cc_t ttydefchars;
#define termioschars(t) memcpy((t)->c_cc, &ttydefchars, sizeof((t)->c_cc))
#endif
@@ -69,9 +69,11 @@ extern cc_t ttydefchars;
#ifdef __FreeBSD__
#include <machine/i4b_ioctl.h>
+#include <machine/i4b_rbch_ioctl.h>
#include <machine/i4b_debug.h>
#else
#include <i4b/i4b_ioctl.h>
+#include <i4b/i4b_rbch_ioctl.h>
#include <i4b/i4b_debug.h>
#endif
@@ -147,8 +149,7 @@ int i4brbchioctl __P((dev_t dev, IOCTL_CMD_T cmd, caddr_t arg, int flag, struct
#ifdef OS_USES_POLL
int i4brbchpoll __P((dev_t dev, int events, struct proc *p));
#else
-/* XXX fix "static" to PDEVSTATIC */
-static int i4brbchselect __P((dev_t dev, int rw, struct proc *p));
+PDEVSTATIC int i4brbchselect __P((dev_t dev, int rw, struct proc *p));
#endif
#endif
@@ -175,6 +176,8 @@ PDEVSTATIC d_select_t i4brbchselect;
#endif
#define CDEV_MAJOR 57
+
+#if defined (__FreeBSD_version) && __FreeBSD_version >= 400006
static struct cdevsw i4brbch_cdevsw = {
/* open */ i4brbchopen,
/* close */ i4brbchclose,
@@ -196,6 +199,13 @@ static struct cdevsw i4brbch_cdevsw = {
/* maxio */ 0,
/* bmaj */ -1
};
+#else
+static struct cdevsw i4brbch_cdevsw = {
+ i4brbchopen, i4brbchclose, i4brbchread, i4brbchwrite,
+ i4brbchioctl, nostop, noreset, nodevtotty,
+ POLLFIELD, nommap, NULL, "i4brbch", NULL, -1
+};
+#endif
static void i4brbchattach(void *);
PSEUDO_SET(i4brbchattach, i4b_rbch);
@@ -210,8 +220,12 @@ PSEUDO_SET(i4brbchattach, i4b_rbch);
static void
i4brbchinit(void *unused)
{
-
- cdevsw_add(&i4brbch_cdevsw);
+#if defined (__FreeBSD_version) && __FreeBSD_version >= 400006
+ cdevsw_add(&i4brbch_cdevsw);
+#else
+ dev_t dev = makedev(CDEV_MAJOR, 0);
+ cdevsw_add(&dev, &i4brbch_cdevsw, NULL);
+#endif
}
SYSINIT(i4brbchdev, SI_SUB_DRIVERS,
@@ -247,6 +261,7 @@ dummy_i4brbchattach(struct device *parent, struct device *self, void *aux)
printf("dummy_i4brbchattach: aux=0x%x\n", aux);
}
#endif /* __bsdi__ */
+
/*---------------------------------------------------------------------------*
* interface attach routine
*---------------------------------------------------------------------------*/
@@ -282,7 +297,7 @@ i4brbchattach()
/*---------------------------------------------------------------------------*
* open rbch device
*---------------------------------------------------------------------------*/
-int
+PDEVSTATIC int
i4brbchopen(dev_t dev, int flag, int fmt, struct proc *p)
{
int unit = minor(dev);
@@ -305,7 +320,7 @@ i4brbchopen(dev_t dev, int flag, int fmt, struct proc *p)
/*---------------------------------------------------------------------------*
* close rbch device
*---------------------------------------------------------------------------*/
-int
+PDEVSTATIC int
i4brbchclose(dev_t dev, int flag, int fmt, struct proc *p)
{
int unit = minor(dev);
@@ -326,7 +341,7 @@ i4brbchclose(dev_t dev, int flag, int fmt, struct proc *p)
/*---------------------------------------------------------------------------*
* read from rbch device
*---------------------------------------------------------------------------*/
-int
+PDEVSTATIC int
i4brbchread(dev_t dev, struct uio *uio, int ioflag)
{
struct mbuf *m;
@@ -419,7 +434,7 @@ i4brbchread(dev_t dev, struct uio *uio, int ioflag)
/*---------------------------------------------------------------------------*
* write to rbch device
*---------------------------------------------------------------------------*/
-int
+PDEVSTATIC int
i4brbchwrite(dev_t dev, struct uio * uio, int ioflag)
{
struct mbuf *m;
@@ -520,60 +535,96 @@ i4brbchwrite(dev_t dev, struct uio * uio, int ioflag)
return(error);
}
+/*---------------------------------------------------------------------------*
+ * rbch device ioctl handlibg
+ *---------------------------------------------------------------------------*/
PDEVSTATIC int
-i4brbchioctl(dev_t dev, IOCTL_CMD_T cmd, caddr_t data, int flag, struct proc* p) {
+i4brbchioctl(dev_t dev, IOCTL_CMD_T cmd, caddr_t data, int flag, struct proc* p)
+{
int error = 0;
int unit = minor(dev);
switch(cmd)
{
-#if 0
- case I4B_RBCH_DIALOUT:
-if(bootverbose)printf("EE-rbch%d: attempting dialout (ioctl)\n", unit);
- i4b_l4_dialout(BDRV_RBCH, unit);
- break;
-#endif
-
case FIOASYNC: /* Set async mode */
- if (*(int *)data) {
-if(bootverbose)printf("EE-rbch%d: setting async mode\n", unit);
- } else {
-if(bootverbose)printf("EE-rbch%d: clearing async mode\n", unit);
+ if (*(int *)data)
+ {
+ DBGL4(L4_RBCHDBG, "i4brbchioctl", ("unit %d, setting async mode\n", unit));
+ }
+ else
+ {
+ DBGL4(L4_RBCHDBG, "i4brbchioctl", ("unit %d, clearing async mode\n", unit));
}
break;
+
case FIONBIO:
- if (*(int *)data) {
-if(bootverbose)printf("EE-rbch%d: setting non-blocking mode\n", unit);
+ if (*(int *)data)
+ {
+ DBGL4(L4_RBCHDBG, "i4brbchioctl", ("unit %d, setting non-blocking mode\n", unit));
rbch_softc[unit].sc_devstate |= ST_NOBLOCK;
- } else {
-if(bootverbose)printf("EE-rbch%d: clearing non-blocking mode\n", unit);
+ }
+ else
+ {
+ DBGL4(L4_RBCHDBG, "i4brbchioctl", ("unit %d, clearing non-blocking mode\n", unit));
rbch_softc[unit].sc_devstate &= ~ST_NOBLOCK;
}
break;
+
case TIOCCDTR: /* Clear DTR */
- if(rbch_softc[unit].sc_devstate & ST_CONNECTED) {
-if(bootverbose)printf("EE-rbch%d: disconnecting for DTR down\n", unit);
+ if(rbch_softc[unit].sc_devstate & ST_CONNECTED)
+ {
+ DBGL4(L4_RBCHDBG, "i4brbchioctl", ("unit %d, disconnecting for DTR down\n", unit));
i4b_l4_disconnect_ind(rbch_softc[unit].cd);
}
break;
+
+ case I4B_RBCH_DIALOUT:
+ {
+ size_t l;
+
+ for (l = 0; l < TELNO_MAX && ((char *)data)[l]; l++)
+ ;
+ if (l)
+ {
+ DBGL4(L4_RBCHDBG, "i4brbchioctl", ("unit %d, attempting dialout to %s\n", unit, (char *)data));
+ i4b_l4_dialoutnumber(BDRV_RBCH, unit, l, (char *)data);
+ break;
+ }
+ /* fall through to SDTR */
+ }
+
case TIOCSDTR: /* Set DTR */
-if(bootverbose)printf("EE-rbch%d: attempting dialout (DTR)\n", unit);
+ DBGL4(L4_RBCHDBG, "i4brbchioctl", ("unit %d, attempting dialout (DTR)\n", unit));
i4b_l4_dialout(BDRV_RBCH, unit);
break;
+
case TIOCSETA: /* Set termios struct */
break;
+
case TIOCGETA: /* Get termios struct */
*(struct termios *)data = rbch_softc[unit].it_in;
break;
+
case TIOCMGET:
*(int *)data = TIOCM_LE|TIOCM_DTR|TIOCM_RTS|TIOCM_CTS|TIOCM_DSR;
if (rbch_softc[unit].sc_devstate & ST_CONNECTED)
*(int *)data |= TIOCM_CD;
break;
+
+ case I4B_RBCH_VR_REQ:
+ {
+ msg_vr_req_t *mvr;
+
+ mvr = (msg_vr_req_t *)data;
+
+ mvr->version = VERSION;
+ mvr->release = REL;
+ mvr->step = STEP;
+ break;
+ }
+
default: /* Unknown stuff */
- printf("\n ========= i4brbch%d - ioctl, unknown cmd %lx ==================== \n",
- unit,
- (u_long)cmd);
+ DBGL4(L4_RBCHDBG, "i4brbchioctl", ("unit %d, ioctl, unknown cmd %lx\n", unit, (u_long)cmd));
error = EINVAL;
break;
}
@@ -642,8 +693,7 @@ i4brbchpoll(dev_t dev, int events, struct proc *p)
/*---------------------------------------------------------------------------*
* device driver select
*---------------------------------------------------------------------------*/
-/* XXX fix "static" to PDEVSTATIC */
-static int
+PDEVSTATIC int
i4brbchselect(dev_t dev, int rw, struct proc *p)
{
int unit = minor(dev);
diff --git a/sys/i4b/driver/i4b_tel.c b/sys/i4b/driver/i4b_tel.c
index d681f3b..a96a77f 100644
--- a/sys/i4b/driver/i4b_tel.c
+++ b/sys/i4b/driver/i4b_tel.c
@@ -27,9 +27,9 @@
* i4b_tel.c - device driver for ISDN telephony
* --------------------------------------------
*
- * $Id: i4b_tel.c,v 1.3 1999/05/20 10:09:03 hm Exp $
+ * $Id: i4b_tel.c,v 1.43 1999/07/09 06:44:00 hm Exp $
*
- * last edit-date: [Thu May 6 09:30:13 1999]
+ * last edit-date: [Fri Jul 9 08:35:30 1999]
*
*---------------------------------------------------------------------------*/
@@ -183,6 +183,7 @@ PDEVSTATIC d_close_t i4btelclose;
PDEVSTATIC d_read_t i4btelread;
PDEVSTATIC d_read_t i4btelwrite;
PDEVSTATIC d_ioctl_t i4btelioctl;
+
#ifdef OS_USES_POLL
PDEVSTATIC d_poll_t i4btelpoll;
#define POLLFIELD i4btelpoll
@@ -192,6 +193,8 @@ PDEVSTATIC d_select_t i4btelsel;
#endif
#define CDEV_MAJOR 56
+
+#if defined (__FreeBSD_version) && __FreeBSD_version >= 400006
static struct cdevsw i4btel_cdevsw = {
/* open */ i4btelopen,
/* close */ i4btelclose,
@@ -213,6 +216,13 @@ static struct cdevsw i4btel_cdevsw = {
/* maxio */ 0,
/* bmaj */ -1
};
+#else
+static struct cdevsw i4btel_cdevsw = {
+ i4btelopen, i4btelclose, i4btelread, i4btelwrite,
+ i4btelioctl, nostop, noreset, nodevtotty,
+ POLLFIELD, nommap, NULL, "i4btel", NULL, -1
+};
+#endif
PDEVSTATIC void i4btelinit(void *unused);
PDEVSTATIC void i4btelattach(void *);
@@ -229,8 +239,12 @@ PSEUDO_SET(i4btelattach, i4b_tel);
PDEVSTATIC void
i4btelinit(void *unused)
{
-
- cdevsw_add(&i4btel_cdevsw);
+#if defined (__FreeBSD_version) && __FreeBSD_version >= 400006
+ cdevsw_add(&i4btel_cdevsw);
+#else
+ dev_t dev = makedev(CDEV_MAJOR, 0);
+ cdevsw_add(&dev, &i4btel_cdevsw, NULL);
+#endif
}
SYSINIT(i4bteldev, SI_SUB_DRIVERS,
@@ -441,6 +455,18 @@ i4btelioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
}
splx(s);
break;
+
+ case I4B_TEL_VR_REQ:
+ {
+ msg_vr_req_t *mvr;
+
+ mvr = (msg_vr_req_t *)data;
+
+ mvr->version = VERSION;
+ mvr->release = REL;
+ mvr->step = STEP;
+ break;
+ }
default:
error = ENOTTY;
diff --git a/sys/i4b/driver/i4b_trace.c b/sys/i4b/driver/i4b_trace.c
index b43ce24..aacf53d 100644
--- a/sys/i4b/driver/i4b_trace.c
+++ b/sys/i4b/driver/i4b_trace.c
@@ -27,9 +27,9 @@
* i4btrc - device driver for trace data read device
* ---------------------------------------------------
*
- * $Id: i4b_trace.c,v 1.3 1999/05/20 10:09:05 hm Exp $
+ * $Id: i4b_trace.c,v 1.20 1999/06/01 10:23:58 hm Exp $
*
- * last edit-date: [Wed Apr 28 10:21:09 1999]
+ * last edit-date: [Tue Jun 1 12:15:40 1999]
*
* NOTE: the code assumes that SPLI4B >= splimp !
*
@@ -125,6 +125,7 @@ static d_open_t i4btrcopen;
static d_close_t i4btrcclose;
static d_read_t i4btrcread;
static d_ioctl_t i4btrcioctl;
+
#ifdef OS_USES_POLL
static d_poll_t i4btrcpoll;
#define POLLFIELD i4btrcpoll
@@ -133,6 +134,8 @@ static d_poll_t i4btrcpoll;
#endif
#define CDEV_MAJOR 59
+
+#if defined (__FreeBSD_version) && __FreeBSD_version >= 400006
static struct cdevsw i4btrc_cdevsw = {
/* open */ i4btrcopen,
/* close */ i4btrcclose,
@@ -154,6 +157,13 @@ static struct cdevsw i4btrc_cdevsw = {
/* maxio */ 0,
/* bmaj */ -1
};
+#else
+static struct cdevsw i4btrc_cdevsw = {
+ i4btrcopen, i4btrcclose, i4btrcread, nowrite,
+ i4btrcioctl, nostop, noreset, nodevtotty,
+ POLLFIELD, nommap, NULL, "i4btrc", NULL, -1
+};
+#endif
/*---------------------------------------------------------------------------*
* interface init routine
@@ -161,8 +171,12 @@ static struct cdevsw i4btrc_cdevsw = {
static
void i4btrcinit(void *unused)
{
-
- cdevsw_add(&i4btrc_cdevsw);
+#if defined (__FreeBSD_version) && __FreeBSD_version >= 400006
+ cdevsw_add(&i4btrc_cdevsw);
+#else
+ dev_t dev = makedev(CDEV_MAJOR, 0);
+ cdevsw_add(&dev, &i4btrc_cdevsw, NULL);
+#endif
}
SYSINIT(i4btrcdev, SI_SUB_DRIVERS,
OpenPOWER on IntegriCloud