summaryrefslogtreecommitdiffstats
path: root/sys/i4b/layer4
diff options
context:
space:
mode:
authorhm <hm@FreeBSD.org>1999-12-14 20:48:35 +0000
committerhm <hm@FreeBSD.org>1999-12-14 20:48:35 +0000
commit57bc8b41244c53f38345080f7e4b02bed8685f82 (patch)
tree01308b146b463af38fde282b569bea03dc8c8b94 /sys/i4b/layer4
parent2edcbc2e0b115cf2b9357f0b246717209c7b6cbf (diff)
downloadFreeBSD-src-57bc8b41244c53f38345080f7e4b02bed8685f82.zip
FreeBSD-src-57bc8b41244c53f38345080f7e4b02bed8685f82.tar.gz
update to isdn4bsd beta release 0.90
Diffstat (limited to 'sys/i4b/layer4')
-rw-r--r--sys/i4b/layer4/i4b_i4bdrv.c96
-rw-r--r--sys/i4b/layer4/i4b_l4.c39
-rw-r--r--sys/i4b/layer4/i4b_l4.h7
-rw-r--r--sys/i4b/layer4/i4b_l4mgmt.c31
-rw-r--r--sys/i4b/layer4/i4b_l4timer.c14
5 files changed, 143 insertions, 44 deletions
diff --git a/sys/i4b/layer4/i4b_i4bdrv.c b/sys/i4b/layer4/i4b_i4bdrv.c
index f45897b..1a07b95 100644
--- a/sys/i4b/layer4/i4b_i4bdrv.c
+++ b/sys/i4b/layer4/i4b_i4bdrv.c
@@ -27,9 +27,11 @@
* i4b_i4bdrv.c - i4b userland interface driver
* --------------------------------------------
*
- * $FreeBSD$
+ * $Id: i4b_i4bdrv.c,v 1.52 1999/12/13 21:25:28 hm Exp $
*
- * last edit-date: [Tue Jun 8 19:48:16 1999]
+ * $FreeBSD$
+ *
+ * last edit-date: [Mon Dec 13 22:06:11 1999]
*
*---------------------------------------------------------------------------*/
@@ -51,7 +53,7 @@
#include <sys/param.h>
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001
+#if defined(__FreeBSD__)
#include <sys/ioccom.h>
#include <sys/malloc.h>
#include <sys/uio.h>
@@ -70,6 +72,18 @@
#include <net/if.h>
#ifdef __FreeBSD__
+
+#if defined(__FreeBSD__) && __FreeBSD__ == 3
+#include "opt_devfs.h"
+#endif
+
+#ifdef DEVFS
+#include <sys/devfsext.h>
+#endif
+
+#endif /* __FreeBSD__*/
+
+#ifdef __FreeBSD__
#include <machine/i4b_debug.h>
#include <machine/i4b_ioctl.h>
#include <machine/i4b_cause.h>
@@ -96,6 +110,12 @@ static int openflag = 0;
static int selflag = 0;
static int readflag = 0;
+#if defined(__FreeBSD__) && __FreeBSD__ == 3
+#ifdef DEVFS
+static void *devfs_token;
+#endif
+#endif
+
#ifndef __FreeBSD__
#define PDEVSTATIC /* - not static - */
@@ -137,22 +157,22 @@ PDEVSTATIC d_select_t i4bselect;
#define CDEV_MAJOR 60
-#if defined (__FreeBSD_version) && __FreeBSD_version >= 400006
+#if defined(__FreeBSD__) && __FreeBSD__ >= 4
static struct cdevsw i4b_cdevsw = {
- /* open */ i4bopen,
- /* close */ i4bclose,
- /* read */ i4bread,
- /* write */ nowrite,
- /* ioctl */ i4bioctl,
- /* poll */ POLLFIELD,
- /* mmap */ nommap,
- /* strategy */ nostrategy,
- /* name */ "i4b",
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ 0,
- /* bmaj */ -1
+ /* open */ i4bopen,
+ /* close */ i4bclose,
+ /* read */ i4bread,
+ /* write */ nowrite,
+ /* ioctl */ i4bioctl,
+ /* poll */ POLLFIELD,
+ /* mmap */ nommap,
+ /* strategy */ nostrategy,
+ /* name */ "i4b",
+ /* maj */ CDEV_MAJOR,
+ /* dump */ nodump,
+ /* psize */ nopsize,
+ /* flags */ 0,
+ /* bmaj */ -1
};
#else
static struct cdevsw i4b_cdevsw = {
@@ -168,7 +188,7 @@ PSEUDO_SET(i4battach, i4b_i4bdrv);
static void
i4b_drvinit(void *unused)
{
-#if defined (__FreeBSD_version) && __FreeBSD_version >= 400006
+#if defined(__FreeBSD__) && __FreeBSD__ >= 4
cdevsw_add(&i4b_cdevsw);
#else
static int i4b_devsw_installed = 0;
@@ -231,7 +251,20 @@ i4battach()
printf("i4b: ISDN call control device attached\n");
#endif
i4b_rdqueue.ifq_maxlen = IFQ_MAXLEN;
+
+#if defined(__FreeBSD__)
+#if __FreeBSD__ == 3
+
+#ifdef DEVFS
+ devfs_token = devfs_add_devswf(&i4b_cdevsw, 0, DV_CHR,
+ UID_ROOT, GID_WHEEL, 0600,
+ "i4b");
+#endif
+
+#else
make_dev(&i4b_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "i4b");
+#endif
+#endif
}
/*---------------------------------------------------------------------------*
@@ -332,7 +365,7 @@ i4bioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
case I4B_CDID_REQ:
{
- msg_cdid_req_t *mir;
+ msg_cdid_req_t *mir;
mir = (msg_cdid_req_t *)data;
cd = reserve_cd();
mir->cdid = cd->cdid;
@@ -353,6 +386,16 @@ i4bioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
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->driver = mcr->driver;
@@ -683,6 +726,19 @@ i4bioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
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 */
diff --git a/sys/i4b/layer4/i4b_l4.c b/sys/i4b/layer4/i4b_l4.c
index 60cf4dc..920772c 100644
--- a/sys/i4b/layer4/i4b_l4.c
+++ b/sys/i4b/layer4/i4b_l4.c
@@ -27,9 +27,11 @@
* i4b_l4.c - kernel interface to userland
* -----------------------------------------
*
- * $FreeBSD$
+ * $Id: i4b_l4.c,v 1.45 1999/12/13 21:25:28 hm Exp $
*
- * last edit-date: [Thu Apr 8 17:31:52 1999]
+ * $FreeBSD$
+ *
+ * last edit-date: [Mon Dec 13 22:06:17 1999]
*
*---------------------------------------------------------------------------*/
@@ -47,7 +49,7 @@
#if NI4B > 0
#include <sys/param.h>
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
+#if defined(__FreeBSD__)
#include <sys/ioccom.h>
#else
#include <sys/ioctl.h>
@@ -77,6 +79,10 @@
#include <i4b/layer3/i4b_l3.h>
#include <i4b/layer4/i4b_l4.h>
+#if !defined(__FreeBSD__) && !defined(__NetBSD__)
+#define memcpy(dst, src, len) bcopy((src), (dst), (len))
+#endif
+
unsigned int i4b_l4_debug = L4_DEBUG_DEFAULT;
struct ctrl_type_desc ctrl_types[CTRL_NUMTYPES] = { { NULL, NULL} };
@@ -109,7 +115,7 @@ i4b_l4_pdeact(int controller, int numactive)
if(cd->timeout_active)
{
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
+#if defined(__FreeBSD__)
untimeout((TIMEOUT_FUNC_T)i4b_idle_check,(void *)cd, cd->idle_timeout_handle);
#else
untimeout((TIMEOUT_FUNC_T)i4b_idle_check,(void *)cd);
@@ -554,6 +560,31 @@ i4b_l4_proceeding_ind(call_desc_t *cd)
}
/*---------------------------------------------------------------------------*
+ * 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
diff --git a/sys/i4b/layer4/i4b_l4.h b/sys/i4b/layer4/i4b_l4.h
index 0225137..35be567 100644
--- a/sys/i4b/layer4/i4b_l4.h
+++ b/sys/i4b/layer4/i4b_l4.h
@@ -27,9 +27,11 @@
* i4b_l4.h - kernel interface to userland header file
* ---------------------------------------------------
*
- * $FreeBSD$
+ * $Id: i4b_l4.h,v 1.17 1999/12/13 21:25:28 hm Exp $
*
- * last edit-date: [Wed Mar 17 16:20:10 1999]
+ * $FreeBSD$
+ *
+ * last edit-date: [Mon Dec 13 22:06:24 1999]
*
*---------------------------------------------------------------------------*/
@@ -53,6 +55,7 @@ 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);
diff --git a/sys/i4b/layer4/i4b_l4mgmt.c b/sys/i4b/layer4/i4b_l4mgmt.c
index aff1eca..064a1f0 100644
--- a/sys/i4b/layer4/i4b_l4mgmt.c
+++ b/sys/i4b/layer4/i4b_l4mgmt.c
@@ -27,9 +27,11 @@
* i4b_l4mgmt.c - layer 4 calldescriptor management utilites
* -----------------------------------------------------------
*
- * $FreeBSD$
+ * $Id: i4b_l4mgmt.c,v 1.26 1999/12/13 21:25:28 hm Exp $
*
- * last edit-date: [Sun Feb 14 10:35:13 1999]
+ * $FreeBSD$
+ *
+ * last edit-date: [Mon Dec 13 22:06:32 1999]
*
*---------------------------------------------------------------------------*/
@@ -38,11 +40,13 @@
#if NI4B > 0
#include <sys/param.h>
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001
+
+#if defined(__FreeBSD__)
#include <sys/ioccom.h>
#else
#include <sys/ioctl.h>
#endif
+
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/mbuf.h>
@@ -50,11 +54,12 @@
#include <net/if.h>
#ifdef __FreeBSD__
-#include <machine/i4b_debug.h>
-#include <machine/i4b_ioctl.h>
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001
#include <machine/random.h>
#endif
+
+#ifdef __FreeBSD__
+#include <machine/i4b_debug.h>
+#include <machine/i4b_ioctl.h>
#else
#include <i4b/i4b_debug.h>
#include <i4b/i4b_ioctl.h>
@@ -74,7 +79,7 @@ static unsigned int get_cdid(void);
int nctrl; /* number of attached controllers */
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001
+#if defined(__FreeBSD__)
void init_callout(call_desc_t *);
#endif
@@ -157,7 +162,7 @@ reserve_cd(void)
if(cd == NULL)
panic("reserve_cd: no free call descriptor available!");
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001
+#if defined(__FreeBSD__)
init_callout(cd);
#endif
@@ -212,7 +217,7 @@ cd_by_cdid(unsigned int cdid)
{
DBGL4(L4_MSG, "cd_by_cdid", ("found cdid - index=%d cdid=%u cr=%d\n",
i, call_desc[i].cdid, call_desc[i].cr));
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001
+#if defined(__FreeBSD__)
init_callout(&call_desc[i]);
#endif
return(&(call_desc[i]));
@@ -243,7 +248,7 @@ cd_by_unitcr(int unit, int cr, int crf)
{
DBGL4(L4_MSG, "cd_by_unitcr", ("found cd, index=%d cdid=%u cr=%d\n",
i, call_desc[i].cdid, call_desc[i].cr));
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001
+#if defined(__FreeBSD__)
init_callout(&call_desc[i]);
#endif
return(&(call_desc[i]));
@@ -268,7 +273,7 @@ get_rand_cr(int unit)
{
int found = 1;
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001
+#if defined(__FreeBSD__)
read_random((char *)&val, sizeof(val));
#else
val |= unit+i;
@@ -300,9 +305,9 @@ get_rand_cr(int unit)
}
/*---------------------------------------------------------------------------*
- * initialize the callout handles for FreeBSD-current 3.0
+ * initialize the callout handles for FreeBSD
*---------------------------------------------------------------------------*/
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001
+#if defined(__FreeBSD__)
void
init_callout(call_desc_t *cd)
{
diff --git a/sys/i4b/layer4/i4b_l4timer.c b/sys/i4b/layer4/i4b_l4timer.c
index fefb25d..21855e2 100644
--- a/sys/i4b/layer4/i4b_l4timer.c
+++ b/sys/i4b/layer4/i4b_l4timer.c
@@ -27,9 +27,11 @@
* i4b_l4timer.c - timer and timeout handling for layer 4
* --------------------------------------------------------
*
- * $FreeBSD$
+ * $Id: i4b_l4timer.c,v 1.15 1999/12/13 21:25:28 hm Exp $
*
- * last edit-date: [Wed Apr 21 09:49:08 1999]
+ * $FreeBSD$
+ *
+ * last edit-date: [Mon Dec 13 22:06:39 1999]
*
*---------------------------------------------------------------------------*/
@@ -38,11 +40,13 @@
#if NI4B > 0
#include <sys/param.h>
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001
+
+#if defined(__FreeBSD__)
#include <sys/ioccom.h>
#else
#include <sys/ioctl.h>
#endif
+
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/mbuf.h>
@@ -84,7 +88,7 @@ T400_start(call_desc_t *cd)
DBGL4(L4_MSG, "T400_start", ("cr = %d\n", cd->cr));
cd->T400 = TIMER_ACTIVE;
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001
+#if defined(__FreeBSD__)
cd->T400_callout = timeout((TIMEOUT_FUNC_T)T400_timeout, (void *)cd, T400DEF);
#else
timeout((TIMEOUT_FUNC_T)T400_timeout, (void *)cd, T400DEF);
@@ -102,7 +106,7 @@ T400_stop(call_desc_t *cd)
if(cd->T400 == TIMER_ACTIVE)
{
-#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001
+#if defined(__FreeBSD__)
untimeout((TIMEOUT_FUNC_T)T400_timeout, (void *)cd, cd->T400_callout);
#else
untimeout((TIMEOUT_FUNC_T)T400_timeout, (void *)cd);
OpenPOWER on IntegriCloud