From d93ee4f68bcac6445f6c63f9d47a97919871f094 Mon Sep 17 00:00:00 2001 From: paul Date: Mon, 7 Jun 1999 19:25:38 +0000 Subject: [PATCH] isdnctrl.man.in --- isdnctrl/isdnctrl.c | 84 ++++++++++++++++++++++++++++++++++++++++++++- isdnctrl/isdnctrl.h | 7 +++- 2 files changed, 89 insertions(+), 2 deletions(-) diff --git a/isdnctrl/isdnctrl.c b/isdnctrl/isdnctrl.c index e5731359..3f8781a5 100644 --- a/isdnctrl/isdnctrl.c +++ b/isdnctrl/isdnctrl.c @@ -1,4 +1,4 @@ -/* $Id: isdnctrl.c,v 1.32 1998/12/23 12:51:44 paul Exp $ +/* $Id: isdnctrl.c,v 1.33 1999/06/07 19:25:38 paul Exp $ * ISDN driver for Linux. (Control-Utility) * * Copyright 1994,95 by Fritz Elfert (fritz@wuemaus.franken.de) @@ -21,6 +21,9 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Log: isdnctrl.c,v $ + * Revision 1.33 1999/06/07 19:25:38 paul + * isdnctrl.man.in + * * Revision 1.32 1998/12/23 12:51:44 paul * didn't compile with old kernel source * @@ -213,8 +216,14 @@ #include #include #include +#include #include + /* fix version skew between 2.0 and 2.1 kernels (structs are identical) */ +#if (NET_DV == 0x04) +# undef NET_DV +# define NET_DV 0x05 +#endif #include #include "config.h" @@ -320,6 +329,7 @@ void usage(void) fprintf(stderr, " writeconf [file] write the settings to file\n"); fprintf(stderr, " readconf [file] read the settings from file\n"); #endif /* I4L_CTRL_CONF */ + fprintf(stderr, " status name show interface status (connected or not)\n"); #ifdef I4L_CTRL_TIMRU fprintf(stderr,"Note: TIMRU Ctrl Extension-Support enabled\n"); #else @@ -513,6 +523,49 @@ static void listif(int isdnctrl, char *name, int errexit) nextslaveif[0] = 0; } + +#ifdef IIOCNETGPN +static void statusif(int isdnctrl, char *name, int errexit) +{ + isdn_net_ioctl_phone phone; + int rc; + static int isdninfo = -1; + + if (isdninfo < 0) { + isdninfo = open("/dev/isdninfo", O_RDONLY); + if (isdninfo < 0) { + perror("Can't open /dev/isdninfo"); + exit(-1); + } + } + memset(&phone, 0, sizeof phone); + strncpy(phone.name, name, sizeof phone.name); + rc = ioctl(isdninfo, IIOCNETGPN, &phone); + if (rc == 0) { + printf("%s connected %s %s\n", + name, phone.outgoing?"to":"from", phone.phone); + return; + } + if (errno == ENOTCONN) { + printf("%s is not connected\n", name); + if (errexit) { + exit(1); /* exit 1 if interface specified & not conn. */ + } + return; + } + if (errno == EINVAL) { + puts("Sorry, not configured in your kernel"); + exit(-1); + } + if (errexit) { + perror(name); + exit(-1); + } +} +#else +#warning IIOCNETGPN not defined? Old isdn4kernel? Or 2.0.x kernel... +#endif + int findcmd(char *str) { int i; @@ -913,6 +966,32 @@ int exec_args(int fd, int argc, char **argv) listif(fd, id, 1); break; + case STATUS: +#ifdef IIOCNETGPN + if (!strcmp(id, "all")) { + char name[10]; + if ((iflst = fopen(FILE_PROC, "r")) == NULL) { + perror(FILE_PROC); + return -1; + } + while (!feof(iflst)) { + fgets(s, sizeof(s), iflst); + if ((p = strchr(s, ':'))) { + *p = 0; + sscanf(s, "%s", name); + statusif(fd, name, 0); + while (*nextslaveif) + statusif(fd, nextslaveif, 0); + } + } + fclose(iflst); + } else + statusif(fd, id, 1); +#else + puts("Sorry, not configured into isdnctrl"); +#endif /* defined IIOCNETGPN */ + break; + case EAZ: strcpy(cfg.name, id); if ((result = ioctl(fd, IIOCNETGCF, &cfg)) < 0) { @@ -1568,6 +1647,9 @@ void check_version(int report) { return; } data_version = (data_version >> 8) & 0xff; + /* consider NET_DV 0x04 and 0x05 to be the same */ + if (data_version == 0x04) + data_version = 0x05; if (data_version != NET_DV) { fprintf(stderr, "Version of kernel ioctl structs (%d) does NOT match\n", data_version); diff --git a/isdnctrl/isdnctrl.h b/isdnctrl/isdnctrl.h index 175d083c..f848ca0f 100644 --- a/isdnctrl/isdnctrl.h +++ b/isdnctrl/isdnctrl.h @@ -1,4 +1,4 @@ -/* $Id: isdnctrl.h,v 1.13 1999/03/15 15:53:06 cpetig Exp $ +/* $Id: isdnctrl.h,v 1.14 1999/06/07 19:25:42 paul Exp $ * ISDN driver for Linux. (Control-Utility) * * Copyright 1994,95 by Fritz Elfert (fritz@wuemaus.franken.de) @@ -21,6 +21,9 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Log: isdnctrl.h,v $ + * Revision 1.14 1999/06/07 19:25:42 paul + * isdnctrl.man.in + * * Revision 1.13 1999/03/15 15:53:06 cpetig * added v110 and modem to the level2 encapsulations * @@ -113,6 +116,7 @@ enum { #ifdef I4L_CTRL_CONF WRITECONF, READCONF, #endif /* I4L_CTRL_CONF */ + STATUS, IFDEFAULTS }; @@ -182,6 +186,7 @@ cmd_struct cmds[] = {"writeconf", "01"}, {"readconf", "01"}, #endif /* I4L_CTRL_CONF */ + {"status", "1"}, {"ifdefaults", "01"}, {NULL,} };