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.

Related: OS#1592
Change-Id: Ie4d622fcfd24cb7d89d19f93e4b2571d8fadd1a3
This commit is contained in:
Neels Hofmeyr 2016-12-08 23:58:31 +01:00 committed by Harald Welte
parent 2fa74faf92
commit 37f9252361
4 changed files with 11 additions and 2 deletions

View File

@ -266,7 +266,7 @@ static void start_test_procedure(struct gsup_client *gsupc)
struct gsup_client *gsup_client_create(const char *ip_addr,
unsigned int tcp_port,
gsup_client_read_cb_t read_cb,
struct oap_client_config *oap_config)
struct oap_client_config *oapc_config)
{
struct gsup_client *gsupc;
int rc;
@ -274,7 +274,8 @@ struct gsup_client *gsup_client_create(const char *ip_addr,
gsupc = talloc_zero(tall_bsc_ctx, struct gsup_client);
OSMO_ASSERT(gsupc);
rc = oap_client_init(oap_config, &gsupc->oap_state);
/* a NULL oapc_config will mark oap_state disabled. */
rc = oap_client_init(oapc_config, &gsupc->oap_state);
if (rc != 0)
goto failed;

View File

@ -35,6 +35,9 @@ int oap_client_init(struct oap_client_config *config,
{
OSMO_ASSERT(state->state == OAP_UNINITIALIZED);
if (!config)
goto disable;
if (config->client_id == 0)
goto disable;

View File

@ -62,6 +62,10 @@ static void test_oap_api(void)
msgb_free(msg_rx);
OSMO_ASSERT(!msg_tx);
fprintf(stderr, "- NULL config should disable\n");
OSMO_ASSERT( 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));

View File

@ -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