diff options
-rw-r--r-- | include/osmocom/gsm/oap_client.h | 28 | ||||
-rw-r--r-- | src/gsm/libosmogsm.map | 8 | ||||
-rw-r--r-- | src/gsm/oap_client.c | 46 |
3 files changed, 41 insertions, 41 deletions
diff --git a/include/osmocom/gsm/oap_client.h b/include/osmocom/gsm/oap_client.h index 80c86d5d..763f982c 100644 --- a/include/osmocom/gsm/oap_client.h +++ b/include/osmocom/gsm/oap_client.h @@ -30,7 +30,7 @@ struct osmo_oap_message; /* This is the config part for vty. It is essentially copied in * oap_client_state, where values are copied over once the config is * considered valid. */ -struct oap_client_config { +struct osmo_oap_client_config { uint16_t client_id; int secret_k_present; uint8_t secret_k[16]; @@ -42,14 +42,14 @@ struct oap_client_config { * duplicated from oap_client_config, so that a separate validation of the * config data is possible, and so that only a struct oap_client_state* is * passed around. */ -struct oap_client_state { +struct osmo_oap_client_state { enum { - OAP_UNINITIALIZED = 0, /* just allocated. */ - OAP_DISABLED, /* disabled by config. */ - OAP_INITIALIZED, /* enabled, config is valid. */ - OAP_REQUESTED_CHALLENGE, - OAP_SENT_CHALLENGE_RESULT, - OAP_REGISTERED + OSMO_OAP_UNINITIALIZED = 0, /* just allocated. */ + OSMO_OAP_DISABLED, /* disabled by config. */ + OSMO_OAP_INITIALIZED, /* enabled, config is valid. */ + OSMO_OAP_REQUESTED_CHALLENGE, + OSMO_OAP_SENT_CHALLENGE_RESULT, + OSMO_OAP_REGISTERED } state; uint16_t client_id; uint8_t secret_k[16]; @@ -58,25 +58,25 @@ struct oap_client_state { }; /* From config, initialize state. Return 0 on success. */ -int oap_client_init(struct oap_client_config *config, - struct oap_client_state *state); +int osmo_oap_client_init(struct osmo_oap_client_config *config, + struct osmo_oap_client_state *state); /* Construct an OAP registration message and return in *msg_tx. Use * state->client_id and update state->state. * Return 0 on success, or a negative value on error. * If an error is returned, *msg_tx is guaranteed to be NULL. */ -int oap_client_register(struct oap_client_state *state, struct msgb **msg_tx); +int osmo_oap_client_register(struct osmo_oap_client_state *state, struct msgb **msg_tx); /* Decode and act on a received OAP message msg_rx. Update state->state. If a * non-NULL pointer is returned in *msg_tx, that msgb should be sent to the OAP * server (and freed) by the caller. The received msg_rx is not freed. * Return 0 on success, or a negative value on error. * If an error is returned, *msg_tx is guaranteed to be NULL. */ -int oap_client_handle(struct oap_client_state *state, - const struct msgb *msg_rx, struct msgb **msg_tx); +int osmo_oap_client_handle(struct osmo_oap_client_state *state, + const struct msgb *msg_rx, struct msgb **msg_tx); /* Allocate a msgb and in it, return the encoded oap_client_msg. Return * NULL on error. (Like oap_client_encode(), but also allocates a msgb.) * About the name: the idea is do_something(oap_client_encoded(my_struct)) */ -struct msgb *oap_client_encoded(const struct osmo_oap_message *oap_client_msg); +struct msgb *osmo_oap_client_encoded(const struct osmo_oap_message *oap_client_msg); diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map index 6eb60cc2..bc9ed528 100644 --- a/src/gsm/libosmogsm.map +++ b/src/gsm/libosmogsm.map @@ -493,10 +493,10 @@ osmo_mncc_stringify; osmo_mncc_names; _osmo_mncc_log; -oap_client_encoded; -oap_client_handle; -oap_client_init; -oap_client_register; +osmo_oap_client_encoded; +osmo_oap_client_handle; +osmo_oap_client_init; +osmo_oap_client_register; local: *; }; diff --git a/src/gsm/oap_client.c b/src/gsm/oap_client.c index 2227a3ce..ea406341 100644 --- a/src/gsm/oap_client.c +++ b/src/gsm/oap_client.c @@ -30,10 +30,10 @@ #include <osmocom/gsm/oap_client.h> -int oap_client_init(struct oap_client_config *config, - struct oap_client_state *state) +int osmo_oap_client_init(struct osmo_oap_client_config *config, + struct osmo_oap_client_state *state) { - OSMO_ASSERT(state->state == OAP_UNINITIALIZED); + OSMO_ASSERT(state->state == OSMO_OAP_UNINITIALIZED); if (!config) goto disable; @@ -54,11 +54,11 @@ int oap_client_init(struct oap_client_config *config, state->client_id = config->client_id; memcpy(state->secret_k, config->secret_k, sizeof(state->secret_k)); memcpy(state->secret_opc, config->secret_opc, sizeof(state->secret_opc)); - state->state = OAP_INITIALIZED; + state->state = OSMO_OAP_INITIALIZED; return 0; disable: - state->state = OAP_DISABLED; + state->state = OSMO_OAP_DISABLED; return 0; } @@ -71,7 +71,7 @@ disable: * response message and update the state. * Return 0 on success; -1 if OAP is disabled; -2 if rx_random and rx_autn fail * the authentication check; -3 for any other errors. */ -static int oap_evaluate_challenge(const struct oap_client_state *state, +static int oap_evaluate_challenge(const struct osmo_oap_client_state *state, const uint8_t *rx_random, const uint8_t *rx_autn, uint8_t *tx_xres) @@ -89,8 +89,8 @@ static int oap_evaluate_challenge(const struct oap_client_state *state, == sizeof(state->secret_opc), _secret_opc_size_match); switch (state->state) { - case OAP_UNINITIALIZED: - case OAP_DISABLED: + case OSMO_OAP_UNINITIALIZED: + case OSMO_OAP_DISABLED: return -1; default: break; @@ -124,7 +124,7 @@ static int oap_evaluate_challenge(const struct oap_client_state *state, return 0; } -struct msgb *oap_client_encoded(const struct osmo_oap_message *oap_msg) +struct msgb *osmo_oap_client_encoded(const struct osmo_oap_message *oap_msg) { struct msgb *msg = msgb_alloc_headroom(1000, 64, __func__); OSMO_ASSERT(msg); @@ -145,16 +145,16 @@ static struct msgb* oap_msg_register(uint16_t client_id) oap_msg.message_type = OAP_MSGT_REGISTER_REQUEST; oap_msg.client_id = client_id; - return oap_client_encoded(&oap_msg); + return osmo_oap_client_encoded(&oap_msg); } -int oap_client_register(struct oap_client_state *state, struct msgb **msg_tx) +int osmo_oap_client_register(struct osmo_oap_client_state *state, struct msgb **msg_tx) { *msg_tx = oap_msg_register(state->client_id); if (!(*msg_tx)) return -1; - state->state = OAP_REQUESTED_CHALLENGE; + state->state = OSMO_OAP_REQUESTED_CHALLENGE; return 0; } @@ -168,10 +168,10 @@ static struct msgb* oap_msg_challenge_response(uint8_t *xres) oap_reply.message_type = OAP_MSGT_CHALLENGE_RESULT; memcpy(oap_reply.xres, xres, sizeof(oap_reply.xres)); oap_reply.xres_present = 1; - return oap_client_encoded(&oap_reply); + return osmo_oap_client_encoded(&oap_reply); } -static int handle_challenge(struct oap_client_state *state, +static int handle_challenge(struct osmo_oap_client_state *state, struct osmo_oap_message *oap_rx, struct msgb **msg_tx) { @@ -199,17 +199,17 @@ static int handle_challenge(struct oap_client_state *state, goto failure; } - state->state = OAP_SENT_CHALLENGE_RESULT; + state->state = OSMO_OAP_SENT_CHALLENGE_RESULT; return 0; failure: OSMO_ASSERT(rc < 0); - state->state = OAP_INITIALIZED; + state->state = OSMO_OAP_INITIALIZED; return rc; } -int oap_client_handle(struct oap_client_state *state, - const struct msgb *msg_rx, struct msgb **msg_tx) +int osmo_oap_client_handle(struct osmo_oap_client_state *state, + const struct msgb *msg_rx, struct msgb **msg_tx) { uint8_t *data = msgb_l2(msg_rx); size_t data_len = msgb_l2len(msg_rx); @@ -229,12 +229,12 @@ int oap_client_handle(struct oap_client_state *state, } switch (state->state) { - case OAP_UNINITIALIZED: + case OSMO_OAP_UNINITIALIZED: LOGP(DLOAP, LOGL_ERROR, "Received OAP message %d, but the OAP client is" " not initialized\n", oap_msg.message_type); return -ENOTCONN; - case OAP_DISABLED: + case OSMO_OAP_DISABLED: LOGP(DLOAP, LOGL_ERROR, "Received OAP message %d, but the OAP client is" " disabled\n", oap_msg.message_type); @@ -249,16 +249,16 @@ int oap_client_handle(struct oap_client_state *state, case OAP_MSGT_REGISTER_RESULT: /* successfully registered */ - state->state = OAP_REGISTERED; + state->state = OSMO_OAP_REGISTERED; break; case OAP_MSGT_REGISTER_ERROR: LOGP(DLOAP, LOGL_ERROR, "OAP registration failed\n"); - state->state = OAP_INITIALIZED; + state->state = OSMO_OAP_INITIALIZED; if (state->registration_failures < 3) { state->registration_failures++; - return oap_client_register(state, msg_tx); + return osmo_oap_client_register(state, msg_tx); } return -11; |