diff options
author | hm <hm@FreeBSD.org> | 2000-10-09 13:18:17 +0000 |
---|---|---|
committer | hm <hm@FreeBSD.org> | 2000-10-09 13:18:17 +0000 |
commit | 9fc2bc8a46f4f09ca71eaf59e5c203b5d61533fb (patch) | |
tree | ca1e99e8eac9fd3f8c8cecbcbfc102b0bfa6f03f /sys/i4b/layer4 | |
parent | 7fc1fa165474e47dca5d7dfb2584d97d169d686d (diff) | |
download | FreeBSD-src-9fc2bc8a46f4f09ca71eaf59e5c203b5d61533fb.zip FreeBSD-src-9fc2bc8a46f4f09ca71eaf59e5c203b5d61533fb.tar.gz |
update to i4b version 0.95.04
Diffstat (limited to 'sys/i4b/layer4')
-rw-r--r-- | sys/i4b/layer4/i4b_i4bdrv.c | 94 | ||||
-rw-r--r-- | sys/i4b/layer4/i4b_l4.c | 207 | ||||
-rw-r--r-- | sys/i4b/layer4/i4b_l4.h | 6 | ||||
-rw-r--r-- | sys/i4b/layer4/i4b_l4mgmt.c | 85 | ||||
-rw-r--r-- | sys/i4b/layer4/i4b_l4timer.c | 34 |
5 files changed, 241 insertions, 185 deletions
diff --git a/sys/i4b/layer4/i4b_i4bdrv.c b/sys/i4b/layer4/i4b_i4bdrv.c index 0821c2d..ed61e64 100644 --- a/sys/i4b/layer4/i4b_i4bdrv.c +++ b/sys/i4b/layer4/i4b_i4bdrv.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved. + * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,11 +27,11 @@ * i4b_i4bdrv.c - i4b userland interface driver * -------------------------------------------- * - * $Id: i4b_i4bdrv.c,v 1.52 1999/12/13 21:25:28 hm Exp $ + * $Id: i4b_i4bdrv.c,v 1.59 2000/10/06 08:37:43 hm Exp $ * * $FreeBSD$ * - * last edit-date: [Mon Dec 13 22:06:11 1999] + * last edit-date: [Mon Oct 2 09:55:28 2000] * *---------------------------------------------------------------------------*/ @@ -39,11 +39,6 @@ #include "i4bipr.h" #include "i4btel.h" -#ifdef __bsdi__ -#include "ibc.h" -#else -#include "i4bisppp.h" -#endif #if NI4B > 1 #error "only 1 (one) i4b device possible!" @@ -71,6 +66,36 @@ #include <sys/select.h> #include <net/if.h> +#ifdef __NetBSD__ +#include <sys/types.h> +#endif + +#if defined(__FreeBSD__) +#include "i4bing.h" +#endif + +#ifdef __bsdi__ +#include "ibc.h" +#else +#ifdef __FreeBSD__ +#include "i4bisppp.h" +#else +#include <net/if_sppp.h> +#endif +#endif + +#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> @@ -99,6 +124,9 @@ static int selflag = 0; static int readflag = 0; #if defined(__FreeBSD__) && __FreeBSD__ == 3 +#ifdef DEVFS +static void *devfs_token; +#endif #endif #ifndef __FreeBSD__ @@ -240,6 +268,11 @@ i4battach() #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"); @@ -296,16 +329,17 @@ i4bread(dev_t dev, struct uio *uio, int ioflag) if(minor(dev)) return(ENODEV); + x = splimp(); while(IF_QEMPTY(&i4b_rdqueue)) { - x = splimp(); readflag = 1; + error = tsleep((caddr_t) &i4b_rdqueue, (PZERO + 1) | PCATCH, "bird", 0); + if (error != 0) { splx(x); - tsleep((caddr_t) &i4b_rdqueue, (PZERO + 1) | PCATCH, "bird", 0); + return error; + } } - x = splimp(); - IF_DEQUEUE(&i4b_rdqueue, m); splx(x); @@ -361,7 +395,7 @@ i4bioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) if((cd = cd_by_cdid(mcr->cdid)) == NULL)/* get cd */ { - DBGL4(L4_ERR, "i4bioctl", ("I4B_CONNECT_REQ ioctl, cdid not found!\n")); + NDBGL4(L4_ERR, "I4B_CONNECT_REQ ioctl, cdid not found!"); error = EINVAL; break; } @@ -399,9 +433,9 @@ i4bioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) cd->dir = DIR_OUTGOING; - DBGL4(L4_TIMO, "i4bioctl", ("I4B_CONNECT_REQ times, algorithm=%ld unitlen=%ld idle=%ld earlyhup=%ld\n", + 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)); + (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); @@ -460,7 +494,7 @@ i4bioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) if((cd = cd_by_cdid(mcrsp->cdid)) == NULL)/* get cd */ { - DBGL4(L4_ERR, "i4bioctl", ("I4B_CONNECT_RESP ioctl, cdid not found!\n")); + NDBGL4(L4_ERR, "I4B_CONNECT_RESP ioctl, cdid not found!"); error = EINVAL; break; } @@ -478,7 +512,7 @@ i4bioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) cd->isdntxdelay = mcrsp->txdelay; - DBGL4(L4_TIMO, "i4bioctl", ("I4B_CONNECT_RESP max_idle_time set to %ld seconds\n", (long)cd->max_idle_time)); + 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; @@ -494,7 +528,7 @@ i4bioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) if((cd = cd_by_cdid(mdr->cdid)) == NULL)/* get cd */ { - DBGL4(L4_ERR, "i4bioctl", ("I4B_DISCONNECT_REQ ioctl, cdid not found!\n")); + NDBGL4(L4_ERR, "I4B_DISCONNECT_REQ ioctl, cdid not found!"); error = EINVAL; break; } @@ -569,6 +603,12 @@ i4bioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) dlt = ibc_ret_linktab(mdrsp->driver_unit); break; #endif + +#if NI4BING > 0 + case BDRV_ING: + dlt = ing_ret_linktab(mdrsp->driver_unit); + break; +#endif } if(dlt != NULL) @@ -585,13 +625,13 @@ i4bioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) mtu = (msg_timeout_upd_t *)data; - DBGL4(L4_TIMO, "i4bioctl", ("I4B_TIMEOUT_UPD ioctl, alg %d, unit %d, idle %d, early %d!\n", + 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 )); + mtu->shorthold_data.idle_time, mtu->shorthold_data.earlyhup_time); if((cd = cd_by_cdid(mtu->cdid)) == NULL)/* get cd */ { - DBGL4(L4_ERR, "i4bioctl", ("I4B_TIMEOUT_UPD ioctl, cdid not found!\n")); + NDBGL4(L4_ERR, "I4B_TIMEOUT_UPD ioctl, cdid not found!"); error = EINVAL; break; } @@ -608,7 +648,7 @@ i4bioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) mtu->shorthold_data.idle_time >= 0 && mtu->shorthold_data.earlyhup_time >= 0)) { - DBGL4(L4_ERR, "i4bioctl", ("I4B_TIMEOUT_UPD ioctl, invalid args for fix unit algorithm!\n")); + NDBGL4(L4_ERR, "I4B_TIMEOUT_UPD ioctl, invalid args for fix unit algorithm!"); error = EINVAL; } break; @@ -625,13 +665,13 @@ i4bioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) mtu->shorthold_data.idle_time >= 0 && mtu->shorthold_data.earlyhup_time == 0)) { - DBGL4(L4_ERR, "i4bioctl", ("I4B_TIMEOUT_UPD ioctl, invalid args for var unit algorithm!\n")); + NDBGL4(L4_ERR, "I4B_TIMEOUT_UPD ioctl, invalid args for var unit algorithm!"); error = EINVAL; } break; default: - DBGL4(L4_ERR, "i4bioctl", ("I4B_TIMEOUT_UPD ioctl, invalid algorithm!\n")); + NDBGL4(L4_ERR, "I4B_TIMEOUT_UPD ioctl, invalid algorithm!"); error = EINVAL; break; } @@ -681,7 +721,7 @@ i4bioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) if((cd = cd_by_cdid(mar->cdid)) == NULL) { - DBGL4(L4_ERR, "i4bioctl", ("I4B_ALERT_REQ ioctl, cdid not found!\n")); + NDBGL4(L4_ERR, "I4B_ALERT_REQ ioctl, cdid not found!"); error = EINVAL; break; } @@ -945,7 +985,7 @@ i4bputqueue(struct mbuf *m) struct mbuf *m1; IF_DEQUEUE(&i4b_rdqueue, m1); i4b_Dfreembuf(m1); - DBGL4(L4_ERR, "i4bputqueue", ("ERROR, queue full, removing entry!\n")); + NDBGL4(L4_ERR, "ERROR, queue full, removing entry!"); } IF_ENQUEUE(&i4b_rdqueue, m); @@ -986,7 +1026,7 @@ i4bputqueue_hipri(struct mbuf *m) struct mbuf *m1; IF_DEQUEUE(&i4b_rdqueue, m1); i4b_Dfreembuf(m1); - DBGL4(L4_ERR, "i4bputqueue", ("ERROR, queue full, removing entry!\n")); + NDBGL4(L4_ERR, "ERROR, queue full, removing entry!"); } IF_PREPEND(&i4b_rdqueue, m); diff --git a/sys/i4b/layer4/i4b_l4.c b/sys/i4b/layer4/i4b_l4.c index d54872a..fbb14f1 100644 --- a/sys/i4b/layer4/i4b_l4.c +++ b/sys/i4b/layer4/i4b_l4.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved. + * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,32 +27,20 @@ * i4b_l4.c - kernel interface to userland * ----------------------------------------- * - * $Id: i4b_l4.c,v 1.45 1999/12/13 21:25:28 hm Exp $ + * $Id: i4b_l4.c,v 1.54 2000/08/28 07:24:59 hm Exp $ * * $FreeBSD$ * - * last edit-date: [Mon Dec 13 22:06:17 1999] + * last edit-date: [Sun Aug 27 14:53:42 2000] * *---------------------------------------------------------------------------*/ #include "i4b.h" #include "i4bipr.h" -#ifdef __bsdi__ -#define NI4BISPPP 0 -#include "ibc.h" -#else -#include "i4bisppp.h" -#endif -#include "i4brbch.h" -#include "i4btel.h" #if NI4B > 0 #include <sys/param.h> -#if defined(__FreeBSD__) -#else -#include <sys/ioctl.h> -#endif #include <sys/kernel.h> #include <sys/systm.h> #include <sys/conf.h> @@ -62,6 +50,28 @@ #include <sys/socket.h> #include <net/if.h> +#ifdef __NetBSD__ +#include <sys/types.h> +#endif + +#if defined(__NetBSD__) && __NetBSD_Version__ >= 104230000 +#include <sys/callout.h> +#endif + +#if defined(__FreeBSD__) +#include "i4bing.h" +#endif + +#ifdef __bsdi__ +#define NI4BISPPP 0 +#include "ibc.h" +#else +#include "i4bisppp.h" +#endif + +#include "i4brbch.h" +#include "i4btel.h" + #ifdef __FreeBSD__ #include <machine/i4b_debug.h> #include <machine/i4b_ioctl.h> @@ -93,6 +103,10 @@ 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 NI4BISPPP > 0 +extern time_t i4bisppp_idletime(int); +#endif /*---------------------------------------------------------------------------* * send MSG_PDEACT_IND message to userland @@ -114,11 +128,7 @@ i4b_l4_pdeact(int controller, int numactive) if(cd->timeout_active) { -#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); -#endif + STOP_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd); } if(cd->dlt != NULL) @@ -370,6 +380,7 @@ i4b_l4_connect_ind(call_desc_t *cd) strcpy(mp->display, cd->display); mp->scr_ind = cd->scr_ind; + mp->prs_ind = cd->prs_ind; T400_start(cd); @@ -390,7 +401,7 @@ i4b_l4_connect_active_ind(call_desc_t *cd) cd->last_active_time = cd->connect_time = SECOND; - DBGL4(L4_TIMO, "i4b_l4_connect_active_ind", ("last_active/connect_time=%ld\n", (long)cd->connect_time)); + NDBGL4(L4_TIMO, "last_active/connect_time=%ld", (long)cd->connect_time); i4b_link_bchandrvr(cd); @@ -425,11 +436,7 @@ i4b_l4_disconnect_ind(call_desc_t *cd) struct mbuf *m; if(cd->timeout_active) -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 - untimeout((TIMEOUT_FUNC_T)i4b_idle_check,(void *)cd, cd->idle_timeout_handle); -#else - untimeout((TIMEOUT_FUNC_T)i4b_idle_check,(void *)cd); -#endif + STOP_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd); if(cd->dlt != NULL) { @@ -444,7 +451,7 @@ i4b_l4_disconnect_ind(call_desc_t *cd) else { /* no error, might be hunting call for callback */ - DBGL4(L4_MSG, "i4b_l4_disconnect_ind", ("channel free not B1/B2 but %d!\n", cd->channelid)); + NDBGL4(L4_MSG, "channel free not B1/B2 but %d!", cd->channelid); } if((m = i4b_Dgetmbuf(sizeof(msg_disconnect_ind_t))) != NULL) @@ -634,6 +641,12 @@ i4b_link_bchandrvr(call_desc_t *cd) break; #endif +#if NI4BING > 0 + case BDRV_ING: + cd->dlt = ing_ret_linktab(cd->driver_unit); + break; +#endif + default: cd->dlt = NULL; break; @@ -681,6 +694,13 @@ i4b_link_bchandrvr(call_desc_t *cd) ibc_set_linktab(cd->driver_unit, cd->ilt); break; #endif + +#if NI4BING > 0 + case BDRV_ING: + ing_set_linktab(cd->driver_unit, cd->ilt); + break; +#endif + default: return(0); break; @@ -688,8 +708,7 @@ i4b_link_bchandrvr(call_desc_t *cd) /* activate B channel */ - (*cd->ilt->bch_config)(ctrl_desc[cd->controller].unit, - cd->channelid, cd->bprot, 1); + (*cd->ilt->bch_config)(cd->ilt->unit, cd->ilt->channel, cd->bprot, 1); return(0); } @@ -716,8 +735,7 @@ i4b_unlink_bchandrvr(call_desc_t *cd) /* deactivate B channel */ - (*cd->ilt->bch_config)(ctrl_desc[cd->controller].unit, - cd->channelid, cd->bprot, 0); + (*cd->ilt->bch_config)(cd->ilt->unit, cd->ilt->channel, cd->bprot, 0); } /*--------------------------------------------------------------------------- @@ -762,14 +780,28 @@ idletime_state: IST_NONCHK IST_CHECK IST_SAFE ---------------------------------------------------------------------------*/ +static time_t +i4b_get_idletime(call_desc_t *cd) +{ + switch (cd->driver) { +#if 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) { - DBGL4(L4_TIMO, "i4b_l4_setup_timeout", ("%ld: direction %d, shorthold algorithm %d\n", - (long)SECOND, cd->dir, cd->shorthold_data.shorthold_algorithm )); + 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; @@ -778,12 +810,9 @@ i4b_l4_setup_timeout(call_desc_t *cd) { /* incoming call: simple max idletime check */ -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 - cd->idle_timeout_handle = -#endif - timeout((TIMEOUT_FUNC_T)i4b_idle_check,(void *)cd, hz/2); + START_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd, hz/2); cd->timeout_active = 1; - DBGL4(L4_TIMO, "i4b_l4_setup_timeout", ("%ld: incoming-call, setup max_idle_time to %ld\n", (long)SECOND, (long)cd->max_idle_time)); + 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)) { @@ -801,7 +830,7 @@ i4b_l4_setup_timeout(call_desc_t *cd) } else { - DBGL4(L4_TIMO, "i4b_l4_setup_timeout", ("no idle_timeout configured\n")); + NDBGL4(L4_TIMO, "no idle_timeout configured"); } } @@ -817,26 +846,20 @@ i4b_l4_setup_timeout_fix_unit(call_desc_t *cd) { /* outgoing call: simple max idletime check */ -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 - cd->idle_timeout_handle = -#endif - timeout((TIMEOUT_FUNC_T)i4b_idle_check,(void *)cd, hz/2); + START_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd, hz/2); cd->timeout_active = 1; - DBGL4(L4_TIMO, "i4b_l4_setup_timeout", ("%ld: outgoing-call, setup idle_time to %ld\n", - (long)SECOND, (long)cd->shorthold_data.idle_time)); + 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 */ -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 - cd->idle_timeout_handle = -#endif - timeout((TIMEOUT_FUNC_T)i4b_idle_check,(void *)cd, hz*(cd->shorthold_data.unitlen_time - (cd->shorthold_data.idle_time + cd->shorthold_data.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; - DBGL4(L4_TIMO, "i4b_l4_setup_timeout", ("%ld: outgoing-call, start %ld sec nocheck window\n", - (long)SECOND, (long)(cd->shorthold_data.unitlen_time - (cd->shorthold_data.idle_time + cd->shorthold_data.earlyhup_time)))); + 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) { @@ -849,8 +872,8 @@ i4b_l4_setup_timeout_fix_unit(call_desc_t *cd) { /* parms somehow got wrong .. */ - DBGL4(L4_ERR, "i4b_l4_setup_timeout", ("%ld: ERROR: idletime[%ld]+earlyhup[%ld] > unitlength[%ld]!\n", - (long)SECOND, (long)cd->shorthold_data.idle_time, (long)cd->shorthold_data.earlyhup_time, (long)cd->shorthold_data.unitlen_time)); + 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); } } @@ -869,13 +892,10 @@ i4b_l4_setup_timeout_var_unit(call_desc_t *cd) */ cd->idletime_state = IST_CHECK; /* move directly to the checking state */ -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 - cd->idle_timeout_handle = -#endif - timeout((TIMEOUT_FUNC_T)i4b_idle_check,(void *)cd, hz * (cd->shorthold_data.unitlen_time - 1) ); + START_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd, hz * (cd->shorthold_data.unitlen_time - 1) ); cd->timeout_active = 1; - DBGL4(L4_TIMO, "i4b_l4_setup_timeout", ("%ld: outgoing-call, var idle time - setup to %ld\n", - (long)SECOND, (long)cd->shorthold_data.unitlen_time)); + NDBGL4(L4_TIMO, "%ld: outgoing-call, var idle time - setup to %ld", + (long)SECOND, (long)cd->shorthold_data.unitlen_time); } @@ -896,7 +916,7 @@ i4b_idle_check(call_desc_t *cd) if(cd->timeout_active == 0) { - DBGL4(L4_ERR, "i4b_idle_check", ("ERROR: timeout_active == 0 !!!\n")); + NDBGL4(L4_ERR, "ERROR: timeout_active == 0 !!!"); } else { @@ -907,21 +927,18 @@ i4b_idle_check(call_desc_t *cd) if(cd->dir == DIR_INCOMING) { - if((cd->last_active_time + cd->max_idle_time) <= SECOND) + if((i4b_get_idletime(cd) + cd->max_idle_time) <= SECOND) { - DBGL4(L4_TIMO, "i4b_idle_check", ("%ld: incoming-call, line idle timeout, disconnecting!\n", (long)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 { - DBGL4(L4_TIMO, "i4b_idle_check", ("%ld: incoming-call, activity, last_active=%ld, max_idle=%ld\n", (long)SECOND, (long)cd->last_active_time, (long)cd->max_idle_time)); + 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); -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 - cd->idle_timeout_handle = -#endif - timeout((TIMEOUT_FUNC_T)i4b_idle_check,(void *)cd, hz/2); + START_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd, hz/2); cd->timeout_active = 1; } } @@ -939,8 +956,8 @@ i4b_idle_check(call_desc_t *cd) i4b_idle_check_var_unit( cd ); break; default: - DBGL4(L4_TIMO, "i4b_idle_check", ("%ld: bad value for shorthold_algorithm of %d\n", - (long)SECOND, cd->shorthold_data.shorthold_algorithm )); + 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; } @@ -959,20 +976,17 @@ i4b_idle_check_fix_unit(call_desc_t *cd) if((cd->shorthold_data.idle_time > 0) && (cd->shorthold_data.unitlen_time == 0)) { - if((cd->last_active_time + cd->shorthold_data.idle_time) <= SECOND) + if((i4b_get_idletime(cd) + cd->shorthold_data.idle_time) <= SECOND) { - DBGL4(L4_TIMO, "i4b_idle_check", ("%ld: outgoing-call-st, idle timeout, disconnecting!\n", (long)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 { - DBGL4(L4_TIMO, "i4b_idle_check", ("%ld: outgoing-call-st, activity, last_active=%ld, max_idle=%ld\n", - (long)SECOND, (long)cd->last_active_time, (long)cd->shorthold_data.idle_time)); -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 - cd->idle_timeout_handle = -#endif - timeout((TIMEOUT_FUNC_T)i4b_idle_check,(void *)cd, hz/2); + 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; } } @@ -987,31 +1001,25 @@ i4b_idle_check_fix_unit(call_desc_t *cd) case IST_NONCHK: /* end of non-check time */ -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 - cd->idle_timeout_handle = -#endif - timeout((TIMEOUT_FUNC_T)i4b_idle_check,(void *)cd, hz*(cd->shorthold_data.idle_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; - DBGL4(L4_TIMO, "i4b_idle_check", ("%ld: outgoing-call, idletime check window reached!\n", (long)SECOND)); + NDBGL4(L4_TIMO, "%ld: outgoing-call, idletime check window reached!", (long)SECOND); break; case IST_CHECK: /* end of idletime chk */ - if((cd->last_active_time > cd->idletimechk_start) && - (cd->last_active_time <= SECOND)) + if((i4b_get_idletime(cd) > cd->idletimechk_start) && + (i4b_get_idletime(cd) <= SECOND)) { /* activity detected */ -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 - cd->idle_timeout_handle = -#endif - timeout((TIMEOUT_FUNC_T)i4b_idle_check,(void *)cd, hz*(cd->shorthold_data.earlyhup_time)); + 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; - DBGL4(L4_TIMO, "i4b_idle_check", ("%ld: outgoing-call, activity at %ld, wait earlyhup-end\n", (long)SECOND, (long)cd->last_active_time)); + NDBGL4(L4_TIMO, "%ld: outgoing-call, activity at %ld, wait earlyhup-end", (long)SECOND, (long)i4b_get_idletime(cd)); } else { /* no activity, hangup */ - DBGL4(L4_TIMO, "i4b_idle_check", ("%ld: outgoing-call, idle timeout, last activity at %ld\n", (long)SECOND, (long)cd->last_active_time)); + 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; @@ -1020,10 +1028,7 @@ i4b_idle_check_fix_unit(call_desc_t *cd) case IST_SAFE: /* end of earlyhup time */ -#if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 - cd->idle_timeout_handle = -#endif - timeout((TIMEOUT_FUNC_T)i4b_idle_check,(void *)cd, hz*(cd->shorthold_data.unitlen_time - (cd->shorthold_data.idle_time+cd->shorthold_data.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; @@ -1034,11 +1039,11 @@ i4b_idle_check_fix_unit(call_desc_t *cd) i4b_l4_charging_ind(cd); } - DBGL4(L4_TIMO, "i4b_idle_check", ("%ld: outgoing-call, earlyhup end, wait for idletime start\n", (long)SECOND)); + NDBGL4(L4_TIMO, "%ld: outgoing-call, earlyhup end, wait for idletime start", (long)SECOND); break; default: - DBGL4(L4_ERR, "i4b_idle_check", ("outgoing-call: invalid idletime_state value!\n")); + NDBGL4(L4_ERR, "outgoing-call: invalid idletime_state value!"); cd->idletime_state = IST_IDLE; break; } @@ -1056,20 +1061,20 @@ i4b_idle_check_var_unit(call_desc_t *cd) /* see if there has been any activity within the last idle_time seconds */ case IST_CHECK: - if( cd->last_active_time > (SECOND - cd->shorthold_data.idle_time)) + if( i4b_get_idletime(cd) > (SECOND - cd->shorthold_data.idle_time)) { /* activity detected */ #if defined(__FreeBSD_version) && __FreeBSD_version >= 300001 cd->idle_timeout_handle = #endif /* check again in one second */ - timeout((TIMEOUT_FUNC_T)i4b_idle_check,(void *)cd, hz ); + START_TIMER(cd->idle_timeout_handle, i4b_idle_check, cd, hz); cd->timeout_active = 1; cd->idletime_state = IST_CHECK; - DBGL4(L4_TIMO, "i4b_idle_check", ("%ld: outgoing-call, var idle timeout - activity at %ld, continuing\n", (long)SECOND, (long)cd->last_active_time)); + NDBGL4(L4_TIMO, "%ld: outgoing-call, var idle timeout - activity at %ld, continuing", (long)SECOND, (long)i4b_get_idletime(cd)); } else { /* no activity, hangup */ - DBGL4(L4_TIMO, "i4b_idle_check", ("%ld: outgoing-call, var idle timeout - last activity at %ld\n", (long)SECOND, (long)cd->last_active_time)); + 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; @@ -1077,7 +1082,7 @@ i4b_idle_check_var_unit(call_desc_t *cd) break; default: - DBGL4(L4_ERR, "i4b_idle_check", ("outgoing-call: var idle timeout invalid idletime_state value!\n")); + 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 index 35be567..f1ec1e2 100644 --- a/sys/i4b/layer4/i4b_l4.h +++ b/sys/i4b/layer4/i4b_l4.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved. + * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,11 +27,11 @@ * i4b_l4.h - kernel interface to userland header file * --------------------------------------------------- * - * $Id: i4b_l4.h,v 1.17 1999/12/13 21:25:28 hm Exp $ + * $Id: i4b_l4.h,v 1.18 2000/04/27 11:35:01 hm Exp $ * * $FreeBSD$ * - * last edit-date: [Mon Dec 13 22:06:24 1999] + * last edit-date: [Thu Apr 27 13:28:01 2000] * *---------------------------------------------------------------------------*/ diff --git a/sys/i4b/layer4/i4b_l4mgmt.c b/sys/i4b/layer4/i4b_l4mgmt.c index 1eca5a1..01ef0ff 100644 --- a/sys/i4b/layer4/i4b_l4mgmt.c +++ b/sys/i4b/layer4/i4b_l4mgmt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved. + * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,11 +27,11 @@ * i4b_l4mgmt.c - layer 4 calldescriptor management utilites * ----------------------------------------------------------- * - * $Id: i4b_l4mgmt.c,v 1.26 1999/12/13 21:25:28 hm Exp $ + * $Id: i4b_l4mgmt.c,v 1.34 2000/09/01 14:11:51 hm Exp $ * * $FreeBSD$ * - * last edit-date: [Mon Dec 13 22:06:32 1999] + * last edit-date: [Fri Sep 1 16:06:44 2000] * *---------------------------------------------------------------------------*/ @@ -40,18 +40,24 @@ #if NI4B > 0 #include <sys/param.h> - -#if defined(__FreeBSD__) -#include <sys/random.h> -#else -#include <sys/ioctl.h> -#endif - +#include <sys/kernel.h> #include <sys/systm.h> #include <sys/mbuf.h> #include <sys/socket.h> #include <net/if.h> +#if defined(__NetBSD__) && __NetBSD_Version__ >= 104230000 +#include <sys/callout.h> +#endif + +#if defined(__FreeBSD__) +#if defined (__FreeBSD_version) && __FreeBSD_version <= 400000 +#include <machine/random.h> +#else +#include <sys/random.h> +#endif +#endif + #ifdef __FreeBSD__ #include <machine/i4b_debug.h> #include <machine/i4b_ioctl.h> @@ -74,8 +80,8 @@ static unsigned int get_cdid(void); int nctrl; /* number of attached controllers */ -#if defined(__FreeBSD__) -void init_callout(call_desc_t *); +#if (defined(__NetBSD__) && __NetBSD_Version__ >= 104230000) || defined(__FreeBSD__) +void i4b_init_callout(call_desc_t *); #endif /*---------------------------------------------------------------------------* @@ -146,8 +152,8 @@ reserve_cd(void) 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 */ - DBGL4(L4_MSG, "reserve_cd", ("found free cd - index=%d cdid=%u\n", - i, call_desc[i].cdid)); + NDBGL4(L4_MSG, "found free cd - index=%d cdid=%u", + i, call_desc[i].cdid); break; } } @@ -157,8 +163,8 @@ reserve_cd(void) if(cd == NULL) panic("reserve_cd: no free call descriptor available!"); -#if defined(__FreeBSD__) - init_callout(cd); +#if (defined(__NetBSD__) && __NetBSD_Version__ >= 104230000) || defined(__FreeBSD__) + i4b_init_callout(cd); #endif return(cd); @@ -181,8 +187,8 @@ freecd_by_cd(call_desc_t *cd) if( (call_desc[i].cdid != CDID_UNUSED) && (&(call_desc[i]) == cd) ) { - DBGL4(L4_MSG, "freecd_by_cd", ("releasing cd - index=%d cdid=%u cr=%d\n", - i, call_desc[i].cdid, cd->cr)); + 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; } @@ -210,10 +216,10 @@ cd_by_cdid(unsigned int cdid) { if(call_desc[i].cdid == 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__) - init_callout(&call_desc[i]); + NDBGL4(L4_MSG, "found cdid - index=%d cdid=%u cr=%d", + i, call_desc[i].cdid, call_desc[i].cr); +#if (defined(__NetBSD__) && __NetBSD_Version__ >= 104230000) || defined(__FreeBSD__) + i4b_init_callout(&call_desc[i]); #endif return(&(call_desc[i])); } @@ -241,10 +247,10 @@ cd_by_unitcr(int unit, int cr, int crf) (call_desc[i].cr == cr) && (call_desc[i].crflag == 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__) - init_callout(&call_desc[i]); + NDBGL4(L4_MSG, "found cd, index=%d cdid=%u cr=%d", + i, call_desc[i].cdid, call_desc[i].cr); +#if (defined(__NetBSD__) && __NetBSD_Version__ >= 104230000) || defined(__FreeBSD__) + i4b_init_callout(&call_desc[i]); #endif return(&(call_desc[i])); } @@ -269,8 +275,14 @@ get_rand_cr(int unit) int found = 1; #if defined(__FreeBSD__) + +#ifdef RANDOMDEV read_random((char *)&val, sizeof(val)); #else + val = (u_char)random(); +#endif /* RANDOMDEV */ + +#else val |= unit+i; val <<= i; val ^= (time.tv_sec >> 8) ^ time.tv_usec; @@ -302,12 +314,13 @@ get_rand_cr(int unit) /*---------------------------------------------------------------------------* * initialize the callout handles for FreeBSD *---------------------------------------------------------------------------*/ -#if defined(__FreeBSD__) +#if (defined(__NetBSD__) && __NetBSD_Version__ >= 104230000) || defined(__FreeBSD__) void -init_callout(call_desc_t *cd) +i4b_init_callout(call_desc_t *cd) { if(cd->callouts_inited == 0) { +#ifdef __FreeBSD__ callout_handle_init(&cd->idle_timeout_handle); callout_handle_init(&cd->T303_callout); callout_handle_init(&cd->T305_callout); @@ -316,6 +329,16 @@ init_callout(call_desc_t *cd) callout_handle_init(&cd->T310_callout); callout_handle_init(&cd->T313_callout); callout_handle_init(&cd->T400_callout); +#else + callout_init(&cd->idle_timeout_handle); + callout_init(&cd->T303_callout); + callout_init(&cd->T305_callout); + callout_init(&cd->T308_callout); + callout_init(&cd->T309_callout); + callout_init(&cd->T310_callout); + callout_init(&cd->T313_callout); + callout_init(&cd->T400_callout); +#endif cd->callouts_inited = 1; } } @@ -335,8 +358,7 @@ i4b_l4_daemon_attached(void) { /*XXX*/ if(ctrl_desc[i].ctrl_type == CTRL_PASSIVE) { - DBGL4(L4_MSG, "i4b_l4_daemon_attached", ("CMR_DOPEN sent to unit %d\n", ctrl_desc[i].unit)); - + 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); } } @@ -357,8 +379,7 @@ i4b_l4_daemon_detached(void) { /*XXX*/ if(ctrl_desc[i].ctrl_type == CTRL_PASSIVE) { - DBGL4(L4_MSG, "i4b_l4_daemon_detached", ("CMR_DCLOSE sent to unit %d\n", ctrl_desc[i].unit)); - + 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); } } diff --git a/sys/i4b/layer4/i4b_l4timer.c b/sys/i4b/layer4/i4b_l4timer.c index 288fc56..c9707d7 100644 --- a/sys/i4b/layer4/i4b_l4timer.c +++ b/sys/i4b/layer4/i4b_l4timer.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved. + * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -27,11 +27,11 @@ * i4b_l4timer.c - timer and timeout handling for layer 4 * -------------------------------------------------------- * - * $Id: i4b_l4timer.c,v 1.15 1999/12/13 21:25:28 hm Exp $ + * $Id: i4b_l4timer.c,v 1.18 2000/08/24 11:48:58 hm Exp $ * * $FreeBSD$ * - * last edit-date: [Mon Dec 13 22:06:39 1999] + * last edit-date: [Thu Aug 24 12:50:17 2000] * *---------------------------------------------------------------------------*/ @@ -40,18 +40,16 @@ #if NI4B > 0 #include <sys/param.h> - -#if defined(__FreeBSD__) -#else -#include <sys/ioctl.h> -#endif - #include <sys/kernel.h> #include <sys/systm.h> #include <sys/mbuf.h> #include <sys/socket.h> #include <net/if.h> +#if defined(__NetBSD__) && __NetBSD_Version__ >= 104230000 +#include <sys/callout.h> +#endif + #ifdef __FreeBSD__ #include <machine/i4b_debug.h> #include <machine/i4b_ioctl.h> @@ -72,7 +70,7 @@ static void T400_timeout(call_desc_t *cd) { - DBGL4(L4_ERR, "T400_timeout", ("cr = %d\n", cd->cr)); + NDBGL4(L4_ERR, "cr = %d", cd->cr); } /*---------------------------------------------------------------------------* @@ -84,14 +82,10 @@ T400_start(call_desc_t *cd) if (cd->T400 == TIMER_ACTIVE) return; - DBGL4(L4_MSG, "T400_start", ("cr = %d\n", cd->cr)); + NDBGL4(L4_MSG, "cr = %d", cd->cr); cd->T400 = TIMER_ACTIVE; -#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); -#endif + START_TIMER(cd->T400_callout, T400_timeout, cd, T400DEF); } /*---------------------------------------------------------------------------* @@ -105,15 +99,11 @@ T400_stop(call_desc_t *cd) if(cd->T400 == TIMER_ACTIVE) { -#if defined(__FreeBSD__) - untimeout((TIMEOUT_FUNC_T)T400_timeout, (void *)cd, cd->T400_callout); -#else - untimeout((TIMEOUT_FUNC_T)T400_timeout, (void *)cd); -#endif + STOP_TIMER(cd->T400_callout, T400_timeout, cd); cd->T400 = TIMER_IDLE; } CRIT_END; - DBGL4(L4_MSG, "T400_stop", ("cr = %d\n", cd->cr)); + NDBGL4(L4_MSG, "cr = %d", cd->cr); } #endif /* NI4B > 0 */ |