ggsn: cmdline: no need to specify interface anymore

--gtpnl is now gone, instead you have --gtpkernel that behaves as an on/off
toggle. We full rely on the kernel routing base to select the real device to
transmit.

I have updated ggsn/cmdline.ggo and then run 'gengetopt' to refresh the
automatic code generation for command line options that openggsn uses.
This commit is contained in:
Pablo Neira Ayuso 2016-05-10 18:43:12 +02:00
parent 7b31987a46
commit d9d7be339d
5 changed files with 35 additions and 34 deletions

View File

@ -1,7 +1,7 @@
/* /*
File autogenerated by gengetopt version 2.22.5 File autogenerated by gengetopt version 2.22.6
generated with the following command: generated with the following command:
gengetopt --conf-parser gengetopt -i cmdline.ggo --conf-parser
The developers of gengetopt consider the fixed text that goes in all The developers of gengetopt consider the fixed text that goes in all
gengetopt output files to be in the public domain: gengetopt output files to be in the public domain:
@ -29,6 +29,8 @@ const char *gengetopt_args_info_purpose = "";
const char *gengetopt_args_info_usage = "Usage: " CMDLINE_PARSER_PACKAGE " [OPTIONS]..."; const char *gengetopt_args_info_usage = "Usage: " CMDLINE_PARSER_PACKAGE " [OPTIONS]...";
const char *gengetopt_args_info_versiontext = "";
const char *gengetopt_args_info_description = ""; const char *gengetopt_args_info_description = "";
const char *gengetopt_args_info_help[] = { const char *gengetopt_args_info_help[] = {
@ -37,8 +39,8 @@ const char *gengetopt_args_info_help[] = {
" -f, --fg Run in foreground (default=off)", " -f, --fg Run in foreground (default=off)",
" -d, --debug Run in debug mode (default=off)", " -d, --debug Run in debug mode (default=off)",
" -c, --conf=STRING Read configuration file (default=`/etc/ggsn.conf')", " -c, --conf=STRING Read configuration file (default=`/etc/ggsn.conf')",
" --pidfile=STRING Filename of process id file \n (default=`/var/run/ggsn.pid')", " --pidfile=STRING Filename of process id file\n (default=`/var/run/ggsn.pid')",
" --statedir=STRING Directory of nonvolatile data \n (default=`/var/lib/ggsn/')", " --statedir=STRING Directory of nonvolatile data\n (default=`/var/lib/ggsn/')",
" -l, --listen=STRING Local interface", " -l, --listen=STRING Local interface",
" -n, --net=STRING Network (default=`192.168.0.0/24')", " -n, --net=STRING Network (default=`192.168.0.0/24')",
" --ipup=STRING Script to run after link-up", " --ipup=STRING Script to run after link-up",
@ -52,7 +54,7 @@ const char *gengetopt_args_info_help[] = {
" -q, --qos=INT Requested quality of service (default=`0x0b921f')", " -q, --qos=INT Requested quality of service (default=`0x0b921f')",
" --logfile=STRING Logfile for errors", " --logfile=STRING Logfile for errors",
" --loglevel=STRING Global log ldevel (default=`error')", " --loglevel=STRING Global log ldevel (default=`error')",
" -g, --gtpnl=STRING GTP kernel support (default=`eth0')", " -g, --gtp-linux GTP linux kernel support (default=off)",
0 0
}; };
@ -122,7 +124,7 @@ void clear_given (struct gengetopt_args_info *args_info)
args_info->qos_given = 0 ; args_info->qos_given = 0 ;
args_info->logfile_given = 0 ; args_info->logfile_given = 0 ;
args_info->loglevel_given = 0 ; args_info->loglevel_given = 0 ;
args_info->gtpnl_given = 0 ; args_info->gtp_linux_given = 0 ;
} }
static static
@ -163,8 +165,7 @@ void clear_args (struct gengetopt_args_info *args_info)
args_info->logfile_orig = NULL; args_info->logfile_orig = NULL;
args_info->loglevel_arg = gengetopt_strdup ("error"); args_info->loglevel_arg = gengetopt_strdup ("error");
args_info->loglevel_orig = NULL; args_info->loglevel_orig = NULL;
args_info->gtpnl_arg = gengetopt_strdup ("eth0"); args_info->gtp_linux_flag = 0;
args_info->gtpnl_orig = NULL;
} }
@ -193,7 +194,7 @@ void init_args_info(struct gengetopt_args_info *args_info)
args_info->qos_help = gengetopt_args_info_help[17] ; args_info->qos_help = gengetopt_args_info_help[17] ;
args_info->logfile_help = gengetopt_args_info_help[18] ; args_info->logfile_help = gengetopt_args_info_help[18] ;
args_info->loglevel_help = gengetopt_args_info_help[19] ; args_info->loglevel_help = gengetopt_args_info_help[19] ;
args_info->gtpnl_help = gengetopt_args_info_help[19] ; args_info->gtp_linux_help = gengetopt_args_info_help[20] ;
} }
@ -203,6 +204,9 @@ cmdline_parser_print_version (void)
printf ("%s %s\n", printf ("%s %s\n",
(strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE), (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE),
CMDLINE_PARSER_VERSION); CMDLINE_PARSER_VERSION);
if (strlen(gengetopt_args_info_versiontext) > 0)
printf("\n%s\n", gengetopt_args_info_versiontext);
} }
static void print_help_common(void) { static void print_help_common(void) {
@ -304,8 +308,6 @@ cmdline_parser_release (struct gengetopt_args_info *args_info)
free_string_field (&(args_info->logfile_orig)); free_string_field (&(args_info->logfile_orig));
free_string_field (&(args_info->loglevel_arg)); free_string_field (&(args_info->loglevel_arg));
free_string_field (&(args_info->loglevel_orig)); free_string_field (&(args_info->loglevel_orig));
free_string_field (&(args_info->gtpnl_arg));
free_string_field (&(args_info->gtpnl_orig));
@ -376,8 +378,8 @@ cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
write_into_file(outfile, "logfile", args_info->logfile_orig, 0); write_into_file(outfile, "logfile", args_info->logfile_orig, 0);
if (args_info->loglevel_given) if (args_info->loglevel_given)
write_into_file(outfile, "loglevel", args_info->loglevel_orig, 0); write_into_file(outfile, "loglevel", args_info->loglevel_orig, 0);
if (args_info->gtpnl_given) if (args_info->gtp_linux_given)
write_into_file(outfile, "gtpnl", args_info->gtpnl_orig, 0); write_into_file(outfile, "gtp-linux", 0, 0 );
i = EXIT_SUCCESS; i = EXIT_SUCCESS;
@ -602,7 +604,7 @@ cmdline_parser_internal (
{ {
int c; /* Character of the parsed option. */ int c; /* Character of the parsed option. */
int error = 0; int error_occurred = 0;
struct gengetopt_args_info local_args_info; struct gengetopt_args_info local_args_info;
int override; int override;
@ -652,11 +654,11 @@ cmdline_parser_internal (
{ "qos", 1, NULL, 'q' }, { "qos", 1, NULL, 'q' },
{ "logfile", 1, NULL, 0 }, { "logfile", 1, NULL, 0 },
{ "loglevel", 1, NULL, 0 }, { "loglevel", 1, NULL, 0 },
{ "gtpnl", 1, NULL, 'g' }, { "gtp-linux", 0, NULL, 'g' },
{ 0, 0, 0, 0 } { 0, 0, 0, 0 }
}; };
c = getopt_long (argc, argv, "hVfdc:l:n:a:q:g:", long_options, &option_index); c = getopt_long (argc, argv, "hVfdc:l:n:a:q:g", long_options, &option_index);
if (c == -1) break; /* Exit from `while (1)' loop. */ if (c == -1) break; /* Exit from `while (1)' loop. */
@ -752,14 +754,12 @@ cmdline_parser_internal (
goto failure; goto failure;
break; break;
case 'g': /* GTP kernel support. */ case 'g': /* GTP linux kernel support. */
if (update_arg( (void *)&(args_info->gtpnl_arg), if (update_arg((void *)&(args_info->gtp_linux_flag), 0, &(args_info->gtp_linux_given),
&(args_info->gtpnl_orig), &(args_info->gtpnl_given), &(local_args_info.gtp_linux_given), optarg, 0, 0, ARG_FLAG,
&(local_args_info.gtpnl_given), optarg, 0, "eth0", ARG_STRING, check_ambiguity, override, 1, 0, "gtp-linux", 'g',
check_ambiguity, override, 0, 0,
"gtpnl", 'g',
additional_error)) additional_error))
goto failure; goto failure;
@ -937,7 +937,7 @@ cmdline_parser_internal (
cmdline_parser_release (&local_args_info); cmdline_parser_release (&local_args_info);
if ( error ) if ( error_occurred )
return (EXIT_FAILURE); return (EXIT_FAILURE);
return 0; return 0;

View File

@ -34,5 +34,5 @@ option "qos" q "Requested quality of service" int default="0x0b921f
option "logfile" - "Logfile for errors" string no option "logfile" - "Logfile for errors" string no
option "loglevel" - "Global log ldevel" string default="error" no option "loglevel" - "Global log ldevel" string default="error" no
option "gtpnl" g "GTP kernel support" string default="eth0" no option "gtp-linux" g "GTP linux kernel support" flag off

View File

@ -1,6 +1,6 @@
/** @file cmdline.h /** @file cmdline.h
* @brief The header file for the command line option parser * @brief The header file for the command line option parser
* generated by GNU Gengetopt version 2.22.5 * generated by GNU Gengetopt version 2.22.6
* http://www.gnu.org/software/gengetopt. * http://www.gnu.org/software/gengetopt.
* DO NOT modify this file, since it can be overwritten * DO NOT modify this file, since it can be overwritten
* @author GNU Gengetopt by Lorenzo Bettini */ * @author GNU Gengetopt by Lorenzo Bettini */
@ -95,9 +95,8 @@ struct gengetopt_args_info
char * loglevel_arg; /**< @brief Global log ldevel (default='error'). */ char * loglevel_arg; /**< @brief Global log ldevel (default='error'). */
char * loglevel_orig; /**< @brief Global log ldevel original value given at command line. */ char * loglevel_orig; /**< @brief Global log ldevel original value given at command line. */
const char *loglevel_help; /**< @brief Global log ldevel help description. */ const char *loglevel_help; /**< @brief Global log ldevel help description. */
char * gtpnl_arg; /**< @brief GTP kernel support (default='eth0'). */ int gtp_linux_flag; /**< @brief GTP linux kernel support (default=off). */
char * gtpnl_orig; /**< @brief GTP kernel support original value given at command line. */ const char *gtp_linux_help; /**< @brief GTP linux kernel support help description. */
const char *gtpnl_help; /**< @brief GTP kernel support help description. */
unsigned int help_given ; /**< @brief Whether help was given. */ unsigned int help_given ; /**< @brief Whether help was given. */
unsigned int version_given ; /**< @brief Whether version was given. */ unsigned int version_given ; /**< @brief Whether version was given. */
@ -119,7 +118,7 @@ struct gengetopt_args_info
unsigned int qos_given ; /**< @brief Whether qos was given. */ unsigned int qos_given ; /**< @brief Whether qos was given. */
unsigned int logfile_given ; /**< @brief Whether logfile was given. */ unsigned int logfile_given ; /**< @brief Whether logfile was given. */
unsigned int loglevel_given ; /**< @brief Whether loglevel was given. */ unsigned int loglevel_given ; /**< @brief Whether loglevel was given. */
unsigned int gtpnl_given ; /**< @brief Whether gtpnl was given. */ unsigned int gtp_linux_given ; /**< @brief Whether gtp-linux was given. */
} ; } ;
@ -137,6 +136,8 @@ struct cmdline_parser_params
extern const char *gengetopt_args_info_purpose; extern const char *gengetopt_args_info_purpose;
/** @brief the usage string of the program */ /** @brief the usage string of the program */
extern const char *gengetopt_args_info_usage; extern const char *gengetopt_args_info_usage;
/** @brief the description string of the program */
extern const char *gengetopt_args_info_description;
/** @brief all the lines making the help output */ /** @brief all the lines making the help output */
extern const char *gengetopt_args_info_help[]; extern const char *gengetopt_args_info_help[];

View File

@ -260,8 +260,8 @@ int main(int argc, char **argv)
printf("pidfile: %s\n", args_info.pidfile_arg); printf("pidfile: %s\n", args_info.pidfile_arg);
if (args_info.statedir_arg) if (args_info.statedir_arg)
printf("statedir: %s\n", args_info.statedir_arg); printf("statedir: %s\n", args_info.statedir_arg);
if (args_info.gtpnl_arg) if (args_info.gtp_linux_flag)
printf("gtpnl: %s\n", args_info.gtpnl_arg); printf("gtp_linux: %d\n", args_info.gtp_linux_flag);
printf("timelimit: %d\n", args_info.timelimit_arg); printf("timelimit: %d\n", args_info.timelimit_arg);
} }
@ -322,8 +322,8 @@ int main(int argc, char **argv)
printf("pidfile: %s\n", args_info.pidfile_arg); printf("pidfile: %s\n", args_info.pidfile_arg);
if (args_info.statedir_arg) if (args_info.statedir_arg)
printf("statedir: %s\n", args_info.statedir_arg); printf("statedir: %s\n", args_info.statedir_arg);
if (args_info.gtpnl_arg) if (args_info.gtp_linux_flag)
printf("gtpnl: %s\n", args_info.gtpnl_arg); printf("gtp-linux: %d\n", args_info.gtp_linux_flag);
printf("timelimit: %d\n", args_info.timelimit_arg); printf("timelimit: %d\n", args_info.timelimit_arg);
} }

View File

@ -94,7 +94,7 @@ int gtp_kernel_init(struct gsn_t *gsn, struct in_addr *net,
struct in_addr *mask, struct in_addr *mask,
struct gengetopt_args_info *args_info) struct gengetopt_args_info *args_info)
{ {
if (!args_info->gtpnl_given) if (!args_info->gtp_linux_given)
return 0; return 0;
if (gtp_dev_create(-1, GTP_DEVNAME, gsn->fd0, gsn->fd1u) < 0) { if (gtp_dev_create(-1, GTP_DEVNAME, gsn->fd0, gsn->fd1u) < 0) {