add dwabc-udpinfo-utilitys in isdnctrl

This commit is contained in:
detabc 1999-11-07 22:04:05 +00:00
parent 8eb5be904e
commit 20e332c124
7 changed files with 360 additions and 3 deletions

View File

@ -1,4 +1,4 @@
# $Id: Makefile.in,v 1.14 1998/12/18 13:19:45 paul Exp $
# $Id: Makefile.in,v 1.15 1999/11/07 22:04:05 detabc Exp $
#
# Makefile for isdnctrl
# (C) 1997 Fritz Elfert
@ -35,10 +35,26 @@ MODULES += ctrltimru.o
MANPAGES += .isdnctrl_timru.8
endif
ifeq (@CONFIG_ISDNCTRL_DWABC_UDP_INFO@,y)
COPTS += -DI4L_DWABC_UDPINFO
ABCLIBDIR = /usr/lib
ABCICLDIR = /usr/include
endif
.SUFFIXES:
.SUFFIXES: .c .o
ifeq (@CONFIG_ISDNCTRL_DWABC_UDP_INFO@,y)
all: libisdnudp.a $(PROGRAMM)
LDFLAGS += libisdnudp.a
libisdnudp.a: isdn_dwabclib.o
ar rs libisdnudp.a isdn_dwabclib.o
ranlib libisdnudp.a
else
all: $(PROGRAM)
endif
%.o: %.c Makefile
$(CC) $(CFLAGS) $(INCLUDES) $(DEFS) $(COPTS) -c -o $@ $<
@ -80,6 +96,12 @@ install-man: $(MANPAGES)
install: $(PROGRAM) install-man
$(INSTALL) -d $(DESTDIR)$(SBINDIR)
$(INSTALL_PROGRAM) $(PROGRAM) $(DESTDIR)$(SBINDIR)/$(PROGRAM)
ifeq (@CONFIG_ISDNCTRL_DWABC_UDP_INFO@,y)
$(INSTALL) -d $(ABCLIBDIR)
$(INSTALL) -d $(ABCICLDIR)
$(INSTALL_MAN) libisdnudp.a $(ABCLIBDIR)/libisdnudp.a
$(INSTALL_MAN) isdn_dwabclib.h $(ABCICLDIR)/isdn_dwabclib.h
endif
install-strip: $(PROGRAM)
$(INSTALL) -d $(DESTDIR)$(SBINDIR)
@ -88,6 +110,9 @@ install-strip: $(PROGRAM)
uninstall:
rm -f $(DESTDIR)$(SBINDIR)/$(PROGRAM)
for i in $(MANPAGES) ; do rm $(DESTDIR)$(MAN8DIR)/$$i ; done
ifeq (@CONFIG_ISDNCTRL_DWABC_UDP_INFO@,y)
rm -f $(ABCLIBDIR)/libisdnudp.a $(ABCICLDIR)/isdn_dwabclib.h
endif
clean:
rm -f *.o *~ $(PROGRAM) *.man *.8 .*.man .*.8

2
isdnctrl/configure vendored
View File

@ -542,6 +542,7 @@ CONFIG_SBINDIR=${CONFIG_SBINDIR:-"/sbin"}
CONFIG_MANDIR=${CONFIG_MANDIR:-"/usr/man"}
CONFIG_ISDNCTRL_CONF=${CONFIG_ISDNCTRL_CONF:-"n"}
CONFIG_ISDNCTRL_TIMRU=${CONFIG_ISDNCTRL_TIMRU:-"n"}
CONFIG_ISDNCTRL_DWABC_UDP_INFO=${CONFIG_ISDNCTRL_DWABC_UDP_INFO:-"n"}
MANDATE=`grep CHECKIN isdnctrl.man.in | awk '{print $4}'`
ac_aux_dir=
@ -1700,6 +1701,7 @@ s%@CONFIG_ISDNCTRL_CONF@%$CONFIG_ISDNCTRL_CONF%g
s%@CONFIG_ISDNCTRL_TIMRU@%$CONFIG_ISDNCTRL_TIMRU%g
s%@CONFIG_SBINDIR@%$CONFIG_SBINDIR%g
s%@CONFIG_MANDIR@%$CONFIG_MANDIR%g
s%@CONFIG_ISDNCTRL_DWABC_UDP_INFO@%$CONFIG_ISDNCTRL_DWABC_UDP_INFO%g
CEOF
EOF

View File

@ -10,6 +10,7 @@ CONFIG_SBINDIR=${CONFIG_SBINDIR:-"/sbin"}
CONFIG_MANDIR=${CONFIG_MANDIR:-"/usr/man"}
CONFIG_ISDNCTRL_CONF=${CONFIG_ISDNCTRL_CONF:-"n"}
CONFIG_ISDNCTRL_TIMRU=${CONFIG_ISDNCTRL_TIMRU:-"n"}
CONFIG_ISDNCTRL_DWABC_UDP_INFO=${CONFIG_ISDNCTRL_DWABC_UDP_INFO:-"n"}
MANDATE=`grep CHECKIN isdnctrl.man.in | awk '{print $4}'`
dnl Checks for programs.
@ -80,6 +81,7 @@ AC_SUBST(I4LCONFFILE)
AC_SUBST(I4LVERSION)
AC_SUBST(CONFIG_ISDNCTRL_CONF)
AC_SUBST(CONFIG_ISDNCTRL_TIMRU)
AC_SUBST(CONFIG_ISDNCTRL_DWABC_UDP_INFO)
AC_SUBST(CONFIG_KERNELDIR)
AC_SUBST(CONFIG_SBINDIR)
AC_SUBST(CONFIG_MANDIR)

202
isdnctrl/isdn_dwabclib.c Normal file
View File

@ -0,0 +1,202 @@
/* $Id: isdn_dwabclib.c,v 1.1 1999/11/07 22:04:05 detabc Exp $
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: isdn_dwabclib.c,v $
* Revision 1.1 1999/11/07 22:04:05 detabc
* add dwabc-udpinfo-utilitys in isdnctrl
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <netdb.h>
#define RXRSZ 1500
static int txrx_udp_socket(char *dest,char *em,char *buf,int bytes)
/*****************************************************************
sizeof(*em) must be >= 1500 bytes
returns:
>= 0 readed bytes from isdn-link-level peer
< 0 -errno
*******************************************************************/
{
struct hostent *he = NULL;
short po = 0;
int sock = -1;
struct sockaddr_in SooooK, *ms;
ms = &SooooK;
if(dest == NULL || em == NULL) {
sprintf(em,"No Destination-Addr or error-pointer defined");
return(-9999);
}
if((he = gethostbyname(dest)) == NULL) {
sprintf(em,"gethostbyaddr(%s) failt errno %d",dest,errno);
err:;
if(sock > -1)
close(sock);
if(errno < sys_nerr)
sprintf(em + strlen(em)," (%s)",sys_errlist[errno]);
return(-errno);
}
if((sock = socket(AF_INET,SOCK_DGRAM,0)) < 0) {
sprintf(em,"socket creat faild errno %d",errno);
goto err;
}
memset((void *)ms,0,sizeof(*ms));
ms->sin_family = he->h_addrtype;
errno = 8888;
for(po = 3999; po >= 0; po--) {
ms->sin_port = htons(20000+po);
if(!bind(sock,ms,sizeof(*ms)))
break;
}
if(po < 0) {
sprintf(em,"cannot bind socket to (23999-20000)");
goto err;
}
memset((void *)ms,0,sizeof(*ms));
ms->sin_family = he->h_addrtype;
ms->sin_port = htons(25001);
memcpy(&ms->sin_addr.s_addr,*(he->h_addr_list),he->h_length);
if(sendto(sock,buf,bytes,0,ms,sizeof(*ms)) != bytes) {
sprintf(em,"sendto <%s> failt errno %d",dest,errno);
goto err;
}
{
fd_set rs;
struct timeval tv;
memset(&rs,0,sizeof(rs));
FD_SET(sock,&rs);
bytes = 0;
tv.tv_sec = 3;
tv.tv_usec = 0;
if((bytes = select(sock+1,&rs,NULL,NULL,&tv)) > 0) {
if(FD_ISSET(sock,&rs)) {
if((bytes = read(sock,em,RXRSZ)) < 0) {
sprintf(em,"read from socket failt errno %d",errno);
goto err;
}
}
} else if(bytes < 0) {
sprintf(em,"select failt errno %d",errno);
goto err;
}
}
close(sock);
return(bytes);
}
static int do_udp(char *dest,char **errm,int todo)
{
int r = 0;
char em[RXRSZ];
char sb[2];
sb[0] = sb[1] = todo;
todo++;
if((r = txrx_udp_socket(dest,em,sb,2)) >= 2) {
if(em[0] == todo && em[1] == todo)
return(1);
} else if(r < 0) {
if(errm != NULL) {
if((*errm = (char *)malloc(strlen(em)+1)) != NULL)
strcpy(*errm,em);
}
return(-r);
}
return(0);
}
int isdn_udp_isisdn(char *dest, char **errm)
{
return(do_udp(dest,errm,0x28));
}
int isdn_udp_online(char *dest, char **errm)
{
return(do_udp(dest,errm,0x30));
}
int isdn_udp_dial(char *dest, char **errm)
{
return(do_udp(dest,errm,0x32));
}
int isdn_udp_hangup(char *dest, char **errm)
{
return(do_udp(dest,errm,0x2a));
}
int isdn_udp_clear_ggau(char *dest, char **errm)
{
return(do_udp(dest,errm,0x11));
}

31
isdnctrl/isdn_dwabclib.h Normal file
View File

@ -0,0 +1,31 @@
/* $Id: isdn_dwabclib.h,v 1.1 1999/11/07 22:04:05 detabc Exp $
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: isdn_dwabclib.h,v $
* Revision 1.1 1999/11/07 22:04:05 detabc
* add dwabc-udpinfo-utilitys in isdnctrl
*
*/
#ifndef ISDN_DWABCLIB_H
#define ISDN_DWABCLIB_H 1
extern int isdn_udp_isisdn(char *dest, char **errm);
extern int isdn_udp_online(char *dest, char **errm);
extern int isdn_udp_dial(char *dest, char **errm);
extern int isdn_udp_hangup(char *dest, char **errm);
extern int isdn_udp_clear_ggau(char *dest, char **errm);
#endif

View File

@ -1,4 +1,4 @@
/* $Id: isdnctrl.c,v 1.36 1999/11/02 20:41:21 keil Exp $
/* $Id: isdnctrl.c,v 1.37 1999/11/07 22:04:05 detabc Exp $
* ISDN driver for Linux. (Control-Utility)
*
* Copyright 1994,95 by Fritz Elfert (fritz@isdn4linux.de)
@ -21,6 +21,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: isdnctrl.c,v $
* Revision 1.37 1999/11/07 22:04:05 detabc
* add dwabc-udpinfo-utilitys in isdnctrl
*
* Revision 1.36 1999/11/02 20:41:21 keil
* make phonenumber ioctl compatible for ctrlconf too
*
@ -228,6 +231,9 @@
#include <errno.h>
#include <linux/isdn.h>
#ifdef I4L_DWABC_UDPINFO
#include <isdn_dwabclib.h>
#endif
/* fix version skew between 2.0 and 2.1 kernels (structs are identical) */
#if (NET_DV == 0x04)
# undef NET_DV
@ -384,6 +390,12 @@ void usage(void)
fprintf(stderr,"Note: TIMRU Kernel Support enabled\n");
#else
fprintf(stderr,"Note: TIMRU Kernel Support disabled\n");
#endif
#ifdef I4L_DWABC_UDPINFO
fprintf(stderr," -udpisisdn destination-host or ip-number\n");
fprintf(stderr," -udponline destination-host or ip-number\n");
fprintf(stderr," -udphangup destination-host or ip-number\n");
fprintf(stderr," -udpdial destination-host or ip-number\n");
#endif
exit(-2);
}
@ -1747,6 +1759,86 @@ int main(int argc, char **argv)
check_version(1);
exit(0);
}
#ifdef I4L_DWABC_UDPINFO
{
int art = 0;
char *p = argv[1];
if(!strcmp(p,"-udpisisdn")) {
art = 1;
} else if(!strcmp(p,"-udponline")) {
art = 2;
} else if(!strcmp(p,"-udphangup")) {
art = 3;
} else if(!strcmp(p,"-udpdial")) {
art = 4;
}
if(art) {
char *err = NULL;
int retw = 0;
p = argv[2];
if(argc != 3) {
usage();
exit(1);
}
switch(art) {
case 1: retw = isdn_udp_isisdn(p,&err); break;
case 2: retw = isdn_udp_online(p,&err); break;
case 3: retw = isdn_udp_hangup(p,&err); break;
case 4: retw = isdn_udp_dial(p,&err); break;
}
if(err != NULL) {
fprintf(stderr,"%s\n",err);
free(err);
err = NULL;
}
if(!retw) {
switch(art) {
case 1:
printf("destination %s is NOT over i4l routed\n",p);
break;
case 2:
printf("destination %s is NOT online\n",p);
break;
case 3:
printf("destination %s CANNOT hangup the line\n",p);
break;
case 4:
printf("destination %s CANNOT dialing\n",p);
break;
}
} else {
switch(art) {
case 1:
printf("destination %s is over i4l routed\n",p);
break;
case 2:
printf("destination %s is online\n",p);
break;
case 3:
printf("destination %s trigger hangup \n",p);
break;
case 4:
printf("destination %s trigger dialing\n",p);
break;
}
}
exit(!retw);
}
}
#endif
check_version(0);
fd = open("/dev/isdnctrl", O_RDWR);

View File

@ -1,5 +1,5 @@
#
# $Id: config.in,v 1.31 1999/10/26 18:17:19 akool Exp $
# $Id: config.in,v 1.32 1999/11/07 22:04:05 detabc Exp $
#
# The whole configuration stuff is borrowed from the kernel
# configuration.
@ -54,6 +54,9 @@ if [ "$CONFIG_ISDNCTRL" = "y" ]; then
# bool 'Enable isdnctrl debug-option' CONFIG_ISDNCTRL_DEBUG
bool 'Enable configfile-option (uses dbm lib)' CONFIG_ISDNCTRL_CONF
bool 'Enable timru-controls' CONFIG_ISDNCTRL_TIMRU
if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
bool 'Enable udp-info-controls' CONFIG_ISDNCTRL_DWABC_UDP_INFO
fi
fi
bool 'iprofd' CONFIG_IPROFD
bool 'divertctrl' CONFIG_DIVERTCTRL