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>
This commit is contained in:
parent
11a398fbc3
commit
41af5691ef
|
@ -1049,6 +1049,12 @@ extern int gtp_create_context_req(struct gsn_t *gsn, struct pdp_t *pdp,
|
|||
sizeof(pdp->imsi), (uint8_t*) &pdp->imsi);
|
||||
}
|
||||
|
||||
/* Section 7.7.3 Routing Area Information */
|
||||
if (pdp->rai_given == 1)
|
||||
gtpie_tv0(&packet, &length, GTP_MAX, GTPIE_RAI,
|
||||
pdp->rai.l, (uint8_t*) &pdp->rai.v);
|
||||
|
||||
|
||||
/* Section 7.7.11 */
|
||||
gtpie_tv1(&packet, &length, GTP_MAX, GTPIE_RECOVERY,
|
||||
gsn->restart_counter);
|
||||
|
|
|
@ -192,6 +192,8 @@ struct pdp_t {
|
|||
int rattype_given; /* Radio Access Technology Type given*/
|
||||
struct ul255_t userloc; /* User Location Information */
|
||||
int userloc_given; /* User Location Information given*/
|
||||
struct ul255_t rai; /* Routing Area Information */
|
||||
int rai_given; /* Routing Area Information given*/
|
||||
struct ul255_t mstz; /* MS Time Zone */
|
||||
int mstz_given; /* MS Time Zone given*/
|
||||
struct ul255_t imeisv; /* IMEI Software Version */
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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;
|
||||
|
|
Reference in New Issue