[MERGED] osmo-ggsn[master]: sgsnemu: Allow specification of PDP (EUA) Type IPv4 or IPv6

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Sun Oct 1 10:24:59 UTC 2017


Harald Welte has submitted this change and it was merged.

Change subject: sgsnemu: Allow specification of PDP (EUA) Type IPv4 or IPv6
......................................................................


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
---
M sgsnemu/cmdline.c
M sgsnemu/cmdline.ggo
M sgsnemu/cmdline.h
M sgsnemu/sgsnemu.c
4 files changed, 44 insertions(+), 2 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



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 @@
 	"      --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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 		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 @@
 			{"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 @@
 				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  "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 @@
 				/**< @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 @@
 					/**< @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 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 @@
 	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 @@
 			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,

-- 
To view, visit https://gerrit.osmocom.org/4046
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I157f9157a7ff2ea56c37a4a902d4706de4c7d35d
Gerrit-PatchSet: 4
Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list