diff options
author | Hellmuth Michaelis <hm@FreeBSD.org> | 2001-10-18 11:58:49 +0000 |
---|---|---|
committer | Hellmuth Michaelis <hm@FreeBSD.org> | 2001-10-18 11:58:49 +0000 |
commit | 8f3a90354e8d2c69aecb2e98ecf71b8538745d89 (patch) | |
tree | dcfe434253eaa1290451be56d7a4ca351036de67 /usr.sbin/i4b | |
parent | 4f63c70a2b69a18f1a0fa253f5e930600ea1e18e (diff) |
Add experimental support for sending keypad facility messages.
MFC after: 2 months
Notes
Notes:
svn path=/head/; revision=85103
Diffstat (limited to 'usr.sbin/i4b')
-rw-r--r-- | usr.sbin/i4b/isdnd/dial.c | 9 | ||||
-rw-r--r-- | usr.sbin/i4b/isdnd/isdnd.h | 4 | ||||
-rw-r--r-- | usr.sbin/i4b/isdnd/main.c | 6 | ||||
-rw-r--r-- | usr.sbin/i4b/isdnd/msghdl.c | 61 | ||||
-rw-r--r-- | usr.sbin/i4b/isdnd/support.c | 76 | ||||
-rw-r--r-- | usr.sbin/i4b/isdnphone/isdnphone.8 | 16 | ||||
-rw-r--r-- | usr.sbin/i4b/isdnphone/main.c | 24 |
7 files changed, 172 insertions, 24 deletions
diff --git a/usr.sbin/i4b/isdnd/dial.c b/usr.sbin/i4b/isdnd/dial.c index dff8787dc5b7..0bb362ce4fc7 100644 --- a/usr.sbin/i4b/isdnd/dial.c +++ b/usr.sbin/i4b/isdnd/dial.c @@ -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 daemon - dial handling routines * ----------------------------------- * - * $Id: dial.c,v 1.8 1999/12/13 21:25:24 hm Exp $ - * * $FreeBSD$ * - * last edit-date: [Mon Dec 13 21:45:51 1999] + * last edit-date: [Thu Oct 18 11:05:01 2001] * *---------------------------------------------------------------------------*/ @@ -46,6 +44,9 @@ select_first_dialno(cfg_entry_t *cep) { int i, j; + if(cep->keypad[0] != '\0') + return; + if(cep->remote_numbers_count < 1) { log(LL_ERR, "select_first_dialno: remote_numbers_count < 1!"); diff --git a/usr.sbin/i4b/isdnd/isdnd.h b/usr.sbin/i4b/isdnd/isdnd.h index 863bf7c4c2bd..557bf178a203 100644 --- a/usr.sbin/i4b/isdnd/isdnd.h +++ b/usr.sbin/i4b/isdnd/isdnd.h @@ -29,7 +29,7 @@ * * $FreeBSD$ * - * last edit-date: [Fri Jul 20 19:17:29 2001] + * last edit-date: [Thu Oct 18 10:59:41 2001] * *---------------------------------------------------------------------------*/ @@ -501,6 +501,7 @@ typedef struct cfg_entry { #define BUDGET_TYPE_CBACK 1 #define BUDGET_TYPE_COUT 2 + char keypad[KEYPAD_MAX]; /* keypad string */ } cfg_entry_t; /*---------------------------------------------------------------------------* @@ -752,6 +753,7 @@ int exec_connect_prog ( cfg_entry_t *cep, const char *prog, int link_down ); pid_t exec_prog ( char *prog, char **arglist ); cfg_entry_t * find_by_device_for_dialout ( int drivertype, int driverunit ); cfg_entry_t *find_by_device_for_dialoutnumber(int drivertype, int driverunit, int cmdlen, char *cmd); +cfg_entry_t *find_by_device_for_keypad(int drivertype, int driverunit, int cmdlen, char *cmd); cfg_entry_t * find_matching_entry_incoming ( msg_connect_ind_t *mp ); cfg_entry_t * find_active_entry_by_driver ( int drivertype, int driverunit ); void finish_log ( void ); diff --git a/usr.sbin/i4b/isdnd/main.c b/usr.sbin/i4b/isdnd/main.c index 5c5a365cbaef..126886666a4d 100644 --- a/usr.sbin/i4b/isdnd/main.c +++ b/usr.sbin/i4b/isdnd/main.c @@ -29,7 +29,7 @@ * * $FreeBSD$ * - * last edit-date: [Tue Jun 5 17:06:20 2001] + * last edit-date: [Thu Oct 18 13:57:45 2001] * *---------------------------------------------------------------------------*/ @@ -713,6 +713,10 @@ isdnrdhdl(void) msg_packet_ind((msg_packet_ind_t *)msg_rd_buf); break; + case MSG_KEYPAD_IND: + msg_keypad((msg_keypad_ind_t *)msg_rd_buf); + break; + default: log(LL_WRN, "ERROR, unknown message received from %sisdn (0x%x)", _PATH_DEV, msg_rd_buf[0]); break; diff --git a/usr.sbin/i4b/isdnd/msghdl.c b/usr.sbin/i4b/isdnd/msghdl.c index fa2354ada03f..d53f5787e803 100644 --- a/usr.sbin/i4b/isdnd/msghdl.c +++ b/usr.sbin/i4b/isdnd/msghdl.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 daemon - message from kernel handling routines * -------------------------------------------------- * - * $Id: msghdl.c,v 1.78 2000/09/21 11:29:51 hm Exp $ - * * $FreeBSD$ * - * last edit-date: [Thu Sep 21 11:11:48 2000] + * last edit-date: [Thu Oct 18 11:13:29 2001] * *---------------------------------------------------------------------------*/ @@ -868,6 +866,60 @@ msg_dialoutnumber(msg_dialoutnumber_ind_t *mp) DBGL(DL_DRVR, (log(LL_DBG, "msg_dialoutnumber: get_cdid() returned 0!"))); return; } + + cep->keypad[0] = '\0'; + cep->charge = 0; + cep->last_charge = 0; + cep->hangup = 0; + + next_state(cep, EV_MDO); +} + +/*---------------------------------------------------------------------------* + * handle incoming KEYPAD message + *---------------------------------------------------------------------------*/ +void +msg_keypad(msg_keypad_ind_t *mp) +{ + cfg_entry_t *cep; + + DBGL(DL_DRVR, (log(LL_DBG, "msg_keypad: dial req from %s, unit %d", bdrivername(mp->driver), mp->driver_unit))); + + if((cep = find_by_device_for_keypad(mp->driver, mp->driver_unit, mp->cmdlen, mp->cmd)) == NULL) + { + DBGL(DL_DRVR, (log(LL_DBG, "msg_keypad: config entry reserved or no match"))); + return; + } + + if(cep->inout == DIR_INONLY) + { + dialresponse(cep, DSTAT_INONLY); + return; + } + + if(cep->budget_calloutperiod && cep->budget_calloutncalls) + { + cep->budget_calltype = 0; + cep->budget_callout_req++; + + if(cep->budget_calloutncalls_cnt == 0) + { + log(LL_CHD, "%05d %s no budget for calling out", 0, cep->name); + cep->budget_callout_rej++; + dialresponse(cep, DSTAT_TFAIL); + return; + } + else + { + cep->budget_calltype = BUDGET_TYPE_COUT; + } + } + + if((cep->cdid = get_cdid()) == 0) + { + DBGL(DL_DRVR, (log(LL_DBG, "msg_keypad: get_cdid() returned 0!"))); + return; + } cep->charge = 0; cep->last_charge = 0; @@ -1166,6 +1218,7 @@ sendm_connect_req(cfg_entry_t *cep) strcpy(mcr.dst_telno, cep->remote_phone_dialout); strcpy(mcr.src_telno, cep->local_phone_dialout); + strcpy(mcr.keypad, cep->keypad); cep->last_dial_time = time(NULL); cep->direction = DIR_OUT; diff --git a/usr.sbin/i4b/isdnd/support.c b/usr.sbin/i4b/isdnd/support.c index f9585c3abaf9..92e52228c8ca 100644 --- a/usr.sbin/i4b/isdnd/support.c +++ b/usr.sbin/i4b/isdnd/support.c @@ -29,7 +29,7 @@ * * $FreeBSD$ * - * last edit-date: [Thu May 3 17:15:00 2001] + * last edit-date: [Thu Oct 18 13:14:55 2001] * *---------------------------------------------------------------------------*/ @@ -191,6 +191,8 @@ find_by_device_for_dialoutnumber(int drivertype, int driverunit, int cmdlen, cha return(NULL); } + cep->keypad[0] = '\0'; + /* check number and copy to cep->remote_numbers[] */ for(j = 0; j < cmdlen; j++) @@ -225,6 +227,78 @@ find_by_device_for_dialoutnumber(int drivertype, int driverunit, int cmdlen, cha } /*---------------------------------------------------------------------------* + * find entry by drivertype and driverunit and setup for send keypad + *---------------------------------------------------------------------------*/ +cfg_entry_t * +find_by_device_for_keypad(int drivertype, int driverunit, int cmdlen, char *cmd) +{ + cfg_entry_t *cep = NULL; + int i, j; + + for(i=0; i < nentries; i++) + { + cep = &cfg_entry_tab[i]; /* ptr to config entry */ + + /* compare driver type and unit */ + + if(!((cep->usrdevicename == drivertype) && + (cep->usrdeviceunit == driverunit))) + { + continue; + } + + /* check time interval */ + + if(isvalidtime(cep) == 0) + { + DBGL(DL_MSG, (log(LL_DBG, "find_by_device_for_keypad: entry %d, time not valid!", i))); + continue; + } + + /* found, check if already reserved */ + + if(cep->cdid == CDID_RESERVED) + { + DBGL(DL_MSG, (log(LL_DBG, "find_by_device_for_keypad: entry %d, cdid reserved!", i))); + return(NULL); + } + + /* check if this entry is already in use ? */ + + if(cep->cdid != CDID_UNUSED) + { + DBGL(DL_MSG, (log(LL_DBG, "find_by_device_for_keypad: entry %d, cdid in use", i))); + return(NULL); + } + + cep->remote_numbers[0].number[0] = '\0'; + cep->remote_numbers_count = 0; + cep->remote_phone_dialout[0] = '\0'; + + bzero(cep->keypad, KEYPAD_MAX); + strncpy(cep->keypad, cmd, cmdlen); + + DBGL(DL_MSG, (log(LL_DBG, "find_by_device_for_keypad: entry %d, keypad string is %s", i, cep->keypad))); + + if((setup_dialout(cep)) == GOOD) + { + /* found an entry to be used for calling out */ + + DBGL(DL_MSG, (log(LL_DBG, "find_by_device_for_keypad: found entry %d!", i))); + return(cep); + } + else + { + DBGL(DL_MSG, (log(LL_DBG, "find_by_device_for_keypad: entry %d, setup_dialout() failed!", i))); + return(NULL); + } + } + + DBGL(DL_MSG, (log(LL_DBG, "find_by_device_for_keypad: no entry found!"))); + return(NULL); +} + +/*---------------------------------------------------------------------------* * find entry by drivertype and driverunit and setup for dialing out *---------------------------------------------------------------------------*/ int diff --git a/usr.sbin/i4b/isdnphone/isdnphone.8 b/usr.sbin/i4b/isdnphone/isdnphone.8 index 72addf98e9fd..997010f2209f 100644 --- a/usr.sbin/i4b/isdnphone/isdnphone.8 +++ b/usr.sbin/i4b/isdnphone/isdnphone.8 @@ -1,5 +1,5 @@ .\" -.\" Copyright (c) 1999 Hellmuth Michaelis. All rights reserved. +.\" Copyright (c) 1999, 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 @@ -22,14 +22,12 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: isdnphone.8,v 1.4 1999/12/13 22:11:55 hm Exp $ -.\" .\" $FreeBSD$ .\" -.\" last edit-date: [Mon Dec 13 23:05:19 1999] +.\" last edit-date: [Thu Oct 18 13:36:52 2001] .\" .\" -.Dd March 24, 1999 +.Dd October 18, 2001 .Dt ISDNPHONE 8 .Os .Sh NAME @@ -37,7 +35,9 @@ .Nd telephone dialing and more for isdn4bsd .Sh SYNOPSIS .Nm +.Op Fl d .Op Fl h +.Op Fl k Ar string .Op Fl n Ar number .Op Fl u Ar unit .Sh DESCRIPTION @@ -51,8 +51,12 @@ a curses-based fullscreen interface. .Pp The following options are available: .Bl -tag -width Ds +.It Fl d +enable debugging message display. .It Fl h hang up a possibly open telefone connection on the selected interface. +.It Fl k +send the specified string using the keypad facility information element. .It Fl n dial the specified number on the selected interface. .It Fl u @@ -71,4 +75,4 @@ dials calls the number 1234 to establish a call on /dev/i4btel0 The .Nm utility and this manpage were written by -.An Hellmuth Michaelis Aq hm@kts.org . +.An Hellmuth Michaelis Aq hm@freebsd.org . diff --git a/usr.sbin/i4b/isdnphone/main.c b/usr.sbin/i4b/isdnphone/main.c index af463570c909..c79e7795136e 100644 --- a/usr.sbin/i4b/isdnphone/main.c +++ b/usr.sbin/i4b/isdnphone/main.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Hellmuth Michaelis. All rights reserved. + * Copyright (c) 1999, 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 @@ * isdnphone - main module * ======================= * - * $Id: main.c,v 1.12 1999/12/13 21:25:26 hm Exp $ - * * $FreeBSD$ * - * last edit-date: [Mon Dec 13 21:53:25 1999] + * last edit-date: [Wed Oct 17 14:08:44 2001] * *---------------------------------------------------------------------------*/ @@ -48,9 +46,10 @@ usage(void) { fprintf(stderr, "\n"); fprintf(stderr, "isdnphone - i4b phone program, version %d.%d.%d, compiled %s %s\n",VERSION, REL, STEP, __DATE__, __TIME__); - fprintf(stderr, "usage: isdnphone -d -h -n <number> -u <unit>\n"); + fprintf(stderr, "usage: isdnphone -d -h -k <string> -n <number> -u <unit>\n"); fprintf(stderr, " -d debug\n"); fprintf(stderr, " -h hangup\n"); + fprintf(stderr, " -k string keypad string\n"); fprintf(stderr, " -n number dial number\n"); fprintf(stderr, " -u unit set unit number\n"); fprintf(stderr, "\n"); @@ -69,11 +68,12 @@ main(int argc, char **argv) int ret; int opt_n = 0; int opt_h = 0; + int opt_k = 0; char *number = ""; numberbuffer[0] = '\0'; - while ((c = getopt(argc, argv, "dhn:u:")) != -1) + while ((c = getopt(argc, argv, "dhk:n:u:")) != -1) { switch(c) { @@ -85,6 +85,11 @@ main(int argc, char **argv) opt_h = 1; break; + case 'k': + number = optarg; + opt_k = 1; + break; + case 'n': number = optarg; opt_n = 1; @@ -108,7 +113,7 @@ main(int argc, char **argv) if((dialerfd = init_dial(namebuffer)) == -1) exit(1); - if(opt_n || opt_h) + if(opt_n || opt_h || opt_k) { char commandbuffer[80]; @@ -119,6 +124,11 @@ main(int argc, char **argv) sprintf(commandbuffer, "D%s", number); } + else if(opt_k) + { + sprintf(commandbuffer, "K%s", number); + + } else if(opt_h) { sprintf(commandbuffer, "H"); |