aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-09-24 11:50:20 +0800
committerHarald Welte <laforge@gnumonks.org>2017-09-24 23:10:05 +0800
commitfbb9c7f59a7f112608b59c7692c1fddd1a5e8c23 (patch)
treeb54b7db8798e9d4a49fe608d41e038d70f147eab
parent93fed3bc510563e7d88cadafa7eada2ae4182213 (diff)
sgsnemu: Add --no-tx-gpdu-seq option to suppress transmission of G-PDU sequence numbers
-rw-r--r--sgsnemu/cmdline.c22
-rw-r--r--sgsnemu/cmdline.ggo2
-rw-r--r--sgsnemu/cmdline.h6
-rw-r--r--sgsnemu/sgsnemu.c10
4 files changed, 39 insertions, 1 deletions
diff --git a/sgsnemu/cmdline.c b/sgsnemu/cmdline.c
index d7be13a..6df8fc1 100644
--- a/sgsnemu/cmdline.c
+++ b/sgsnemu/cmdline.c
@@ -75,6 +75,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)",
+ " --no-tx-gpdu-seq Don't transmit G-PDU sequence nums\n (default=off)",
0
};
@@ -159,6 +160,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->no_tx_gpdu_seq_given = 0;
}
static
@@ -238,6 +240,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->no_tx_gpdu_seq_flag = 0;
}
@@ -286,6 +289,7 @@ void init_args_info(struct gengetopt_args_info *args_info)
args_info->pingsize_help = gengetopt_args_info_help[38];
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];
}
@@ -532,6 +536,8 @@ int cmdline_parser_dump(FILE * outfile, struct gengetopt_args_info *args_info)
0);
if (args_info->pingquiet_given)
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);
i = EXIT_SUCCESS;
return i;
@@ -826,6 +832,7 @@ cmdline_parser_internal(int argc, char **argv,
{"pingsize", 1, NULL, 0},
{"pingcount", 1, NULL, 0},
{"pingquiet", 0, NULL, 0},
+ {"no-tx-gpdu-seq", 0, NULL, 0},
{0, 0, 0, 0}
};
@@ -1401,6 +1408,21 @@ cmdline_parser_internal(int argc, char **argv,
goto failure;
}
+ /* Don't transmit G-PDU sequence nums. */
+ else if (strcmp
+ (long_options[option_index].name,
+ "no-tx-gpdu-seq") == 0) {
+
+ if (update_arg
+ ((void *)&(args_info->no_tx_gpdu_seq_flag),
+ 0, &(args_info->no_tx_gpdu_seq_given),
+ &(local_args_info.no_tx_gpdu_seq_given),
+ optarg, 0, 0, ARG_FLAG, check_ambiguity,
+ override, 1, 0, "no-tx-gpdu-seq", '-',
+ additional_error))
+ goto failure;
+
+ }
break;
case '?': /* Invalid option. */
diff --git a/sgsnemu/cmdline.ggo b/sgsnemu/cmdline.ggo
index 4fcc64a..a2681f1 100644
--- a/sgsnemu/cmdline.ggo
+++ b/sgsnemu/cmdline.ggo
@@ -60,4 +60,4 @@ option "pingrate" - "Number of ping req per second" int default="1" no
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
diff --git a/sgsnemu/cmdline.h b/sgsnemu/cmdline.h
index b93fa0b..38db7da 100644
--- a/sgsnemu/cmdline.h
+++ b/sgsnemu/cmdline.h
@@ -264,6 +264,10 @@ extern "C" {
/**< @brief Do not print ping packet info (default=off). */
const char *pingquiet_help;
/**< @brief Do not print ping packet info help description. */
+ int no_tx_gpdu_seq_flag;
+ /**< @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. */
unsigned int help_given;
/**< @brief Whether help was given. */
@@ -347,6 +351,8 @@ extern "C" {
/**< @brief Whether pingcount was given. */
unsigned int pingquiet_given;
/**< @brief Whether pingquiet was given. */
+ unsigned int no_tx_gpdu_seq_given;
+ /**< @brief Whether no-tx-gpdu-seq was given. */
};
diff --git a/sgsnemu/sgsnemu.c b/sgsnemu/sgsnemu.c
index 2bfe801..4cc2021 100644
--- a/sgsnemu/sgsnemu.c
+++ b/sgsnemu/sgsnemu.c
@@ -117,6 +117,7 @@ struct {
int imeisv_given;
struct ul16_t msisdn;
int norecovery_given;
+ int tx_gpdu_seq;
} options;
/* Definitions to use for PING. Most of the ping code was derived from */
@@ -297,6 +298,7 @@ int process_options(int argc, char **argv)
printf("pingcount: %d\n", args_info.pingcount_arg);
printf("pingquiet: %d\n", args_info.pingquiet_flag);
printf("norecovery: %d\n", args_info.norecovery_flag);
+ printf("no-tx-gpdu-seq: %d\n", args_info.no_tx_gpdu_seq_flag);
}
/* Try out our new parser */
@@ -354,6 +356,7 @@ int process_options(int argc, char **argv)
printf("pingcount: %d\n", args_info.pingcount_arg);
printf("pingquiet: %d\n", args_info.pingquiet_flag);
printf("norecovery: %d\n", args_info.norecovery_flag);
+ printf("no-tx-gpdu-seq: %d\n", args_info.no_tx_gpdu_seq_flag);
}
}
@@ -918,6 +921,11 @@ int process_options(int argc, char **argv)
/* norecovery */
options.norecovery_given = args_info.norecovery_flag;
+ if (args_info.no_tx_gpdu_seq_flag)
+ options.tx_gpdu_seq = 0;
+ else
+ options.tx_gpdu_seq = 1;
+
return 0;
}
@@ -1591,6 +1599,8 @@ int main(int argc, char **argv)
pdp->cch_pdp = options.cch; /* 2048 = Normal, 1024 = Prepaid,
512 = Flat rate, 256 = Hot billing */
+ pdp->tx_gpdu_seq = options.tx_gpdu_seq;
+
/* Create context */
/* We send this of once. Retransmissions are handled by gtplib */
gtp_create_context_req(gsn, pdp, &iparr[n]);