libosmogsm 1.9.0.196-9975
Osmocom GSM library
cbsp.c File Reference
#include "config.h"
#include <errno.h>
#include <sys/types.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/msgb.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/gsm/cbsp.h>
#include <osmocom/gsm/gsm0808_utils.h>

Functions

struct msgbosmo_cbsp_msgb_alloc (void *ctx, const char *name)
 
static void msgb_put_cbsp_cell_list (struct msgb *msg, const struct osmo_cbsp_cell_list *cl)
 
static void msgb_put_cbsp_fail_list (struct msgb *msg, const struct llist_head *fl)
 
static void msgb_put_cbsp_loading_list (struct msgb *msg, const struct osmo_cbsp_loading_list *ll)
 
static void msgb_put_cbsp_num_compl_list (struct msgb *msg, const struct osmo_cbsp_num_compl_list *cl)
 
static int encode_wperiod (uint32_t secs)
 
static int cbsp_enc_write_repl (struct msgb *msg, const struct osmo_cbsp_write_replace *in)
 
static int cbsp_enc_write_repl_compl (struct msgb *msg, const struct osmo_cbsp_write_replace_complete *in)
 
static int cbsp_enc_write_repl_fail (struct msgb *msg, const struct osmo_cbsp_write_replace_failure *in)
 
static int cbsp_enc_kill (struct msgb *msg, const struct osmo_cbsp_kill *in)
 
static int cbsp_enc_kill_compl (struct msgb *msg, const struct osmo_cbsp_kill_complete *in)
 
static int cbsp_enc_kill_fail (struct msgb *msg, const struct osmo_cbsp_kill_failure *in)
 
static int cbsp_enc_load_query (struct msgb *msg, const struct osmo_cbsp_load_query *in)
 
static int cbsp_enc_load_query_compl (struct msgb *msg, const struct osmo_cbsp_load_query_complete *in)
 
static int cbsp_enc_load_query_fail (struct msgb *msg, const struct osmo_cbsp_load_query_failure *in)
 
static int cbsp_enc_msg_status_query (struct msgb *msg, const struct osmo_cbsp_msg_status_query *in)
 
static int cbsp_enc_msg_status_query_compl (struct msgb *msg, const struct osmo_cbsp_msg_status_query_complete *in)
 
static int cbsp_enc_msg_status_query_fail (struct msgb *msg, const struct osmo_cbsp_msg_status_query_failure *in)
 
static int cbsp_enc_reset (struct msgb *msg, const struct osmo_cbsp_reset *in)
 
static int cbsp_enc_reset_compl (struct msgb *msg, const struct osmo_cbsp_reset_complete *in)
 
static int cbsp_enc_reset_fail (struct msgb *msg, const struct osmo_cbsp_reset_failure *in)
 
static int cbsp_enc_keep_alive (struct msgb *msg, const struct osmo_cbsp_keep_alive *in)
 
static int cbsp_enc_keep_alive_compl (struct msgb *msg, const struct osmo_cbsp_keep_alive_complete *in)
 
static int cbsp_enc_restart (struct msgb *msg, const struct osmo_cbsp_restart *in)
 
static int cbsp_enc_failure (struct msgb *msg, const struct osmo_cbsp_failure *in)
 
static int cbsp_enc_error_ind (struct msgb *msg, const struct osmo_cbsp_error_ind *in)
 
struct msgbosmo_cbsp_encode (void *ctx, const struct osmo_cbsp_decoded *in)
 Encode a CBSP message from the decoded/parsed structure representation to binary PDU. More...
 
static int cbsp_decode_cell_list (struct osmo_cbsp_cell_list *cl, void *ctx, const uint8_t *buf, unsigned int len)
 
static int cbsp_decode_fail_list (struct llist_head *fl, void *ctx, const uint8_t *buf, unsigned int len)
 
static int cbsp_decode_loading_list (struct osmo_cbsp_loading_list *ll, void *ctx, const uint8_t *buf, unsigned int len)
 
static int cbsp_decode_num_compl_list (struct osmo_cbsp_num_compl_list *cl, void *ctx, const uint8_t *buf, unsigned int len)
 
static uint32_t decode_wperiod (uint8_t in)
 
static int cbsp_dec_write_repl (struct osmo_cbsp_write_replace *out, const struct tlv_parsed *tp, struct msgb *in, void *ctx)
 
static int cbsp_dec_write_repl_compl (struct osmo_cbsp_write_replace_complete *out, const struct tlv_parsed *tp, struct msgb *in, void *ctx)
 
static int cbsp_dec_write_repl_fail (struct osmo_cbsp_write_replace_failure *out, const struct tlv_parsed *tp, struct msgb *in, void *ctx)
 
static int cbsp_dec_kill (struct osmo_cbsp_kill *out, const struct tlv_parsed *tp, struct msgb *in, void *ctx)
 
static int cbsp_dec_kill_compl (struct osmo_cbsp_kill_complete *out, const struct tlv_parsed *tp, struct msgb *in, void *ctx)
 
static int cbsp_dec_kill_fail (struct osmo_cbsp_kill_failure *out, const struct tlv_parsed *tp, struct msgb *in, void *ctx)
 
static int cbsp_dec_load_query (struct osmo_cbsp_load_query *out, const struct tlv_parsed *tp, struct msgb *in, void *ctx)
 
static int cbsp_dec_load_query_compl (struct osmo_cbsp_load_query_complete *out, const struct tlv_parsed *tp, struct msgb *in, void *ctx)
 
static int cbsp_dec_load_query_fail (struct osmo_cbsp_load_query_failure *out, const struct tlv_parsed *tp, struct msgb *in, void *ctx)
 
static int cbsp_dec_msg_status_query (struct osmo_cbsp_msg_status_query *out, const struct tlv_parsed *tp, struct msgb *in, void *ctx)
 
static int cbsp_dec_msg_status_query_compl (struct osmo_cbsp_msg_status_query_complete *out, const struct tlv_parsed *tp, struct msgb *in, void *ctx)
 
static int cbsp_dec_msg_status_query_fail (struct osmo_cbsp_msg_status_query_failure *out, const struct tlv_parsed *tp, struct msgb *in, void *ctx)
 
static int cbsp_dec_reset (struct osmo_cbsp_reset *out, const struct tlv_parsed *tp, struct msgb *in, void *ctx)
 
static int cbsp_dec_reset_compl (struct osmo_cbsp_reset_complete *out, const struct tlv_parsed *tp, struct msgb *in, void *ctx)
 
static int cbsp_dec_reset_fail (struct osmo_cbsp_reset_failure *out, const struct tlv_parsed *tp, struct msgb *in, void *ctx)
 
static int cbsp_dec_keep_alive (struct osmo_cbsp_keep_alive *out, const struct tlv_parsed *tp, struct msgb *in, void *ctx)
 
static int cbsp_dec_keep_alive_compl (struct osmo_cbsp_keep_alive_complete *out, const struct tlv_parsed *tp, struct msgb *in, void *ctx)
 
static int cbsp_dec_restart (struct osmo_cbsp_restart *out, const struct tlv_parsed *tp, struct msgb *in, void *ctx)
 
static int cbsp_dec_failure (struct osmo_cbsp_failure *out, const struct tlv_parsed *tp, struct msgb *in, void *ctx)
 
static int cbsp_dec_error_ind (struct osmo_cbsp_error_ind *out, const struct tlv_parsed *tp, struct msgb *in, void *ctx)
 
struct osmo_cbsp_decodedosmo_cbsp_decode (void *ctx, struct msgb *in)
 Decode a CBSP message from wire formwat to pased structure. More...
 
void osmo_cbsp_init_struct (struct osmo_cbsp_decoded *cbsp, enum cbsp_msg_type msg_type)
 
struct osmo_cbsp_decodedosmo_cbsp_decoded_alloc (void *ctx, enum cbsp_msg_type msg_type)
 Dynamically allocate and initialize decoded CBSP structure. More...
 

Variables

__thread const char * osmo_cbsp_errstr
 

Function Documentation

◆ cbsp_dec_error_ind()

◆ cbsp_dec_failure()

static int cbsp_dec_failure ( struct osmo_cbsp_failure out,
const struct tlv_parsed tp,
struct msgb in,
void *  ctx 
)
static

◆ cbsp_dec_keep_alive()

static int cbsp_dec_keep_alive ( struct osmo_cbsp_keep_alive out,
const struct tlv_parsed tp,
struct msgb in,
void *  ctx 
)
static

◆ cbsp_dec_keep_alive_compl()

static int cbsp_dec_keep_alive_compl ( struct osmo_cbsp_keep_alive_complete out,
const struct tlv_parsed tp,
struct msgb in,
void *  ctx 
)
static

Referenced by osmo_cbsp_decode().

◆ cbsp_dec_kill()

◆ cbsp_dec_kill_compl()

◆ cbsp_dec_kill_fail()

◆ cbsp_dec_load_query()

◆ cbsp_dec_load_query_compl()

◆ cbsp_dec_load_query_fail()

◆ cbsp_dec_msg_status_query()

◆ cbsp_dec_msg_status_query_compl()

◆ cbsp_dec_msg_status_query_fail()

◆ cbsp_dec_reset()

static int cbsp_dec_reset ( struct osmo_cbsp_reset out,
const struct tlv_parsed tp,
struct msgb in,
void *  ctx 
)
static

◆ cbsp_dec_reset_compl()

static int cbsp_dec_reset_compl ( struct osmo_cbsp_reset_complete out,
const struct tlv_parsed tp,
struct msgb in,
void *  ctx 
)
static

◆ cbsp_dec_reset_fail()

◆ cbsp_dec_restart()

◆ cbsp_dec_write_repl()

◆ cbsp_dec_write_repl_compl()

◆ cbsp_dec_write_repl_fail()

◆ cbsp_decode_cell_list()

◆ cbsp_decode_fail_list()

◆ cbsp_decode_loading_list()

◆ cbsp_decode_num_compl_list()

◆ cbsp_enc_error_ind()

◆ cbsp_enc_failure()

static int cbsp_enc_failure ( struct msgb msg,
const struct osmo_cbsp_failure in 
)
static

◆ cbsp_enc_keep_alive()

static int cbsp_enc_keep_alive ( struct msgb msg,
const struct osmo_cbsp_keep_alive in 
)
static

◆ cbsp_enc_keep_alive_compl()

static int cbsp_enc_keep_alive_compl ( struct msgb msg,
const struct osmo_cbsp_keep_alive_complete in 
)
static

Referenced by osmo_cbsp_encode().

◆ cbsp_enc_kill()

◆ cbsp_enc_kill_compl()

◆ cbsp_enc_kill_fail()

◆ cbsp_enc_load_query()

static int cbsp_enc_load_query ( struct msgb msg,
const struct osmo_cbsp_load_query in 
)
static

◆ cbsp_enc_load_query_compl()

◆ cbsp_enc_load_query_fail()

◆ cbsp_enc_msg_status_query()

◆ cbsp_enc_msg_status_query_compl()

◆ cbsp_enc_msg_status_query_fail()

◆ cbsp_enc_reset()

static int cbsp_enc_reset ( struct msgb msg,
const struct osmo_cbsp_reset in 
)
static

◆ cbsp_enc_reset_compl()

static int cbsp_enc_reset_compl ( struct msgb msg,
const struct osmo_cbsp_reset_complete in 
)
static

◆ cbsp_enc_reset_fail()

◆ cbsp_enc_restart()

◆ cbsp_enc_write_repl()

◆ cbsp_enc_write_repl_compl()

◆ cbsp_enc_write_repl_fail()

◆ decode_wperiod()

static uint32_t decode_wperiod ( uint8_t  in)
static

◆ encode_wperiod()

static int encode_wperiod ( uint32_t  secs)
static

◆ msgb_put_cbsp_cell_list()

◆ msgb_put_cbsp_fail_list()

◆ msgb_put_cbsp_loading_list()

◆ msgb_put_cbsp_num_compl_list()

◆ osmo_cbsp_decode()

struct osmo_cbsp_decoded * osmo_cbsp_decode ( void *  ctx,
struct msgb in 
)

Decode a CBSP message from wire formwat to pased structure.

Parameters
[in]ctxtalloc context from which to allocate decoded output.
[in]inmessage buffer contiaining binary CBSP message.
Returns
callee-allocated decoded representation of CBSP message; NULL on error

References ARRAY_SIZE, cbsp_att_tlvdef, cbsp_dec_error_ind(), cbsp_dec_failure(), cbsp_dec_keep_alive(), cbsp_dec_keep_alive_compl(), cbsp_dec_kill(), cbsp_dec_kill_compl(), cbsp_dec_kill_fail(), cbsp_dec_load_query(), cbsp_dec_load_query_compl(), cbsp_dec_load_query_fail(), cbsp_dec_msg_status_query(), cbsp_dec_msg_status_query_compl(), cbsp_dec_msg_status_query_fail(), cbsp_dec_reset(), cbsp_dec_reset_compl(), cbsp_dec_reset_fail(), cbsp_dec_restart(), cbsp_dec_write_repl(), cbsp_dec_write_repl_compl(), cbsp_dec_write_repl_fail(), CBSP_MSGT_ERROR_IND, CBSP_MSGT_FAILURE, CBSP_MSGT_KEEP_ALIVE, CBSP_MSGT_KEEP_ALIVE_COMPL, CBSP_MSGT_KILL, CBSP_MSGT_KILL_COMPL, CBSP_MSGT_KILL_FAIL, CBSP_MSGT_LOAD_QUERY, CBSP_MSGT_LOAD_QUERY_COMPL, CBSP_MSGT_LOAD_QUERY_FAIL, CBSP_MSGT_MSG_STATUS_QUERY, CBSP_MSGT_MSG_STATUS_QUERY_COMPL, CBSP_MSGT_MSG_STATUS_QUERY_FAIL, CBSP_MSGT_RESET, CBSP_MSGT_RESET_COMPL, CBSP_MSGT_RESET_FAIL, CBSP_MSGT_RESTART, CBSP_MSGT_SET_DRX, CBSP_MSGT_SET_DRX_COMPL, CBSP_MSGT_SET_DRX_FAIL, CBSP_MSGT_WRITE_REPLACE, CBSP_MSGT_WRITE_REPLACE_COMPL, CBSP_MSGT_WRITE_REPLACE_FAIL, msgb::data, osmo_cbsp_decoded::error_ind, osmo_cbsp_decoded::failure, h, osmo_cbsp_decoded::keep_alive, osmo_cbsp_decoded::keep_alive_compl, osmo_cbsp_decoded::kill, osmo_cbsp_decoded::kill_compl, osmo_cbsp_decoded::kill_fail, msgb::l1h, msgb::l2h, len, osmo_cbsp_decoded::load_query, osmo_cbsp_decoded::load_query_compl, osmo_cbsp_decoded::load_query_fail, osmo_cbsp_decoded::msg_status_query, osmo_cbsp_decoded::msg_status_query_compl, osmo_cbsp_decoded::msg_status_query_fail, osmo_cbsp_decoded::msg_type, msgb_l1, msgb_l1len(), msgb_l2, msgb_l2len(), msgb_trim(), OSMO_ASSERT, osmo_cbsp_errstr, osmo_cbsp_decoded::reset, osmo_cbsp_decoded::reset_compl, osmo_cbsp_decoded::reset_fail, osmo_cbsp_decoded::restart, tlv_parse2(), osmo_cbsp_decoded::u, osmo_cbsp_decoded::write_replace, osmo_cbsp_decoded::write_replace_compl, and osmo_cbsp_decoded::write_replace_fail.

◆ osmo_cbsp_decoded_alloc()

struct osmo_cbsp_decoded * osmo_cbsp_decoded_alloc ( void *  ctx,
enum cbsp_msg_type  msg_type 
)

Dynamically allocate and initialize decoded CBSP structure.

Parameters
[in]ctxtalloc context from which to allocate
[in]msg_typeCBSP message type for which to initialize result
Returns
allocated + initialized decoded CBSP structure; NULL on talloc failure

References msg_type, and osmo_cbsp_init_struct().

◆ osmo_cbsp_encode()

struct msgb * osmo_cbsp_encode ( void *  ctx,
const struct osmo_cbsp_decoded in 
)

Encode a CBSP message from the decoded/parsed structure representation to binary PDU.

Parameters
[in]ctxtalloc context from which to allocate returned msgb.
[in]indecoded CBSP message which is to be encoded. Ownership not transferred.
Returns
callee-allocated message buffer containing binary CBSP PDU; NULL on error

References cbsp_enc_error_ind(), cbsp_enc_failure(), cbsp_enc_keep_alive(), cbsp_enc_keep_alive_compl(), cbsp_enc_kill(), cbsp_enc_kill_compl(), cbsp_enc_kill_fail(), cbsp_enc_load_query(), cbsp_enc_load_query_compl(), cbsp_enc_load_query_fail(), cbsp_enc_msg_status_query(), cbsp_enc_msg_status_query_compl(), cbsp_enc_msg_status_query_fail(), cbsp_enc_reset(), cbsp_enc_reset_compl(), cbsp_enc_reset_fail(), cbsp_enc_restart(), cbsp_enc_write_repl(), cbsp_enc_write_repl_compl(), cbsp_enc_write_repl_fail(), CBSP_MSGT_ERROR_IND, CBSP_MSGT_FAILURE, CBSP_MSGT_KEEP_ALIVE, CBSP_MSGT_KEEP_ALIVE_COMPL, CBSP_MSGT_KILL, CBSP_MSGT_KILL_COMPL, CBSP_MSGT_KILL_FAIL, CBSP_MSGT_LOAD_QUERY, CBSP_MSGT_LOAD_QUERY_COMPL, CBSP_MSGT_LOAD_QUERY_FAIL, CBSP_MSGT_MSG_STATUS_QUERY, CBSP_MSGT_MSG_STATUS_QUERY_COMPL, CBSP_MSGT_MSG_STATUS_QUERY_FAIL, CBSP_MSGT_RESET, CBSP_MSGT_RESET_COMPL, CBSP_MSGT_RESET_FAIL, CBSP_MSGT_RESTART, CBSP_MSGT_SET_DRX, CBSP_MSGT_SET_DRX_COMPL, CBSP_MSGT_SET_DRX_FAIL, CBSP_MSGT_WRITE_REPLACE, CBSP_MSGT_WRITE_REPLACE_COMPL, CBSP_MSGT_WRITE_REPLACE_FAIL, osmo_cbsp_decoded::error_ind, osmo_cbsp_decoded::failure, osmo_cbsp_decoded::keep_alive, osmo_cbsp_decoded::keep_alive_compl, osmo_cbsp_decoded::kill, osmo_cbsp_decoded::kill_compl, osmo_cbsp_decoded::kill_fail, len, osmo_cbsp_decoded::load_query, osmo_cbsp_decoded::load_query_compl, osmo_cbsp_decoded::load_query_fail, msg, osmo_cbsp_decoded::msg_status_query, osmo_cbsp_decoded::msg_status_query_compl, osmo_cbsp_decoded::msg_status_query_fail, osmo_cbsp_decoded::msg_type, msgb_free(), msgb_length(), msgb_push_u8(), osmo_cbsp_errstr, osmo_cbsp_msgb_alloc(), osmo_cbsp_decoded::reset, osmo_cbsp_decoded::reset_compl, osmo_cbsp_decoded::reset_fail, osmo_cbsp_decoded::restart, osmo_cbsp_decoded::u, osmo_cbsp_decoded::write_replace, osmo_cbsp_decoded::write_replace_compl, and osmo_cbsp_decoded::write_replace_fail.

◆ osmo_cbsp_init_struct()

void osmo_cbsp_init_struct ( struct osmo_cbsp_decoded cbsp,
enum cbsp_msg_type  msg_type 
)

References CBSP_MSGT_FAILURE, CBSP_MSGT_KILL, CBSP_MSGT_KILL_COMPL, CBSP_MSGT_KILL_FAIL, CBSP_MSGT_LOAD_QUERY, CBSP_MSGT_LOAD_QUERY_COMPL, CBSP_MSGT_LOAD_QUERY_FAIL, CBSP_MSGT_MSG_STATUS_QUERY, CBSP_MSGT_MSG_STATUS_QUERY_COMPL, CBSP_MSGT_MSG_STATUS_QUERY_FAIL, CBSP_MSGT_RESET, CBSP_MSGT_RESET_COMPL, CBSP_MSGT_RESET_FAIL, CBSP_MSGT_RESTART, CBSP_MSGT_WRITE_REPLACE, CBSP_MSGT_WRITE_REPLACE_COMPL, CBSP_MSGT_WRITE_REPLACE_FAIL, osmo_cbsp_write_replace::cell_list, osmo_cbsp_write_replace_complete::cell_list, osmo_cbsp_write_replace_failure::cell_list, osmo_cbsp_kill::cell_list, osmo_cbsp_kill_complete::cell_list, osmo_cbsp_kill_failure::cell_list, osmo_cbsp_load_query::cell_list, osmo_cbsp_msg_status_query::cell_list, osmo_cbsp_reset::cell_list, osmo_cbsp_reset_complete::cell_list, osmo_cbsp_reset_failure::cell_list, osmo_cbsp_restart::cell_list, osmo_cbsp_write_replace_failure::fail_list, osmo_cbsp_kill_failure::fail_list, osmo_cbsp_load_query_failure::fail_list, osmo_cbsp_msg_status_query_failure::fail_list, osmo_cbsp_reset_failure::fail_list, osmo_cbsp_failure::fail_list, osmo_cbsp_decoded::failure, INIT_LLIST_HEAD, osmo_cbsp_decoded::kill, osmo_cbsp_decoded::kill_compl, osmo_cbsp_decoded::kill_fail, osmo_cbsp_cell_list::list, osmo_cbsp_num_compl_list::list, osmo_cbsp_loading_list::list, osmo_cbsp_decoded::load_query, osmo_cbsp_decoded::load_query_compl, osmo_cbsp_decoded::load_query_fail, osmo_cbsp_load_query_complete::loading_list, osmo_cbsp_decoded::msg_status_query, osmo_cbsp_decoded::msg_status_query_compl, osmo_cbsp_decoded::msg_status_query_fail, osmo_cbsp_decoded::msg_type, msg_type, osmo_cbsp_write_replace_complete::num_compl_list, osmo_cbsp_write_replace_failure::num_compl_list, osmo_cbsp_kill_complete::num_compl_list, osmo_cbsp_kill_failure::num_compl_list, osmo_cbsp_msg_status_query_complete::num_compl_list, osmo_cbsp_msg_status_query_failure::num_compl_list, osmo_cbsp_decoded::reset, osmo_cbsp_decoded::reset_compl, osmo_cbsp_decoded::reset_fail, osmo_cbsp_decoded::restart, osmo_cbsp_decoded::u, osmo_cbsp_decoded::write_replace, osmo_cbsp_decoded::write_replace_compl, and osmo_cbsp_decoded::write_replace_fail.

Referenced by osmo_cbsp_decoded_alloc().

◆ osmo_cbsp_msgb_alloc()

struct msgb * osmo_cbsp_msgb_alloc ( void *  ctx,
const char *  name 
)

References msgb_alloc_headroom_c(), and name.

Referenced by osmo_cbsp_encode().

Variable Documentation

◆ osmo_cbsp_errstr