/* File autogenerated by gengetopt version 2.22 generated with the following command: gengetopt -C --no-handle-help --no-handle-version The developers of gengetopt consider the fixed text that goes in all gengetopt output files to be in the public domain: we make no copyright claims on it. */ /* If we use autoconf. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include "getopt.h" #include "cmdline.h" const char *gengetopt_args_info_purpose = ""; const char *gengetopt_args_info_usage = "Usage: " CMDLINE_PARSER_PACKAGE " [OPTIONS]..."; const char *gengetopt_args_info_description = ""; const char *gengetopt_args_info_help[] = { " -h, --help Print help and exit", " -V, --version Print version and exit", " -f, --fg Run in foreground (default=off)", " -d, --debug Run in debug mode (default=off)", " --debugfacility=INT Which modules to print debug messages for \n (default=`1')", " --logfacility=INT Syslog facility to be used for logging \n (default=`-1')", " -c, --conf=STRING Read configuration file", " --interval=INT Re-read configuration file at this interval \n (default=`3600')", " --pidfile=STRING Filename of process id file", " --statedir=STRING Directory of nonvolatile data", " -n, --net=STRING Network (default=`192.168.182.0/24')", " --dhcpstart=INT Network DHCP Starting IP (default=`0')", " --dhcpend=INT Network DHCP Ending IP (default=`0')", " --dynip=STRING Dynamic IP address pool", " --nodynip No Dynamic IP assignment (default=off)", " --statip=STRING Static IP address pool", " --dns1=STRING Primary DNS server IP address", " --dns2=STRING Secondary DNS server IP address", " --domain=STRING Domain to use for DNS lookups \n (default=`coova.org')", " --ipup=STRING Script to run after link-up", " --ipdown=STRING Script to run after link-down", " --conup=STRING Script to run after user logon", " --condown=STRING Script to run after user logoff", " --txqlen=INT TX Queue length for tun interface (linux only) \n (default=`100')", " --tundev=STRING TUN/TAP Device, as in tun0 or tap1", " --radiuslisten=STRING IP address to send from", " --radiusserver1=STRING IP address of radius server 1 \n (default=`rad01.coova.org')", " --radiusserver2=STRING IP address of radius server 2 \n (default=`rad01.coova.org')", " --radiusauthport=INT Authentication UDP port of radius server \n (default=`1812')", " --radiusacctport=INT Accounting UDP port of radius server \n (default=`1813')", " --radiussecret=STRING Radius shared secret \n (default=`coova-anonymous')", " --radiustimeout=INT Retry timeout in seconds (default=`30')", " --radiusretry=INT Total number of retries (default=`6')", " --radiusretrysec=INT Number of retries before using secondary \n (default=`3')", " --radiusnasid=STRING Radius NAS-Identifier (default=`nas01')", " --radiuslocationid=STRING WISPr Location ID", " --radiuslocationname=STRING\n WISPr Location Name", " --locationname=STRING Location Name", " --radiusnasporttype=INT Radius NAS-Port-Type (default=`19')", " --coaport=INT Radius disconnect port to listen to \n (default=`0')", " --coanoipcheck Allow radius disconnect from any IP \n (default=off)", " --proxylisten=STRING IP address to listen to", " --proxyport=INT UDP port to listen to (default=`0')", " --proxyclient=STRING IP address of proxy client(s)", " --proxysecret=STRING Radius proxy shared secret", " --dhcpif=STRING Local Ethernet interface", " --dhcpmac=STRING Interface MAC address", " --dhcpradius Map certain DHCP options to RADIUS attributes \n (default=off)", " --dhcpgateway=STRING DHCP gateway addresss for relay", " --dhcpgatewayport=INT DHCP gateway port for relay (default=`67')", " --dhcprelayagent=STRING DHCP relay agent IP addresss (default \n uamlisten)", " --lease=INT Lease time to allocate to clients \n (default=`600')", " --eapolenable Enable IEEE 802.1x authentication \n (default=off)", " --uamserver=STRING URL of authentication web server", " --uamhomepage=STRING URL of homepage to redirect unauthenticated \n users to", " --uamsecret=STRING Shared secret between uamserver and chilli", " --uamlisten=STRING IP address to listen to for authentication \n requests", " --uamport=INT TCP port to bind to for authentication requests \n (default=`3990')", " --uamuiport=INT TCP port to bind to for UAM UI requests \n (default=`3991')", " --uamallowed=STRING Domain names exempt from access check ", " --uamdomain=STRING Domain name allowed (active dns filtering; one \n per line!) ", " --uamanydns Allow client to use any DNS server \n (default=off)", " --uamanyip Allow client to use any IP Address \n (default=off)", " --wisprlogin=STRING A specific WISPr login url to be used", " --nouamsuccess Do not return to the UAM server on success, \n original url instead (default=off)", " --nouamwispr Do not send WISPr XML from ChilliSpot, assume \n back-end does (default=off)", " --uamlogoutip=STRING HTTP Auto-Logout IP Address \n (default=`1.1.1.1')", " --defsessiontimeout=LONG Default session-timeout if not returned by \n RADIUS (default=`0')", " --defidletimeout=INT Default idle-timeout if not returned by RADIUS \n (default=`0')", " --defbandwidthmaxdown=LONG\n Default WISPr-Bandwidth-Max-Down if not \n returned by RADIUS (default=`0')", " --defbandwidthmaxup=LONG Default WISPr-Bandwidth-Max-Up if not returned \n by RADIUS (default=`0')", " --definteriminterval=INT Default interim-interval for accounting if not \n returned by RADIUS (default=`300')", " --macauth Authenticate based on MAC address \n (default=off)", " --macauthdeny Deny access (even UAM) to MAC addresses given \n Access-Reject (default=off)", " --macallowed=STRING List of allowed MAC addresses", " --macsuffix=STRING Suffix to add to the MAC address", " --macpasswd=STRING Password used when performing MAC \n authentication", " --macallowlocal Do not use RADIUS for authenticating the \n macallowed (default=off)", " --wwwdir=STRING Local content served by chilli (for splash \n page, etc)", " --wwwbin=STRING Script binary (such as haserl) for simple web \n programming", " --uamui=STRING Program in inetd style to handle all uam \n requests", " --adminuser=STRING RADIUS administrative user login username \n (default=`chillispot')", " --adminpasswd=STRING RADIUS administrative user login password \n (default=`chillispot')", " --nasmac=STRING Unique MAC address of the NAS \n (called-station-id)", " --nasip=STRING Unique IP address of the NAS (nas-ip-address)", " --ssid=STRING SSID of the session", " --vlan=STRING VLAN of the session", " --cmdsocket=STRING path to the command unix socket", " --radiusoriginalurl Turn on the sending of ChilliSpot-OriginalURL \n in Access-Request (default=off)", " --swapoctets Swap the meaning of input/output octets/packets \n (default=off)", " --usestatusfile Use the status file to keep track of sessions \n (default=off)", " --localusers=STRING File keep 'Local' usernames and passwords", " --postauthproxy=STRING IP of an upstream transparent proxy", " --postauthproxyport=INT Port of an upstream transparent proxy \n (default=`0')", " --wpaguests Allow WPA 'Guest' access (default=off)", " --openidauth Allow OpenID authentication (default=off)", " --papalwaysok Always allow 'PAP' authentication (depreciated; \n always on) (default=off)", " --chillixml Use ChilliSpot XML in WISPr blocks \n (default=off)", " --acctupdate Allow updating of session attributes in \n Accounting-Response (default=off)", " --dnsparanoia Inspect DNS packets and drop responses with any \n non- A, CNAME, SOA, or MX records (to prevent \n dns tunnels) (default=off)", " --usetap Use a TAP instead of TUN (linux only) \n (default=off)", " --routeif=STRING Interface to use as default route; turns on \n 'manual' routing", 0 }; typedef enum {ARG_NO , ARG_FLAG , ARG_STRING , ARG_INT , ARG_LONG } cmdline_parser_arg_type; static void clear_given (struct gengetopt_args_info *args_info); static void clear_args (struct gengetopt_args_info *args_info); static int cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, struct cmdline_parser_params *params, const char *additional_error); static int cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error); struct line_list { char * string_arg; struct line_list * next; }; static struct line_list *cmd_line_list = 0; static struct line_list *cmd_line_list_tmp = 0; static void free_cmd_list(void) { /* free the list of a previous call */ if (cmd_line_list) { while (cmd_line_list) { cmd_line_list_tmp = cmd_line_list; cmd_line_list = cmd_line_list->next; free (cmd_line_list_tmp->string_arg); free (cmd_line_list_tmp); } } } static char * gengetopt_strdup (const char *s); static void clear_given (struct gengetopt_args_info *args_info) { args_info->help_given = 0 ; args_info->version_given = 0 ; args_info->fg_given = 0 ; args_info->debug_given = 0 ; args_info->debugfacility_given = 0 ; args_info->logfacility_given = 0 ; args_info->conf_given = 0 ; args_info->interval_given = 0 ; args_info->pidfile_given = 0 ; args_info->statedir_given = 0 ; args_info->net_given = 0 ; args_info->dhcpstart_given = 0 ; args_info->dhcpend_given = 0 ; args_info->dynip_given = 0 ; args_info->nodynip_given = 0 ; args_info->statip_given = 0 ; args_info->dns1_given = 0 ; args_info->dns2_given = 0 ; args_info->domain_given = 0 ; args_info->ipup_given = 0 ; args_info->ipdown_given = 0 ; args_info->conup_given = 0 ; args_info->condown_given = 0 ; args_info->txqlen_given = 0 ; args_info->tundev_given = 0 ; args_info->radiuslisten_given = 0 ; args_info->radiusserver1_given = 0 ; args_info->radiusserver2_given = 0 ; args_info->radiusauthport_given = 0 ; args_info->radiusacctport_given = 0 ; args_info->radiussecret_given = 0 ; args_info->radiustimeout_given = 0 ; args_info->radiusretry_given = 0 ; args_info->radiusretrysec_given = 0 ; args_info->radiusnasid_given = 0 ; args_info->radiuslocationid_given = 0 ; args_info->radiuslocationname_given = 0 ; args_info->locationname_given = 0 ; args_info->radiusnasporttype_given = 0 ; args_info->coaport_given = 0 ; args_info->coanoipcheck_given = 0 ; args_info->proxylisten_given = 0 ; args_info->proxyport_given = 0 ; args_info->proxyclient_given = 0 ; args_info->proxysecret_given = 0 ; args_info->dhcpif_given = 0 ; args_info->dhcpmac_given = 0 ; args_info->dhcpradius_given = 0 ; args_info->dhcpgateway_given = 0 ; args_info->dhcpgatewayport_given = 0 ; args_info->dhcprelayagent_given = 0 ; args_info->lease_given = 0 ; args_info->eapolenable_given = 0 ; args_info->uamserver_given = 0 ; args_info->uamhomepage_given = 0 ; args_info->uamsecret_given = 0 ; args_info->uamlisten_given = 0 ; args_info->uamport_given = 0 ; args_info->uamuiport_given = 0 ; args_info->uamallowed_given = 0 ; args_info->uamdomain_given = 0 ; args_info->uamanydns_given = 0 ; args_info->uamanyip_given = 0 ; args_info->wisprlogin_given = 0 ; args_info->nouamsuccess_given = 0 ; args_info->nouamwispr_given = 0 ; args_info->uamlogoutip_given = 0 ; args_info->defsessiontimeout_given = 0 ; args_info->defidletimeout_given = 0 ; args_info->defbandwidthmaxdown_given = 0 ; args_info->defbandwidthmaxup_given = 0 ; args_info->definteriminterval_given = 0 ; args_info->macauth_given = 0 ; args_info->macauthdeny_given = 0 ; args_info->macallowed_given = 0 ; args_info->macsuffix_given = 0 ; args_info->macpasswd_given = 0 ; args_info->macallowlocal_given = 0 ; args_info->wwwdir_given = 0 ; args_info->wwwbin_given = 0 ; args_info->uamui_given = 0 ; args_info->adminuser_given = 0 ; args_info->adminpasswd_given = 0 ; args_info->nasmac_given = 0 ; args_info->nasip_given = 0 ; args_info->ssid_given = 0 ; args_info->vlan_given = 0 ; args_info->cmdsocket_given = 0 ; args_info->radiusoriginalurl_given = 0 ; args_info->swapoctets_given = 0 ; args_info->usestatusfile_given = 0 ; args_info->localusers_given = 0 ; args_info->postauthproxy_given = 0 ; args_info->postauthproxyport_given = 0 ; args_info->wpaguests_given = 0 ; args_info->openidauth_given = 0 ; args_info->papalwaysok_given = 0 ; args_info->chillixml_given = 0 ; args_info->acctupdate_given = 0 ; args_info->dnsparanoia_given = 0 ; args_info->usetap_given = 0 ; args_info->routeif_given = 0 ; } static void clear_args (struct gengetopt_args_info *args_info) { args_info->fg_flag = 0; args_info->debug_flag = 0; args_info->debugfacility_arg = 1; args_info->debugfacility_orig = NULL; args_info->logfacility_arg = -1; args_info->logfacility_orig = NULL; args_info->conf_arg = NULL; args_info->conf_orig = NULL; args_info->interval_arg = 3600; args_info->interval_orig = NULL; args_info->pidfile_arg = NULL; args_info->pidfile_orig = NULL; args_info->statedir_arg = NULL; args_info->statedir_orig = NULL; args_info->net_arg = gengetopt_strdup ("192.168.182.0/24"); args_info->net_orig = NULL; args_info->dhcpstart_arg = 0; args_info->dhcpstart_orig = NULL; args_info->dhcpend_arg = 0; args_info->dhcpend_orig = NULL; args_info->dynip_arg = NULL; args_info->dynip_orig = NULL; args_info->nodynip_flag = 0; args_info->statip_arg = NULL; args_info->statip_orig = NULL; args_info->dns1_arg = NULL; args_info->dns1_orig = NULL; args_info->dns2_arg = NULL; args_info->dns2_orig = NULL; args_info->domain_arg = gengetopt_strdup ("coova.org"); args_info->domain_orig = NULL; args_info->ipup_arg = NULL; args_info->ipup_orig = NULL; args_info->ipdown_arg = NULL; args_info->ipdown_orig = NULL; args_info->conup_arg = NULL; args_info->conup_orig = NULL; args_info->condown_arg = NULL; args_info->condown_orig = NULL; args_info->txqlen_arg = 100; args_info->txqlen_orig = NULL; args_info->tundev_arg = NULL; args_info->tundev_orig = NULL; args_info->radiuslisten_arg = NULL; args_info->radiuslisten_orig = NULL; args_info->radiusserver1_arg = gengetopt_strdup ("rad01.coova.org"); args_info->radiusserver1_orig = NULL; args_info->radiusserver2_arg = gengetopt_strdup ("rad01.coova.org"); args_info->radiusserver2_orig = NULL; args_info->radiusauthport_arg = 1812; args_info->radiusauthport_orig = NULL; args_info->radiusacctport_arg = 1813; args_info->radiusacctport_orig = NULL; args_info->radiussecret_arg = gengetopt_strdup ("coova-anonymous"); args_info->radiussecret_orig = NULL; args_info->radiustimeout_arg = 30; args_info->radiustimeout_orig = NULL; args_info->radiusretry_arg = 6; args_info->radiusretry_orig = NULL; args_info->radiusretrysec_arg = 3; args_info->radiusretrysec_orig = NULL; args_info->radiusnasid_arg = gengetopt_strdup ("nas01"); args_info->radiusnasid_orig = NULL; args_info->radiuslocationid_arg = NULL; args_info->radiuslocationid_orig = NULL; args_info->radiuslocationname_arg = NULL; args_info->radiuslocationname_orig = NULL; args_info->locationname_arg = NULL; args_info->locationname_orig = NULL; args_info->radiusnasporttype_arg = 19; args_info->radiusnasporttype_orig = NULL; args_info->coaport_arg = 0; args_info->coaport_orig = NULL; args_info->coanoipcheck_flag = 0; args_info->proxylisten_arg = NULL; args_info->proxylisten_orig = NULL; args_info->proxyport_arg = 0; args_info->proxyport_orig = NULL; args_info->proxyclient_arg = NULL; args_info->proxyclient_orig = NULL; args_info->proxysecret_arg = NULL; args_info->proxysecret_orig = NULL; args_info->dhcpif_arg = NULL; args_info->dhcpif_orig = NULL; args_info->dhcpmac_arg = NULL; args_info->dhcpmac_orig = NULL; args_info->dhcpradius_flag = 0; args_info->dhcpgateway_arg = NULL; args_info->dhcpgateway_orig = NULL; args_info->dhcpgatewayport_arg = 67; args_info->dhcpgatewayport_orig = NULL; args_info->dhcprelayagent_arg = NULL; args_info->dhcprelayagent_orig = NULL; args_info->lease_arg = 600; args_info->lease_orig = NULL; args_info->eapolenable_flag = 0; args_info->uamserver_arg = NULL; args_info->uamserver_orig = NULL; args_info->uamhomepage_arg = NULL; args_info->uamhomepage_orig = NULL; args_info->uamsecret_arg = NULL; args_info->uamsecret_orig = NULL; args_info->uamlisten_arg = NULL; args_info->uamlisten_orig = NULL; args_info->uamport_arg = 3990; args_info->uamport_orig = NULL; args_info->uamuiport_arg = 3991; args_info->uamuiport_orig = NULL; args_info->uamallowed_arg = NULL; args_info->uamallowed_orig = NULL; args_info->uamdomain_arg = NULL; args_info->uamdomain_orig = NULL; args_info->uamanydns_flag = 0; args_info->uamanyip_flag = 0; args_info->wisprlogin_arg = NULL; args_info->wisprlogin_orig = NULL; args_info->nouamsuccess_flag = 0; args_info->nouamwispr_flag = 0; args_info->uamlogoutip_arg = gengetopt_strdup ("1.1.1.1"); args_info->uamlogoutip_orig = NULL; args_info->defsessiontimeout_arg = 0; args_info->defsessiontimeout_orig = NULL; args_info->defidletimeout_arg = 0; args_info->defidletimeout_orig = NULL; args_info->defbandwidthmaxdown_arg = 0; args_info->defbandwidthmaxdown_orig = NULL; args_info->defbandwidthmaxup_arg = 0; args_info->defbandwidthmaxup_orig = NULL; args_info->definteriminterval_arg = 300; args_info->definteriminterval_orig = NULL; args_info->macauth_flag = 0; args_info->macauthdeny_flag = 0; args_info->macallowed_arg = NULL; args_info->macallowed_orig = NULL; args_info->macsuffix_arg = NULL; args_info->macsuffix_orig = NULL; args_info->macpasswd_arg = NULL; args_info->macpasswd_orig = NULL; args_info->macallowlocal_flag = 0; args_info->wwwdir_arg = NULL; args_info->wwwdir_orig = NULL; args_info->wwwbin_arg = NULL; args_info->wwwbin_orig = NULL; args_info->uamui_arg = NULL; args_info->uamui_orig = NULL; args_info->adminuser_arg = gengetopt_strdup ("chillispot"); args_info->adminuser_orig = NULL; args_info->adminpasswd_arg = gengetopt_strdup ("chillispot"); args_info->adminpasswd_orig = NULL; args_info->nasmac_arg = NULL; args_info->nasmac_orig = NULL; args_info->nasip_arg = NULL; args_info->nasip_orig = NULL; args_info->ssid_arg = NULL; args_info->ssid_orig = NULL; args_info->vlan_arg = NULL; args_info->vlan_orig = NULL; args_info->cmdsocket_arg = NULL; args_info->cmdsocket_orig = NULL; args_info->radiusoriginalurl_flag = 0; args_info->swapoctets_flag = 0; args_info->usestatusfile_flag = 0; args_info->localusers_arg = NULL; args_info->localusers_orig = NULL; args_info->postauthproxy_arg = NULL; args_info->postauthproxy_orig = NULL; args_info->postauthproxyport_arg = 0; args_info->postauthproxyport_orig = NULL; args_info->wpaguests_flag = 0; args_info->openidauth_flag = 0; args_info->papalwaysok_flag = 0; args_info->chillixml_flag = 0; args_info->acctupdate_flag = 0; args_info->dnsparanoia_flag = 0; args_info->usetap_flag = 0; args_info->routeif_arg = NULL; args_info->routeif_orig = NULL; } static void init_args_info(struct gengetopt_args_info *args_info) { args_info->help_help = gengetopt_args_info_help[0] ; args_info->version_help = gengetopt_args_info_help[1] ; args_info->fg_help = gengetopt_args_info_help[2] ; args_info->debug_help = gengetopt_args_info_help[3] ; args_info->debugfacility_help = gengetopt_args_info_help[4] ; args_info->logfacility_help = gengetopt_args_info_help[5] ; args_info->conf_help = gengetopt_args_info_help[6] ; args_info->interval_help = gengetopt_args_info_help[7] ; args_info->pidfile_help = gengetopt_args_info_help[8] ; args_info->statedir_help = gengetopt_args_info_help[9] ; args_info->net_help = gengetopt_args_info_help[10] ; args_info->dhcpstart_help = gengetopt_args_info_help[11] ; args_info->dhcpend_help = gengetopt_args_info_help[12] ; args_info->dynip_help = gengetopt_args_info_help[13] ; args_info->nodynip_help = gengetopt_args_info_help[14] ; args_info->statip_help = gengetopt_args_info_help[15] ; args_info->dns1_help = gengetopt_args_info_help[16] ; args_info->dns2_help = gengetopt_args_info_help[17] ; args_info->domain_help = gengetopt_args_info_help[18] ; args_info->ipup_help = gengetopt_args_info_help[19] ; args_info->ipdown_help = gengetopt_args_info_help[20] ; args_info->conup_help = gengetopt_args_info_help[21] ; args_info->condown_help = gengetopt_args_info_help[22] ; args_info->txqlen_help = gengetopt_args_info_help[23] ; args_info->tundev_help = gengetopt_args_info_help[24] ; args_info->radiuslisten_help = gengetopt_args_info_help[25] ; args_info->radiusserver1_help = gengetopt_args_info_help[26] ; args_info->radiusserver2_help = gengetopt_args_info_help[27] ; args_info->radiusauthport_help = gengetopt_args_info_help[28] ; args_info->radiusacctport_help = gengetopt_args_info_help[29] ; args_info->radiussecret_help = gengetopt_args_info_help[30] ; args_info->radiustimeout_help = gengetopt_args_info_help[31] ; args_info->radiusretry_help = gengetopt_args_info_help[32] ; args_info->radiusretrysec_help = gengetopt_args_info_help[33] ; args_info->radiusnasid_help = gengetopt_args_info_help[34] ; args_info->radiuslocationid_help = gengetopt_args_info_help[35] ; args_info->radiuslocationname_help = gengetopt_args_info_help[36] ; args_info->locationname_help = gengetopt_args_info_help[37] ; args_info->radiusnasporttype_help = gengetopt_args_info_help[38] ; args_info->coaport_help = gengetopt_args_info_help[39] ; args_info->coanoipcheck_help = gengetopt_args_info_help[40] ; args_info->proxylisten_help = gengetopt_args_info_help[41] ; args_info->proxyport_help = gengetopt_args_info_help[42] ; args_info->proxyclient_help = gengetopt_args_info_help[43] ; args_info->proxysecret_help = gengetopt_args_info_help[44] ; args_info->dhcpif_help = gengetopt_args_info_help[45] ; args_info->dhcpmac_help = gengetopt_args_info_help[46] ; args_info->dhcpradius_help = gengetopt_args_info_help[47] ; args_info->dhcpgateway_help = gengetopt_args_info_help[48] ; args_info->dhcpgatewayport_help = gengetopt_args_info_help[49] ; args_info->dhcprelayagent_help = gengetopt_args_info_help[50] ; args_info->lease_help = gengetopt_args_info_help[51] ; args_info->eapolenable_help = gengetopt_args_info_help[52] ; args_info->uamserver_help = gengetopt_args_info_help[53] ; args_info->uamhomepage_help = gengetopt_args_info_help[54] ; args_info->uamsecret_help = gengetopt_args_info_help[55] ; args_info->uamlisten_help = gengetopt_args_info_help[56] ; args_info->uamport_help = gengetopt_args_info_help[57] ; args_info->uamuiport_help = gengetopt_args_info_help[58] ; args_info->uamallowed_help = gengetopt_args_info_help[59] ; args_info->uamallowed_min = -1; args_info->uamallowed_max = -1; args_info->uamdomain_help = gengetopt_args_info_help[60] ; args_info->uamdomain_min = -1; args_info->uamdomain_max = -1; args_info->uamanydns_help = gengetopt_args_info_help[61] ; args_info->uamanyip_help = gengetopt_args_info_help[62] ; args_info->wisprlogin_help = gengetopt_args_info_help[63] ; args_info->nouamsuccess_help = gengetopt_args_info_help[64] ; args_info->nouamwispr_help = gengetopt_args_info_help[65] ; args_info->uamlogoutip_help = gengetopt_args_info_help[66] ; args_info->defsessiontimeout_help = gengetopt_args_info_help[67] ; args_info->defidletimeout_help = gengetopt_args_info_help[68] ; args_info->defbandwidthmaxdown_help = gengetopt_args_info_help[69] ; args_info->defbandwidthmaxup_help = gengetopt_args_info_help[70] ; args_info->definteriminterval_help = gengetopt_args_info_help[71] ; args_info->macauth_help = gengetopt_args_info_help[72] ; args_info->macauthdeny_help = gengetopt_args_info_help[73] ; args_info->macallowed_help = gengetopt_args_info_help[74] ; args_info->macallowed_min = -1; args_info->macallowed_max = -1; args_info->macsuffix_help = gengetopt_args_info_help[75] ; args_info->macpasswd_help = gengetopt_args_info_help[76] ; args_info->macallowlocal_help = gengetopt_args_info_help[77] ; args_info->wwwdir_help = gengetopt_args_info_help[78] ; args_info->wwwbin_help = gengetopt_args_info_help[79] ; args_info->uamui_help = gengetopt_args_info_help[80] ; args_info->adminuser_help = gengetopt_args_info_help[81] ; args_info->adminpasswd_help = gengetopt_args_info_help[82] ; args_info->nasmac_help = gengetopt_args_info_help[83] ; args_info->nasip_help = gengetopt_args_info_help[84] ; args_info->ssid_help = gengetopt_args_info_help[85] ; args_info->vlan_help = gengetopt_args_info_help[86] ; args_info->cmdsocket_help = gengetopt_args_info_help[87] ; args_info->radiusoriginalurl_help = gengetopt_args_info_help[88] ; args_info->swapoctets_help = gengetopt_args_info_help[89] ; args_info->usestatusfile_help = gengetopt_args_info_help[90] ; args_info->localusers_help = gengetopt_args_info_help[91] ; args_info->postauthproxy_help = gengetopt_args_info_help[92] ; args_info->postauthproxyport_help = gengetopt_args_info_help[93] ; args_info->wpaguests_help = gengetopt_args_info_help[94] ; args_info->openidauth_help = gengetopt_args_info_help[95] ; args_info->papalwaysok_help = gengetopt_args_info_help[96] ; args_info->chillixml_help = gengetopt_args_info_help[97] ; args_info->acctupdate_help = gengetopt_args_info_help[98] ; args_info->dnsparanoia_help = gengetopt_args_info_help[99] ; args_info->usetap_help = gengetopt_args_info_help[100] ; args_info->routeif_help = gengetopt_args_info_help[101] ; } void cmdline_parser_print_version (void) { printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION); } static void print_help_common(void) { cmdline_parser_print_version (); if (strlen(gengetopt_args_info_purpose) > 0) printf("\n%s\n", gengetopt_args_info_purpose); if (strlen(gengetopt_args_info_usage) > 0) printf("\n%s\n", gengetopt_args_info_usage); printf("\n"); if (strlen(gengetopt_args_info_description) > 0) printf("%s\n", gengetopt_args_info_description); } void cmdline_parser_print_help (void) { int i = 0; print_help_common(); while (gengetopt_args_info_help[i]) printf("%s\n", gengetopt_args_info_help[i++]); } void cmdline_parser_init (struct gengetopt_args_info *args_info) { clear_given (args_info); clear_args (args_info); init_args_info (args_info); } void cmdline_parser_params_init(struct cmdline_parser_params *params) { if (params) { params->override = 0; params->initialize = 1; params->check_required = 1; params->check_ambiguity = 0; params->print_errors = 1; } } struct cmdline_parser_params * cmdline_parser_params_create(void) { struct cmdline_parser_params *params = (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params)); cmdline_parser_params_init(params); return params; } static void free_string_field (char **s) { if (*s) { free (*s); *s = 0; } } /** @brief generic value variable */ union generic_value { int int_arg; long long_arg; char *string_arg; }; /** @brief holds temporary values for multiple options */ struct generic_list { union generic_value arg; char *orig; struct generic_list *next; }; /** * @brief add a node at the head of the list */ static void add_node(struct generic_list **list) { struct generic_list *new_node = (struct generic_list *) malloc (sizeof (struct generic_list)); new_node->next = *list; *list = new_node; new_node->arg.string_arg = NULL; new_node->orig = NULL; } static void free_multiple_string_field(unsigned int len, char ***arg, char ***orig) { unsigned int i; if (*arg) { for (i = 0; i < len; ++i) { free_string_field(&((*arg)[i])); free_string_field(&((*orig)[i])); } free_string_field(&((*arg)[0])); /* free default string */ free (*arg); *arg = 0; free (*orig); *orig = 0; } } static void cmdline_parser_release (struct gengetopt_args_info *args_info) { free_string_field (&(args_info->debugfacility_orig)); free_string_field (&(args_info->logfacility_orig)); free_string_field (&(args_info->conf_arg)); free_string_field (&(args_info->conf_orig)); free_string_field (&(args_info->interval_orig)); free_string_field (&(args_info->pidfile_arg)); free_string_field (&(args_info->pidfile_orig)); free_string_field (&(args_info->statedir_arg)); free_string_field (&(args_info->statedir_orig)); free_string_field (&(args_info->net_arg)); free_string_field (&(args_info->net_orig)); free_string_field (&(args_info->dhcpstart_orig)); free_string_field (&(args_info->dhcpend_orig)); free_string_field (&(args_info->dynip_arg)); free_string_field (&(args_info->dynip_orig)); free_string_field (&(args_info->statip_arg)); free_string_field (&(args_info->statip_orig)); free_string_field (&(args_info->dns1_arg)); free_string_field (&(args_info->dns1_orig)); free_string_field (&(args_info->dns2_arg)); free_string_field (&(args_info->dns2_orig)); free_string_field (&(args_info->domain_arg)); free_string_field (&(args_info->domain_orig)); free_string_field (&(args_info->ipup_arg)); free_string_field (&(args_info->ipup_orig)); free_string_field (&(args_info->ipdown_arg)); free_string_field (&(args_info->ipdown_orig)); free_string_field (&(args_info->conup_arg)); free_string_field (&(args_info->conup_orig)); free_string_field (&(args_info->condown_arg)); free_string_field (&(args_info->condown_orig)); free_string_field (&(args_info->txqlen_orig)); free_string_field (&(args_info->tundev_arg)); free_string_field (&(args_info->tundev_orig)); free_string_field (&(args_info->radiuslisten_arg)); free_string_field (&(args_info->radiuslisten_orig)); free_string_field (&(args_info->radiusserver1_arg)); free_string_field (&(args_info->radiusserver1_orig)); free_string_field (&(args_info->radiusserver2_arg)); free_string_field (&(args_info->radiusserver2_orig)); free_string_field (&(args_info->radiusauthport_orig)); free_string_field (&(args_info->radiusacctport_orig)); free_string_field (&(args_info->radiussecret_arg)); free_string_field (&(args_info->radiussecret_orig)); free_string_field (&(args_info->radiustimeout_orig)); free_string_field (&(args_info->radiusretry_orig)); free_string_field (&(args_info->radiusretrysec_orig)); free_string_field (&(args_info->radiusnasid_arg)); free_string_field (&(args_info->radiusnasid_orig)); free_string_field (&(args_info->radiuslocationid_arg)); free_string_field (&(args_info->radiuslocationid_orig)); free_string_field (&(args_info->radiuslocationname_arg)); free_string_field (&(args_info->radiuslocationname_orig)); free_string_field (&(args_info->locationname_arg)); free_string_field (&(args_info->locationname_orig)); free_string_field (&(args_info->radiusnasporttype_orig)); free_string_field (&(args_info->coaport_orig)); free_string_field (&(args_info->proxylisten_arg)); free_string_field (&(args_info->proxylisten_orig)); free_string_field (&(args_info->proxyport_orig)); free_string_field (&(args_info->proxyclient_arg)); free_string_field (&(args_info->proxyclient_orig)); free_string_field (&(args_info->proxysecret_arg)); free_string_field (&(args_info->proxysecret_orig)); free_string_field (&(args_info->dhcpif_arg)); free_string_field (&(args_info->dhcpif_orig)); free_string_field (&(args_info->dhcpmac_arg)); free_string_field (&(args_info->dhcpmac_orig)); free_string_field (&(args_info->dhcpgateway_arg)); free_string_field (&(args_info->dhcpgateway_orig)); free_string_field (&(args_info->dhcpgatewayport_orig)); free_string_field (&(args_info->dhcprelayagent_arg)); free_string_field (&(args_info->dhcprelayagent_orig)); free_string_field (&(args_info->lease_orig)); free_string_field (&(args_info->uamserver_arg)); free_string_field (&(args_info->uamserver_orig)); free_string_field (&(args_info->uamhomepage_arg)); free_string_field (&(args_info->uamhomepage_orig)); free_string_field (&(args_info->uamsecret_arg)); free_string_field (&(args_info->uamsecret_orig)); free_string_field (&(args_info->uamlisten_arg)); free_string_field (&(args_info->uamlisten_orig)); free_string_field (&(args_info->uamport_orig)); free_string_field (&(args_info->uamuiport_orig)); free_multiple_string_field (args_info->uamallowed_given, &(args_info->uamallowed_arg), &(args_info->uamallowed_orig)); free_multiple_string_field (args_info->uamdomain_given, &(args_info->uamdomain_arg), &(args_info->uamdomain_orig)); free_string_field (&(args_info->wisprlogin_arg)); free_string_field (&(args_info->wisprlogin_orig)); free_string_field (&(args_info->uamlogoutip_arg)); free_string_field (&(args_info->uamlogoutip_orig)); free_string_field (&(args_info->defsessiontimeout_orig)); free_string_field (&(args_info->defidletimeout_orig)); free_string_field (&(args_info->defbandwidthmaxdown_orig)); free_string_field (&(args_info->defbandwidthmaxup_orig)); free_string_field (&(args_info->definteriminterval_orig)); free_multiple_string_field (args_info->macallowed_given, &(args_info->macallowed_arg), &(args_info->macallowed_orig)); free_string_field (&(args_info->macsuffix_arg)); free_string_field (&(args_info->macsuffix_orig)); free_string_field (&(args_info->macpasswd_arg)); free_string_field (&(args_info->macpasswd_orig)); free_string_field (&(args_info->wwwdir_arg)); free_string_field (&(args_info->wwwdir_orig)); free_string_field (&(args_info->wwwbin_arg)); free_string_field (&(args_info->wwwbin_orig)); free_string_field (&(args_info->uamui_arg)); free_string_field (&(args_info->uamui_orig)); free_string_field (&(args_info->adminuser_arg)); free_string_field (&(args_info->adminuser_orig)); free_string_field (&(args_info->adminpasswd_arg)); free_string_field (&(args_info->adminpasswd_orig)); free_string_field (&(args_info->nasmac_arg)); free_string_field (&(args_info->nasmac_orig)); free_string_field (&(args_info->nasip_arg)); free_string_field (&(args_info->nasip_orig)); free_string_field (&(args_info->ssid_arg)); free_string_field (&(args_info->ssid_orig)); free_string_field (&(args_info->vlan_arg)); free_string_field (&(args_info->vlan_orig)); free_string_field (&(args_info->cmdsocket_arg)); free_string_field (&(args_info->cmdsocket_orig)); free_string_field (&(args_info->localusers_arg)); free_string_field (&(args_info->localusers_orig)); free_string_field (&(args_info->postauthproxy_arg)); free_string_field (&(args_info->postauthproxy_orig)); free_string_field (&(args_info->postauthproxyport_orig)); free_string_field (&(args_info->routeif_arg)); free_string_field (&(args_info->routeif_orig)); clear_given (args_info); } static void write_into_file(FILE *outfile, const char *opt, const char *arg, char *values[]) { if (arg) { fprintf(outfile, "%s=\"%s\"\n", opt, arg); } else { fprintf(outfile, "%s\n", opt); } } static void write_multiple_into_file(FILE *outfile, int len, const char *opt, char **arg, char *values[]) { int i; for (i = 0; i < len; ++i) write_into_file(outfile, opt, (arg ? arg[i] : 0), values); } int cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info) { int i = 0; if (!outfile) { fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE); return EXIT_FAILURE; } if (args_info->help_given) write_into_file(outfile, "help", 0, 0 ); if (args_info->version_given) write_into_file(outfile, "version", 0, 0 ); if (args_info->fg_given) write_into_file(outfile, "fg", 0, 0 ); if (args_info->debug_given) write_into_file(outfile, "debug", 0, 0 ); if (args_info->debugfacility_given) write_into_file(outfile, "debugfacility", args_info->debugfacility_orig, 0); if (args_info->logfacility_given) write_into_file(outfile, "logfacility", args_info->logfacility_orig, 0); if (args_info->conf_given) write_into_file(outfile, "conf", args_info->conf_orig, 0); if (args_info->interval_given) write_into_file(outfile, "interval", args_info->interval_orig, 0); if (args_info->pidfile_given) write_into_file(outfile, "pidfile", args_info->pidfile_orig, 0); if (args_info->statedir_given) write_into_file(outfile, "statedir", args_info->statedir_orig, 0); if (args_info->net_given) write_into_file(outfile, "net", args_info->net_orig, 0); if (args_info->dhcpstart_given) write_into_file(outfile, "dhcpstart", args_info->dhcpstart_orig, 0); if (args_info->dhcpend_given) write_into_file(outfile, "dhcpend", args_info->dhcpend_orig, 0); if (args_info->dynip_given) write_into_file(outfile, "dynip", args_info->dynip_orig, 0); if (args_info->nodynip_given) write_into_file(outfile, "nodynip", 0, 0 ); if (args_info->statip_given) write_into_file(outfile, "statip", args_info->statip_orig, 0); if (args_info->dns1_given) write_into_file(outfile, "dns1", args_info->dns1_orig, 0); if (args_info->dns2_given) write_into_file(outfile, "dns2", args_info->dns2_orig, 0); if (args_info->domain_given) write_into_file(outfile, "domain", args_info->domain_orig, 0); if (args_info->ipup_given) write_into_file(outfile, "ipup", args_info->ipup_orig, 0); if (args_info->ipdown_given) write_into_file(outfile, "ipdown", args_info->ipdown_orig, 0); if (args_info->conup_given) write_into_file(outfile, "conup", args_info->conup_orig, 0); if (args_info->condown_given) write_into_file(outfile, "condown", args_info->condown_orig, 0); if (args_info->txqlen_given) write_into_file(outfile, "txqlen", args_info->txqlen_orig, 0); if (args_info->tundev_given) write_into_file(outfile, "tundev", args_info->tundev_orig, 0); if (args_info->radiuslisten_given) write_into_file(outfile, "radiuslisten", args_info->radiuslisten_orig, 0); if (args_info->radiusserver1_given) write_into_file(outfile, "radiusserver1", args_info->radiusserver1_orig, 0); if (args_info->radiusserver2_given) write_into_file(outfile, "radiusserver2", args_info->radiusserver2_orig, 0); if (args_info->radiusauthport_given) write_into_file(outfile, "radiusauthport", args_info->radiusauthport_orig, 0); if (args_info->radiusacctport_given) write_into_file(outfile, "radiusacctport", args_info->radiusacctport_orig, 0); if (args_info->radiussecret_given) write_into_file(outfile, "radiussecret", args_info->radiussecret_orig, 0); if (args_info->radiustimeout_given) write_into_file(outfile, "radiustimeout", args_info->radiustimeout_orig, 0); if (args_info->radiusretry_given) write_into_file(outfile, "radiusretry", args_info->radiusretry_orig, 0); if (args_info->radiusretrysec_given) write_into_file(outfile, "radiusretrysec", args_info->radiusretrysec_orig, 0); if (args_info->radiusnasid_given) write_into_file(outfile, "radiusnasid", args_info->radiusnasid_orig, 0); if (args_info->radiuslocationid_given) write_into_file(outfile, "radiuslocationid", args_info->radiuslocationid_orig, 0); if (args_info->radiuslocationname_given) write_into_file(outfile, "radiuslocationname", args_info->radiuslocationname_orig, 0); if (args_info->locationname_given) write_into_file(outfile, "locationname", args_info->locationname_orig, 0); if (args_info->radiusnasporttype_given) write_into_file(outfile, "radiusnasporttype", args_info->radiusnasporttype_orig, 0); if (args_info->coaport_given) write_into_file(outfile, "coaport", args_info->coaport_orig, 0); if (args_info->coanoipcheck_given) write_into_file(outfile, "coanoipcheck", 0, 0 ); if (args_info->proxylisten_given) write_into_file(outfile, "proxylisten", args_info->proxylisten_orig, 0); if (args_info->proxyport_given) write_into_file(outfile, "proxyport", args_info->proxyport_orig, 0); if (args_info->proxyclient_given) write_into_file(outfile, "proxyclient", args_info->proxyclient_orig, 0); if (args_info->proxysecret_given) write_into_file(outfile, "proxysecret", args_info->proxysecret_orig, 0); if (args_info->dhcpif_given) write_into_file(outfile, "dhcpif", args_info->dhcpif_orig, 0); if (args_info->dhcpmac_given) write_into_file(outfile, "dhcpmac", args_info->dhcpmac_orig, 0); if (args_info->dhcpradius_given) write_into_file(outfile, "dhcpradius", 0, 0 ); if (args_info->dhcpgateway_given) write_into_file(outfile, "dhcpgateway", args_info->dhcpgateway_orig, 0); if (args_info->dhcpgatewayport_given) write_into_file(outfile, "dhcpgatewayport", args_info->dhcpgatewayport_orig, 0); if (args_info->dhcprelayagent_given) write_into_file(outfile, "dhcprelayagent", args_info->dhcprelayagent_orig, 0); if (args_info->lease_given) write_into_file(outfile, "lease", args_info->lease_orig, 0); if (args_info->eapolenable_given) write_into_file(outfile, "eapolenable", 0, 0 ); if (args_info->uamserver_given) write_into_file(outfile, "uamserver", args_info->uamserver_orig, 0); if (args_info->uamhomepage_given) write_into_file(outfile, "uamhomepage", args_info->uamhomepage_orig, 0); if (args_info->uamsecret_given) write_into_file(outfile, "uamsecret", args_info->uamsecret_orig, 0); if (args_info->uamlisten_given) write_into_file(outfile, "uamlisten", args_info->uamlisten_orig, 0); if (args_info->uamport_given) write_into_file(outfile, "uamport", args_info->uamport_orig, 0); if (args_info->uamuiport_given) write_into_file(outfile, "uamuiport", args_info->uamuiport_orig, 0); write_multiple_into_file(outfile, args_info->uamallowed_given, "uamallowed", args_info->uamallowed_orig, 0); write_multiple_into_file(outfile, args_info->uamdomain_given, "uamdomain", args_info->uamdomain_orig, 0); if (args_info->uamanydns_given) write_into_file(outfile, "uamanydns", 0, 0 ); if (args_info->uamanyip_given) write_into_file(outfile, "uamanyip", 0, 0 ); if (args_info->wisprlogin_given) write_into_file(outfile, "wisprlogin", args_info->wisprlogin_orig, 0); if (args_info->nouamsuccess_given) write_into_file(outfile, "nouamsuccess", 0, 0 ); if (args_info->nouamwispr_given) write_into_file(outfile, "nouamwispr", 0, 0 ); if (args_info->uamlogoutip_given) write_into_file(outfile, "uamlogoutip", args_info->uamlogoutip_orig, 0); if (args_info->defsessiontimeout_given) write_into_file(outfile, "defsessiontimeout", args_info->defsessiontimeout_orig, 0); if (args_info->defidletimeout_given) write_into_file(outfile, "defidletimeout", args_info->defidletimeout_orig, 0); if (args_info->defbandwidthmaxdown_given) write_into_file(outfile, "defbandwidthmaxdown", args_info->defbandwidthmaxdown_orig, 0); if (args_info->defbandwidthmaxup_given) write_into_file(outfile, "defbandwidthmaxup", args_info->defbandwidthmaxup_orig, 0); if (args_info->definteriminterval_given) write_into_file(outfile, "definteriminterval", args_info->definteriminterval_orig, 0); if (args_info->macauth_given) write_into_file(outfile, "macauth", 0, 0 ); if (args_info->macauthdeny_given) write_into_file(outfile, "macauthdeny", 0, 0 ); write_multiple_into_file(outfile, args_info->macallowed_given, "macallowed", args_info->macallowed_orig, 0); if (args_info->macsuffix_given) write_into_file(outfile, "macsuffix", args_info->macsuffix_orig, 0); if (args_info->macpasswd_given) write_into_file(outfile, "macpasswd", args_info->macpasswd_orig, 0); if (args_info->macallowlocal_given) write_into_file(outfile, "macallowlocal", 0, 0 ); if (args_info->wwwdir_given) write_into_file(outfile, "wwwdir", args_info->wwwdir_orig, 0); if (args_info->wwwbin_given) write_into_file(outfile, "wwwbin", args_info->wwwbin_orig, 0); if (args_info->uamui_given) write_into_file(outfile, "uamui", args_info->uamui_orig, 0); if (args_info->adminuser_given) write_into_file(outfile, "adminuser", args_info->adminuser_orig, 0); if (args_info->adminpasswd_given) write_into_file(outfile, "adminpasswd", args_info->adminpasswd_orig, 0); if (args_info->nasmac_given) write_into_file(outfile, "nasmac", args_info->nasmac_orig, 0); if (args_info->nasip_given) write_into_file(outfile, "nasip", args_info->nasip_orig, 0); if (args_info->ssid_given) write_into_file(outfile, "ssid", args_info->ssid_orig, 0); if (args_info->vlan_given) write_into_file(outfile, "vlan", args_info->vlan_orig, 0); if (args_info->cmdsocket_given) write_into_file(outfile, "cmdsocket", args_info->cmdsocket_orig, 0); if (args_info->radiusoriginalurl_given) write_into_file(outfile, "radiusoriginalurl", 0, 0 ); if (args_info->swapoctets_given) write_into_file(outfile, "swapoctets", 0, 0 ); if (args_info->usestatusfile_given) write_into_file(outfile, "usestatusfile", 0, 0 ); if (args_info->localusers_given) write_into_file(outfile, "localusers", args_info->localusers_orig, 0); if (args_info->postauthproxy_given) write_into_file(outfile, "postauthproxy", args_info->postauthproxy_orig, 0); if (args_info->postauthproxyport_given) write_into_file(outfile, "postauthproxyport", args_info->postauthproxyport_orig, 0); if (args_info->wpaguests_given) write_into_file(outfile, "wpaguests", 0, 0 ); if (args_info->openidauth_given) write_into_file(outfile, "openidauth", 0, 0 ); if (args_info->papalwaysok_given) write_into_file(outfile, "papalwaysok", 0, 0 ); if (args_info->chillixml_given) write_into_file(outfile, "chillixml", 0, 0 ); if (args_info->acctupdate_given) write_into_file(outfile, "acctupdate", 0, 0 ); if (args_info->dnsparanoia_given) write_into_file(outfile, "dnsparanoia", 0, 0 ); if (args_info->usetap_given) write_into_file(outfile, "usetap", 0, 0 ); if (args_info->routeif_given) write_into_file(outfile, "routeif", args_info->routeif_orig, 0); i = EXIT_SUCCESS; return i; } int cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info) { FILE *outfile; int i = 0; outfile = fopen(filename, "w"); if (!outfile) { fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename); return EXIT_FAILURE; } i = cmdline_parser_dump(outfile, args_info); fclose (outfile); return i; } void cmdline_parser_free (struct gengetopt_args_info *args_info) { cmdline_parser_release (args_info); } /** @brief replacement of strdup, which is not standard */ char * gengetopt_strdup (const char *s) { char *result = NULL; if (!s) return result; result = (char*)malloc(strlen(s) + 1); if (result == (char*)0) return (char*)0; strcpy(result, s); return result; } static char * get_multiple_arg_token(const char *arg) { char *tok, *ret; size_t len, num_of_escape, i, j; if (!arg) return NULL; tok = strchr (arg, ','); num_of_escape = 0; /* make sure it is not escaped */ while (tok) { if (*(tok-1) == '\\') { /* find the next one */ tok = strchr (tok+1, ','); ++num_of_escape; } else break; } if (tok) len = (size_t)(tok - arg + 1); else len = strlen (arg) + 1; len -= num_of_escape; ret = (char *) malloc (len); i = 0; j = 0; while (arg[i] && (j < len-1)) { if (arg[i] == '\\' && arg[ i + 1 ] && arg[ i + 1 ] == ',') ++i; ret[j++] = arg[i++]; } ret[len-1] = '\0'; return ret; } static char * get_multiple_arg_token_next(const char *arg) { char *tok; if (!arg) return NULL; tok = strchr (arg, ','); /* make sure it is not escaped */ while (tok) { if (*(tok-1) == '\\') { /* find the next one */ tok = strchr (tok+1, ','); } else break; } if (! tok || strlen(tok) == 1) return 0; return tok+1; } static int check_multiple_option_occurrences(const char *prog_name, unsigned int option_given, int min, int max, const char *option_desc); int check_multiple_option_occurrences(const char *prog_name, unsigned int option_given, int min, int max, const char *option_desc) { int error = 0; if (option_given && ! (min < 0 && max < 0)) { if (min >= 0 && max >= 0) { if (min == max) { /* specific occurrences */ if (option_given != min) { fprintf (stderr, "%s: %s option occurrences must be %d\n", prog_name, option_desc, min); error = 1; } } else if (option_given < min || option_given > max) { /* range occurrences */ fprintf (stderr, "%s: %s option occurrences must be between %d and %d\n", prog_name, option_desc, min, max); error = 1; } } else if (min >= 0) { /* at least check */ if (option_given < min) { fprintf (stderr, "%s: %s option occurrences must be at least %d\n", prog_name, option_desc, min); error = 1; } } else if (max >= 0) { /* at most check */ if (option_given > max) { fprintf (stderr, "%s: %s option occurrences must be at most %d\n", prog_name, option_desc, max); error = 1; } } } return error; } int cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info) { return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); } int cmdline_parser_ext (int argc, char * const *argv, struct gengetopt_args_info *args_info, struct cmdline_parser_params *params) { int result; result = cmdline_parser_internal (argc, argv, args_info, params, NULL); if (result == EXIT_FAILURE) { cmdline_parser_free (args_info); exit (EXIT_FAILURE); } return result; } int cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) { int result; struct cmdline_parser_params params; params.override = override; params.initialize = initialize; params.check_required = check_required; params.check_ambiguity = 0; params.print_errors = 1; result = cmdline_parser_internal (argc, argv, args_info, ¶ms, NULL); if (result == EXIT_FAILURE) { cmdline_parser_free (args_info); exit (EXIT_FAILURE); } return result; } int cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name) { int result = EXIT_SUCCESS; if (cmdline_parser_required2(args_info, prog_name, NULL) > 0) result = EXIT_FAILURE; if (result == EXIT_FAILURE) { cmdline_parser_free (args_info); exit (EXIT_FAILURE); } return result; } int cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error) { int error = 0; /* checks for required options */ if (check_multiple_option_occurrences(prog_name, args_info->uamallowed_given, args_info->uamallowed_min, args_info->uamallowed_max, "'--uamallowed'")) error = 1; if (check_multiple_option_occurrences(prog_name, args_info->uamdomain_given, args_info->uamdomain_min, args_info->uamdomain_max, "'--uamdomain'")) error = 1; if (check_multiple_option_occurrences(prog_name, args_info->macallowed_given, args_info->macallowed_min, args_info->macallowed_max, "'--macallowed'")) error = 1; /* checks for dependences among options */ return error; } static char *package_name = 0; /** * @brief updates an option * @param field the generic pointer to the field to update * @param orig_field the pointer to the orig field * @param field_given the pointer to the number of occurrence of this option * @param prev_given the pointer to the number of occurrence already seen * @param value the argument for this option (if null no arg was specified) * @param possible_values the possible values for this option (if specified) * @param default_value the default value (in case the option only accepts fixed values) * @param arg_type the type of this option * @param check_ambiguity @see cmdline_parser_params.check_ambiguity * @param override @see cmdline_parser_params.override * @param no_free whether to free a possible previous value * @param multiple_option whether this is a multiple option * @param long_opt the corresponding long option * @param short_opt the corresponding short option (or '-' if none) * @param additional_error possible further error specification */ static int update_arg(void *field, char **orig_field, unsigned int *field_given, unsigned int *prev_given, char *value, char *possible_values[], const char *default_value, cmdline_parser_arg_type arg_type, int check_ambiguity, int override, int no_free, int multiple_option, const char *long_opt, char short_opt, const char *additional_error) { char *stop_char = 0; const char *val = value; int found; char **string_field; stop_char = 0; found = 0; if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given))) { if (short_opt != '-') fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n", package_name, long_opt, short_opt, (additional_error ? additional_error : "")); else fprintf (stderr, "%s: `--%s' option given more than once%s\n", package_name, long_opt, (additional_error ? additional_error : "")); return 1; /* failure */ } if (field_given && *field_given && ! override) return 0; if (prev_given) (*prev_given)++; if (field_given) (*field_given)++; if (possible_values) val = possible_values[found]; switch(arg_type) { case ARG_FLAG: *((int *)field) = !*((int *)field); break; case ARG_INT: if (val) *((int *)field) = strtol (val, &stop_char, 0); break; case ARG_LONG: if (val) *((long *)field) = (long)strtol (val, &stop_char, 0); break; case ARG_STRING: if (val) { string_field = (char **)field; if (!no_free && *string_field) free (*string_field); /* free previous string */ *string_field = gengetopt_strdup (val); } break; default: break; }; /* check numeric conversion */ switch(arg_type) { case ARG_INT: case ARG_LONG: if (val && !(stop_char && *stop_char == '\0')) { fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val); return 1; /* failure */ } break; default: ; }; /* store the original value */ switch(arg_type) { case ARG_NO: case ARG_FLAG: break; default: if (value && orig_field) { if (no_free) { *orig_field = value; } else { if (*orig_field) free (*orig_field); /* free previous string */ *orig_field = gengetopt_strdup (value); } } }; return 0; /* OK */ } /** * @brief store information about a multiple option in a temporary list * @param list where to (temporarily) store multiple options */ static int update_multiple_arg_temp(struct generic_list **list, unsigned int *prev_given, const char *val, char *possible_values[], const char *default_value, cmdline_parser_arg_type arg_type, const char *long_opt, char short_opt, const char *additional_error) { char *multi_token, *multi_next; /* store single arguments */ if (arg_type == ARG_NO) { (*prev_given)++; return 0; /* OK */ } multi_token = get_multiple_arg_token(val); multi_next = get_multiple_arg_token_next (val); while (1) { add_node (list); if (update_arg((void *)&((*list)->arg), &((*list)->orig), 0, prev_given, multi_token, possible_values, default_value, arg_type, 0, 1, 1, 1, long_opt, short_opt, additional_error)) { if (multi_token) free(multi_token); return 1; /* failure */ } if (multi_next) { multi_token = get_multiple_arg_token(multi_next); multi_next = get_multiple_arg_token_next (multi_next); } else break; } return 0; /* OK */ } /** * @brief free the passed list (including possible string argument) */ static void free_list(struct generic_list *list, short string_arg) { if (list) { struct generic_list *tmp; while (list) { tmp = list; if (string_arg && list->arg.string_arg) free (list->arg.string_arg); if (list->orig) free (list->orig); list = list->next; free (tmp); } } } /** * @brief updates a multiple option starting from the passed list */ static void update_multiple_arg(void *field, char ***orig_field, unsigned int field_given, unsigned int prev_given, union generic_value *default_value, cmdline_parser_arg_type arg_type, struct generic_list *list) { int i; struct generic_list *tmp; if (prev_given && list) { *orig_field = (char **) realloc (*orig_field, (field_given + prev_given) * sizeof (char *)); switch(arg_type) { case ARG_INT: *((int **)field) = (int *)realloc (*((int **)field), (field_given + prev_given) * sizeof (int)); break; case ARG_LONG: *((long **)field) = (long *)realloc (*((long **)field), (field_given + prev_given) * sizeof (long)); break; case ARG_STRING: *((char ***)field) = (char **)realloc (*((char ***)field), (field_given + prev_given) * sizeof (char *)); break; default: break; }; for (i = (prev_given - 1); i >= 0; --i) { tmp = list; switch(arg_type) { case ARG_INT: (*((int **)field))[i + field_given] = tmp->arg.int_arg; break; case ARG_LONG: (*((long **)field))[i + field_given] = tmp->arg.long_arg; break; case ARG_STRING: (*((char ***)field))[i + field_given] = tmp->arg.string_arg; break; default: break; } (*orig_field) [i + field_given] = list->orig; list = list->next; free (tmp); } } else { /* set the default value */ if (default_value && ! field_given) { switch(arg_type) { case ARG_INT: if (! *((int **)field)) { *((int **)field) = (int *)malloc (sizeof (int)); (*((int **)field))[0] = default_value->int_arg; } break; case ARG_LONG: if (! *((long **)field)) { *((long **)field) = (long *)malloc (sizeof (long)); (*((long **)field))[0] = default_value->long_arg; } break; case ARG_STRING: if (! *((char ***)field)) { *((char ***)field) = (char **)malloc (sizeof (char *)); (*((char ***)field))[0] = gengetopt_strdup(default_value->string_arg); } break; default: break; } if (!(*orig_field)) { *orig_field = (char **) malloc (sizeof (char *)); (*orig_field)[0] = NULL; } } } } int cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info, struct cmdline_parser_params *params, const char *additional_error) { int c; /* Character of the parsed option. */ struct generic_list * uamallowed_list = NULL; struct generic_list * uamdomain_list = NULL; struct generic_list * macallowed_list = NULL; int error = 0; struct gengetopt_args_info local_args_info; int override; int initialize; int check_required; int check_ambiguity; package_name = argv[0]; override = params->override; initialize = params->initialize; check_required = params->check_required; check_ambiguity = params->check_ambiguity; if (initialize) cmdline_parser_init (args_info); cmdline_parser_init (&local_args_info); optarg = 0; optind = 0; opterr = params->print_errors; optopt = '?'; while (1) { int option_index = 0; static struct option long_options[] = { { "help", 0, NULL, 'h' }, { "version", 0, NULL, 'V' }, { "fg", 0, NULL, 'f' }, { "debug", 0, NULL, 'd' }, { "debugfacility", 1, NULL, 0 }, { "logfacility", 1, NULL, 0 }, { "conf", 1, NULL, 'c' }, { "interval", 1, NULL, 0 }, { "pidfile", 1, NULL, 0 }, { "statedir", 1, NULL, 0 }, { "net", 1, NULL, 'n' }, { "dhcpstart", 1, NULL, 0 }, { "dhcpend", 1, NULL, 0 }, { "dynip", 1, NULL, 0 }, { "nodynip", 0, NULL, 0 }, { "statip", 1, NULL, 0 }, { "dns1", 1, NULL, 0 }, { "dns2", 1, NULL, 0 }, { "domain", 1, NULL, 0 }, { "ipup", 1, NULL, 0 }, { "ipdown", 1, NULL, 0 }, { "conup", 1, NULL, 0 }, { "condown", 1, NULL, 0 }, { "txqlen", 1, NULL, 0 }, { "tundev", 1, NULL, 0 }, { "radiuslisten", 1, NULL, 0 }, { "radiusserver1", 1, NULL, 0 }, { "radiusserver2", 1, NULL, 0 }, { "radiusauthport", 1, NULL, 0 }, { "radiusacctport", 1, NULL, 0 }, { "radiussecret", 1, NULL, 0 }, { "radiustimeout", 1, NULL, 0 }, { "radiusretry", 1, NULL, 0 }, { "radiusretrysec", 1, NULL, 0 }, { "radiusnasid", 1, NULL, 0 }, { "radiuslocationid", 1, NULL, 0 }, { "radiuslocationname", 1, NULL, 0 }, { "locationname", 1, NULL, 0 }, { "radiusnasporttype", 1, NULL, 0 }, { "coaport", 1, NULL, 0 }, { "coanoipcheck", 0, NULL, 0 }, { "proxylisten", 1, NULL, 0 }, { "proxyport", 1, NULL, 0 }, { "proxyclient", 1, NULL, 0 }, { "proxysecret", 1, NULL, 0 }, { "dhcpif", 1, NULL, 0 }, { "dhcpmac", 1, NULL, 0 }, { "dhcpradius", 0, NULL, 0 }, { "dhcpgateway", 1, NULL, 0 }, { "dhcpgatewayport", 1, NULL, 0 }, { "dhcprelayagent", 1, NULL, 0 }, { "lease", 1, NULL, 0 }, { "eapolenable", 0, NULL, 0 }, { "uamserver", 1, NULL, 0 }, { "uamhomepage", 1, NULL, 0 }, { "uamsecret", 1, NULL, 0 }, { "uamlisten", 1, NULL, 0 }, { "uamport", 1, NULL, 0 }, { "uamuiport", 1, NULL, 0 }, { "uamallowed", 1, NULL, 0 }, { "uamdomain", 1, NULL, 0 }, { "uamanydns", 0, NULL, 0 }, { "uamanyip", 0, NULL, 0 }, { "wisprlogin", 1, NULL, 0 }, { "nouamsuccess", 0, NULL, 0 }, { "nouamwispr", 0, NULL, 0 }, { "uamlogoutip", 1, NULL, 0 }, { "defsessiontimeout", 1, NULL, 0 }, { "defidletimeout", 1, NULL, 0 }, { "defbandwidthmaxdown", 1, NULL, 0 }, { "defbandwidthmaxup", 1, NULL, 0 }, { "definteriminterval", 1, NULL, 0 }, { "macauth", 0, NULL, 0 }, { "macauthdeny", 0, NULL, 0 }, { "macallowed", 1, NULL, 0 }, { "macsuffix", 1, NULL, 0 }, { "macpasswd", 1, NULL, 0 }, { "macallowlocal", 0, NULL, 0 }, { "wwwdir", 1, NULL, 0 }, { "wwwbin", 1, NULL, 0 }, { "uamui", 1, NULL, 0 }, { "adminuser", 1, NULL, 0 }, { "adminpasswd", 1, NULL, 0 }, { "nasmac", 1, NULL, 0 }, { "nasip", 1, NULL, 0 }, { "ssid", 1, NULL, 0 }, { "vlan", 1, NULL, 0 }, { "cmdsocket", 1, NULL, 0 }, { "radiusoriginalurl", 0, NULL, 0 }, { "swapoctets", 0, NULL, 0 }, { "usestatusfile", 0, NULL, 0 }, { "localusers", 1, NULL, 0 }, { "postauthproxy", 1, NULL, 0 }, { "postauthproxyport", 1, NULL, 0 }, { "wpaguests", 0, NULL, 0 }, { "openidauth", 0, NULL, 0 }, { "papalwaysok", 0, NULL, 0 }, { "chillixml", 0, NULL, 0 }, { "acctupdate", 0, NULL, 0 }, { "dnsparanoia", 0, NULL, 0 }, { "usetap", 0, NULL, 0 }, { "routeif", 1, NULL, 0 }, { NULL, 0, NULL, 0 } }; c = getopt_long (argc, argv, "hVfdc:n:", long_options, &option_index); if (c == -1) break; /* Exit from `while (1)' loop. */ switch (c) { case 'h': /* Print help and exit. */ if (update_arg( 0 , 0 , &(args_info->help_given), &(local_args_info.help_given), optarg, 0, 0, ARG_NO, check_ambiguity, override, 0, 0, "help", 'h', additional_error)) goto failure; cmdline_parser_free (&local_args_info); return 0; break; case 'V': /* Print version and exit. */ if (update_arg( 0 , 0 , &(args_info->version_given), &(local_args_info.version_given), optarg, 0, 0, ARG_NO, check_ambiguity, override, 0, 0, "version", 'V', additional_error)) goto failure; cmdline_parser_free (&local_args_info); return 0; break; case 'f': /* Run in foreground. */ if (update_arg((void *)&(args_info->fg_flag), 0, &(args_info->fg_given), &(local_args_info.fg_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "fg", 'f', additional_error)) goto failure; break; case 'd': /* Run in debug mode. */ if (update_arg((void *)&(args_info->debug_flag), 0, &(args_info->debug_given), &(local_args_info.debug_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "debug", 'd', additional_error)) goto failure; break; case 'c': /* Read configuration file. */ if (update_arg( (void *)&(args_info->conf_arg), &(args_info->conf_orig), &(args_info->conf_given), &(local_args_info.conf_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "conf", 'c', additional_error)) goto failure; break; case 'n': /* Network. */ if (update_arg( (void *)&(args_info->net_arg), &(args_info->net_orig), &(args_info->net_given), &(local_args_info.net_given), optarg, 0, "192.168.182.0/24", ARG_STRING, check_ambiguity, override, 0, 0, "net", 'n', additional_error)) goto failure; break; case 0: /* Long option with no short option */ /* Which modules to print debug messages for. */ if (strcmp (long_options[option_index].name, "debugfacility") == 0) { if (update_arg( (void *)&(args_info->debugfacility_arg), &(args_info->debugfacility_orig), &(args_info->debugfacility_given), &(local_args_info.debugfacility_given), optarg, 0, "1", ARG_INT, check_ambiguity, override, 0, 0, "debugfacility", '-', additional_error)) goto failure; } /* Syslog facility to be used for logging. */ else if (strcmp (long_options[option_index].name, "logfacility") == 0) { if (update_arg( (void *)&(args_info->logfacility_arg), &(args_info->logfacility_orig), &(args_info->logfacility_given), &(local_args_info.logfacility_given), optarg, 0, "-1", ARG_INT, check_ambiguity, override, 0, 0, "logfacility", '-', additional_error)) goto failure; } /* Re-read configuration file at this interval. */ else if (strcmp (long_options[option_index].name, "interval") == 0) { if (update_arg( (void *)&(args_info->interval_arg), &(args_info->interval_orig), &(args_info->interval_given), &(local_args_info.interval_given), optarg, 0, "3600", ARG_INT, check_ambiguity, override, 0, 0, "interval", '-', additional_error)) goto failure; } /* Filename of process id file. */ else if (strcmp (long_options[option_index].name, "pidfile") == 0) { if (update_arg( (void *)&(args_info->pidfile_arg), &(args_info->pidfile_orig), &(args_info->pidfile_given), &(local_args_info.pidfile_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "pidfile", '-', additional_error)) goto failure; } /* Directory of nonvolatile data. */ else if (strcmp (long_options[option_index].name, "statedir") == 0) { if (update_arg( (void *)&(args_info->statedir_arg), &(args_info->statedir_orig), &(args_info->statedir_given), &(local_args_info.statedir_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "statedir", '-', additional_error)) goto failure; } /* Network DHCP Starting IP. */ else if (strcmp (long_options[option_index].name, "dhcpstart") == 0) { if (update_arg( (void *)&(args_info->dhcpstart_arg), &(args_info->dhcpstart_orig), &(args_info->dhcpstart_given), &(local_args_info.dhcpstart_given), optarg, 0, "0", ARG_INT, check_ambiguity, override, 0, 0, "dhcpstart", '-', additional_error)) goto failure; } /* Network DHCP Ending IP. */ else if (strcmp (long_options[option_index].name, "dhcpend") == 0) { if (update_arg( (void *)&(args_info->dhcpend_arg), &(args_info->dhcpend_orig), &(args_info->dhcpend_given), &(local_args_info.dhcpend_given), optarg, 0, "0", ARG_INT, check_ambiguity, override, 0, 0, "dhcpend", '-', additional_error)) goto failure; } /* Dynamic IP address pool. */ else if (strcmp (long_options[option_index].name, "dynip") == 0) { if (update_arg( (void *)&(args_info->dynip_arg), &(args_info->dynip_orig), &(args_info->dynip_given), &(local_args_info.dynip_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "dynip", '-', additional_error)) goto failure; } /* No Dynamic IP assignment. */ else if (strcmp (long_options[option_index].name, "nodynip") == 0) { if (update_arg((void *)&(args_info->nodynip_flag), 0, &(args_info->nodynip_given), &(local_args_info.nodynip_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "nodynip", '-', additional_error)) goto failure; } /* Static IP address pool. */ else if (strcmp (long_options[option_index].name, "statip") == 0) { if (update_arg( (void *)&(args_info->statip_arg), &(args_info->statip_orig), &(args_info->statip_given), &(local_args_info.statip_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "statip", '-', additional_error)) goto failure; } /* Primary DNS server IP address. */ else if (strcmp (long_options[option_index].name, "dns1") == 0) { if (update_arg( (void *)&(args_info->dns1_arg), &(args_info->dns1_orig), &(args_info->dns1_given), &(local_args_info.dns1_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "dns1", '-', additional_error)) goto failure; } /* Secondary DNS server IP address. */ else if (strcmp (long_options[option_index].name, "dns2") == 0) { if (update_arg( (void *)&(args_info->dns2_arg), &(args_info->dns2_orig), &(args_info->dns2_given), &(local_args_info.dns2_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "dns2", '-', additional_error)) goto failure; } /* Domain to use for DNS lookups. */ else if (strcmp (long_options[option_index].name, "domain") == 0) { if (update_arg( (void *)&(args_info->domain_arg), &(args_info->domain_orig), &(args_info->domain_given), &(local_args_info.domain_given), optarg, 0, "coova.org", ARG_STRING, check_ambiguity, override, 0, 0, "domain", '-', additional_error)) goto failure; } /* Script to run after link-up. */ else if (strcmp (long_options[option_index].name, "ipup") == 0) { if (update_arg( (void *)&(args_info->ipup_arg), &(args_info->ipup_orig), &(args_info->ipup_given), &(local_args_info.ipup_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "ipup", '-', additional_error)) goto failure; } /* Script to run after link-down. */ else if (strcmp (long_options[option_index].name, "ipdown") == 0) { if (update_arg( (void *)&(args_info->ipdown_arg), &(args_info->ipdown_orig), &(args_info->ipdown_given), &(local_args_info.ipdown_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "ipdown", '-', additional_error)) goto failure; } /* Script to run after user logon. */ else if (strcmp (long_options[option_index].name, "conup") == 0) { if (update_arg( (void *)&(args_info->conup_arg), &(args_info->conup_orig), &(args_info->conup_given), &(local_args_info.conup_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "conup", '-', additional_error)) goto failure; } /* Script to run after user logoff. */ else if (strcmp (long_options[option_index].name, "condown") == 0) { if (update_arg( (void *)&(args_info->condown_arg), &(args_info->condown_orig), &(args_info->condown_given), &(local_args_info.condown_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "condown", '-', additional_error)) goto failure; } /* TX Queue length for tun interface (linux only). */ else if (strcmp (long_options[option_index].name, "txqlen") == 0) { if (update_arg( (void *)&(args_info->txqlen_arg), &(args_info->txqlen_orig), &(args_info->txqlen_given), &(local_args_info.txqlen_given), optarg, 0, "100", ARG_INT, check_ambiguity, override, 0, 0, "txqlen", '-', additional_error)) goto failure; } /* TUN/TAP Device, as in tun0 or tap1. */ else if (strcmp (long_options[option_index].name, "tundev") == 0) { if (update_arg( (void *)&(args_info->tundev_arg), &(args_info->tundev_orig), &(args_info->tundev_given), &(local_args_info.tundev_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "tundev", '-', additional_error)) goto failure; } /* IP address to send from. */ else if (strcmp (long_options[option_index].name, "radiuslisten") == 0) { if (update_arg( (void *)&(args_info->radiuslisten_arg), &(args_info->radiuslisten_orig), &(args_info->radiuslisten_given), &(local_args_info.radiuslisten_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "radiuslisten", '-', additional_error)) goto failure; } /* IP address of radius server 1. */ else if (strcmp (long_options[option_index].name, "radiusserver1") == 0) { if (update_arg( (void *)&(args_info->radiusserver1_arg), &(args_info->radiusserver1_orig), &(args_info->radiusserver1_given), &(local_args_info.radiusserver1_given), optarg, 0, "rad01.coova.org", ARG_STRING, check_ambiguity, override, 0, 0, "radiusserver1", '-', additional_error)) goto failure; } /* IP address of radius server 2. */ else if (strcmp (long_options[option_index].name, "radiusserver2") == 0) { if (update_arg( (void *)&(args_info->radiusserver2_arg), &(args_info->radiusserver2_orig), &(args_info->radiusserver2_given), &(local_args_info.radiusserver2_given), optarg, 0, "rad01.coova.org", ARG_STRING, check_ambiguity, override, 0, 0, "radiusserver2", '-', additional_error)) goto failure; } /* Authentication UDP port of radius server. */ else if (strcmp (long_options[option_index].name, "radiusauthport") == 0) { if (update_arg( (void *)&(args_info->radiusauthport_arg), &(args_info->radiusauthport_orig), &(args_info->radiusauthport_given), &(local_args_info.radiusauthport_given), optarg, 0, "1812", ARG_INT, check_ambiguity, override, 0, 0, "radiusauthport", '-', additional_error)) goto failure; } /* Accounting UDP port of radius server. */ else if (strcmp (long_options[option_index].name, "radiusacctport") == 0) { if (update_arg( (void *)&(args_info->radiusacctport_arg), &(args_info->radiusacctport_orig), &(args_info->radiusacctport_given), &(local_args_info.radiusacctport_given), optarg, 0, "1813", ARG_INT, check_ambiguity, override, 0, 0, "radiusacctport", '-', additional_error)) goto failure; } /* Radius shared secret. */ else if (strcmp (long_options[option_index].name, "radiussecret") == 0) { if (update_arg( (void *)&(args_info->radiussecret_arg), &(args_info->radiussecret_orig), &(args_info->radiussecret_given), &(local_args_info.radiussecret_given), optarg, 0, "coova-anonymous", ARG_STRING, check_ambiguity, override, 0, 0, "radiussecret", '-', additional_error)) goto failure; } /* Retry timeout in seconds. */ else if (strcmp (long_options[option_index].name, "radiustimeout") == 0) { if (update_arg( (void *)&(args_info->radiustimeout_arg), &(args_info->radiustimeout_orig), &(args_info->radiustimeout_given), &(local_args_info.radiustimeout_given), optarg, 0, "30", ARG_INT, check_ambiguity, override, 0, 0, "radiustimeout", '-', additional_error)) goto failure; } /* Total number of retries. */ else if (strcmp (long_options[option_index].name, "radiusretry") == 0) { if (update_arg( (void *)&(args_info->radiusretry_arg), &(args_info->radiusretry_orig), &(args_info->radiusretry_given), &(local_args_info.radiusretry_given), optarg, 0, "6", ARG_INT, check_ambiguity, override, 0, 0, "radiusretry", '-', additional_error)) goto failure; } /* Number of retries before using secondary. */ else if (strcmp (long_options[option_index].name, "radiusretrysec") == 0) { if (update_arg( (void *)&(args_info->radiusretrysec_arg), &(args_info->radiusretrysec_orig), &(args_info->radiusretrysec_given), &(local_args_info.radiusretrysec_given), optarg, 0, "3", ARG_INT, check_ambiguity, override, 0, 0, "radiusretrysec", '-', additional_error)) goto failure; } /* Radius NAS-Identifier. */ else if (strcmp (long_options[option_index].name, "radiusnasid") == 0) { if (update_arg( (void *)&(args_info->radiusnasid_arg), &(args_info->radiusnasid_orig), &(args_info->radiusnasid_given), &(local_args_info.radiusnasid_given), optarg, 0, "nas01", ARG_STRING, check_ambiguity, override, 0, 0, "radiusnasid", '-', additional_error)) goto failure; } /* WISPr Location ID. */ else if (strcmp (long_options[option_index].name, "radiuslocationid") == 0) { if (update_arg( (void *)&(args_info->radiuslocationid_arg), &(args_info->radiuslocationid_orig), &(args_info->radiuslocationid_given), &(local_args_info.radiuslocationid_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "radiuslocationid", '-', additional_error)) goto failure; } /* WISPr Location Name. */ else if (strcmp (long_options[option_index].name, "radiuslocationname") == 0) { if (update_arg( (void *)&(args_info->radiuslocationname_arg), &(args_info->radiuslocationname_orig), &(args_info->radiuslocationname_given), &(local_args_info.radiuslocationname_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "radiuslocationname", '-', additional_error)) goto failure; } /* Location Name. */ else if (strcmp (long_options[option_index].name, "locationname") == 0) { if (update_arg( (void *)&(args_info->locationname_arg), &(args_info->locationname_orig), &(args_info->locationname_given), &(local_args_info.locationname_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "locationname", '-', additional_error)) goto failure; } /* Radius NAS-Port-Type. */ else if (strcmp (long_options[option_index].name, "radiusnasporttype") == 0) { if (update_arg( (void *)&(args_info->radiusnasporttype_arg), &(args_info->radiusnasporttype_orig), &(args_info->radiusnasporttype_given), &(local_args_info.radiusnasporttype_given), optarg, 0, "19", ARG_INT, check_ambiguity, override, 0, 0, "radiusnasporttype", '-', additional_error)) goto failure; } /* Radius disconnect port to listen to. */ else if (strcmp (long_options[option_index].name, "coaport") == 0) { if (update_arg( (void *)&(args_info->coaport_arg), &(args_info->coaport_orig), &(args_info->coaport_given), &(local_args_info.coaport_given), optarg, 0, "0", ARG_INT, check_ambiguity, override, 0, 0, "coaport", '-', additional_error)) goto failure; } /* Allow radius disconnect from any IP. */ else if (strcmp (long_options[option_index].name, "coanoipcheck") == 0) { if (update_arg((void *)&(args_info->coanoipcheck_flag), 0, &(args_info->coanoipcheck_given), &(local_args_info.coanoipcheck_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "coanoipcheck", '-', additional_error)) goto failure; } /* IP address to listen to. */ else if (strcmp (long_options[option_index].name, "proxylisten") == 0) { if (update_arg( (void *)&(args_info->proxylisten_arg), &(args_info->proxylisten_orig), &(args_info->proxylisten_given), &(local_args_info.proxylisten_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "proxylisten", '-', additional_error)) goto failure; } /* UDP port to listen to. */ else if (strcmp (long_options[option_index].name, "proxyport") == 0) { if (update_arg( (void *)&(args_info->proxyport_arg), &(args_info->proxyport_orig), &(args_info->proxyport_given), &(local_args_info.proxyport_given), optarg, 0, "0", ARG_INT, check_ambiguity, override, 0, 0, "proxyport", '-', additional_error)) goto failure; } /* IP address of proxy client(s). */ else if (strcmp (long_options[option_index].name, "proxyclient") == 0) { if (update_arg( (void *)&(args_info->proxyclient_arg), &(args_info->proxyclient_orig), &(args_info->proxyclient_given), &(local_args_info.proxyclient_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "proxyclient", '-', additional_error)) goto failure; } /* Radius proxy shared secret. */ else if (strcmp (long_options[option_index].name, "proxysecret") == 0) { if (update_arg( (void *)&(args_info->proxysecret_arg), &(args_info->proxysecret_orig), &(args_info->proxysecret_given), &(local_args_info.proxysecret_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "proxysecret", '-', additional_error)) goto failure; } /* Local Ethernet interface. */ else if (strcmp (long_options[option_index].name, "dhcpif") == 0) { if (update_arg( (void *)&(args_info->dhcpif_arg), &(args_info->dhcpif_orig), &(args_info->dhcpif_given), &(local_args_info.dhcpif_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "dhcpif", '-', additional_error)) goto failure; } /* Interface MAC address. */ else if (strcmp (long_options[option_index].name, "dhcpmac") == 0) { if (update_arg( (void *)&(args_info->dhcpmac_arg), &(args_info->dhcpmac_orig), &(args_info->dhcpmac_given), &(local_args_info.dhcpmac_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "dhcpmac", '-', additional_error)) goto failure; } /* Map certain DHCP options to RADIUS attributes. */ else if (strcmp (long_options[option_index].name, "dhcpradius") == 0) { if (update_arg((void *)&(args_info->dhcpradius_flag), 0, &(args_info->dhcpradius_given), &(local_args_info.dhcpradius_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "dhcpradius", '-', additional_error)) goto failure; } /* DHCP gateway addresss for relay. */ else if (strcmp (long_options[option_index].name, "dhcpgateway") == 0) { if (update_arg( (void *)&(args_info->dhcpgateway_arg), &(args_info->dhcpgateway_orig), &(args_info->dhcpgateway_given), &(local_args_info.dhcpgateway_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "dhcpgateway", '-', additional_error)) goto failure; } /* DHCP gateway port for relay. */ else if (strcmp (long_options[option_index].name, "dhcpgatewayport") == 0) { if (update_arg( (void *)&(args_info->dhcpgatewayport_arg), &(args_info->dhcpgatewayport_orig), &(args_info->dhcpgatewayport_given), &(local_args_info.dhcpgatewayport_given), optarg, 0, "67", ARG_INT, check_ambiguity, override, 0, 0, "dhcpgatewayport", '-', additional_error)) goto failure; } /* DHCP relay agent IP addresss (default uamlisten). */ else if (strcmp (long_options[option_index].name, "dhcprelayagent") == 0) { if (update_arg( (void *)&(args_info->dhcprelayagent_arg), &(args_info->dhcprelayagent_orig), &(args_info->dhcprelayagent_given), &(local_args_info.dhcprelayagent_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "dhcprelayagent", '-', additional_error)) goto failure; } /* Lease time to allocate to clients. */ else if (strcmp (long_options[option_index].name, "lease") == 0) { if (update_arg( (void *)&(args_info->lease_arg), &(args_info->lease_orig), &(args_info->lease_given), &(local_args_info.lease_given), optarg, 0, "600", ARG_INT, check_ambiguity, override, 0, 0, "lease", '-', additional_error)) goto failure; } /* Enable IEEE 802.1x authentication. */ else if (strcmp (long_options[option_index].name, "eapolenable") == 0) { if (update_arg((void *)&(args_info->eapolenable_flag), 0, &(args_info->eapolenable_given), &(local_args_info.eapolenable_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "eapolenable", '-', additional_error)) goto failure; } /* URL of authentication web server. */ else if (strcmp (long_options[option_index].name, "uamserver") == 0) { if (update_arg( (void *)&(args_info->uamserver_arg), &(args_info->uamserver_orig), &(args_info->uamserver_given), &(local_args_info.uamserver_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "uamserver", '-', additional_error)) goto failure; } /* URL of homepage to redirect unauthenticated users to. */ else if (strcmp (long_options[option_index].name, "uamhomepage") == 0) { if (update_arg( (void *)&(args_info->uamhomepage_arg), &(args_info->uamhomepage_orig), &(args_info->uamhomepage_given), &(local_args_info.uamhomepage_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "uamhomepage", '-', additional_error)) goto failure; } /* Shared secret between uamserver and chilli. */ else if (strcmp (long_options[option_index].name, "uamsecret") == 0) { if (update_arg( (void *)&(args_info->uamsecret_arg), &(args_info->uamsecret_orig), &(args_info->uamsecret_given), &(local_args_info.uamsecret_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "uamsecret", '-', additional_error)) goto failure; } /* IP address to listen to for authentication requests. */ else if (strcmp (long_options[option_index].name, "uamlisten") == 0) { if (update_arg( (void *)&(args_info->uamlisten_arg), &(args_info->uamlisten_orig), &(args_info->uamlisten_given), &(local_args_info.uamlisten_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "uamlisten", '-', additional_error)) goto failure; } /* TCP port to bind to for authentication requests. */ else if (strcmp (long_options[option_index].name, "uamport") == 0) { if (update_arg( (void *)&(args_info->uamport_arg), &(args_info->uamport_orig), &(args_info->uamport_given), &(local_args_info.uamport_given), optarg, 0, "3990", ARG_INT, check_ambiguity, override, 0, 0, "uamport", '-', additional_error)) goto failure; } /* TCP port to bind to for UAM UI requests. */ else if (strcmp (long_options[option_index].name, "uamuiport") == 0) { if (update_arg( (void *)&(args_info->uamuiport_arg), &(args_info->uamuiport_orig), &(args_info->uamuiport_given), &(local_args_info.uamuiport_given), optarg, 0, "3991", ARG_INT, check_ambiguity, override, 0, 0, "uamuiport", '-', additional_error)) goto failure; } /* Domain names exempt from access check . */ else if (strcmp (long_options[option_index].name, "uamallowed") == 0) { if (update_multiple_arg_temp(&uamallowed_list, &(local_args_info.uamallowed_given), optarg, 0, 0, ARG_STRING, "uamallowed", '-', additional_error)) goto failure; } /* Domain name allowed (active dns filtering; one per line!) . */ else if (strcmp (long_options[option_index].name, "uamdomain") == 0) { if (update_multiple_arg_temp(&uamdomain_list, &(local_args_info.uamdomain_given), optarg, 0, 0, ARG_STRING, "uamdomain", '-', additional_error)) goto failure; } /* Allow client to use any DNS server. */ else if (strcmp (long_options[option_index].name, "uamanydns") == 0) { if (update_arg((void *)&(args_info->uamanydns_flag), 0, &(args_info->uamanydns_given), &(local_args_info.uamanydns_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "uamanydns", '-', additional_error)) goto failure; } /* Allow client to use any IP Address. */ else if (strcmp (long_options[option_index].name, "uamanyip") == 0) { if (update_arg((void *)&(args_info->uamanyip_flag), 0, &(args_info->uamanyip_given), &(local_args_info.uamanyip_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "uamanyip", '-', additional_error)) goto failure; } /* A specific WISPr login url to be used. */ else if (strcmp (long_options[option_index].name, "wisprlogin") == 0) { if (update_arg( (void *)&(args_info->wisprlogin_arg), &(args_info->wisprlogin_orig), &(args_info->wisprlogin_given), &(local_args_info.wisprlogin_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "wisprlogin", '-', additional_error)) goto failure; } /* Do not return to the UAM server on success, original url instead. */ else if (strcmp (long_options[option_index].name, "nouamsuccess") == 0) { if (update_arg((void *)&(args_info->nouamsuccess_flag), 0, &(args_info->nouamsuccess_given), &(local_args_info.nouamsuccess_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "nouamsuccess", '-', additional_error)) goto failure; } /* Do not send WISPr XML from ChilliSpot, assume back-end does. */ else if (strcmp (long_options[option_index].name, "nouamwispr") == 0) { if (update_arg((void *)&(args_info->nouamwispr_flag), 0, &(args_info->nouamwispr_given), &(local_args_info.nouamwispr_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "nouamwispr", '-', additional_error)) goto failure; } /* HTTP Auto-Logout IP Address. */ else if (strcmp (long_options[option_index].name, "uamlogoutip") == 0) { if (update_arg( (void *)&(args_info->uamlogoutip_arg), &(args_info->uamlogoutip_orig), &(args_info->uamlogoutip_given), &(local_args_info.uamlogoutip_given), optarg, 0, "1.1.1.1", ARG_STRING, check_ambiguity, override, 0, 0, "uamlogoutip", '-', additional_error)) goto failure; } /* Default session-timeout if not returned by RADIUS. */ else if (strcmp (long_options[option_index].name, "defsessiontimeout") == 0) { if (update_arg( (void *)&(args_info->defsessiontimeout_arg), &(args_info->defsessiontimeout_orig), &(args_info->defsessiontimeout_given), &(local_args_info.defsessiontimeout_given), optarg, 0, "0", ARG_LONG, check_ambiguity, override, 0, 0, "defsessiontimeout", '-', additional_error)) goto failure; } /* Default idle-timeout if not returned by RADIUS. */ else if (strcmp (long_options[option_index].name, "defidletimeout") == 0) { if (update_arg( (void *)&(args_info->defidletimeout_arg), &(args_info->defidletimeout_orig), &(args_info->defidletimeout_given), &(local_args_info.defidletimeout_given), optarg, 0, "0", ARG_INT, check_ambiguity, override, 0, 0, "defidletimeout", '-', additional_error)) goto failure; } /* Default WISPr-Bandwidth-Max-Down if not returned by RADIUS. */ else if (strcmp (long_options[option_index].name, "defbandwidthmaxdown") == 0) { if (update_arg( (void *)&(args_info->defbandwidthmaxdown_arg), &(args_info->defbandwidthmaxdown_orig), &(args_info->defbandwidthmaxdown_given), &(local_args_info.defbandwidthmaxdown_given), optarg, 0, "0", ARG_LONG, check_ambiguity, override, 0, 0, "defbandwidthmaxdown", '-', additional_error)) goto failure; } /* Default WISPr-Bandwidth-Max-Up if not returned by RADIUS. */ else if (strcmp (long_options[option_index].name, "defbandwidthmaxup") == 0) { if (update_arg( (void *)&(args_info->defbandwidthmaxup_arg), &(args_info->defbandwidthmaxup_orig), &(args_info->defbandwidthmaxup_given), &(local_args_info.defbandwidthmaxup_given), optarg, 0, "0", ARG_LONG, check_ambiguity, override, 0, 0, "defbandwidthmaxup", '-', additional_error)) goto failure; } /* Default interim-interval for accounting if not returned by RADIUS. */ else if (strcmp (long_options[option_index].name, "definteriminterval") == 0) { if (update_arg( (void *)&(args_info->definteriminterval_arg), &(args_info->definteriminterval_orig), &(args_info->definteriminterval_given), &(local_args_info.definteriminterval_given), optarg, 0, "300", ARG_INT, check_ambiguity, override, 0, 0, "definteriminterval", '-', additional_error)) goto failure; } /* Authenticate based on MAC address. */ else if (strcmp (long_options[option_index].name, "macauth") == 0) { if (update_arg((void *)&(args_info->macauth_flag), 0, &(args_info->macauth_given), &(local_args_info.macauth_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "macauth", '-', additional_error)) goto failure; } /* Deny access (even UAM) to MAC addresses given Access-Reject. */ else if (strcmp (long_options[option_index].name, "macauthdeny") == 0) { if (update_arg((void *)&(args_info->macauthdeny_flag), 0, &(args_info->macauthdeny_given), &(local_args_info.macauthdeny_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "macauthdeny", '-', additional_error)) goto failure; } /* List of allowed MAC addresses. */ else if (strcmp (long_options[option_index].name, "macallowed") == 0) { if (update_multiple_arg_temp(&macallowed_list, &(local_args_info.macallowed_given), optarg, 0, 0, ARG_STRING, "macallowed", '-', additional_error)) goto failure; } /* Suffix to add to the MAC address. */ else if (strcmp (long_options[option_index].name, "macsuffix") == 0) { if (update_arg( (void *)&(args_info->macsuffix_arg), &(args_info->macsuffix_orig), &(args_info->macsuffix_given), &(local_args_info.macsuffix_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "macsuffix", '-', additional_error)) goto failure; } /* Password used when performing MAC authentication. */ else if (strcmp (long_options[option_index].name, "macpasswd") == 0) { if (update_arg( (void *)&(args_info->macpasswd_arg), &(args_info->macpasswd_orig), &(args_info->macpasswd_given), &(local_args_info.macpasswd_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "macpasswd", '-', additional_error)) goto failure; } /* Do not use RADIUS for authenticating the macallowed. */ else if (strcmp (long_options[option_index].name, "macallowlocal") == 0) { if (update_arg((void *)&(args_info->macallowlocal_flag), 0, &(args_info->macallowlocal_given), &(local_args_info.macallowlocal_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "macallowlocal", '-', additional_error)) goto failure; } /* Local content served by chilli (for splash page, etc). */ else if (strcmp (long_options[option_index].name, "wwwdir") == 0) { if (update_arg( (void *)&(args_info->wwwdir_arg), &(args_info->wwwdir_orig), &(args_info->wwwdir_given), &(local_args_info.wwwdir_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "wwwdir", '-', additional_error)) goto failure; } /* Script binary (such as haserl) for simple web programming. */ else if (strcmp (long_options[option_index].name, "wwwbin") == 0) { if (update_arg( (void *)&(args_info->wwwbin_arg), &(args_info->wwwbin_orig), &(args_info->wwwbin_given), &(local_args_info.wwwbin_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "wwwbin", '-', additional_error)) goto failure; } /* Program in inetd style to handle all uam requests. */ else if (strcmp (long_options[option_index].name, "uamui") == 0) { if (update_arg( (void *)&(args_info->uamui_arg), &(args_info->uamui_orig), &(args_info->uamui_given), &(local_args_info.uamui_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "uamui", '-', additional_error)) goto failure; } /* RADIUS administrative user login username. */ else if (strcmp (long_options[option_index].name, "adminuser") == 0) { if (update_arg( (void *)&(args_info->adminuser_arg), &(args_info->adminuser_orig), &(args_info->adminuser_given), &(local_args_info.adminuser_given), optarg, 0, "chillispot", ARG_STRING, check_ambiguity, override, 0, 0, "adminuser", '-', additional_error)) goto failure; } /* RADIUS administrative user login password. */ else if (strcmp (long_options[option_index].name, "adminpasswd") == 0) { if (update_arg( (void *)&(args_info->adminpasswd_arg), &(args_info->adminpasswd_orig), &(args_info->adminpasswd_given), &(local_args_info.adminpasswd_given), optarg, 0, "chillispot", ARG_STRING, check_ambiguity, override, 0, 0, "adminpasswd", '-', additional_error)) goto failure; } /* Unique MAC address of the NAS (called-station-id). */ else if (strcmp (long_options[option_index].name, "nasmac") == 0) { if (update_arg( (void *)&(args_info->nasmac_arg), &(args_info->nasmac_orig), &(args_info->nasmac_given), &(local_args_info.nasmac_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "nasmac", '-', additional_error)) goto failure; } /* Unique IP address of the NAS (nas-ip-address). */ else if (strcmp (long_options[option_index].name, "nasip") == 0) { if (update_arg( (void *)&(args_info->nasip_arg), &(args_info->nasip_orig), &(args_info->nasip_given), &(local_args_info.nasip_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "nasip", '-', additional_error)) goto failure; } /* SSID of the session. */ else if (strcmp (long_options[option_index].name, "ssid") == 0) { if (update_arg( (void *)&(args_info->ssid_arg), &(args_info->ssid_orig), &(args_info->ssid_given), &(local_args_info.ssid_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "ssid", '-', additional_error)) goto failure; } /* VLAN of the session. */ else if (strcmp (long_options[option_index].name, "vlan") == 0) { if (update_arg( (void *)&(args_info->vlan_arg), &(args_info->vlan_orig), &(args_info->vlan_given), &(local_args_info.vlan_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "vlan", '-', additional_error)) goto failure; } /* path to the command unix socket. */ else if (strcmp (long_options[option_index].name, "cmdsocket") == 0) { if (update_arg( (void *)&(args_info->cmdsocket_arg), &(args_info->cmdsocket_orig), &(args_info->cmdsocket_given), &(local_args_info.cmdsocket_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "cmdsocket", '-', additional_error)) goto failure; } /* Turn on the sending of ChilliSpot-OriginalURL in Access-Request. */ else if (strcmp (long_options[option_index].name, "radiusoriginalurl") == 0) { if (update_arg((void *)&(args_info->radiusoriginalurl_flag), 0, &(args_info->radiusoriginalurl_given), &(local_args_info.radiusoriginalurl_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "radiusoriginalurl", '-', additional_error)) goto failure; } /* Swap the meaning of input/output octets/packets. */ else if (strcmp (long_options[option_index].name, "swapoctets") == 0) { if (update_arg((void *)&(args_info->swapoctets_flag), 0, &(args_info->swapoctets_given), &(local_args_info.swapoctets_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "swapoctets", '-', additional_error)) goto failure; } /* Use the status file to keep track of sessions. */ else if (strcmp (long_options[option_index].name, "usestatusfile") == 0) { if (update_arg((void *)&(args_info->usestatusfile_flag), 0, &(args_info->usestatusfile_given), &(local_args_info.usestatusfile_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "usestatusfile", '-', additional_error)) goto failure; } /* File keep 'Local' usernames and passwords. */ else if (strcmp (long_options[option_index].name, "localusers") == 0) { if (update_arg( (void *)&(args_info->localusers_arg), &(args_info->localusers_orig), &(args_info->localusers_given), &(local_args_info.localusers_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "localusers", '-', additional_error)) goto failure; } /* IP of an upstream transparent proxy. */ else if (strcmp (long_options[option_index].name, "postauthproxy") == 0) { if (update_arg( (void *)&(args_info->postauthproxy_arg), &(args_info->postauthproxy_orig), &(args_info->postauthproxy_given), &(local_args_info.postauthproxy_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "postauthproxy", '-', additional_error)) goto failure; } /* Port of an upstream transparent proxy. */ else if (strcmp (long_options[option_index].name, "postauthproxyport") == 0) { if (update_arg( (void *)&(args_info->postauthproxyport_arg), &(args_info->postauthproxyport_orig), &(args_info->postauthproxyport_given), &(local_args_info.postauthproxyport_given), optarg, 0, "0", ARG_INT, check_ambiguity, override, 0, 0, "postauthproxyport", '-', additional_error)) goto failure; } /* Allow WPA 'Guest' access. */ else if (strcmp (long_options[option_index].name, "wpaguests") == 0) { if (update_arg((void *)&(args_info->wpaguests_flag), 0, &(args_info->wpaguests_given), &(local_args_info.wpaguests_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "wpaguests", '-', additional_error)) goto failure; } /* Allow OpenID authentication. */ else if (strcmp (long_options[option_index].name, "openidauth") == 0) { if (update_arg((void *)&(args_info->openidauth_flag), 0, &(args_info->openidauth_given), &(local_args_info.openidauth_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "openidauth", '-', additional_error)) goto failure; } /* Always allow 'PAP' authentication (depreciated; always on). */ else if (strcmp (long_options[option_index].name, "papalwaysok") == 0) { if (update_arg((void *)&(args_info->papalwaysok_flag), 0, &(args_info->papalwaysok_given), &(local_args_info.papalwaysok_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "papalwaysok", '-', additional_error)) goto failure; } /* Use ChilliSpot XML in WISPr blocks. */ else if (strcmp (long_options[option_index].name, "chillixml") == 0) { if (update_arg((void *)&(args_info->chillixml_flag), 0, &(args_info->chillixml_given), &(local_args_info.chillixml_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "chillixml", '-', additional_error)) goto failure; } /* Allow updating of session attributes in Accounting-Response. */ else if (strcmp (long_options[option_index].name, "acctupdate") == 0) { if (update_arg((void *)&(args_info->acctupdate_flag), 0, &(args_info->acctupdate_given), &(local_args_info.acctupdate_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "acctupdate", '-', additional_error)) goto failure; } /* Inspect DNS packets and drop responses with any non- A, CNAME, SOA, or MX records (to prevent dns tunnels). */ else if (strcmp (long_options[option_index].name, "dnsparanoia") == 0) { if (update_arg((void *)&(args_info->dnsparanoia_flag), 0, &(args_info->dnsparanoia_given), &(local_args_info.dnsparanoia_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "dnsparanoia", '-', additional_error)) goto failure; } /* Use a TAP instead of TUN (linux only). */ else if (strcmp (long_options[option_index].name, "usetap") == 0) { if (update_arg((void *)&(args_info->usetap_flag), 0, &(args_info->usetap_given), &(local_args_info.usetap_given), optarg, 0, 0, ARG_FLAG, check_ambiguity, override, 1, 0, "usetap", '-', additional_error)) goto failure; } /* Interface to use as default route; turns on 'manual' routing. */ else if (strcmp (long_options[option_index].name, "routeif") == 0) { if (update_arg( (void *)&(args_info->routeif_arg), &(args_info->routeif_orig), &(args_info->routeif_given), &(local_args_info.routeif_given), optarg, 0, 0, ARG_STRING, check_ambiguity, override, 0, 0, "routeif", '-', additional_error)) goto failure; } break; case '?': /* Invalid option. */ /* `getopt_long' already printed an error message. */ goto failure; default: /* bug: option not considered. */ fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : "")); abort (); } /* switch */ } /* while */ update_multiple_arg((void *)&(args_info->uamallowed_arg), &(args_info->uamallowed_orig), args_info->uamallowed_given, local_args_info.uamallowed_given, 0 , ARG_STRING, uamallowed_list); update_multiple_arg((void *)&(args_info->uamdomain_arg), &(args_info->uamdomain_orig), args_info->uamdomain_given, local_args_info.uamdomain_given, 0 , ARG_STRING, uamdomain_list); update_multiple_arg((void *)&(args_info->macallowed_arg), &(args_info->macallowed_orig), args_info->macallowed_given, local_args_info.macallowed_given, 0 , ARG_STRING, macallowed_list); args_info->uamallowed_given += local_args_info.uamallowed_given; local_args_info.uamallowed_given = 0; args_info->uamdomain_given += local_args_info.uamdomain_given; local_args_info.uamdomain_given = 0; args_info->macallowed_given += local_args_info.macallowed_given; local_args_info.macallowed_given = 0; if (check_required) { error += cmdline_parser_required2 (args_info, argv[0], additional_error); } cmdline_parser_release (&local_args_info); if ( error ) return (EXIT_FAILURE); return 0; failure: free_list (uamallowed_list, 1 ); free_list (uamdomain_list, 1 ); free_list (macallowed_list, 1 ); cmdline_parser_release (&local_args_info); return (EXIT_FAILURE); } #ifndef CONFIG_FILE_LINE_SIZE #define CONFIG_FILE_LINE_SIZE 2048 #endif #define ADDITIONAL_ERROR " in configuration file " #define CONFIG_FILE_LINE_BUFFER_SIZE (CONFIG_FILE_LINE_SIZE+3) /* 3 is for "--" and "=" */ static int _cmdline_parser_configfile (char * const filename, int *my_argc) { FILE* file; char my_argv[CONFIG_FILE_LINE_BUFFER_SIZE+1]; char linebuf[CONFIG_FILE_LINE_SIZE]; int line_num = 0; int result = 0, equal; char *fopt, *farg; char *str_index; size_t len, next_token; char delimiter; if ((file = fopen(filename, "r")) == NULL) { fprintf (stderr, "%s: Error opening configuration file '%s'\n", CMDLINE_PARSER_PACKAGE, filename); return EXIT_FAILURE; } while ((fgets(linebuf, CONFIG_FILE_LINE_SIZE, file)) != NULL) { ++line_num; my_argv[0] = '\0'; len = strlen(linebuf); if (len > (CONFIG_FILE_LINE_BUFFER_SIZE-1)) { fprintf (stderr, "%s:%s:%d: Line too long in configuration file\n", CMDLINE_PARSER_PACKAGE, filename, line_num); result = EXIT_FAILURE; break; } /* find first non-whitespace character in the line */ next_token = strspn (linebuf, " \t\r\n"); str_index = linebuf + next_token; if ( str_index[0] == '\0' || str_index[0] == '#') continue; /* empty line or comment line is skipped */ fopt = str_index; /* truncate fopt at the end of the first non-valid character */ next_token = strcspn (fopt, " \t\r\n="); if (fopt[next_token] == '\0') /* the line is over */ { farg = NULL; equal = 0; goto noarg; } /* remember if equal sign is present */ equal = (fopt[next_token] == '='); fopt[next_token++] = '\0'; /* advance pointers to the next token after the end of fopt */ next_token += strspn (fopt + next_token, " \t\r\n"); /* check for the presence of equal sign, and if so, skip it */ if ( !equal ) if ((equal = (fopt[next_token] == '='))) { next_token++; next_token += strspn (fopt + next_token, " \t\r\n"); } str_index += next_token; /* find argument */ farg = str_index; if ( farg[0] == '\"' || farg[0] == '\'' ) { /* quoted argument */ str_index = strchr (++farg, str_index[0] ); /* skip opening quote */ if (! str_index) { fprintf (stderr, "%s:%s:%d: unterminated string in configuration file\n", CMDLINE_PARSER_PACKAGE, filename, line_num); result = EXIT_FAILURE; break; } } else { /* read up the remaining part up to a delimiter */ next_token = strcspn (farg, " \t\r\n#\'\""); str_index += next_token; } /* truncate farg at the delimiter and store it for further check */ delimiter = *str_index, *str_index++ = '\0'; /* everything but comment is illegal at the end of line */ if (delimiter != '\0' && delimiter != '#') { str_index += strspn(str_index, " \t\r\n"); if (*str_index != '\0' && *str_index != '#') { fprintf (stderr, "%s:%s:%d: malformed string in configuration file\n", CMDLINE_PARSER_PACKAGE, filename, line_num); result = EXIT_FAILURE; break; } } noarg: if (!strcmp(fopt,"include")) { if (farg && *farg) { result = _cmdline_parser_configfile(farg, my_argc); } else { fprintf(stderr, "%s:%s:%d: include requires a filename argument.\n", CMDLINE_PARSER_PACKAGE, filename, line_num); } continue; } len = strlen(fopt); strcat (my_argv, len > 1 ? "--" : "-"); strcat (my_argv, fopt); if (len > 1 && ((farg && *farg) || equal)) strcat (my_argv, "="); if (farg && *farg) strcat (my_argv, farg); ++(*my_argc); cmd_line_list_tmp = (struct line_list *) malloc (sizeof (struct line_list)); cmd_line_list_tmp->next = cmd_line_list; cmd_line_list = cmd_line_list_tmp; cmd_line_list->string_arg = gengetopt_strdup(my_argv); } /* while */ if (file) fclose(file); return result; } int cmdline_parser_configfile (char * const filename, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) { struct cmdline_parser_params params; params.override = override; params.initialize = initialize; params.check_required = check_required; params.check_ambiguity = 0; params.print_errors = 1; return cmdline_parser_config_file (filename, args_info, ¶ms); } int cmdline_parser_config_file (char * const filename, struct gengetopt_args_info *args_info, struct cmdline_parser_params *params) { int i, result; int my_argc = 1; char **my_argv_arg; char *additional_error; /* store the program name */ cmd_line_list_tmp = (struct line_list *) malloc (sizeof (struct line_list)); cmd_line_list_tmp->next = cmd_line_list; cmd_line_list = cmd_line_list_tmp; cmd_line_list->string_arg = gengetopt_strdup (CMDLINE_PARSER_PACKAGE); result = _cmdline_parser_configfile(filename, &my_argc); if (result != EXIT_FAILURE) { my_argv_arg = (char **) malloc((my_argc+1) * sizeof(char *)); cmd_line_list_tmp = cmd_line_list; for (i = my_argc - 1; i >= 0; --i) { my_argv_arg[i] = cmd_line_list_tmp->string_arg; cmd_line_list_tmp = cmd_line_list_tmp->next; } my_argv_arg[my_argc] = 0; additional_error = (char *)malloc(strlen(filename) + strlen(ADDITIONAL_ERROR) + 1); strcpy (additional_error, ADDITIONAL_ERROR); strcat (additional_error, filename); result = cmdline_parser_internal (my_argc, my_argv_arg, args_info, params, additional_error); free (additional_error); free (my_argv_arg); } free_cmd_list(); if (result == EXIT_FAILURE) { cmdline_parser_free (args_info); exit (EXIT_FAILURE); } return result; }