aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-09-24 18:12:40 +0800
committerHarald Welte <laforge@gnumonks.org>2017-10-01 18:19:07 +0800
commit840a8e9713f1e1c60e3b38ba51847355555cafd9 (patch)
tree47a889a7811258e586bc6668331ffb73d3e58e21
parentcee7546f15bc66443c17a0b2cbca2570d85e3517 (diff)
sgsnemu: Allow specification of PDP (EUA) Type IPv4 or IPv6
This just adds the capability to sgsnemu to request a certain PDP EUA type. It doesn't mean it actually handles anything beyond the existing IPv4 yet. Change-Id: I157f9157a7ff2ea56c37a4a902d4706de4c7d35d
-rw-r--r--sgsnemu/cmdline.c25
-rw-r--r--sgsnemu/cmdline.ggo1
-rw-r--r--sgsnemu/cmdline.h8
-rw-r--r--sgsnemu/sgsnemu.c12
4 files changed, 44 insertions, 2 deletions
diff --git a/sgsnemu/cmdline.c b/sgsnemu/cmdline.c
index 6df8fc1..60c0a25 100644
--- a/sgsnemu/cmdline.c
+++ b/sgsnemu/cmdline.c
@@ -76,6 +76,7 @@ const char *gengetopt_args_info_help[] = {
" --pingcount=INT Number of ping req to send (default=`0')",
" --pingquiet Do not print ping packet info (default=off)",
" --no-tx-gpdu-seq Don't transmit G-PDU sequence nums\n (default=off)",
+ " -t, --pdp-type=(v4|v6) PDP Type (default=`v4')",
0
};
@@ -161,6 +162,7 @@ void clear_given(struct gengetopt_args_info *args_info)
args_info->pingcount_given = 0;
args_info->pingquiet_given = 0;
args_info->no_tx_gpdu_seq_given = 0;
+ args_info->pdp_type_given = 0;
}
static
@@ -241,6 +243,8 @@ void clear_args(struct gengetopt_args_info *args_info)
args_info->pingcount_orig = NULL;
args_info->pingquiet_flag = 0;
args_info->no_tx_gpdu_seq_flag = 0;
+ args_info->pdp_type_arg = gengetopt_strdup("v4");
+ args_info->pdp_type_orig = NULL;
}
@@ -290,6 +294,7 @@ void init_args_info(struct gengetopt_args_info *args_info)
args_info->pingcount_help = gengetopt_args_info_help[39];
args_info->pingquiet_help = gengetopt_args_info_help[40];
args_info->no_tx_gpdu_seq_help = gengetopt_args_info_help[41];
+ args_info->pdp_type_help = gengetopt_args_info_help[42];
}
@@ -419,6 +424,8 @@ static void cmdline_parser_release(struct gengetopt_args_info *args_info)
free_string_field(&(args_info->pingrate_orig));
free_string_field(&(args_info->pingsize_orig));
free_string_field(&(args_info->pingcount_orig));
+ free_string_field(&(args_info->pdp_type_arg));
+ free_string_field(&(args_info->pdp_type_orig));
clear_given(args_info);
}
@@ -538,6 +545,9 @@ int cmdline_parser_dump(FILE * outfile, struct gengetopt_args_info *args_info)
write_into_file(outfile, "pingquiet", 0, 0);
if (args_info->no_tx_gpdu_seq_given)
write_into_file(outfile, "no-tx-gpdu-seq", 0, 0);
+ if (args_info->pdp_type_given)
+ write_into_file(outfile, "pdp-type", args_info->pdp_type_orig,
+ 0);
i = EXIT_SUCCESS;
return i;
@@ -833,10 +843,11 @@ cmdline_parser_internal(int argc, char **argv,
{"pingcount", 1, NULL, 0},
{"pingquiet", 0, NULL, 0},
{"no-tx-gpdu-seq", 0, NULL, 0},
+ {"pdp-type", 1, NULL, 't'},
{0, 0, 0, 0}
};
- c = getopt_long(argc, argv, "hVdc:l:r:a:i:m:q:u:p:n:",
+ c = getopt_long(argc, argv, "hVdc:l:r:a:i:m:q:u:p:n:t:",
long_options, &option_index);
if (c == -1)
@@ -982,6 +993,18 @@ cmdline_parser_internal(int argc, char **argv,
goto failure;
break;
+ case 't': /* PDP Type. */
+
+ if (update_arg((void *)&(args_info->pdp_type_arg),
+ &(args_info->pdp_type_orig),
+ &(args_info->pdp_type_given),
+ &(local_args_info.pdp_type_given),
+ optarg, 0, "v4", ARG_STRING,
+ check_ambiguity, override, 0, 0,
+ "pdp-type", 't', additional_error))
+ goto failure;
+
+ break;
case 0: /* Long option with no short option */
/* Filename of process id file. */
diff --git a/sgsnemu/cmdline.ggo b/sgsnemu/cmdline.ggo
index a2681f1..d8b3c26 100644
--- a/sgsnemu/cmdline.ggo
+++ b/sgsnemu/cmdline.ggo
@@ -61,3 +61,4 @@ option "pingsize" - "Number of ping data bytes" int default="56" no
option "pingcount" - "Number of ping req to send" int default="0" no
option "pingquiet" - "Do not print ping packet info" flag off
option "no-tx-gpdu-seq" - "Don't transmit G-PDU sequence nums" flag off
+option "pdp-type" t "PDP Type" string default="v4" no typestr="(v4|v6)"
diff --git a/sgsnemu/cmdline.h b/sgsnemu/cmdline.h
index 38db7da..1accfd0 100644
--- a/sgsnemu/cmdline.h
+++ b/sgsnemu/cmdline.h
@@ -268,6 +268,12 @@ extern "C" {
/**< @brief Don't transmit G-PDU sequence nums (default=off). */
const char *no_tx_gpdu_seq_help;
/**< @brief Don't transmit G-PDU sequence nums help description. */
+ char *pdp_type_arg;
+ /**< @brief PDP Type (default='v4'). */
+ char *pdp_type_orig;
+ /**< @brief PDP Type original value given at command line. */
+ const char *pdp_type_help;
+ /**< @brief PDP Type help description. */
unsigned int help_given;
/**< @brief Whether help was given. */
@@ -353,6 +359,8 @@ extern "C" {
/**< @brief Whether pingquiet was given. */
unsigned int no_tx_gpdu_seq_given;
/**< @brief Whether no-tx-gpdu-seq was given. */
+ unsigned int pdp_type_given;
+ /**< @brief Whether pdp-type was given. */
};
diff --git a/sgsnemu/sgsnemu.c b/sgsnemu/sgsnemu.c
index 4cc2021..c181603 100644
--- a/sgsnemu/sgsnemu.c
+++ b/sgsnemu/sgsnemu.c
@@ -118,6 +118,7 @@ struct {
struct ul16_t msisdn;
int norecovery_given;
int tx_gpdu_seq;
+ uint8_t pdp_type;
} options;
/* Definitions to use for PING. Most of the ping code was derived from */
@@ -926,6 +927,12 @@ int process_options(int argc, char **argv)
else
options.tx_gpdu_seq = 1;
+ /* PDP Type */
+ if (!strcmp(args_info.pdp_type_arg, "v6"))
+ options.pdp_type = PDP_EUA_TYPE_v6;
+ else
+ options.pdp_type = PDP_EUA_TYPE_v4;
+
return 0;
}
@@ -1580,7 +1587,10 @@ int main(int argc, char **argv)
msisdn_add(&options.msisdn, &pdp->msisdn, n);
}
- ipv42eua(&pdp->eua, NULL); /* Request dynamic IP address */
+ /* Request dynamic IP address */
+ pdp->eua.v[0] = PDP_EUA_ORG_IETF;
+ pdp->eua.v[1] = options.pdp_type;
+ pdp->eua.l = 2;
if (options.pco.l > sizeof(pdp->pco_req.v)) {
SYS_ERR(DSGSN, LOGL_ERROR, 0,