[PATCH] openbsc[master]: oap_client: make use of OAP optional: disable for NULL config

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/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Fri Dec 9 00:38:27 UTC 2016


Review at  https://gerrit.osmocom.org/1396

oap_client: make use of OAP optional: disable for NULL config

When passing a NULL config to osmo_oap_client_init(), set OAP to disabled
state. Along with the previous fix that ensures message rejection in the
disabled state, this makes use of OAP in the GSUP client optional.

oap_client_test: expect null config to set state to disabled.

Change-Id: Ie4d622fcfd24cb7d89d19f93e4b2571d8fadd1a3
---
M openbsc/src/libcommon/gsup_client.c
M openbsc/src/libcommon/oap_client.c
M openbsc/tests/oap/oap_client_test.c
M openbsc/tests/oap/oap_client_test.err
4 files changed, 9 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/96/1396/1

diff --git a/openbsc/src/libcommon/gsup_client.c b/openbsc/src/libcommon/gsup_client.c
index 398bfa8..d25ecf3 100644
--- a/openbsc/src/libcommon/gsup_client.c
+++ b/openbsc/src/libcommon/gsup_client.c
@@ -275,6 +275,7 @@
 	gsupc = talloc_zero(tall_bsc_ctx, struct osmo_gsup_client);
 	OSMO_ASSERT(gsupc);
 
+	/* a NULL oap_config will mark oap_state disabled. */
 	rc = osmo_oap_client_init(oap_config, &gsupc->oap_state);
 	if (rc != 0)
 		goto failed;
diff --git a/openbsc/src/libcommon/oap_client.c b/openbsc/src/libcommon/oap_client.c
index d9688b5..a050ccb 100644
--- a/openbsc/src/libcommon/oap_client.c
+++ b/openbsc/src/libcommon/oap_client.c
@@ -34,6 +34,9 @@
 {
 	OSMO_ASSERT(state->state == OAP_UNINITIALIZED);
 
+	if (!config)
+		goto disable;
+
 	if (config->client_id == 0)
 		goto disable;
 
diff --git a/openbsc/tests/oap/oap_client_test.c b/openbsc/tests/oap/oap_client_test.c
index d83e6f8..f65721e 100644
--- a/openbsc/tests/oap/oap_client_test.c
+++ b/openbsc/tests/oap/oap_client_test.c
@@ -62,6 +62,10 @@
 	msgb_free(msg_rx);
 	OSMO_ASSERT(!msg_tx);
 
+	fprintf(stderr, "- NULL config should disable\n");
+	OSMO_ASSERT( osmo_oap_client_init(NULL, state) == 0 );
+	OSMO_ASSERT(state->state == OAP_DISABLED);
+
 	fprintf(stderr, "- reject messages in disabled state\n");
 	memset(state, 0, sizeof(*state));
 	memset(&oap_rx, 0, sizeof(oap_rx));
diff --git a/openbsc/tests/oap/oap_client_test.err b/openbsc/tests/oap/oap_client_test.err
index 8c538dc..62ddc9e 100644
--- a/openbsc/tests/oap/oap_client_test.err
+++ b/openbsc/tests/oap/oap_client_test.err
@@ -1,6 +1,7 @@
 - make sure filling with zeros means uninitialized
 - reject messages in uninitialized state
 DLOAP Received OAP message 5, but the OAP client is not initialized
+- NULL config should disable
 - reject messages in disabled state
 DLOAP Received OAP message 5, but the OAP client is disabled
 - invalid client_id and shared secret

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie4d622fcfd24cb7d89d19f93e4b2571d8fadd1a3
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list