|
@@ -113,7 +113,7 @@ add_cmts_mic (unsigned char *tlvbuf, unsigned int tlvbuflen,
|
|
|
else
|
|
|
{
|
|
|
if ( cp[0] == 64 ) {
|
|
|
- printf("%s: warning: TLV64 (length > 255) not allowed in DOCSIS config files\n", prog_name);
|
|
|
+ printf("docsis: warning: TLV64 (length > 255) not allowed in DOCSIS config files\n");
|
|
|
cp = cp + (size_t) ntohs(*((unsigned short *)(cp+1))) + 3;
|
|
|
} else {
|
|
|
cp = cp + cp[1] + 2;
|
|
@@ -134,11 +134,11 @@ add_cmts_mic (unsigned char *tlvbuf, unsigned int tlvbuflen,
|
|
|
}
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
-static void usage (char *prog_name) __attribute__((__noreturn__));
|
|
|
+static void usage () __attribute__((__noreturn__));
|
|
|
#endif
|
|
|
|
|
|
static void
|
|
|
-usage (char *prog_name)
|
|
|
+usage ()
|
|
|
{
|
|
|
printf ("DOCSIS Configuration File creator, version %s\n", VERSION);
|
|
|
printf
|
|
@@ -147,19 +147,14 @@ usage (char *prog_name)
|
|
|
("Copyright (c) 2002,2003,2004,2005 Evvolve Media SRL, docsis@evvolve.com \n\n");
|
|
|
|
|
|
printf
|
|
|
- ("To encode a cable modem configuration file: \n\t %s -e <modem_cfg_file> <key_file> <output_file>\n",
|
|
|
- prog_name);
|
|
|
+ ("To encode a cable modem configuration file: \n\t docsis -e <modem_cfg_file> <key_file> <output_file>\n");
|
|
|
printf
|
|
|
- ("To encode multiple cable modem configuration files: \n\t %s -m <modem_cfg_file1> ... <key_file> <new_extension>\n",
|
|
|
- prog_name);
|
|
|
+ ("To encode multiple cable modem configuration files: \n\t docsis -m <modem_cfg_file1> ... <key_file> <new_extension>\n");
|
|
|
printf
|
|
|
- ("To encode a MTA configuration file: \n\t %s -p <mta_cfg_file> <output_file>\n",
|
|
|
- prog_name);
|
|
|
+ ("To encode a MTA configuration file: \n\t docsis -p <mta_cfg_file> <output_file>\n");
|
|
|
printf
|
|
|
- ("To encode multiple MTA configuration files: \n\t %s -m -p <mta_file1> ... <new_extension>\n",
|
|
|
- prog_name);
|
|
|
- printf ("To decode a CM or MTA config file: \n\t %s -d <binary_file>\n",
|
|
|
- prog_name);
|
|
|
+ ("To encode multiple MTA configuration files: \n\t docsis -m -p <mta_file1> ... <new_extension>\n");
|
|
|
+ printf ("To decode a CM or MTA config file: \n\t docsis -d <binary_file>\n");
|
|
|
printf
|
|
|
("\nWhere:\n<cfg_file>\t\t= name of text (human readable) cable modem or MTA \n\t\t\t configuration file\n<key_file>\t\t= text file containing the authentication key \n\t\t\t (shared secret) to be used for the CMTS MIC\n<output_file> \t\t= name of output file where the binary data will\n\t\t\t be written to (if it does not exist it is created).\n<binary_file>\t\t= name of binary file to be decoded\n<new_extension>\t\t= new extension to be used when encoding multiple files\n");
|
|
|
printf ("\nSee examples/*.cfg for configuration file format.\n");
|
|
@@ -179,17 +174,14 @@ main (int argc, char *argv[])
|
|
|
unsigned int encode_docsis = FALSE, decode_bin = FALSE;
|
|
|
int i;
|
|
|
|
|
|
- memset (prog_name, 0, 255);
|
|
|
- strncpy (prog_name, argv[0], 254);
|
|
|
-
|
|
|
if (argc < 2 ) {
|
|
|
- usage(prog_name);
|
|
|
+ usage();
|
|
|
exit (10);
|
|
|
}
|
|
|
|
|
|
if (!strcmp (argv[1], "-m") ){ /* variable number of args, encoding multiple files */
|
|
|
if (argc < 5 ) {
|
|
|
- usage(prog_name);
|
|
|
+ usage();
|
|
|
exit (10);
|
|
|
}
|
|
|
extension_string = argv[argc-1];
|
|
@@ -204,21 +196,21 @@ main (int argc, char *argv[])
|
|
|
{
|
|
|
case 3:
|
|
|
if (strcmp (argv[1], "-d"))
|
|
|
- usage (prog_name);
|
|
|
+ usage ();
|
|
|
decode_bin = TRUE;
|
|
|
config_file = argv[2];
|
|
|
break;
|
|
|
;;
|
|
|
case 4:
|
|
|
if (strcmp (argv[1], "-p"))
|
|
|
- usage (prog_name);
|
|
|
+ usage ();
|
|
|
config_file = argv[2];
|
|
|
output_file = argv[3];
|
|
|
break;
|
|
|
;;
|
|
|
case 5:
|
|
|
if (strcmp (argv[1], "-e"))
|
|
|
- usage (prog_name);
|
|
|
+ usage ();
|
|
|
encode_docsis = TRUE;
|
|
|
config_file = argv[2];
|
|
|
key_file = argv[3];
|
|
@@ -226,7 +218,7 @@ main (int argc, char *argv[])
|
|
|
break;
|
|
|
;;
|
|
|
default:
|
|
|
- usage (prog_name);
|
|
|
+ usage ();
|
|
|
exit (10);
|
|
|
}
|
|
|
}
|
|
@@ -235,7 +227,7 @@ main (int argc, char *argv[])
|
|
|
{
|
|
|
if ((kf = fopen (key_file, "r")) == NULL)
|
|
|
{
|
|
|
- printf ("%s: error: can't open keyfile %s\n", prog_name, key_file);
|
|
|
+ printf ("docsis: error: can't open keyfile %s\n", key_file);
|
|
|
exit (-5);
|
|
|
}
|
|
|
keylen = fread (key, sizeof (unsigned char), 64, kf);
|
|
@@ -307,7 +299,7 @@ int encode_one_file ( char *input_file, char *output_file,
|
|
|
|
|
|
if (!strcmp (input_file, output_file))
|
|
|
{
|
|
|
- printf ("%s: Error: source file is the same as destination file\n", prog_name);
|
|
|
+ printf ("docsis: Error: source file is the same as destination file\n");
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
@@ -350,7 +342,7 @@ int encode_one_file ( char *input_file, char *output_file,
|
|
|
decode_main_aggregate (buffer, buflen);
|
|
|
if ((of = fopen (output_file, "wb")) == NULL)
|
|
|
{
|
|
|
- printf ("%s: error: can't open output file %s\n", prog_name, output_file);
|
|
|
+ printf ("docsis: error: can't open output file %s\n", output_file);
|
|
|
return -2;
|
|
|
}
|
|
|
fwrite (buffer, sizeof (unsigned char), buflen, of);
|