Added Version-Checking of NET_DV.

This commit is contained in:
Fritz Elfert 1997-08-21 14:47:02 +00:00
parent e5b71f635a
commit 5dc75c91fd
3 changed files with 68 additions and 7 deletions

View File

@ -19,6 +19,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log$
* Revision 1.4 1997/07/23 20:39:14 luethje
* added the option "force" for the commands delif and reset
*
* Revision 1.3 1997/07/22 22:36:08 luethje
* isdnrep: Use " " for blanks
* isdnctrl: Add the option "reset"
@ -209,7 +212,7 @@ static char* readoptions(int fd, char *name, int is_master, section *CSec, secti
if (cfg.chargeint)
{
sprintf(string,"%d",cfg.chargeint);
sprintf(string,"%d",(data_version < 2)?0:cfg.chargeint);
if (Set_Entry(SubSec,interface,CONF_ENT_CHARGEINT, string, C_OVERWRITE | C_WARN) == NULL)
return NULL;
}
@ -232,7 +235,7 @@ static char* readoptions(int fd, char *name, int is_master, section *CSec, secti
if (Set_Entry(SubSec,interface,CONF_ENT_SDELAY, string, C_OVERWRITE | C_WARN) == NULL)
return NULL;
sprintf(string,"%d",cfg.triggercps);
sprintf(string,"%d",(data_version < 3)?6000:cfg.triggercps);
if (Set_Entry(SubSec,interface,CONF_ENT_TRIGGERCPS, string, C_OVERWRITE | C_WARN) == NULL)
return NULL;

View File

@ -21,6 +21,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log$
* Revision 1.8 1997/07/30 20:09:24 luethje
* the call "isdnctrl pppbind ipppX" will be bound the interface to X
*
* Revision 1.7 1997/07/23 20:39:15 luethje
* added the option "force" for the commands delif and reset
*
@ -297,13 +300,19 @@ static void listif(int isdnctrl, char *name, int errexit)
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);
if (data_version < 2)
printf("Charge-Interval: n.a.\n");
else
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));
printf("Slave Interface: %s\n", strlen(cfg.slave) ? cfg.slave : "None");
printf("Slave delay: %d\n", cfg.slavedelay);
printf("Slave trigger: %d cps\n", cfg.triggercps);
if (data_version < 3)
printf("Slave trigger: n.a.\n");
else
printf("Slave trigger: %d cps\n", cfg.triggercps);
printf("Master Interface: %s\n", strlen(cfg.master) ? cfg.master : "None");
printf("Pre-Bound to: ");
listbind(cfg.drvid, cfg.exclusive);
@ -741,7 +750,10 @@ int exec_args(int fd, int argc, char **argv)
return -1;
}
}
printf("Charge Interval for %s is %d sec.\n", cfg.name, cfg.chargeint);
if (data_version < 2)
printf("Option 'chargeint' IGNORED!\n");
else
printf("Charge Interval for %s is %d sec.\n", cfg.name, cfg.chargeint);
break;
case DIALMAX:
@ -808,8 +820,11 @@ int exec_args(int fd, int argc, char **argv)
exit(-1);
}
}
printf("Slave triggerlevel for %s is %d cps.\n", cfg.name,
cfg.triggercps);
if (data_version < 3)
printf("Option 'trigger' IGNORED!\n");
else
printf("Slave triggerlevel for %s is %d cps.\n",
cfg.name, cfg.triggercps);
break;
case CHARGEHUP:
@ -1057,6 +1072,43 @@ int exec_args(int fd, int argc, char **argv)
return 0;
}
void check_version(int fd) {
data_version = ioctl(fd, IIOCGETDVR, 0);
if (data_version < 0) {
fprintf(stderr, "Could not get version of kernel ioctl structs!\n");
fprintf(stderr, "Make sure, you are using the correct version.\n");
fprintf(stderr, "(Try recompiling isdnctrl).\n");
exit(-1);
}
data_version = (data_version >> 8) & 0xff;
if (data_version != NET_DV) {
fprintf(stderr, "Version of kernel ioctl structs (%d) does NOT match\n",
data_version);
fprintf(stderr, "version of isdnctrl (%d)!\n", NET_DV);
if (data_version < 1) {
fprintf(stderr, "Kernel-Version too old, terminating.\n");
fprintf(stderr, "UPDATE YOUR KERNEL.\n");
exit(-1);
}
if (data_version > NET_DV) {
fprintf(stderr, "Kernel-Version newer than isdnctrl-Version, terminating.\n");
fprintf(stderr, "GET A NEW VERSION OF isdn4k-utils.\n");
exit(-1);
}
if ((NET_DV == 3) || (data_version == 3)) {
fprintf(stderr, "Version 3 is an interim NOT compatible to others, terminating\n");
fprintf(stderr, "RECOMPILE isdnctrl!\n");
exit(-1);
}
if (data_version < 3)
fprintf(stderr, "- Option 'trigger' disabled.\n");
if (data_version < 2)
fprintf(stderr, "- Option 'chargeint' disabled.\n");
fprintf(stderr, "Make sure, you are using the correct version.\n");
fprintf(stderr, "Recompiling of isdnctrl is STRONGLY RECOMMENDED.\n");
}
}
void main(int argc, char **argv)
{
int fd;
@ -1076,6 +1128,7 @@ void main(int argc, char **argv)
usage();
exit(-1);
}
check_version(fd);
exec_args(fd,argc-1,argv+1);
close(fd);

View File

@ -21,6 +21,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log$
* Revision 1.5 1997/07/30 20:09:26 luethje
* the call "isdnctrl pppbind ipppX" will be bound the interface to X
*
* Revision 1.4 1997/07/23 20:39:16 luethje
* added the option "force" for the commands delif and reset
*
@ -157,6 +160,8 @@ _EXTERN char *num2callb[];
#endif
_EXTERN int data_version;
_EXTERN char *cmd;
_EXTERN int key2num(char *key, char **keytable, int *numtable);