From 49e3567ef7c9c2e6bb7da47b86af7b991b1d1bd1 Mon Sep 17 00:00:00 2001 From: hm Date: Thu, 18 Oct 2001 11:58:49 +0000 Subject: Add experimental support for sending keypad facility messages. MFC after: 2 months --- sys/i4b/driver/i4b_tel.c | 107 +++++----------------------------------- sys/i4b/include/i4b_ioctl.h | 20 ++++++-- sys/i4b/include/i4b_l3l4.h | 9 ++-- sys/i4b/include/i4b_tel_ioctl.h | 7 ++- sys/i4b/layer3/i4b_l2if.c | 69 ++++++++++++++------------ sys/i4b/layer3/i4b_q931.h | 12 ++--- sys/i4b/layer4/i4b_i4bdrv.c | 8 ++- sys/i4b/layer4/i4b_l4.c | 33 +++++++++++-- sys/i4b/layer4/i4b_l4.h | 7 ++- 9 files changed, 120 insertions(+), 152 deletions(-) (limited to 'sys/i4b') diff --git a/sys/i4b/driver/i4b_tel.c b/sys/i4b/driver/i4b_tel.c index c9a195d..877b560 100644 --- a/sys/i4b/driver/i4b_tel.c +++ b/sys/i4b/driver/i4b_tel.c @@ -29,7 +29,7 @@ * * $FreeBSD$ * - * last edit-date: [Tue May 8 10:19:36 2001] + * last edit-date: [Thu Oct 18 13:24:50 2001] * *---------------------------------------------------------------------------*/ @@ -42,13 +42,8 @@ #include #include -#if defined(__FreeBSD__) || defined(__NetBSD__) #include #include -#else -#include -#include -#endif #include #include @@ -58,25 +53,13 @@ #include #include -#ifdef __FreeBSD__ #ifdef DEVFS #include #endif -#endif /* __FreeBSD__ */ - -#ifdef __bsdi__ -#include -#endif -#ifdef __FreeBSD__ #include #include #include -#else -#include -#include -#include -#endif #include #include @@ -151,37 +134,13 @@ static unsigned char u2a_tab[]; static unsigned char bitreverse[]; static u_char sinetab[]; -#ifndef __FreeBSD__ -#define PDEVSTATIC /* - not static - */ -PDEVSTATIC void i4btelattach __P((void)); - -#ifdef __bsdi__ -PDEVSTATIC int i4btelioctl __P((dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td)); -#else -PDEVSTATIC int i4btelioctl __P((dev_t dev, int cmd, caddr_t data, int flag, struct thread *td)); -#endif - -int i4btelopen __P((dev_t dev, int flag, int fmt, struct thread *td)); -int i4btelclose __P((dev_t dev, int flag, int fmt, struct thread *td)); -int i4btelread __P((dev_t dev, struct uio *uio, int ioflag)); -int i4btelwrite __P((dev_t dev, struct uio * uio, int ioflag)); - -#ifdef OS_USES_POLL -int i4btelpoll __P((dev_t dev, int events, struct thread *td)); -#else -int i4btelsel __P((dev_t dev, int rw, struct thread *td)); -#endif - -#endif /* ! __FreeBSD__ */ - -#if BSD > 199306 && defined(__FreeBSD__) - #define PDEVSTATIC static + PDEVSTATIC d_open_t i4btelopen; -PDEVSTATIC d_close_t i4btelclose; -PDEVSTATIC d_read_t i4btelread; -PDEVSTATIC d_read_t i4btelwrite; -PDEVSTATIC d_ioctl_t i4btelioctl; +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; @@ -230,50 +189,11 @@ i4btelinit(void *unused) SYSINIT(i4bteldev, SI_SUB_DRIVERS, SI_ORDER_MIDDLE+CDEV_MAJOR, &i4btelinit, NULL); -#endif /* BSD > 199306 && defined(__FreeBSD__) */ - -#ifdef __bsdi__ - -int i4btelsel(dev_t dev, int rw, struct thread *td); -int i4btelmatch(struct device *parent, struct cfdata *cf, void *aux); -void dummy_i4btelattach(struct device*, struct device *, void *); - -#define CDEV_MAJOR 62 - -static struct cfdriver i4btelcd = - { NULL, "i4btel", i4btelmatch, dummy_i4btelattach, DV_DULL, - sizeof(struct cfdriver) }; -struct devsw i4btelsw = - { &i4btelcd, - i4btelopen, i4btelclose, i4btelread, i4btelwrite, - i4btelioctl, i4btelsel, nommap, nostrat, - nodump, nopsize, 0, nostop -}; - -int -i4btelmatch(struct device *parent, struct cfdata *cf, void *aux) -{ - NDBGL4(L4_TELDBG, "aux=0x%x", aux); - return 1; -} - -void -dummy_i4btelattach(struct device *parent, struct device *self, void *aux) -{ - NDBGL4(L4_TELDBG, "aux=0x%x", aux); -} - -#endif /* __bsdi__ */ - /*---------------------------------------------------------------------------* * interface attach routine *---------------------------------------------------------------------------*/ PDEVSTATIC void -#ifdef __FreeBSD__ i4btelattach(void *dummy) -#else -i4btelattach() -#endif { int i, j; @@ -289,7 +209,6 @@ i4btelattach() tel_sc[i][j].wcvttab = 0; tel_sc[i][j].result = 0; -#if defined(__FreeBSD__) switch(j) { case FUNCTEL: /* normal i4btel device */ @@ -304,7 +223,6 @@ i4btelattach() 0600, "i4bteld%d", i); break; } -#endif } tel_init_linktab(i); } @@ -386,13 +304,7 @@ i4btelclose(dev_t dev, int flag, int fmt, struct thread *td) * i4btelioctl - device driver ioctl routine *---------------------------------------------------------------------------*/ PDEVSTATIC int -#if defined(__FreeBSD__) -i4btelioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) -#elif defined(__bsdi__) i4btelioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct thread *td) -#else -i4btelioctl(dev_t dev, int cmd, caddr_t data, int flag, struct thread *td) -#endif { int unit = UNIT(dev); int func = FUNC(dev); @@ -540,6 +452,7 @@ i4btelread(dev_t dev, struct uio *uio, int ioflag) sc->devstate |= ST_RDWAITDATA; NDBGL4(L4_TELDBG, "i4btel%d, queue empty!", unit); + #if defined (__FreeBSD__) && __FreeBSD__ > 4 if((error = msleep((caddr_t) &sc->isdn_linktab->rx_queue, &sc->isdn_linktab->rx_queue->ifq_mtx, @@ -675,6 +588,7 @@ i4btelwrite(dev_t dev, struct uio * uio, int ioflag) (sc->devstate & ST_ISOPEN)) { sc->devstate |= ST_WRWAITEMPTY; + #if defined (__FreeBSD__) && __FreeBSD__ > 4 if((error = msleep((caddr_t) &sc->isdn_linktab->tx_queue, &sc->isdn_linktab->tx_queue->ifq_mtx, @@ -721,6 +635,7 @@ i4btelwrite(dev_t dev, struct uio * uio, int ioflag) /* always reverse bitorder to line */ mtod(m,u_char *)[i] = bitreverse[mtod(m,u_char *)[i]]; } + #if defined (__FreeBSD__) && __FreeBSD__ > 4 (void) IF_HANDOFF(sc->isdn_linktab->tx_queue, m, NULL); #else @@ -750,6 +665,10 @@ i4btelwrite(dev_t dev, struct uio * uio, int ioflag) { i4b_l4_drvrdisc(BDRV_TEL, unit); } + else if(cmdbuf[0] == CMD_KEYP) + { + i4b_l4_keypad(BDRV_TEL, unit, len-1, &cmdbuf[1]); + } } else { diff --git a/sys/i4b/include/i4b_ioctl.h b/sys/i4b/include/i4b_ioctl.h index e71c486..8e685e3 100644 --- a/sys/i4b/include/i4b_ioctl.h +++ b/sys/i4b/include/i4b_ioctl.h @@ -29,7 +29,7 @@ * * $FreeBSD$ * - * last edit-date: [Sat Jul 21 12:24:56 2001] + * last edit-date: [Thu Oct 18 13:40:40 2001] * *---------------------------------------------------------------------------*/ @@ -46,8 +46,8 @@ * version and release number for isdn4bsd package *---------------------------------------------------------------------------*/ #define VERSION 1 /* version number */ -#define REL 0 /* release number */ -#define STEP 1 /* release step */ +#define REL 1 /* release number */ +#define STEP 0 /* release step */ /*---------------------------------------------------------------------------* * date/time format in i4b log messages @@ -170,6 +170,7 @@ #define TELNO_MAX 41 /* max length of a telephone number (+ '\0') */ #define DISPLAY_MAX 91 /* max length of display information (+ '\0') */ #define DATETIME_MAX 21 /* max length of datetime information (+ '\0')*/ +#define KEYPAD_MAX 35 /* max length of a keypad string (+ '\0') */ /*---------------------------------------------------------------------------* * in case the src or dst telephone number is empty @@ -318,6 +319,7 @@ typedef struct { #define MSG_IFSTATE_CHANGED_IND 'o' #define MSG_DIALOUTNUMBER_IND 'p' #define MSG_PACKET_IND 'q' +#define MSG_KEYPAD_IND 'r' int cdid; /* call descriptor id */ } msg_hdr_t; @@ -410,6 +412,17 @@ typedef struct { } msg_dialoutnumber_ind_t; /*---------------------------------------------------------------------------* + * send keypad string + *---------------------------------------------------------------------------*/ +typedef struct { + msg_hdr_t header; /* common header */ + int driver; /* driver type */ + int driver_unit; /* driver unit number */ + int cmdlen; /* length of string */ + char cmd[KEYPAD_MAX];/* keypad string */ +} msg_keypad_ind_t; + +/*---------------------------------------------------------------------------* * idle timeout disconnect sent indication * kernel has sent disconnect request because of b-ch idle *---------------------------------------------------------------------------*/ @@ -556,6 +569,7 @@ typedef struct { #define ULEN_METHOD_DYNAMIC 1 /* use AOCD */ char dst_telno[TELNO_MAX]; /* destination telephone no */ char src_telno[TELNO_MAX]; /* source telephone number */ + char keypad[KEYPAD_MAX]; /* keypad string */ } msg_connect_req_t; #define I4B_CONNECT_REQ _IOW('4', 1, msg_connect_req_t) diff --git a/sys/i4b/include/i4b_l3l4.h b/sys/i4b/include/i4b_l3l4.h index d70a211..64617a2 100644 --- a/sys/i4b/include/i4b_l3l4.h +++ b/sys/i4b/include/i4b_l3l4.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved. + * 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 @@ -27,11 +27,9 @@ * i4b_l3l4.h - layer 3 / layer 4 interface * ------------------------------------------ * - * $Id: i4b_l3l4.h,v 1.32 2000/08/24 11:48:57 hm Exp $ - * * $FreeBSD$ * - * last edit-date: [Fri Jun 2 14:29:35 2000] + * last edit-date: [Thu Oct 18 13:26:16 2001] * *---------------------------------------------------------------------------*/ @@ -240,7 +238,8 @@ typedef struct int isdntxdelay; /* isdn tx delay after connect */ u_char display[DISPLAY_MAX]; /* display information element */ - char datetime[DATETIME_MAX]; /* date/time information element*/ + char datetime[DATETIME_MAX]; /* date/time information element*/ + u_char keypad[KEYPAD_MAX]; /* keypad facility */ } call_desc_t; extern call_desc_t call_desc[N_CALL_DESC]; diff --git a/sys/i4b/include/i4b_tel_ioctl.h b/sys/i4b/include/i4b_tel_ioctl.h index 0f955af..3b92922 100644 --- a/sys/i4b/include/i4b_tel_ioctl.h +++ b/sys/i4b/include/i4b_tel_ioctl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved. + * 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 @@ -27,11 +27,9 @@ * i4b_tel_ioctl.h telephony interface ioctls * ------------------------------------------ * - * $Id: i4b_tel_ioctl.h,v 1.13 2000/01/12 14:49:36 hm Exp $ - * * $FreeBSD$ * - * last edit-date: [Wed Jan 12 15:47:11 2000] + * last edit-date: [Wed Oct 17 13:47:03 2001] * *---------------------------------------------------------------------------*/ @@ -83,6 +81,7 @@ struct i4b_tel_tones { #define CMD_DIAL 'D' /* dial the following number string */ #define CMD_HUP 'H' /* hangup */ +#define CMD_KEYP 'K' /* send keypad string */ /* dialer responses */ diff --git a/sys/i4b/layer3/i4b_l2if.c b/sys/i4b/layer3/i4b_l2if.c index f6cb507..2c94c31 100644 --- a/sys/i4b/layer3/i4b_l2if.c +++ b/sys/i4b/layer3/i4b_l2if.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved. + * 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 @@ -27,38 +27,23 @@ * i4b_l2if.c - Layer 3 interface to Layer 2 * ------------------------------------------- * - * $Id: i4b_l2if.c,v 1.23 2000/08/24 11:48:58 hm Exp $ - * * $FreeBSD$ * - * last edit-date: [Mon May 29 16:56:22 2000] + * last edit-date: [Thu Oct 18 13:29:19 2001] * *---------------------------------------------------------------------------*/ -#ifdef __FreeBSD__ #include "i4bq931.h" -#else -#define NI4BQ931 1 -#endif + #if NI4BQ931 > 0 #include #include #include -#if defined(__NetBSD__) && __NetBSD_Version__ >= 104230000 -#include -#endif - -#ifdef __FreeBSD__ #include #include #include -#else -#include -#include -#include -#endif #include #include @@ -435,8 +420,10 @@ i4b_l3_tx_setup(call_desc_t *cd) { struct mbuf *m; u_char *ptr; + int len; int slen = strlen(cd->src_telno); int dlen = strlen(cd->dst_telno); + int klen = strlen(cd->keypad); /* * there is one additional octet if cd->bprot == BPROT_NONE @@ -447,8 +434,14 @@ i4b_l3_tx_setup(call_desc_t *cd) NDBGL3(L3_PRIM, "unit %d, cr = 0x%02x", ctrl_desc[cd->controller].unit, cd->cr); - if((m = i4b_Dgetmbuf(I_FRAME_HDRLEN + MSG_SETUP_LEN + slen + dlen + - (cd->bprot == BPROT_NONE ? 1 : 0))) == NULL) + len = I_FRAME_HDRLEN + + MSG_SETUP_LEN + + (slen ? (3+slen) : 0) + + (dlen ? (3+dlen) : 0) + + (klen ? (2+klen) : 0) + + (cd->bprot == BPROT_NONE ? 1 : 0); + + if((m = i4b_Dgetmbuf(len)) == NULL) { panic("i4b_l3_tx_setup: can't allocate mbuf\n"); } @@ -511,17 +504,31 @@ i4b_l3_tx_setup(call_desc_t *cd) break; } - *ptr++ = IEI_CALLINGPN; /* calling party no */ - *ptr++ = IEI_CALLINGPN_LEN+slen;/* calling party no length */ - *ptr++ = NUMBER_TYPEPLAN; /* type of number, number plan id */ - strncpy(ptr, cd->src_telno, slen); - ptr += slen; - - *ptr++ = IEI_CALLEDPN; /* called party no */ - *ptr++ = IEI_CALLEDPN_LEN+dlen; /* called party no length */ - *ptr++ = NUMBER_TYPEPLAN; /* type of number, number plan id */ - strncpy(ptr, cd->dst_telno, dlen); - ptr += dlen; + if(klen) + { + *ptr++ = IEI_KEYPAD; /* keypad facility */ + *ptr++ = klen; /* keypad facility length */ + strncpy(ptr, cd->keypad, klen); + ptr += klen; + } + + if(slen) + { + *ptr++ = IEI_CALLINGPN; /* calling party no */ + *ptr++ = IEI_CALLINGPN_LEN+slen;/* calling party no length */ + *ptr++ = NUMBER_TYPEPLAN; /* type of number, number plan id */ + strncpy(ptr, cd->src_telno, slen); + ptr += slen; + } + + if(dlen) + { + *ptr++ = IEI_CALLEDPN; /* called party no */ + *ptr++ = IEI_CALLEDPN_LEN+dlen; /* called party no length */ + *ptr++ = NUMBER_TYPEPLAN; /* type of number, number plan id */ + strncpy(ptr, cd->dst_telno, dlen); + ptr += dlen; + } DL_Data_Req(ctrl_desc[cd->controller].unit, m); } diff --git a/sys/i4b/layer3/i4b_q931.h b/sys/i4b/layer3/i4b_q931.h index 5568607..e00a8b4 100644 --- a/sys/i4b/layer3/i4b_q931.h +++ b/sys/i4b/layer3/i4b_q931.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved. + * 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 @@ -27,11 +27,9 @@ * i4b_q931.h - Q931 handling header file * -------------------------------------- * - * $Id: i4b_q931.h,v 1.9 2000/04/27 09:25:22 hm Exp $ - * * $FreeBSD$ * - * last edit-date: [Thu Apr 27 11:07:37 2000] + * last edit-date: [Thu Oct 18 13:29:01 2001] * *---------------------------------------------------------------------------*/ @@ -72,9 +70,11 @@ /* SETUP */ -#define MSG_SETUP_LEN 18 /* without number strings ! */ +#define MSG_SETUP_LEN 12 /* without called party, */ + /* calling party and */ + /* keypad facility ! */ -#define IEI_BEARERCAP_LEN 2 /* 2 octetts lenght */ +#define IEI_BEARERCAP_LEN 2 /* 2 octetts length */ #define IT_CAP_SPEECH 0x80 /* BC: information xfer capability */ #define IT_CAP_UNR_DIG_INFO 0x88 /* BC: information xfer capability */ diff --git a/sys/i4b/layer4/i4b_i4bdrv.c b/sys/i4b/layer4/i4b_i4bdrv.c index f5f3224..41b3c57 100644 --- a/sys/i4b/layer4/i4b_i4bdrv.c +++ b/sys/i4b/layer4/i4b_i4bdrv.c @@ -29,7 +29,7 @@ * * $FreeBSD$ * - * last edit-date: [Fri Jan 12 16:49:34 2001] + * last edit-date: [Wed Oct 17 13:37:56 2001] * *---------------------------------------------------------------------------*/ @@ -439,6 +439,12 @@ i4bioctl(dev_t dev, int cmd, caddr_t data, int flag, struct thread *td) strcpy(cd->dst_telno, mcr->dst_telno); strcpy(cd->src_telno, mcr->src_telno); + + 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); diff --git a/sys/i4b/layer4/i4b_l4.c b/sys/i4b/layer4/i4b_l4.c index 9cb3f26..4981b96 100644 --- a/sys/i4b/layer4/i4b_l4.c +++ b/sys/i4b/layer4/i4b_l4.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved. + * 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 @@ -27,11 +27,9 @@ * i4b_l4.c - kernel interface to userland * ----------------------------------------- * - * $Id: i4b_l4.c,v 1.54 2000/08/28 07:24:59 hm Exp $ - * * $FreeBSD$ * - * last edit-date: [Sun Aug 27 14:53:42 2000] + * last edit-date: [Thu Oct 18 13:31:22 2001] * *---------------------------------------------------------------------------*/ @@ -249,6 +247,33 @@ i4b_l4_dialoutnumber(int driver, int driver_unit, int cmdlen, char *cmd) } /*---------------------------------------------------------------------------* + * 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 diff --git a/sys/i4b/layer4/i4b_l4.h b/sys/i4b/layer4/i4b_l4.h index f1ec1e2..46f9aab 100644 --- a/sys/i4b/layer4/i4b_l4.h +++ b/sys/i4b/layer4/i4b_l4.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved. + * 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 @@ -27,11 +27,9 @@ * i4b_l4.h - kernel interface to userland header file * --------------------------------------------------- * - * $Id: i4b_l4.h,v 1.18 2000/04/27 11:35:01 hm Exp $ - * * $FreeBSD$ * - * last edit-date: [Thu Apr 27 13:28:01 2000] + * last edit-date: [Thu Oct 18 10:11:51 2001] * *---------------------------------------------------------------------------*/ @@ -49,6 +47,7 @@ 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 ); -- cgit v1.1