Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Aug 1998 18:14:10 +0200
From:      Julian Stacey <jhs@FreeBSD.ORG>
To:        hm@kts.org
Cc:        freebsd-isdn@FreeBSD.ORG
Subject:   Patches to add names instead of numbers to i4b monitor and log
Message-ID:  <199808171614.SAA01234@jhs.muc.de>

next in thread | raw e-mail | index | archive | help
Hi Hellmuth,
cc freebsd-isdn@freebsd.org

Here are i4b patches to display phone caller's names instead of numbers to the
i4b monitor screen and log  ( isdnd -f & tail -f /var/log/isdn ).
I wrote it this afternoon, so I expect I'll tweak it later, 
it works on my isdnd 00.63 + FreeBSD 2.2.6-RELEASE. It's only 10K, so appended.

Hopefully it can be integrated into master sources, once it meets approval.

Any later versions I generate will appear in my web trees:
	http://www.muc.de/~jhs/src/bsd/fixes/FreeBSD/src/i4b_gen/i4b/isdnd/
	http://www.freebsd.org/~jhs/src/bsd/fixes/FreeBSD/src/i4b_gen/i4b/isdnd/
(long names, but my automatic customiser knows to grab it from there)
& I'll mail any signifcant changes to hm@kts.org

PS
The current generic code (& mine too) says
	"[from] 8178955331"
when (I think) I'd prefer it to say
	"from 08178955331"
but I didn't change this, 
so /etc/isdn/isdntel.alias need to have leading zeroes stripped off,
which is unfortunate as that's not compatible with /usr/ports/misc/estic
(ISDN TK-Anlage PBX control program) & probably other local tables of numbers.
Perhaps hm@ can restore the leading zero in next release please ? Thanks.

-------------
cd src/i4b/isdnd 
	ln -s ../isdntel/alias.c
	ln -s ../isdntel/defs.h
(If/when i4b is integrated into FreeBSD (& NetBSD etc) we'll need to
do something else, as links are not allowed in FreeBSD src/ )

*** 00.63/src/i4b/isdnd/Makefile	Mon Aug 17 17:30:36 1998
--- numbers_to_names/src/i4b/isdnd/Makefile	Mon Aug 17 15:27:12 1998
***************
*** 8,14 ****
  
  PROG	=	isdnd
  SRCS	=	rc_parse.y rc_scan.l main.c rc_config.c log.c curses.c	\
! 		process.c rates.c msghdl.c fsm.c support.c timer.c	\
  		exec.c dial.c monitor.c pcause.c
  
  .if (${BSDTYPE} == "FreeBSD" && ${RELEASE} == "3.0-CURRENT")
--- 8,14 ----
  
  PROG	=	isdnd
  SRCS	=	rc_parse.y rc_scan.l main.c rc_config.c log.c curses.c	\
! 		process.c rates.c alias.c msghdl.c fsm.c support.c timer.c \
  		exec.c dial.c monitor.c pcause.c
  
  .if (${BSDTYPE} == "FreeBSD" && ${RELEASE} == "3.0-CURRENT")
*** 00.63/src/i4b/isdnd/main.c	Mon Aug 17 17:30:13 1998
--- numbers_to_names/src/i4b/isdnd/main.c	Mon Aug 17 16:15:14 1998
***************
*** 52,57 ****
--- 52,62 ----
  #include "isdnd.h"
  #undef MAIN
  
+ #define ALIASFILE       "/etc/isdn/isdntel.alias"
+ /* tons of stuff I don't want in ../isdntel/defs.h,
+ 	so I'm leaving hm@kts.org to move this duplicate ALIASFILE define
+ 	to somewhere common, later */
+ 
  #ifdef I4B_EXTERNAL_MONITOR
  
  #ifdef I4B_NOTCPIP_MONITOR
***************
*** 91,101 ****
  	int remotesockfd = -1;		/* tcp/ip monitor socket */
  #endif
  #endif
  	
! 	while ((i = getopt(argc, argv, "bmc:d:fFlL:r:s:t:u:?")) != EOF)
  	{
  		switch (i)
  		{
  			case 'b':
  				do_bell = 1;
  				break;
--- 96,112 ----
  	int remotesockfd = -1;		/* tcp/ip monitor socket */
  #endif
  #endif
+ 	void init_alias(char *filename) ;
+ 	char *aliasfile = ALIASFILE;
  	
! 	while ((i = getopt(argc, argv, "a:bmc:d:fFlL:r:s:t:u:?")) != EOF)
  	{
  		switch (i)
  		{
+ 			case 'a':
+                                 aliasfile = optarg; 
+                                 break;
+ 
  			case 'b':
  				do_bell = 1;
  				break;
***************
*** 333,338 ****
--- 344,353 ----
  	}
  #endif
  
+ 	/* Initialise aliases table (not necessary for functionality,
+ 	   but names look nicer than numbers in log & monitor display mode */
+ 	init_alias(aliasfile);
+ 
  	srandom(580403);	/* init random number gen */
  	
  	mloop(		/* enter loop of no return .. */
***************
*** 379,388 ****
  {
  	fprintf(stderr, "\n");
  	fprintf(stderr, "isdnd - i4b ISDN manager daemon, version %02d.%02d, compiled %s %s\n", VERSION, REL, __DATE__, __TIME__);
  #ifdef DEBUG
! 	fprintf(stderr, "  usage: isdnd [-b] [-c file] [-d level] [-F]\n");
  #else
! 	fprintf(stderr, "  usage: isdnd [-b] [-c file] [-F]\n");
  #endif	
  	fprintf(stderr, "                [-f [-r dev] [-t termtype]] [-u time]\n");
  	fprintf(stderr, "                [-l] [-L file] [-s facility] [-m]\n");
--- 394,404 ----
  {
  	fprintf(stderr, "\n");
  	fprintf(stderr, "isdnd - i4b ISDN manager daemon, version %02d.%02d, compiled %s %s\n", VERSION, REL, __DATE__, __TIME__);
+ 	fprintf(stderr, "  usage: isdnd -a <filename> alias file name (def: %s)\n", ALIASFILE);
  #ifdef DEBUG
! 	fprintf(stderr, "  [-b] [-c file] [-d level] [-F]\n");
  #else
! 	fprintf(stderr, "  [-b] [-c file] [-F]\n");
  #endif	
  	fprintf(stderr, "                [-f [-r dev] [-t termtype]] [-u time]\n");
  	fprintf(stderr, "                [-l] [-L file] [-s facility] [-m]\n");
*** 00.63/src/i4b/isdnd/msghdl.c	Mon Aug 17 17:30:13 1998
--- numbers_to_names/src/i4b/isdnd/msghdl.c	Mon Aug 17 15:51:01 1998
***************
*** 46,63 ****
  #include "isdnd.h"
  
  /*---------------------------------------------------------------------------*
   *	handle incoming CONNECT_IND (=SETUP) message
   *---------------------------------------------------------------------------*/
  void
  msg_connect_ind(msg_connect_ind_t *mp)
  {
  	cfg_entry_t *cep;
  
  	if((cep = find_entry(mp->header.cdid, mp->controller, mp->channel,
  		mp->bprot, mp->dst_telno, mp->src_telno, mp->scr_ind)) == NULL)
  	{
! 		log(LL_CHD, "%05d <unknown> incoming call from %s to %s",
! 		    CDID_UNUSED, mp->src_telno, mp->dst_telno);
  		sendm_connect_resp(NULL, mp->header.cdid, SETUP_RESP_DNTCRE, 0);
  		return;
  	}
--- 46,116 ----
  #include "isdnd.h"
  
  /*---------------------------------------------------------------------------*
+  *      fatal error exit
+  *---------------------------------------------------------------------------*/
+ void
+ fatal(char *fmt, ...)
+ {
+ #if 0	/* Original from ../isdntel/main.c */
+         va_list ap;
+                         
+         va_start(ap, fmt);
+ 
+         if(curses_ready)
+         {       
+                 move(LINES-1, 0);
+                 clrtoeol();
+                 refresh();
+                 endwin();
+         }       
+                         
+         fprintf(stderr, "\nFatal error: ");
+         vfprintf(stderr, fmt, ap);
+         fprintf(stderr, "\n\n");
+                 
+         va_end(ap);
+                         
+         exit(1);
+ #endif
+ 	log(LL_CHD, "%05d Fatal alias error", CDID_UNUSED );
+ 	do_exit(1);
+ }                               
+ 
+ /*---------------------------------------------------------------------------*
+  *	convert phone numbers to names where possible
+  *---------------------------------------------------------------------------*/
+ char *
+ number_name(char *number)
+ {
+ 	char * get_alias(char *number) ;
+ 	char *tmp ;
+ 
+ 	if ((tmp = get_alias(number)) != NULL ) return tmp ;
+ 	else return number ;
+ }
+ 
+ /*---------------------------------------------------------------------------*
   *	handle incoming CONNECT_IND (=SETUP) message
   *---------------------------------------------------------------------------*/
  void
  msg_connect_ind(msg_connect_ind_t *mp)
  {
  	cfg_entry_t *cep;
+ 	char *src_telna, *dst_telna ;
+ 
+ 	src_telna = number_name(mp->src_telno);
+ 	dst_telna = number_name(mp->dst_telno);
  
  	if((cep = find_entry(mp->header.cdid, mp->controller, mp->channel,
  		mp->bprot, mp->dst_telno, mp->src_telno, mp->scr_ind)) == NULL)
  	{
! 		/* I jhs presume if you configure /etc/isdn/isdnd.rc to accept
! 			 anonymous data calls, that find_entry returns not NULL
! 		   in which case "non data" below is correct, 
! 		   hm@ plse confirm */
! 		/* "non data" = phone or fax (etc ?) */
! 		log(LL_CHD, "%05d non data call in from %s to %s",
! 		    CDID_UNUSED, src_telna, dst_telna );
  		sendm_connect_resp(NULL, mp->header.cdid, SETUP_RESP_DNTCRE, 0);
  		return;
  	}
***************
*** 65,71 ****
  	if(cep->inout == DIR_OUTONLY)
  	{
  		log(LL_CHD, "%05d %s incoming call from %s to %s not allowed by configuration!",
! 		    CDID_UNUSED, cep->name, mp->src_telno, mp->dst_telno);
  		sendm_connect_resp(NULL, mp->header.cdid, SETUP_RESP_DNTCRE, 0);
  		return;
  	}
--- 118,124 ----
  	if(cep->inout == DIR_OUTONLY)
  	{
  		log(LL_CHD, "%05d %s incoming call from %s to %s not allowed by configuration!",
! 		    CDID_UNUSED, cep->name, src_telna, dst_telna);
  		sendm_connect_resp(NULL, mp->header.cdid, SETUP_RESP_DNTCRE, 0);
  		return;
  	}
***************
*** 77,90 ****
  	{
  		case REACT_ACCEPT:
  			log(LL_CHD, "%05d %s accepting: incoming call from %s to %s",
! 				mp->header.cdid, cep->name, mp->src_telno, mp->dst_telno);
  			next_state(cep, EV_MCI);
  			break;
  
  		case REACT_REJECT:
  			log(LL_CHD, "%05d %s rejecting: incoming call from %s to %s",
  				CDID_UNUSED, cep->name,
! 				mp->src_telno, mp->dst_telno);
  			sendm_connect_resp(cep, mp->header.cdid, SETUP_RESP_REJECT,
  				(CAUSET_I4B << 8) | CAUSE_I4B_REJECT);
  			cep->cdid = CDID_UNUSED;
--- 130,144 ----
  	{
  		case REACT_ACCEPT:
  			log(LL_CHD, "%05d %s accepting: incoming call from %s to %s",
! 				mp->header.cdid, cep->name, 
! 				src_telna, dst_telna);
  			next_state(cep, EV_MCI);
  			break;
  
  		case REACT_REJECT:
  			log(LL_CHD, "%05d %s rejecting: incoming call from %s to %s",
  				CDID_UNUSED, cep->name,
! 				src_telna, dst_telna);
  			sendm_connect_resp(cep, mp->header.cdid, SETUP_RESP_REJECT,
  				(CAUSET_I4B << 8) | CAUSE_I4B_REJECT);
  			cep->cdid = CDID_UNUSED;
***************
*** 93,99 ****
  		case REACT_IGNORE:
  			log(LL_CHD, "%05d %s ignoring: incoming call from %s to %s",
  				CDID_UNUSED, cep->name,
! 				mp->src_telno, mp->dst_telno);
  			sendm_connect_resp(NULL, mp->header.cdid, SETUP_RESP_DNTCRE, 0);
  			break;
  
--- 147,153 ----
  		case REACT_IGNORE:
  			log(LL_CHD, "%05d %s ignoring: incoming call from %s to %s",
  				CDID_UNUSED, cep->name,
! 				src_telna, dst_telna);
  			sendm_connect_resp(NULL, mp->header.cdid, SETUP_RESP_DNTCRE, 0);
  			break;
  
***************
*** 102,115 ****
  			{
  				log(LL_CHD, "%05d %s alerting: incoming call from %s to %s",
  				        mp->header.cdid, cep->name,
! 				        mp->src_telno, mp->dst_telno);
  				next_state(cep, EV_ALRT);
  			}
  			else
  			{
  				log(LL_CHD, "%05d %s answering: incoming call from %s to %s",
  					mp->header.cdid, cep->name,
! 				        mp->src_telno, mp->dst_telno);
  				next_state(cep, EV_MCI);
  			}
  			break;
--- 156,169 ----
  			{
  				log(LL_CHD, "%05d %s alerting: incoming call from %s to %s",
  				        mp->header.cdid, cep->name,
! 				        src_telna, dst_telna);
  				next_state(cep, EV_ALRT);
  			}
  			else
  			{
  				log(LL_CHD, "%05d %s answering: incoming call from %s to %s",
  					mp->header.cdid, cep->name,
! 				        src_telna, dst_telna);
  				next_state(cep, EV_MCI);
  			}
  			break;
***************
*** 119,125 ****
  			{
  				log(LL_CHD, "%05d %s reserved: incoming call from %s to %s",
  					CDID_UNUSED, cep->name,
! 					mp->src_telno, mp->dst_telno);
  				sendm_connect_resp(cep, mp->header.cdid, SETUP_RESP_REJECT,
  					(CAUSET_I4B << 8) | CAUSE_I4B_NORMAL);
  				/* no state change */
--- 173,179 ----
  			{
  				log(LL_CHD, "%05d %s reserved: incoming call from %s to %s",
  					CDID_UNUSED, cep->name,
! 					src_telna, dst_telna);
  				sendm_connect_resp(cep, mp->header.cdid, SETUP_RESP_REJECT,
  					(CAUSET_I4B << 8) | CAUSE_I4B_NORMAL);
  				/* no state change */
***************
*** 128,134 ****
  			{
  				log(LL_CHD, "%05d %s callback: incoming call from %s to %s",
  					CDID_UNUSED, cep->name,
! 					mp->src_telno, mp->dst_telno);
  				sendm_connect_resp(cep, mp->header.cdid, SETUP_RESP_REJECT,
  					(CAUSET_I4B << 8) | CAUSE_I4B_NORMAL);
  				cep->last_release_time = time(NULL);
--- 182,188 ----
  			{
  				log(LL_CHD, "%05d %s callback: incoming call from %s to %s",
  					CDID_UNUSED, cep->name,
! 					src_telna, dst_telna);
  				sendm_connect_resp(cep, mp->header.cdid, SETUP_RESP_REJECT,
  					(CAUSET_I4B << 8) | CAUSE_I4B_NORMAL);
  				cep->last_release_time = time(NULL);
Julian
Julian H. Stacey	http://www.muc.de/~jhs/
	Free email privacy encryption package:	http://www.ifi.uio.no/pgp/ 

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-isdn" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199808171614.SAA01234>