Loading...
Searching...
No Matches
oap_client.h
Go to the documentation of this file.
/* Osmocom Authentication Protocol API */
/* (C) 2015 by Sysmocom s.f.m.c. GmbH
* All Rights Reserved
*
* Author: Neels Hofmeyr
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-2.0+
*/
#pragma once
#include <stdint.h>
struct msgb;
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 osmo_oap_client_config {
uint16_t client_id;
int secret_k_present;
uint8_t secret_k[16];
int secret_opc_present;
uint8_t secret_opc[16];
};
/* The runtime state of the OAP client. client_id and the secrets are in fact
* 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 osmo_oap_client_state {
enum {
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];
uint8_t secret_opc[16];
int registration_failures;
};
/* From config, initialize state. Return 0 on success. */
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 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 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 *osmo_oap_client_encoded(const struct osmo_oap_message *oap_client_msg);
config
write Write running configuration to or terminal n Write configuration to the copy running config startup config
osmo_oap_client_handle
int osmo_oap_client_handle(struct osmo_oap_client_state *state, const struct msgb *msg_rx, struct msgb **msg_tx)
Definition oap_client.c:213
osmo_oap_client_encoded
struct msgb * osmo_oap_client_encoded(const struct osmo_oap_message *oap_client_msg)
Definition oap_client.c:129
osmo_oap_client_init
int osmo_oap_client_init(struct osmo_oap_client_config *config, struct osmo_oap_client_state *state)
Definition oap_client.c:35
osmo_oap_client_register
int osmo_oap_client_register(struct osmo_oap_client_state *state, struct msgb **msg_tx)
Definition oap_client.c:153
msgb
osmo_oap_client_config
Definition oap_client.h:34
osmo_oap_client_config::secret_k
uint8_t secret_k[16]
Definition oap_client.h:37
osmo_oap_client_config::secret_opc_present
int secret_opc_present
Definition oap_client.h:38
osmo_oap_client_config::client_id
uint16_t client_id
Definition oap_client.h:35
osmo_oap_client_config::secret_k_present
int secret_k_present
Definition oap_client.h:36
osmo_oap_client_config::secret_opc
uint8_t secret_opc[16]
Definition oap_client.h:39
osmo_oap_client_state
Definition oap_client.h:46
osmo_oap_client_state::state
enum osmo_oap_client_state::@060340341340361264031203323122240337014251263045 state
osmo_oap_client_state::OSMO_OAP_UNINITIALIZED
@ OSMO_OAP_UNINITIALIZED
Definition oap_client.h:48
osmo_oap_client_state::OSMO_OAP_INITIALIZED
@ OSMO_OAP_INITIALIZED
Definition oap_client.h:50
osmo_oap_client_state::OSMO_OAP_REQUESTED_CHALLENGE
@ OSMO_OAP_REQUESTED_CHALLENGE
Definition oap_client.h:51
osmo_oap_client_state::OSMO_OAP_DISABLED
@ OSMO_OAP_DISABLED
Definition oap_client.h:49
osmo_oap_client_state::OSMO_OAP_REGISTERED
@ OSMO_OAP_REGISTERED
Definition oap_client.h:53
osmo_oap_client_state::OSMO_OAP_SENT_CHALLENGE_RESULT
@ OSMO_OAP_SENT_CHALLENGE_RESULT
Definition oap_client.h:52
osmo_oap_client_state::client_id
uint16_t client_id
Definition oap_client.h:55
osmo_oap_client_state::secret_k
uint8_t secret_k[16]
Definition oap_client.h:56
osmo_oap_client_state::registration_failures
int registration_failures
Definition oap_client.h:58
osmo_oap_client_state::secret_opc
uint8_t secret_opc[16]
Definition oap_client.h:57
osmo_oap_message
Parsed/decoded OAP protocol message.
Definition oap.h:65