8
0
Fork 0

Added selmode

origin
jjako 19 years ago
parent 9b4971d4a6
commit 1a51df7111
  1. 11
      doc/sgsnemu.8
  2. 4
      examples/sgsnemu.conf
  3. 35
      sgsnemu/cmdline.c
  4. 1
      sgsnemu/cmdline.ggo
  5. 2
      sgsnemu/cmdline.h
  6. 9
      sgsnemu/sgsnemu.c

@ -53,6 +53,8 @@ sgsnemu \- Serving GPRS Support Node Emulator
] [
.BI \-\-apn " apn"
] [
.BI \-\-selmode " selmode"
] [
.BI \-\-imsi " imsi"
] [
.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
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
.BI --imsi " imsi"
.I imsi

@ -56,6 +56,10 @@
# Access point name to connect to when run in client mode.
#apn internet
# TAG: selmode
# Selection mode to use when connecting to GGSN.
#selmode 0x01
# TAG: imsi
# IMSI number used when run in client mode.
#imsi 2400101234567890

@ -1,7 +1,7 @@
/*
File autogenerated by gengetopt version 2.8
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
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(" --gtpversion=INT GTP version to use (default='1')\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(" --nsapi=INT NSAPI (default='0')\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->gtpversion_given = 0 ;
args_info->apn_given = 0 ;
args_info->selmode_given = 0 ;
args_info->imsi_given = 0 ;
args_info->nsapi_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->gtpversion_arg = 1 ;\
args_info->apn_arg = strdup("internet") ;\
args_info->selmode_arg = 0x01 ;\
args_info->imsi_arg = strdup("240010123456789") ;\
args_info->nsapi_arg = 0 ;\
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 },
{ "gtpversion", 1, NULL, 0 },
{ "apn", 1, NULL, 'a' },
{ "selmode", 1, NULL, 0 },
{ "imsi", 1, NULL, 'i' },
{ "nsapi", 1, NULL, 0 },
{ "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);
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. */
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;
}
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 (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 "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 "nsapi" - "NSAPI" int default="0" 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 gtpversion_arg; /* GTP version to use (default='1'). */
char * apn_arg; /* Access point name (default='internet'). */
int selmode_arg; /* Selection mode (default='0x01'). */
char * imsi_arg; /* IMSI (default='240010123456789'). */
int nsapi_arg; /* NSAPI (default='0'). */
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 gtpversion_given ; /* Whether gtpversion was given. */
int apn_given ; /* Whether apn was given. */
int selmode_given ; /* Whether selmode was given. */
int imsi_given ; /* Whether imsi was given. */
int nsapi_given ; /* Whether nsapi was given. */
int msisdn_given ; /* Whether msisdn was given. */

@ -108,6 +108,7 @@ struct {
struct ul255_t qos;
uint16_t cch;
struct ul255_t apn;
uint8_t selmode;
struct ul16_t msisdn;
} options;
@ -447,6 +448,12 @@ int process_options(int argc, char **argv) {
options.apn.v[0] = (char) strlen(args_info.apn_arg);
strncpy(&options.apn.v[1], args_info.apn_arg, sizeof(options.apn.v)-1);
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 */
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;
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)) {
sys_err(LOG_ERR, __FILE__, __LINE__, 0, "APN length too big");