diff -u -r isdn4k-utils-2.0/doc/isdnctrl.8 isdn4k-utils-2.0.new/doc/isdnctrl.8
--- isdn4k-utils-2.0/doc/isdnctrl.8	Mon Jul  1 17:44:38 1996
+++ isdn4k-utils-2.0.new/doc/isdnctrl.8	Mon Jul  1 17:14:54 1996
@@ -97,6 +97,21 @@
 info will be received if the interface is inactive. If none of
 on or off is given the current setting is printed.
 .TP 5
+.B chargeint name [seconds]
+When "seconds" are given, the charge interval for the given
+interface is set. This may be of use on ISDN lines with no
+chargeinfo or no online chargeinfo. The connection will only
+be closed 2 seconds before the end of the next charge interval
+and only, if 
+.I huptimeout
+seconds of inactivity have been reached. If 
+.I ihup 
+is on, also incomming connections are closed by this mechanism.
+On lines with online charge info you also might ask by 
+.I chargeint name 
+for the current charge interval as delivered from the
+telecom on a given interface.
+.TP 5
 .B secure name [on|off]
 Turns on or off the security feature for interface "name". If
 set to on, incoming calls will only be accepted if the calling
diff -u -r isdn4k-utils-2.0/isdn/isdnctrl.c isdn4k-utils-2.0.new/isdn/isdnctrl.c
--- isdn4k-utils-2.0/isdn/isdnctrl.c	Mon Jul  1 17:44:30 1996
+++ isdn4k-utils-2.0.new/isdn/isdnctrl.c	Mon Jul  1 19:50:34 1996
@@ -118,6 +118,7 @@
   fprintf(stderr,"    huptimeout name [seconds]  (get/set hangup-timeout for interface)\n");
   fprintf(stderr,"    ihup name [on|off]         (get/set incoming-hangup for interface)\n");
   fprintf(stderr,"    chargehup name [on|off]    (get/set charge-hangup for interface)\n");
+  fprintf(stderr,"    chargeint name [seconds]   (get/set charge-interval if not given by telco)\n");
   fprintf(stderr,"    secure name [on|off]       (get/set secure-feature for interface)\n");
   fprintf(stderr,"    callback name [in|outon|off]\n");
   fprintf(stderr,"                               (get/set active callback-feature for interface)\n");
@@ -229,6 +230,7 @@
   printf("Incoming-Hangup:        %s\n",cfg.ihup?"on":"off");
   printf("ChargeHangup:           %s\n",cfg.chargehup?"on":"off");
   printf("Charge-Units:           %d\n",cfg.charge);
+  printf("Charge-Interval:        %d\n",cfg.chargeint);
   printf("Layer-2-Protocol:       %s\n",num2key(cfg.l2_proto,l2protostr,l2protoval));
   printf("Layer-3-Protocol:       %s\n",num2key(cfg.l3_proto,l3protostr,l3protoval));
   printf("Encapsulation:          %s\n",num2key(cfg.p_encap,pencapstr,pencapval));
@@ -278,10 +280,70 @@
   fclose(f);
 }
 
+enum {
+	ADDIF,		ADDSLAVE,	DELIF,		DIAL,
+	BIND,		UNBIND,		PPPBIND,	PPPUNBIND,
+	BUSREJECT,	MAPPING,	SYSTEM,		HANGUP,
+	ADDPHONE,	DELPHONE,	LIST,		EAZ,	
+	VERBOSE,	GETCONF,	HUPTIMEOUT,	CBDELAY,
+	CHARGEINT,	DIALMAX,	SDELAY,		CHARGEHUP,
+	CBHUP,		IHUP,		SECURE,		CALLBACK,
+	L2_PROT,	L3_PROT,	ADDLINK,	REMOVELINK,
+	ENCAP };
+
+typedef struct {
+	char	*cmd;
+	char	*argno;
+} cmd_struct;
+ 
+static cmd_struct cmds [] = {
+	{ "addif", 	"0"},
+	{ "addslave", 	"1" },
+	{ "delif", 	"0" },
+	{ "dial", 	"0" },
+	{ "bind", 	"12"},
+	{ "unbind", 	"0" },
+	{ "pppbind", 	"1" },
+	{ "pppunbind", 	"0" },
+	{ "busreject",  "1" },
+	{ "mapping", 	"0" },
+	{ "system", 	"0" },
+	{ "hangup", 	"0" },
+	{ "addphone", 	"2" },
+	{ "delphone", 	"2" },
+	{ "list", 	"0" },
+	{ "eaz", 	"01"},
+	{ "verbose", 	"0" },
+	{ "getconf", 	"0" },
+	{ "huptimeout", "01"},
+	{ "cbdelay",    "01"},
+	{ "chargeint",  "01"},
+	{ "dialmax",    "01"},
+	{ "sdelay",     "01"},
+	{ "chargehup",  "01"},
+	{ "cbhup",      "01"},
+	{ "ihup",       "01"},
+	{ "secure", 	"01"},
+	{ "callback", 	"01"},
+	{ "l2_prot", 	"01"},
+	{ "l3_prot", 	"01"},
+	{ "addlink", 	"0" },
+	{ "removelink", "0" },
+	{ "encap", 	"01"},
+	{ NULL, } };
+
+int findcmd (char *str) {
+  int i;
+
+  for (i = 0; cmds [i].cmd; i++) 
+    if (!strcmp (cmds [i].cmd, str)) return i;
+  return -1;
+}
+  
 void
 main(int argc, char **argv) {
   int fd;
-  int i;
+  int i, n, args, cmdptr;
   int result;
   FILE *iflst;
   char *p;
@@ -289,317 +351,255 @@
   isdn_net_ioctl_phone phone;
   isdn_net_ioctl_cfg   cfg;
   isdn_ioctl_struct    iocts;
+  unsigned long j;
+  char nstring[255];
+  char *id;
+  char *arg1;
+  char *arg2;
 
   cmd = argv[0];
-  if (argc>=2) {
-    fd = open("/dev/isdnctrl",O_RDWR);
-    if (fd < 0) {
-      perror("/dev/isdnctrl");
-      exit(-1);
-    }
-    if (!strcmp(argv[1],"addif")) {
-      if (argc==2)
-	strcpy(s,"  ");
-      else {
-	if (strlen(argv[2])>8) {
-	  fprintf(stderr,"name must not exceed 8 characters\n");
-	  exit(-1);
-	}
-	strcpy(s,argv[2]);
-      }
+  if (argc < 3) {
+    usage ();
+    return;
+  }
+  fd = open("/dev/isdnctrl",O_RDWR);
+  if (fd < 0) {
+    perror("/dev/isdnctrl");
+    exit(-1);
+  }
+  id = argv [2];
+  i = findcmd (argv [1]);
+  for (cmdptr = 2; cmdptr < argc; ) {
+    if (i < 0) {		/* Unknown command */
+      fprintf (stderr, "The given command \"%s\" is unknown.\n\n", argv [1]); 
+      usage ();
+      return;
+    }
+    if (i != GETCONF) {
+      if (strlen (id) > 8) {
+	fprintf (stderr, "Interface name must not exceed 8 characters!\n");
+	close (fd);
+	return;
+      }
+    }
+    args = 0;
+    for (n = 0; cmds [i].argno [n]; n++) {
+      args = cmds [i].argno [n] - '0';
+      if (!n && (args + cmdptr > argc-1)) {
+	fprintf (stderr, "Too few arguments given for %s\n", cmds [i].cmd);
+        usage ();
+	return;
+      }
+      if (n && ((cmdptr+args > argc-1) || findcmd (argv [cmdptr+args])>=0)) {
+	args = cmds [i].argno [n-1] - '0';
+        break;
+      }
+    }
+    arg1 = args    ? argv [cmdptr+1] : "";
+    arg2 = (args>1)? argv [cmdptr+2] : "";
+    switch (i) {
+    case ADDIF:
+      strcpy(s,id);
       if ((result=ioctl(fd,IIOCNETAIF,s))<0) {
 	perror("addif");
 	exit(-1);
       }
       printf("%s added\n",s);
-      close(fd);
-      return;
-    }
-    if (!strcmp(argv[1],"addslave")) {
-      if (argc<4)
-	usage();
-      else {
-	if (strlen(argv[2])>8) {
-	  fprintf(stderr,"name must not exceed 8 characters\n");
-	  exit(-1);
-	}
-	if (strlen(argv[3])>8) {
-	  fprintf(stderr,"slavename must not exceed 8 characters\n");
-	  exit(-1);
-	}
-	sprintf(s,"%s,%s",argv[2],argv[3]);
+      break;
+
+    case ADDSLAVE:
+      if (strlen(arg1)>8) {
+	fprintf(stderr,"slavename must not exceed 8 characters\n");
+        exit(-1);
       }
+      sprintf(s,"%s,%s",id, arg1);
       if ((result=ioctl(fd,IIOCNETASL,s))<0) {
 	perror("addslave");
 	exit(-1);
       }
-      printf("%s added as slave to %s\n",s,argv[2]);
-      close(fd);
-      return;
-    }
-    if (!strcmp(argv[1],"delif")) {
-      if (argc<3)
-	usage();
-      if (strlen(argv[2])>8) {
-	fprintf(stderr,"name must not exceed 8 characters\n");
-	exit(-1);
-      }
-      if ((result=ioctl(fd,IIOCNETDIF,argv[2]))<0) {
-	perror(argv[2]);
-	exit(-1);
-      }
-      printf("%s deleted\n",argv[2]);
-      close(fd);
-      return;
-    }  
-    if (!strcmp(argv[1],"dial")) {
-      if (argc<3)
-	usage();
-      if (strlen(argv[2])>8) {
-	fprintf(stderr,"name must not exceed 8 characters\n");
-	exit(-1);
-      }
-      if ((result=ioctl(fd,IIOCNETDIL,argv[2]))<0) {
-	perror(argv[2]);
+      printf("%s added as slave to %s\n",s,id);
+      break;
+
+    case DELIF:
+      if ((result=ioctl(fd,IIOCNETDIF,id))<0) {
+	perror(id);
 	exit(-1);
       }
-      printf("Dialing of %s triggered\n",argv[2]);
-      close(fd);
-      return;
-    }  
-    if (!strcmp(argv[1],"bind")) {
-      if ((argc<4) || (argc>5))
-	usage();
-      if (strlen(argv[2])>8) {
-	fprintf(stderr,"name must not exceed 8 characters\n");
+      printf("%s deleted\n", id);
+      break;
+
+    case DIAL:
+      if ((result=ioctl(fd,IIOCNETDIL, id))<0) {
+	perror(id);
 	exit(-1);
       }
-      if (argc==5)
-	if (strncmp(argv[4],"excl",4))
+      printf("Dialing of %s triggered\n", id);
+      break;
+
+    case BIND:
+      if (args==2)
+	if (strncmp(arg2, "excl",4))
 	  usage();
-      strcpy(cfg.name,argv[2]);
+      strcpy(cfg.name, id);
       if ((result=ioctl(fd,IIOCNETGCF,&cfg))<0) {
-	perror(argv[2]);
+	perror(id);
 	exit(-1);
       }
       sscanf(argv[3],"%s",cfg.drvid);
-      cfg.exclusive = (argc == 5);
+      cfg.exclusive = (args == 2);
       if ((result=ioctl(fd,IIOCNETSCF,&cfg))<0) {
-	sprintf(s,"%s or %s",argv[2],argv[3]);
+	sprintf(s,"%s or %s", id, arg2);
 	perror(s);
 	exit(-1);
       }
-      printf("%s bound to ",argv[2]);
+      printf("%s bound to ", id);
       listbind(cfg.drvid,cfg.exclusive);
-      close(fd);
-      return;
-    }  
-    if (!strcmp(argv[1],"unbind")) {
-      if (argc<3)
-	usage();
-      if (strlen(argv[2])>8) {
-	fprintf(stderr,"name must not exceed 8 characters\n");
-	exit(-1);
-      }
-      strcpy(cfg.name,argv[2]);
+      break;
+
+    case UNBIND:
+      strcpy(cfg.name, id);
       if ((result=ioctl(fd,IIOCNETGCF,&cfg))<0) {
-	perror(argv[2]);
+	perror(id);
 	exit(-1);
       }
       if (!strlen(cfg.drvid)) {
-	printf("%s was not bound to anything\n",argv[2]);
+	printf("%s was not bound to anything\n", id);
 	exit(0);
       }
       cfg.drvid[0] = '\0';
       cfg.exclusive = -1;
       if ((result=ioctl(fd,IIOCNETSCF,&cfg))<0) {
-	perror(argv[2]);
+	perror(id);
 	exit(-1);
       }
-      printf("%s unbound successfully\n",argv[2]);
-      close(fd);
-      return;
-    }  
+      printf("%s unbound successfully\n", id);
+      break;
 
-    if (!strcmp(argv[1],"pppbind")) {
-      if (argc<4)
-        usage();
-      if (strlen(argv[2])>8) {
-        fprintf(stderr,"name must not exceed 8 characters\n");
-        exit(-1);
-      }
-      strcpy(cfg.name,argv[2]);
+    case PPPBIND:
+      strcpy(cfg.name, id);
       if ((result=ioctl(fd,IIOCNETGCF,&cfg))<0) {
-        perror(argv[2]);
+        perror(id);
         exit(-1);
       }
-      sscanf(argv[3],"%d",&cfg.pppbind);
+      sscanf(arg1,"%d",&cfg.pppbind);
       if ((result=ioctl(fd,IIOCNETSCF,&cfg))<0) {
-        sprintf(s,"%s or %s",argv[2],argv[3]);
+        sprintf(s,"%s or %s", id, arg1);
         perror(s);
         exit(-1);
       }
-      printf("%s bound to %s",argv[2],argv[3]);
-      close(fd);
-      return;
-    }
-    if (!strcmp(argv[1],"pppunbind")) {
-      if (argc<3)
-        usage();
-      if (strlen(argv[2])>8) {
-        fprintf(stderr,"name must not exceed 8 characters\n");
-        exit(-1);
-      }
-      strcpy(cfg.name,argv[2]);
+      printf("%s bound to %s", id, arg1);
+      break;
+
+    case PPPUNBIND:
+      strcpy(cfg.name, id);
       if ((result=ioctl(fd,IIOCNETGCF,&cfg))<0) {
-        perror(argv[2]);
+        perror(id);
         exit(-1);
       }
       if (cfg.pppbind < 0) {
-        printf("%s was not bound to anything\n",argv[2]);
+        printf("%s was not bound to anything\n", id);
         exit(0);
       }
       cfg.pppbind = -1;
       if ((result=ioctl(fd,IIOCNETSCF,&cfg))<0) {
-        perror(argv[2]);
+        perror(id);
         exit(-1);
       }
-      printf("%s unbound successfully\n",argv[2]);
-      close(fd);
-      return;
-    }
-
-    if (!strcmp(argv[1],"busreject")) {
-      if (argc<4)
-	usage();
-      strcpy(iocts.drvid,argv[2]);
-      if (strcmp(argv[3],"on") && strcmp(argv[3],"off")) {
+      printf("%s unbound successfully\n", id);
+      break;
+    
+    case BUSREJECT:
+      strcpy(iocts.drvid, id);
+      if (strcmp(arg1, "on") && strcmp(arg1, "off")) {
 	fprintf(stderr,"Bus-Reject must be 'on' or 'off'\n");
 	exit(-1);
       }
-      iocts.arg = strcmp(argv[3],"off");
+      iocts.arg = strcmp(arg1,"off");
       if ((result=ioctl(fd,IIOCSETBRJ,&iocts))<0) {
-	perror(argv[2]);
+	perror(id);
 	exit(-1);
       }
-      close(fd);
-      return;
-    }
-    if (!strcmp(argv[1],"mapping")) {
-      char nstring[255];
-      if (argc<3)
-	usage();
-      strcpy(iocts.drvid,argv[2]);
-      if (argc<4) {
+      break;
+
+    case MAPPING:
+      strcpy(iocts.drvid, id);
+      if (!args) {
 	iocts.arg = (unsigned long)&nstring;
 	if ((result=ioctl(fd,IIOCGETMAP,&iocts))<0) {
-	  perror(argv[2]);
+	  perror(id);
 	  exit(-1);
 	}
-	printf("MSN/EAZ-mapping for %s:\n%s\n",argv[2],nstring);
+	printf("MSN/EAZ-mapping for %s:\n%s\n", id,nstring);
       } else {
-	iocts.arg = (unsigned long)argv[3];
+	iocts.arg = (unsigned long)arg1;
 	if ((result=ioctl(fd,IIOCSETMAP,&iocts))<0) {
-	  perror(argv[2]);
+	  perror(id);
 	  exit(-1);
 	}
       }
-      close(fd);
-      return;
-    }
-    if (!strcmp(argv[1],"system")) {
-      unsigned long i;
+      break;
 
-      if (argc<3)
-	usage();
-      if (strcmp(argv[2],"on") && strcmp(argv[2],"off")) {
+    case SYSTEM:
+      if (strcmp(id,"on") && strcmp(id,"off")) {
 	fprintf(stderr,"System-Mode must be 'on' or 'off'\n");
 	exit(-1);
       }
-      i = strcmp(argv[2],"on");
-      if ((result=ioctl(fd,IIOCSETGST,i))<0) {
-	perror(argv[2]);
+      j = strcmp(id,"on");
+      if ((result=ioctl(fd,IIOCSETGST,j))<0) {
+	perror(id);
 	exit(-1);
       }
-      close(fd);
-      return;
-    }
-    if (!strcmp(argv[1],"hangup")) {
-      if (argc<3)
-	usage();
-      if (strlen(argv[2])>8) {
-	fprintf(stderr,"name must not exceed 8 characters\n");
-	exit(-1);
-      }
-      if ((result=ioctl(fd,IIOCNETHUP,argv[2]))<0) {
-	perror(argv[2]);
+      break;
+
+    case HANGUP:
+      if ((result=ioctl(fd,IIOCNETHUP,id))<0) {
+	perror(id);
 	exit(-1);
       }
       if (result)
-	printf("%s not connected\n",argv[2]);
+	printf("%s not connected\n", id);
       else
-	printf("%s hung up\n",argv[2]);
-      close(fd);
-      return;
-    }  
-    if (!strcmp(argv[1],"addphone")) {
-      if (argc<5)
-	usage();
-      if (strlen(argv[2])>8) {
-	fprintf(stderr,"name must not exceed 8 characters\n");
-	exit(-1);
-      }
-      if (strcmp(argv[3],"in") && strcmp(argv[3],"out")) {
+	printf("%s hung up\n", id);
+      break;
+
+    case ADDPHONE:
+      if (strcmp(arg1,"in") && strcmp(arg1,"out")) {
 	fprintf(stderr,"Direction must be \"in\" or \"out\"\n");
 	exit(-1);
       }
-      phone.outgoing = strcmp(argv[3],"out")?0:1;
-      if (strlen(argv[4])>20) {
+      phone.outgoing = strcmp(arg1,"out")?0:1;
+      if (strlen(arg2)>20) {
 	fprintf(stderr,"phone-number must not exceed 20 characters\n");
 	exit(-1);
       }
-      strcpy(phone.name,argv[2]);
-      strcpy(phone.phone,argv[4]);
+      strcpy(phone.name, id);
+      strcpy(phone.phone, arg2);
       if ((result=ioctl(fd,IIOCNETANM,&phone))<0) {
-	perror(argv[2]);
-	exit(-1);
-      }
-      close(fd);
-      return;
-    }  
-    if (!strcmp(argv[1],"delphone")) {
-      if (argc<5)
-	usage();
-      if (strlen(argv[2])>8) {
-	fprintf(stderr,"name must not exceed 8 characters\n");
+	perror(id);
 	exit(-1);
       }
-      if (strcmp(argv[3],"in") && strcmp(argv[3],"out")) {
+      break;
+
+    case DELPHONE:
+      if (strcmp(arg1,"in") && strcmp(arg1,"out")) {
 	fprintf(stderr,"Direction must be \"in\" or \"out\"\n");
 	exit(-1);
       }
-      phone.outgoing = strcmp(argv[3],"out")?0:1;
-      if (strlen(argv[4])>20) {
+      phone.outgoing = strcmp(arg1, "out")?0:1;
+      if (strlen(arg2)>20) {
 	fprintf(stderr,"phone-number must not exceed 20 characters\n");
 	exit(-1);
       }
-      strcpy(phone.name,argv[2]);
-      strcpy(phone.phone,argv[4]);
+      strcpy(phone.name, id);
+      strcpy(phone.phone, arg2);
       if ((result=ioctl(fd,IIOCNETDNM,&phone))<0) {
-	perror(argv[2]);
+	perror(id);
 	exit(-1);
       }
-      close(fd);
-      return;
-    }
-    if (!strcmp(argv[1],"list")) {
-      if (argc<3)
-	usage();
-      if (strlen(argv[2])>8) {
-	fprintf(stderr,"name must not exceed 8 characters\n");
-	exit(-1);
-      }
-      if (!strcmp(argv[2],"all")) {
+      break;
+
+    case LIST:
+      if (!strcmp(id,"all")) {
 	char name[10];
 	if ((iflst = fopen("/proc/net/dev","r"))==NULL) {
 	  perror("/proc/net/dev");
@@ -617,39 +617,29 @@
 	}
 	fclose(iflst);
       } else
-	listif(fd,argv[2],1);
-      close(fd);
-      return;
-    }  
-    if (!strcmp(argv[1],"eaz")) {
-      if (argc<3)
-	usage();
-      if (strlen(argv[2])>8) {
-	fprintf(stderr,"name must not exceed 8 characters\n");
-	exit(-1);
-      }
-      strcpy(cfg.name,argv[2]);
+	listif(fd,id ,1);
+      break;
+
+    case EAZ:
+      strcpy(cfg.name, id);
       if ((result=ioctl(fd,IIOCNETGCF,&cfg))<0) {
-	perror(argv[2]);
+	perror(id);
 	exit(-1);
       }
-      if (argc>3) {
+      if (args) {
 	i = -1;
-	strncpy(cfg.eaz,argv[3],sizeof(cfg.eaz)-1);
+	strncpy(cfg.eaz, arg1, sizeof(cfg.eaz)-1);
 	if ((result=ioctl(fd,IIOCNETSCF,&cfg))<0) {
-	  perror(argv[2]);
+	  perror(id);
 	  exit(-1);
 	}
       }
       printf("EAZ/MSN for %s is %s\n",cfg.name,cfg.eaz);
-      close(fd);
-      return;
-    }  
-    if (!strcmp(argv[1],"verbose")) {
-      if (argc<3)
-	usage();
+      break;
+
+    case VERBOSE:
       i = -1;
-      sscanf(argv[2],"%d",&i);
+      sscanf(id,"%d",&i);
       if (i<0) {
 	fprintf(stderr,"Verbose-level must be >= 0\n");
 	exit(-1);
@@ -659,290 +649,239 @@
 	exit(-1);
       }
       printf("Verbose-level set to %d.\n",i);
-      close(fd);
-      return;
-    }
-    if (!strcmp(argv[1],"getconf")) {
-      if (argc<3)
-	usage();
-      get_setup(fd,argv[2]);
-      printf("Configuration written to %s.\n",argv[2]);
-      close(fd);
-      return;
-    }
-    if (!strcmp(argv[1],"huptimeout")) {
-      if (argc<3)
-	usage();
-      if (strlen(argv[2])>8) {
-	fprintf(stderr,"name must not exceed 8 characters\n");
-	exit(-1);
-      }
-      strcpy(cfg.name,argv[2]);
+      break;
+  
+    case GETCONF:
+      get_setup(fd, id);
+      printf("Configuration written to %s.\n", id);
+      break;
+
+    case HUPTIMEOUT:
+      strcpy(cfg.name, id);
       if ((result=ioctl(fd,IIOCNETGCF,&cfg))<0) {
-	perror(argv[2]);
+	perror(id);
 	exit(-1);
       }
-      if (argc>3) {
+      if (args) {
 	i = -1;
-	sscanf(argv[3],"%d",&i);
+	sscanf(arg1,"%d",&i);
 	if (i<0) {
 	  fprintf(stderr,"Hangup-Timeout must be >= 0\n");
 	  exit(-1);
 	}
 	cfg.onhtime = i;
 	if ((result=ioctl(fd,IIOCNETSCF,&cfg))<0) {
-	  perror(argv[2]);
+	  perror(id);
 	  exit(-1);
 	}
       }
       printf("Hangup-Timeout for %s is %d sec.\n",cfg.name,cfg.onhtime);
-      close(fd);
-      return;
-    }  
-    if (!strcmp(argv[1],"cbdelay")) {
-      if (argc<3)
-	usage();
-      if (strlen(argv[2])>8) {
-	fprintf(stderr,"name must not exceed 8 characters\n");
-	exit(-1);
-      }
-      strcpy(cfg.name,argv[2]);
+      break;
+
+    case CBDELAY:
+      strcpy(cfg.name,id);
       if ((result=ioctl(fd,IIOCNETGCF,&cfg))<0) {
-	perror(argv[2]);
+	perror(id);
 	exit(-1);
       }
-      if (argc>3) {
+      if (args) {
 	i = -1;
-	sscanf(argv[3],"%d",&i);
+	sscanf(arg1,"%d",&i);
 	if (i<0) {
 	  fprintf(stderr,"Callback delay must be >= 0\n");
 	  exit(-1);
 	}
 	cfg.cbdelay = i*5;
 	if ((result=ioctl(fd,IIOCNETSCF,&cfg))<0) {
-	  perror(argv[2]);
+	  perror(id);
 	  exit(-1);
 	}
       }
       printf("Callback delay for %s is %d sec.\n",cfg.name,cfg.cbdelay/5);
-      close(fd);
-      return;
-    }  
-    if (!strcmp(argv[1],"dialmax")) {
-      if (argc<3)
-	usage();
-      if (strlen(argv[2])>8) {
-	fprintf(stderr,"name must not exceed 8 characters\n");
+      break;
+
+    case CHARGEINT:
+      strcpy(cfg.name, id);
+      if ((result=ioctl(fd,IIOCNETGCF,&cfg))<0) {
+	perror(id);
 	exit(-1);
       }
-      strcpy(cfg.name,argv[2]);
+      if (args) {
+	i = -1;
+	sscanf(arg1,"%d",&i);
+	if (i<0) {
+	  fprintf(stderr,"Charge interval must be >= 0\n");
+	  exit(-1);
+	}
+	cfg.chargeint = i;
+	if ((result=ioctl(fd,IIOCNETSCF,&cfg))<0) {
+	  perror(id);
+	  exit(-1);
+	}
+      }
+      printf("Charge Interval for %s is %d sec.\n",cfg.name,cfg.chargeint);
+      break;
+
+    case DIALMAX:
+      strcpy(cfg.name, id);
       if ((result=ioctl(fd,IIOCNETGCF,&cfg))<0) {
-	perror(argv[2]);
+	perror(id);
 	exit(-1);
       }
-      if (argc>3) {
+      if (args) {
 	i = -1;
-	sscanf(argv[3],"%d",&i);
+	sscanf(arg1,"%d",&i);
 	if (i<1) {
 	  fprintf(stderr,"Dialmax must be > 0\n");
 	  exit(-1);
 	}
 	cfg.dialmax = i;
 	if ((result=ioctl(fd,IIOCNETSCF,&cfg))<0) {
-	  perror(argv[2]);
+	  perror(id);
 	  exit(-1);
 	}
       }
       printf("Dialmax for %s is %d times.\n",cfg.name,cfg.dialmax);
-      close(fd);
-      return;
-    }  
-    if (!strcmp(argv[1],"sdelay")) {
-      if (argc<3)
-	usage();
-      if (strlen(argv[2])>8) {
-	fprintf(stderr,"name must not exceed 8 characters\n");
-	exit(-1);
-      }
-      strcpy(cfg.name,argv[2]);
+      break;
+
+    case SDELAY:
+      strcpy(cfg.name,id);
       if ((result=ioctl(fd,IIOCNETGCF,&cfg))<0) {
-	perror(argv[2]);
+	perror(id);
 	exit(-1);
       }
-      if (argc>3) {
+      if (args) {
 	i = -1;
-	sscanf(argv[3],"%d",&i);
+	sscanf(arg1,"%d",&i);
 	if (i<1) {
 	  fprintf(stderr,"Slave-activation delay must be >= 1\n");
 	  exit(-1);
 	}
 	cfg.slavedelay = i;
 	if ((result=ioctl(fd,IIOCNETSCF,&cfg))<0) {
-	  perror(argv[2]);
+	  perror(id);
 	  exit(-1);
 	}
       }
       printf("Slave-activation delay for %s is %d sec.\n",cfg.name,
 	     cfg.slavedelay);
-      close(fd);
-      return;
-    }  
-    if (!strcmp(argv[1],"chargehup")) {
-      if (argc<3)
-	usage();
-      if (strlen(argv[2])>8) {
-	fprintf(stderr,"name must not exceed 8 characters\n");
-	exit(-1);
-      }
-      strcpy(cfg.name,argv[2]);
+      break;
+
+    case CHARGEHUP:
+      strcpy(cfg.name,id);
       if ((result=ioctl(fd,IIOCNETGCF,&cfg))<0) {
-	perror(argv[2]);
+	perror(id);
 	exit(-1);
       }
-      if (argc>3) {
+      if (args) {
 	i = -1;
-	if (strcmp(argv[3],"on") && strcmp(argv[3],"off")) {
+	if (strcmp(arg1, "on") && strcmp(arg1, "off")) {
 	  fprintf(stderr,"Charge-Hangup must be 'on' or 'off'\n");
 	  exit(-1);
 	}
-	cfg.chargehup = strcmp(argv[3],"off");
+	cfg.chargehup = strcmp(arg1,"off");
 	if ((result=ioctl(fd,IIOCNETSCF,&cfg))<0) {
-	  perror(argv[2]);
+	  perror(id);
 	  exit(-1);
 	}
       }
       printf("Charge-Hangup for %s is %s\n",cfg.name,cfg.chargehup?"on":"off");
-      close(fd);
-      return;
-    }  
-    if (!strcmp(argv[1],"cbhup")) {
-      if (argc<3)
-	usage();
-      if (strlen(argv[2])>8) {
-	fprintf(stderr,"name must not exceed 8 characters\n");
-	exit(-1);
-      }
-      strcpy(cfg.name,argv[2]);
+      break;
+
+    case CBHUP:
+      strcpy(cfg.name,id);
       if ((result=ioctl(fd,IIOCNETGCF,&cfg))<0) {
-	perror(argv[2]);
+	perror(id);
 	exit(-1);
       }
-      if (argc>3) {
+      if (args) {
 	i = -1;
-	if (strcmp(argv[3],"on") && strcmp(argv[3],"off")) {
+	if (strcmp(arg1, "on") && strcmp(arg1, "off")) {
 	  fprintf(stderr,"Callback-Hangup must be 'on' or 'off'\n");
 	  exit(-1);
 	}
-	cfg.cbhup = strcmp(argv[3],"off");
+	cfg.cbhup = strcmp(arg1,"off");
 	if ((result=ioctl(fd,IIOCNETSCF,&cfg))<0) {
-	  perror(argv[2]);
+	  perror(id);
 	  exit(-1);
 	}
       }
       printf("Reject before Callback for %s is %s\n",cfg.name,cfg.cbhup?"on":"off");
-      close(fd);
-      return;
-    }  
-    if (!strcmp(argv[1],"ihup")) {
-      if (argc<3)
-	usage();
-      if (strlen(argv[2])>8) {
-	fprintf(stderr,"name must not exceed 8 characters\n");
-	exit(-1);
-      }
-      strcpy(cfg.name,argv[2]);
+      break;
+
+    case IHUP:
+      strcpy(cfg.name, id);
       if ((result=ioctl(fd,IIOCNETGCF,&cfg))<0) {
-	perror(argv[2]);
+	perror(id);
 	exit(-1);
       }
-      if (argc>3) {
+      if (args) {
 	i = -1;
-	if (strcmp(argv[3],"on") && strcmp(argv[3],"off")) {
+	if (strcmp(arg1,"on") && strcmp(arg1,"off")) {
 	  fprintf(stderr,"Incoming-Hangup must be 'on' or 'off'\n");
 	  exit(-1);
 	}
-	cfg.ihup = strcmp(argv[3],"off");
+	cfg.ihup = strcmp(arg1,"off");
 	if ((result=ioctl(fd,IIOCNETSCF,&cfg))<0) {
-	  perror(argv[2]);
+	  perror(id);
 	  exit(-1);
 	}
       }
       printf("Incoming-Hangup for %s is %s\n",cfg.name,cfg.ihup?"on":"off");
-      close(fd);
-      return;
-    }  
-    if (!strcmp(argv[1],"secure")) {
-      if (argc<3)
-	usage();
-      if (strlen(argv[2])>8) {
-	fprintf(stderr,"name must not exceed 8 characters\n");
-	exit(-1);
-      }
-      strcpy(cfg.name,argv[2]);
+      break;
+
+    case SECURE:
+      strcpy(cfg.name, id);
       if ((result=ioctl(fd,IIOCNETGCF,&cfg))<0) {
-	perror(argv[2]);
+	perror(id);
 	exit(-1);
       }
-      if (argc>3) {
+      if (args) {
 	i = -1;
-	if (strcmp(argv[3],"on") && strcmp(argv[3],"off")) {
+	if (strcmp(arg1,"on") && strcmp(arg1,"off")) {
 	  fprintf(stderr,"Secure-parameter must be 'on' or 'off'\n");
 	  exit(-1);
 	}
-	cfg.secure = strcmp(argv[3],"off");
+	cfg.secure = strcmp(arg1,"off");
 	if ((result=ioctl(fd,IIOCNETSCF,&cfg))<0) {
-	  perror(argv[2]);
+	  perror(id);
 	  exit(-1);
 	}
       }
       printf("Security for %s is %s\n",cfg.name,cfg.secure?"on":"off");
-      close(fd);
-      return;
-    }  
-    if (!strcmp(argv[1],"callback")) {
-      if (argc<3)
-	usage();
-      if (strlen(argv[2])>8) {
-	fprintf(stderr,"name must not exceed 8 characters\n");
-	exit(-1);
-      }
-      strcpy(cfg.name,argv[2]);
+      break;
+
+    case CALLBACK:
+      strcpy(cfg.name,id);
       if ((result=ioctl(fd,IIOCNETGCF,&cfg))<0) {
-	perror(argv[2]);
+	perror(id);
 	exit(-1);
       }
-      if (argc>3) {
+      if (args) {
 	i = -1;
-	if (strcmp(argv[3],"on") && strcmp(argv[3],"off") &&
-	    strcmp(argv[3],"in") && strcmp(argv[3],"out")) {
+	if (strcmp(arg1,"on") && strcmp(arg1,"off") &&
+	    strcmp(arg1,"in") && strcmp(arg1,"out")) {
 	  fprintf(stderr,"Callback-parameter must be 'on', 'in', 'out' or 'off'\n");
 	  exit(-1);
 	}
-	cfg.callback = strcmp(argv[3],"off")?1:0;
-	if (!strcmp(argv[3],"out")) cfg.callback = 2;
+	cfg.callback = strcmp(arg1,"off")?1:0;
+	if (!strcmp(arg1,"out")) cfg.callback = 2;
 	if ((result=ioctl(fd,IIOCNETSCF,&cfg))<0) {
-	  perror(argv[2]);
+	  perror(id);
 	  exit(-1);
 	}
       }
       printf("Callback for %s is %s\n",cfg.name,num2callb[cfg.callback]);
-      close(fd);
-      return;
-    }  
-    if (!strcmp(argv[1],"l2_prot")) {
-      if (argc<3)
-	usage();
-      if (strlen(argv[2])>8) {
-	fprintf(stderr,"name must not exceed 8 characters\n");
-	exit(-1);
-      }
-      strcpy(cfg.name,argv[2]);
+      break;
+
+    case L2_PROT:
+      strcpy(cfg.name,id);
       if ((result=ioctl(fd,IIOCNETGCF,&cfg))<0) {
-	perror(argv[2]);
+	perror(id);
 	exit(-1);
       }
-      if (argc>3) {
-	i = key2num(argv[3],l2protostr,l2protoval);
+      if (args) {
+	i = key2num(arg1,l2protostr,l2protoval);
 	if (i<0) {
 	  fprintf(stderr,"Layer-2-Protocol must be one of the following:\n");
 	  i = 0;
@@ -952,29 +891,22 @@
 	}
 	cfg.l2_proto = i;
 	if ((result=ioctl(fd,IIOCNETSCF,&cfg))<0) {
-	  perror(argv[2]);
+	  perror(id);
 	  exit(-1);
 	}
       }
       printf("Layer-2-Protocol for %s is %s\n",cfg.name,
 	     num2key(cfg.l2_proto,l2protostr,l2protoval));
-      close(fd);
-      return;
-    }  
-    if (!strcmp(argv[1],"l3_prot")) {
-      if (argc<3)
-	usage();
-      if (strlen(argv[2])>8) {
-	fprintf(stderr,"name must not exceed 8 characters\n");
-	exit(-1);
-      }
-      strcpy(cfg.name,argv[2]);
+      break;
+   
+    case L3_PROT:
+      strcpy(cfg.name, id);
       if ((result=ioctl(fd,IIOCNETGCF,&cfg))<0) {
-	perror(argv[2]);
+	perror(id);
 	exit(-1);
       }
-      if (argc>3) {
-	i = key2num(argv[3],l3protostr,l3protoval);
+      if (args) {
+	i = key2num(arg1,l3protostr,l3protoval);
 	if (i<0) {
 	  fprintf(stderr,"Layer-3-Protocol must be one of the following:\n");
 	  i = 0;
@@ -984,67 +916,46 @@
 	}
 	cfg.l3_proto = i;
 	if ((result=ioctl(fd,IIOCNETSCF,&cfg))<0) {
-	  perror(argv[2]);
+	  perror(id);
 	  exit(-1);
 	}
       }
       printf("Layer-3-Protocol for %s is %s\n",cfg.name,
 	     num2key(cfg.l3_proto,l3protostr,l3protoval));
-      close(fd);
-      return;
-    } 
-    if(!strcmp(argv[1],"addlink")) {
-      if(argc!=3)
-        usage();
-      if(strlen(argv[2])>8) {
-        fprintf(stderr,"name must not exceed 8 characters\n");
-        exit(-1);
-      }
-      if((result=ioctl(fd,IIOCNETALN,argv[2]))<0)
+      break;
+
+    case ADDLINK:
+      if((result=ioctl(fd,IIOCNETALN, id))<0)
       {
-        perror(argv[2]);
+        perror(id);
         exit(-1);
       }
       if(result)
         printf("Can't increase number of links: %d\n",result);
       else
         printf("Ok, added a new link. (dialing)\n");
-      close(fd);
-      return; 
-    }
-    if(!strcmp(argv[1],"removelink")) {
-      if(argc!=3)
-        usage();
-      if(strlen(argv[2])>8) {
-        fprintf(stderr,"name must not exceed 8 characters\n");
-        exit(-1);
-      }
-      if((result=ioctl(fd,IIOCNETDLN,argv[2]))<0)
+      break;
+
+    case REMOVELINK:
+      if((result=ioctl(fd,IIOCNETDLN,id))<0)
       {
-        perror(argv[2]);
+        perror(id);
         exit(-1);
       }
       if(result)
         printf("Can't decrease number of links: %d\n",result);
       else
         printf("Ok, removed a link. (hangup)\n");
-      close(fd);
-      return;
-    }
-    if (!strcmp(argv[1],"encap")) {
-      if (argc<3)
-	usage();
-      if (strlen(argv[2])>8) {
-	fprintf(stderr,"name must not exceed 8 characters\n");
-	exit(-1);
-      }
-      strcpy(cfg.name,argv[2]);
+      break;
+
+    case ENCAP:
+      strcpy(cfg.name,id);
       if ((result=ioctl(fd,IIOCNETGCF,&cfg))<0) {
-	perror(argv[2]);
+	perror(id);
 	exit(-1);
       }
-      if (argc>3) {
-	i = key2num(argv[3],pencapstr,pencapval);
+      if (args) {
+	i = key2num(arg1,pencapstr,pencapval);
 	if (i<0) {
 	  fprintf(stderr,"Encapsulation must be one of the following:\n");
 	  i = 0;
@@ -1054,18 +965,19 @@
 	}
 	cfg.p_encap = i;
 	if ((result=ioctl(fd,IIOCNETSCF,&cfg))<0) {
-	  perror(argv[2]);
+	  perror(id);
 	  exit(-1);
 	}
       }
       printf("Encapsulation for %s is %s\n",cfg.name,
 	     num2key(cfg.p_encap,pencapstr,pencapval));
-      close(fd);
-      return;
-    }  
-    close(fd);
+      break;
+    }
+    cmdptr += 1+args;
+    if (cmdptr < argc) 
+      i = findcmd (argv [cmdptr]);
   }
-  usage();
+  close(fd);
 }
 
 
