9
0
Fork 0

optionally do not send recovery with sgsnemu

According to 3GPP TS 29.060 recovery is optional, add command line option --norecovery to remove this field in sgsnemu

Signed-off-by: Yann BONNAMY <yann_bonnamy@yahoo.fr>
Signed-off-by: Harald Welte <laforge@gnumonks.org>
This commit is contained in:
Harald Welte 2011-10-07 18:45:54 +02:00
parent 41af5691ef
commit 3a4c67b4bf
5 changed files with 36 additions and 1 deletions

View File

@ -1056,7 +1056,8 @@ extern int gtp_create_context_req(struct gsn_t *gsn, struct pdp_t *pdp,
/* Section 7.7.11 */
gtpie_tv1(&packet, &length, GTP_MAX, GTPIE_RECOVERY,
if (pdp->norecovery_given == 0)
gtpie_tv1(&packet, &length, GTP_MAX, GTPIE_RECOVERY,
gsn->restart_counter);
/* Section 7.7.12 */

View File

@ -198,6 +198,7 @@ struct pdp_t {
int mstz_given; /* MS Time Zone given*/
struct ul255_t imeisv; /* IMEI Software Version */
int imeisv_given; /* IMEI Software Version given*/
int norecovery_given; /* norecovery given*/
/* Additional parameters used by library */

View File

@ -66,6 +66,7 @@ const char *gengetopt_args_info_help[] = {
" --pingsize=INT Number of ping data bytes (default=`56')",
" --pingcount=INT Number of ping req to send (default=`0')",
" --pingquiet Do not print ping packet info (default=off)",
" --norecovery Do not send recovery (default=off)",
0
};
@ -148,6 +149,7 @@ void clear_given (struct gengetopt_args_info *args_info)
args_info->pingsize_given = 0 ;
args_info->pingcount_given = 0 ;
args_info->pingquiet_given = 0 ;
args_info->norecovery_given = 0 ;
}
static
@ -225,6 +227,7 @@ void clear_args (struct gengetopt_args_info *args_info)
args_info->pingcount_arg = 0;
args_info->pingcount_orig = NULL;
args_info->pingquiet_flag = 0;
args_info->norecovery_flag = 0;
}
@ -262,6 +265,7 @@ void init_args_info(struct gengetopt_args_info *args_info)
args_info->pingsize_help = gengetopt_args_info_help[28] ;
args_info->pingcount_help = gengetopt_args_info_help[29] ;
args_info->pingquiet_help = gengetopt_args_info_help[30] ;
args_info->norecovery_help = gengetopt_args_info_help[31] ;
}
@ -708,6 +712,9 @@ cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_
if (args_info->pingquiet_given) {
fprintf(outfile, "%s\n", "pingquiet");
}
if (args_info->norecovery_given) {
fprintf(outfile, "%s\n", "norecovery");
}
fclose (outfile);
@ -830,6 +837,7 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf
{ "pingsize", 1, NULL, 0 },
{ "pingcount", 1, NULL, 0 },
{ "pingquiet", 0, NULL, 0 },
{ "norecovery", 0, NULL, 0 },
{ NULL, 0, NULL, 0 }
};
@ -1529,6 +1537,20 @@ cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_inf
args_info->pingquiet_given = 1;
args_info->pingquiet_flag = !(args_info->pingquiet_flag);
}
/* Do not send recovery. */
else if (strcmp (long_options[option_index].name, "norecovery") == 0)
{
if (local_args_info.norecovery_given)
{
fprintf (stderr, "%s: `--norecovery' option given more than once%s\n", argv[0], (additional_error ? additional_error : ""));
goto failure;
}
if (args_info->norecovery_given && ! override)
continue;
local_args_info.norecovery_given = 1;
args_info->norecovery_given = 1;
args_info->norecovery_flag = !(args_info->norecovery_flag);
}
break;
case '?': /* Invalid option. */

View File

@ -132,6 +132,8 @@ struct gengetopt_args_info
const char *pingcount_help; /* Number of ping req to send help description. */
int pingquiet_flag; /* Do not print ping packet info (default=off). */
const char *pingquiet_help; /* Do not print ping packet info help description. */
int norecovery_flag; /* Do not print ping packet info (default=off). */
const char *norecovery_help; /* Do not print ping packet info help description. */
int help_given ; /* Whether help was given. */
int version_given ; /* Whether version was given. */
@ -173,6 +175,7 @@ struct gengetopt_args_info
int pingsize_given ; /* Whether pingsize was given. */
int pingcount_given ; /* Whether pingcount was given. */
int pingquiet_given ; /* Whether pingquiet was given. */
int norecovery_given ; /* Whether norecovery was given. */
} ;

View File

@ -115,6 +115,7 @@ struct {
struct ul255_t imeisv;
int imeisv_given;
struct ul16_t msisdn;
int norecovery_given;
} options;
@ -272,6 +273,7 @@ int process_options(int argc, char **argv) {
printf("pingsize: %d\n", args_info.pingsize_arg);
printf("pingcount: %d\n", args_info.pingcount_arg);
printf("pingquiet: %d\n", args_info.pingquiet_flag);
printf("norecovery: %d\n", args_info.norecovery_flag);
}
/* Try out our new parser */
@ -310,6 +312,7 @@ int process_options(int argc, char **argv) {
printf("pingsize: %d\n", args_info.pingsize_arg);
printf("pingcount: %d\n", args_info.pingcount_arg);
printf("pingquiet: %d\n", args_info.pingquiet_flag);
printf("norecovery: %d\n", args_info.norecovery_flag);
}
}
@ -861,6 +864,9 @@ int process_options(int argc, char **argv) {
options.pingcount = args_info.pingcount_arg;
options.pingquiet = args_info.pingquiet_flag;
/* norecovery */
options.norecovery_given = args_info.norecovery_flag;
return 0;
}
@ -1465,6 +1471,8 @@ int main(int argc, char **argv)
memcpy(pdp->imeisv.v, options.imeisv.v, options.imeisv.l);
pdp->imeisv_given = options.imeisv_given;
pdp->norecovery_given = options.norecovery_given;
if (options.apn.l > sizeof(pdp->apn_use.v)) {
sys_err(LOG_ERR, __FILE__, __LINE__, 0, "APN length too big");
exit(1);