aboutsummaryrefslogtreecommitdiffstats
path: root/sgsnemu
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2011-10-07 18:42:34 +0200
committerHarald Welte <laforge@gnumonks.org>2011-10-07 18:42:34 +0200
commit41af5691ef08fb70e2c65aba03c8b9e6c20983a6 (patch)
treee0e46b53f3c271d4b3d3db6fc6f2755923ab01a0 /sgsnemu
parent11a398fbc3ad9b655d8ba947bea7012f7ce81604 (diff)
Add optional RAI Field
Routing Area Information is an optional Field described in 3GPP TS 29.060 7.7.3 it can be added with command line option rai, in the dot separated format MCC.MNC.LAC.RAC example : --rai 208.10.65535.255 Signed-off-by: Yann BONNAMY <yann_bonnamy@yahoo.fr> Signed-off-by: Harald Welte <laforge@gnumonks.org>
Diffstat (limited to 'sgsnemu')
-rw-r--r--sgsnemu/cmdline.c17
-rw-r--r--sgsnemu/cmdline.h4
-rw-r--r--sgsnemu/sgsnemu.c83
3 files changed, 104 insertions, 0 deletions
diff --git a/sgsnemu/cmdline.c b/sgsnemu/cmdline.c
index 83897cf..7bd1849 100644
--- a/sgsnemu/cmdline.c
+++ b/sgsnemu/cmdline.c
@@ -42,6 +42,7 @@ const char *gengetopt_args_info_help[] = {
" --selmode=INT Selection mode (default=`0x01')",
" --rattype=INT Radio Access Technology Type (optional-1to5)",
" --userloc=STRING User Location Information (optional-type.MCC.MNC.LAC.CIorSACorRAC)",
+ " --rai=STRING Routing Area Information (optional-MCC.MNC.LAC.RAC)",
" --mstz=STRING MS Time Zone (optional- sign.NbQuartersOfAnHour.DSTAdjustment)",
" --imeisv=STRING IMEI(SV) International Mobile Equipment Identity (and Software Version) (optional,16 digits)",
" -i, --imsi=STRING IMSI (default=`240010123456789')",
@@ -123,6 +124,7 @@ void clear_given (struct gengetopt_args_info *args_info)
args_info->selmode_given = 0 ;
args_info->rattype_given = 0 ;
args_info->userloc_given = 0 ;
+ args_info->rai_given = 0 ;
args_info->mstz_given = 0 ;
args_info->imeisv_given = 0 ;
args_info->imsi_given = 0 ;
@@ -178,6 +180,8 @@ void clear_args (struct gengetopt_args_info *args_info)
args_info->rattype_orig = NULL;
args_info->userloc_arg = strdup("02509946241207");
args_info->userloc_orig = NULL;
+ args_info->rai_arg = strdup("02509946241207");
+ args_info->rai_orig = NULL;
args_info->mstz_arg = strdup("0");
args_info->mstz_orig = NULL;
args_info->imeisv_arg = strdup("2143658709214365");
@@ -802,6 +806,7 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf
{ "selmode", 1, NULL, 0 },
{ "rattype", 1, NULL, 0},
{ "userloc", 1, NULL, 0},
+ { "rai", 1, NULL, 0},
{ "mstz", 1, NULL, 0},
{ "imeisv", 1, NULL, 0},
{ "imsi", 1, NULL, 'i' },
@@ -1284,6 +1289,18 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf
args_info->userloc_arg = strdup (optarg);
break;
}
+ /* Routing Area Information. */
+ else if (strcmp (long_options[option_index].name, "rai") == 0)
+ {
+ if (args_info->rai_given)
+ {
+ fprintf (stderr, "%s: `--rai' option given more than once\n", PACKAGE);
+ exit (EXIT_FAILURE);
+ }
+ args_info->rai_given = 1;
+ args_info->rai_arg = strdup (optarg);
+ break;
+ }
/* MS Time Zone */
else if (strcmp (long_options[option_index].name, "mstz") == 0)
{
diff --git a/sgsnemu/cmdline.h b/sgsnemu/cmdline.h
index 869262f..5a4f8d9 100644
--- a/sgsnemu/cmdline.h
+++ b/sgsnemu/cmdline.h
@@ -67,6 +67,9 @@ struct gengetopt_args_info
char * userloc_arg; /* User Location Information (optional). */
char * userloc_orig;
char * userloc_help;
+ char * rai_arg; /* Routing Area Information (optional). */
+ char * rai_orig;
+ char * rai_help;
char * mstz_arg; /* MS Time Zone (optional). */
char * mstz_orig;
char * mstz_help;
@@ -146,6 +149,7 @@ struct gengetopt_args_info
int selmode_given ; /* Whether selmode was given. */
int rattype_given ; /* Whether rattype was given. */
int userloc_given ; /* Whether userloc was given. */
+ int rai_given ; /* Whether RAI was given. */
int mstz_given ; /* Whether mstz was given. */
int imeisv_given ; /* Whether imeisv was given. */
int imsi_given ; /* Whether imsi was given. */
diff --git a/sgsnemu/sgsnemu.c b/sgsnemu/sgsnemu.c
index edee09e..7d164b3 100644
--- a/sgsnemu/sgsnemu.c
+++ b/sgsnemu/sgsnemu.c
@@ -108,6 +108,8 @@ struct {
int rattype_given;
struct ul255_t userloc;
int userloc_given;
+ struct ul255_t rai;
+ int rai_given;
struct ul255_t mstz;
int mstz_given;
struct ul255_t imeisv;
@@ -231,6 +233,7 @@ int process_options(int argc, char **argv) {
int lac_d;
char * rest;
char *userloc_el[] = {"TYPE","MCC","MNC","LAC","REST"};
+ char *rai_el[] = {"MCC","MNC","LAC","RAC"};
char *mstz_el[] = {"SIGN","QUARTERS","DST"};
int sign ;
int nbquarters ;
@@ -610,6 +613,82 @@ int process_options(int argc, char **argv) {
options.userloc.v[6] = i; /* octet 10 - t0,CI / t1,SAC / t2,RAC */
options.userloc.v[7] = lac_d; /* octet 11 - t0,CI / t1,SAC / t2,RAC */
}
+
+ /* RAI */
+ if (args_info.rai_given == 1 ) {
+ printf("Using RAI: %s\n", args_info.rai_arg);
+ tmp = args_info.rai_arg ;
+ n=0;
+ pch = strtok (tmp,".");
+ while (pch != NULL) {
+ rai_el[n] = pch ;
+ pch = strtok (NULL, ".");
+ n++;
+ }
+
+ options.rai_given = 1 ;
+ options.rai.l = 6 ;
+
+
+ /* MCC */
+ mcc = rai_el[0] ;
+ printf("->mcc : %s\n", mcc);
+ if (strlen(mcc)!=3) {
+ printf("Invalid MCC lenght\n");
+ return -1;
+ }
+
+ /* MNC */
+ mnc = rai_el[1] ;
+ printf("->mnc : %s\n", mnc);
+
+ a = (uint8_t) (mcc[0] - 48);
+ b = (uint8_t) (mcc[1] - 48);
+ options.rai.v[0] = 16*b+a ;
+
+ /* octet 3 - MNC Digit 3 - MCC Digit 3 */
+ a = (uint8_t) (mcc[2] - 48);
+
+ if ( (strlen(mnc) > 3) || (strlen(mnc) < 2)) {
+ printf("Invalid MNC lenght\n");
+ return -1;
+ }
+ if (strlen(mnc)==2) {
+ b = 15 ;
+ }
+ if (strlen(mnc)==3) {
+ b = (uint8_t) (mnc[2] - 48);
+ }
+ options.rai.v[1] = 16*b+a ;
+
+ /* octet 4 - MNC Digit 2 - MNC Digit 1 */
+ a = (uint8_t) (mnc[0]- 48);
+ b = (uint8_t) (mnc[1]- 48);
+ options.rai.v[2] = 16*b+a ;
+
+ /* LAC */
+ lac = rai_el[2] ;
+ printf("->LAC: %s\n", lac);
+ lac_d = atoi(lac);
+ if (lac_d>65535 || lac_d<1) {
+ printf("Invalid LAC\n");
+ return -1;
+ }
+ i = lac_d >> 8 ;
+ options.rai.v[3] = i; /* octet 5 - LAC */
+ options.rai.v[4] = lac_d; /* octet 6 - LAC */
+
+ /* RAC */
+ rest = rai_el[3] ;
+ printf("->RAC : %s\n", rest);
+ lac_d = atoi(rest);
+ if (lac_d>255 || lac_d<1) {
+ printf("Invalid RAC\n");
+ return -1;
+ }
+ options.rai.v[5] = lac_d; /* octet 7 - RAC */
+ }
+
/* mstz */
if (args_info.mstz_given == 1 ) {
options.mstz_given = 1 ;
@@ -1374,6 +1453,10 @@ int main(int argc, char **argv)
memcpy(pdp->userloc.v, options.userloc.v, options.userloc.l);
pdp->userloc_given = options.userloc_given;
+ pdp->rai.l = options.rai.l;
+ memcpy(pdp->rai.v, options.rai.v, options.rai.l);
+ pdp->rai_given = options.rai_given;
+
pdp->mstz.l = options.mstz.l;
memcpy(pdp->mstz.v, options.mstz.v, options.mstz.l);
pdp->mstz_given = options.mstz_given;