Added selmode
This commit is contained in:
parent
9b4971d4a6
commit
1a51df7111
|
@ -53,6 +53,8 @@ sgsnemu \- Serving GPRS Support Node Emulator
|
||||||
] [
|
] [
|
||||||
.BI \-\-apn " apn"
|
.BI \-\-apn " apn"
|
||||||
] [
|
] [
|
||||||
|
.BI \-\-selmode " selmode"
|
||||||
|
] [
|
||||||
.BI \-\-imsi " imsi"
|
.BI \-\-imsi " imsi"
|
||||||
] [
|
] [
|
||||||
.BI \-\-nsapi " nsapi"
|
.BI \-\-nsapi " nsapi"
|
||||||
|
@ -207,6 +209,15 @@ to establish a GTPv1 context sgsnemu will fall back to using GTPv0.
|
||||||
to use when connecting to the GGSN (default = internet). APN is an
|
to use when connecting to the GGSN (default = internet). APN is an
|
||||||
abbreviation of Access Point Name.
|
abbreviation of Access Point Name.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.BI --selmode " selmode"
|
||||||
|
Selection mode to use when connecting to the GGSN (default =
|
||||||
|
0x01). The encoding of the selection mode is as follows: 0: MS or
|
||||||
|
network provided APN, subscribed verified, 1: MS provided APN,
|
||||||
|
subscription not verified, 2: Network provided APN, subscription not
|
||||||
|
verified.
|
||||||
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BI --imsi " imsi"
|
.BI --imsi " imsi"
|
||||||
.I imsi
|
.I imsi
|
||||||
|
|
|
@ -56,6 +56,10 @@
|
||||||
# Access point name to connect to when run in client mode.
|
# Access point name to connect to when run in client mode.
|
||||||
#apn internet
|
#apn internet
|
||||||
|
|
||||||
|
# TAG: selmode
|
||||||
|
# Selection mode to use when connecting to GGSN.
|
||||||
|
#selmode 0x01
|
||||||
|
|
||||||
# TAG: imsi
|
# TAG: imsi
|
||||||
# IMSI number used when run in client mode.
|
# IMSI number used when run in client mode.
|
||||||
#imsi 2400101234567890
|
#imsi 2400101234567890
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
File autogenerated by gengetopt version 2.8
|
File autogenerated by gengetopt version 2.8
|
||||||
generated with the following command:
|
generated with the following command:
|
||||||
/mnt/hda5/bin/gengetopt --conf-parser
|
gengetopt --conf-parser
|
||||||
|
|
||||||
The developers of gengetopt consider the fixed text that goes in all
|
The developers of gengetopt consider the fixed text that goes in all
|
||||||
gengetopt output files to be in the public domain:
|
gengetopt output files to be in the public domain:
|
||||||
|
@ -55,6 +55,7 @@ cmdline_parser_print_help (void)
|
||||||
printf(" --timelimit=INT Exit after timelimit seconds (default='0')\n");
|
printf(" --timelimit=INT Exit after timelimit seconds (default='0')\n");
|
||||||
printf(" --gtpversion=INT GTP version to use (default='1')\n");
|
printf(" --gtpversion=INT GTP version to use (default='1')\n");
|
||||||
printf(" -aSTRING --apn=STRING Access point name (default='internet')\n");
|
printf(" -aSTRING --apn=STRING Access point name (default='internet')\n");
|
||||||
|
printf(" --selmode=INT Selection mode (default='0x01')\n");
|
||||||
printf(" -iSTRING --imsi=STRING IMSI (default='240010123456789')\n");
|
printf(" -iSTRING --imsi=STRING IMSI (default='240010123456789')\n");
|
||||||
printf(" --nsapi=INT NSAPI (default='0')\n");
|
printf(" --nsapi=INT NSAPI (default='0')\n");
|
||||||
printf(" -mSTRING --msisdn=STRING Mobile Station ISDN number (default='46702123456')\n");
|
printf(" -mSTRING --msisdn=STRING Mobile Station ISDN number (default='46702123456')\n");
|
||||||
|
@ -108,6 +109,7 @@ cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_i
|
||||||
args_info->timelimit_given = 0 ;
|
args_info->timelimit_given = 0 ;
|
||||||
args_info->gtpversion_given = 0 ;
|
args_info->gtpversion_given = 0 ;
|
||||||
args_info->apn_given = 0 ;
|
args_info->apn_given = 0 ;
|
||||||
|
args_info->selmode_given = 0 ;
|
||||||
args_info->imsi_given = 0 ;
|
args_info->imsi_given = 0 ;
|
||||||
args_info->nsapi_given = 0 ;
|
args_info->nsapi_given = 0 ;
|
||||||
args_info->msisdn_given = 0 ;
|
args_info->msisdn_given = 0 ;
|
||||||
|
@ -137,6 +139,7 @@ cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_i
|
||||||
args_info->timelimit_arg = 0 ;\
|
args_info->timelimit_arg = 0 ;\
|
||||||
args_info->gtpversion_arg = 1 ;\
|
args_info->gtpversion_arg = 1 ;\
|
||||||
args_info->apn_arg = strdup("internet") ;\
|
args_info->apn_arg = strdup("internet") ;\
|
||||||
|
args_info->selmode_arg = 0x01 ;\
|
||||||
args_info->imsi_arg = strdup("240010123456789") ;\
|
args_info->imsi_arg = strdup("240010123456789") ;\
|
||||||
args_info->nsapi_arg = 0 ;\
|
args_info->nsapi_arg = 0 ;\
|
||||||
args_info->msisdn_arg = strdup("46702123456") ;\
|
args_info->msisdn_arg = strdup("46702123456") ;\
|
||||||
|
@ -181,6 +184,7 @@ cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_i
|
||||||
{ "timelimit", 1, NULL, 0 },
|
{ "timelimit", 1, NULL, 0 },
|
||||||
{ "gtpversion", 1, NULL, 0 },
|
{ "gtpversion", 1, NULL, 0 },
|
||||||
{ "apn", 1, NULL, 'a' },
|
{ "apn", 1, NULL, 'a' },
|
||||||
|
{ "selmode", 1, NULL, 0 },
|
||||||
{ "imsi", 1, NULL, 'i' },
|
{ "imsi", 1, NULL, 'i' },
|
||||||
{ "nsapi", 1, NULL, 0 },
|
{ "nsapi", 1, NULL, 0 },
|
||||||
{ "msisdn", 1, NULL, 'm' },
|
{ "msisdn", 1, NULL, 'm' },
|
||||||
|
@ -418,6 +422,19 @@ cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_i
|
||||||
args_info->gtpversion_arg = strtol (optarg,&stop_char,0);
|
args_info->gtpversion_arg = strtol (optarg,&stop_char,0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
/* Selection mode. */
|
||||||
|
else if (strcmp (long_options[option_index].name, "selmode") == 0)
|
||||||
|
{
|
||||||
|
if (args_info->selmode_given)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s: `--selmode' option given more than once\n", PACKAGE);
|
||||||
|
clear_args ();
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
args_info->selmode_given = 1;
|
||||||
|
args_info->selmode_arg = strtol (optarg,&stop_char,0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
/* NSAPI. */
|
/* NSAPI. */
|
||||||
else if (strcmp (long_options[option_index].name, "nsapi") == 0)
|
else if (strcmp (long_options[option_index].name, "nsapi") == 0)
|
||||||
{
|
{
|
||||||
|
@ -803,6 +820,22 @@ cmdline_parser_configfile (char * const filename, struct gengetopt_args_info *ar
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!strcmp(fopt, "selmode"))
|
||||||
|
{
|
||||||
|
if (override || !args_info->selmode_given)
|
||||||
|
{
|
||||||
|
args_info->selmode_given = 1;
|
||||||
|
if (fnum == 2)
|
||||||
|
args_info->selmode_arg = strtol (farg,&stop_char,0);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s:%d: required <option_name> <option_val>\n",
|
||||||
|
filename, line_num);
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!strcmp(fopt, "imsi"))
|
if (!strcmp(fopt, "imsi"))
|
||||||
{
|
{
|
||||||
if (override || !args_info->imsi_given)
|
if (override || !args_info->imsi_given)
|
||||||
|
|
|
@ -30,6 +30,7 @@ option "timelimit" - "Exit after timelimit seconds" int default="0" no
|
||||||
|
|
||||||
option "gtpversion" - "GTP version to use" int default="1" no
|
option "gtpversion" - "GTP version to use" int default="1" no
|
||||||
option "apn" a "Access point name" string default="internet" no
|
option "apn" a "Access point name" string default="internet" no
|
||||||
|
option "selmode" - "Selection mode" int default="0x01" no
|
||||||
option "imsi" i "IMSI" string default="240010123456789" no
|
option "imsi" i "IMSI" string default="240010123456789" no
|
||||||
option "nsapi" - "NSAPI" int default="0" no
|
option "nsapi" - "NSAPI" int default="0" no
|
||||||
option "msisdn" m "Mobile Station ISDN number" string default="46702123456" no
|
option "msisdn" m "Mobile Station ISDN number" string default="46702123456" no
|
||||||
|
|
|
@ -31,6 +31,7 @@ struct gengetopt_args_info
|
||||||
int timelimit_arg; /* Exit after timelimit seconds (default='0'). */
|
int timelimit_arg; /* Exit after timelimit seconds (default='0'). */
|
||||||
int gtpversion_arg; /* GTP version to use (default='1'). */
|
int gtpversion_arg; /* GTP version to use (default='1'). */
|
||||||
char * apn_arg; /* Access point name (default='internet'). */
|
char * apn_arg; /* Access point name (default='internet'). */
|
||||||
|
int selmode_arg; /* Selection mode (default='0x01'). */
|
||||||
char * imsi_arg; /* IMSI (default='240010123456789'). */
|
char * imsi_arg; /* IMSI (default='240010123456789'). */
|
||||||
int nsapi_arg; /* NSAPI (default='0'). */
|
int nsapi_arg; /* NSAPI (default='0'). */
|
||||||
char * msisdn_arg; /* Mobile Station ISDN number (default='46702123456'). */
|
char * msisdn_arg; /* Mobile Station ISDN number (default='46702123456'). */
|
||||||
|
@ -62,6 +63,7 @@ struct gengetopt_args_info
|
||||||
int timelimit_given ; /* Whether timelimit was given. */
|
int timelimit_given ; /* Whether timelimit was given. */
|
||||||
int gtpversion_given ; /* Whether gtpversion was given. */
|
int gtpversion_given ; /* Whether gtpversion was given. */
|
||||||
int apn_given ; /* Whether apn was given. */
|
int apn_given ; /* Whether apn was given. */
|
||||||
|
int selmode_given ; /* Whether selmode was given. */
|
||||||
int imsi_given ; /* Whether imsi was given. */
|
int imsi_given ; /* Whether imsi was given. */
|
||||||
int nsapi_given ; /* Whether nsapi was given. */
|
int nsapi_given ; /* Whether nsapi was given. */
|
||||||
int msisdn_given ; /* Whether msisdn was given. */
|
int msisdn_given ; /* Whether msisdn was given. */
|
||||||
|
|
|
@ -108,6 +108,7 @@ struct {
|
||||||
struct ul255_t qos;
|
struct ul255_t qos;
|
||||||
uint16_t cch;
|
uint16_t cch;
|
||||||
struct ul255_t apn;
|
struct ul255_t apn;
|
||||||
|
uint8_t selmode;
|
||||||
struct ul16_t msisdn;
|
struct ul16_t msisdn;
|
||||||
} options;
|
} options;
|
||||||
|
|
||||||
|
@ -447,6 +448,12 @@ int process_options(int argc, char **argv) {
|
||||||
options.apn.v[0] = (char) strlen(args_info.apn_arg);
|
options.apn.v[0] = (char) strlen(args_info.apn_arg);
|
||||||
strncpy(&options.apn.v[1], args_info.apn_arg, sizeof(options.apn.v)-1);
|
strncpy(&options.apn.v[1], args_info.apn_arg, sizeof(options.apn.v)-1);
|
||||||
printf("Using APN: %s\n", args_info.apn_arg);
|
printf("Using APN: %s\n", args_info.apn_arg);
|
||||||
|
|
||||||
|
|
||||||
|
/* selmode */
|
||||||
|
options.selmode = args_info.selmode_arg;
|
||||||
|
printf("Using selection mode: %d\n", args_info.selmode_arg);
|
||||||
|
|
||||||
|
|
||||||
/* msisdn */
|
/* msisdn */
|
||||||
if (strlen(args_info.msisdn_arg)>(sizeof(options.msisdn.v)-1)) {
|
if (strlen(args_info.msisdn_arg)>(sizeof(options.msisdn.v)-1)) {
|
||||||
|
@ -1134,7 +1141,7 @@ int main(int argc, char **argv)
|
||||||
pdp->qos_req.v[0] = 0x00;
|
pdp->qos_req.v[0] = 0x00;
|
||||||
memcpy(pdp->qos_req.v+1, options.qos.v, options.qos.l);
|
memcpy(pdp->qos_req.v+1, options.qos.v, options.qos.l);
|
||||||
|
|
||||||
pdp->selmode = 0x01; /* MS provided APN, subscription not verified */
|
pdp->selmode = options.selmode;
|
||||||
|
|
||||||
if (options.apn.l > sizeof(pdp->apn_use.v)) {
|
if (options.apn.l > sizeof(pdp->apn_use.v)) {
|
||||||
sys_err(LOG_ERR, __FILE__, __LINE__, 0, "APN length too big");
|
sys_err(LOG_ERR, __FILE__, __LINE__, 0, "APN length too big");
|
||||||
|
|
Reference in New Issue