[MERGED] libosmocore[master]: osmo-auc-gen: cmdline help: list algorithms; error messages

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Mon Feb 6 13:47:17 UTC 2017

Neels Hofmeyr has submitted this change and it was merged.

Change subject: osmo-auc-gen: cmdline help: list algorithms; error messages

osmo-auc-gen: cmdline help: list algorithms; error messages

In the -h help output, list the names of available algorithms.

In case of option parsing failure, also print help() (so that e.g. for a typo
in the algorithm, the list of algorithms is printed along with the error

If there are -2/-3 or -a missing, show an error message that explains this.

Change-Id: I76732b28d7a553a6293d1707fe398d28b5ef4886
M utils/osmo-auc-gen.c
1 file changed, 10 insertions(+), 1 deletion(-)

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

diff --git a/utils/osmo-auc-gen.c b/utils/osmo-auc-gen.c
index 872d6f3..f0cfa79 100644
--- a/utils/osmo-auc-gen.c
+++ b/utils/osmo-auc-gen.c
@@ -70,6 +70,7 @@
 static void help()
+	int alg;
 	printf( "-2  --2g\tUse 2G (GSM) authentication\n"
 		"-3  --3g\tUse 3G (UMTS) authentication\n"
 		"-a  --algorithm\tSpecify name of the algorithm\n"
@@ -81,6 +82,11 @@
 		"-A  --auts\tSpecify AUTS (only for 3G)\n"
 		"-r  --rand\tSpecify random value\n"
 		"-I  --ipsec\tOutput in triplets.dat format for strongswan\n");
+	fprintf(stderr, "\nAvailable algorithms for option -a:\n");
+	for (alg = 1; alg < _OSMO_AUTH_ALG_NUM; alg++)
+		fprintf(stderr, "  %s\n",
+			osmo_auth_alg_name(alg));
 int main(int argc, char **argv)
@@ -209,7 +215,8 @@
 		if (rc < 0) {
-			fprintf(stderr, "Error parsing argument of option `%c'\n", c);
+			help();
+			fprintf(stderr, "\nError parsing argument of option `%c'\n", c);
@@ -229,6 +236,8 @@
 	if (test_aud.type == OSMO_AUTH_TYPE_NONE ||
 	    test_aud.algo == OSMO_AUTH_ALG_NONE) {
+		fprintf(stderr, "\nError: you need to pass at least"
+			" -2 or -3, as well as an algorithm to use.\n");

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I76732b28d7a553a6293d1707fe398d28b5ef4886
Gerrit-PatchSet: 3
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>

More information about the gerrit-log mailing list