libosmogb 1.9.0.196-9975
Osmocom Gb library
gprs_bssgp.c File Reference

GPRS BSSGP protocol implementation as per 3GPP TS 08.18. More...

#include <errno.h>
#include <stdint.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/byteswap.h>
#include <osmocom/core/bit16gen.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/rate_ctr.h>
#include <osmocom/core/stats.h>
#include <osmocom/gprs/gprs_bssgp.h>
#include <osmocom/gprs/gprs_bssgp_bss.h>
#include <osmocom/gprs/gprs_ns.h>
#include "osmocom/gsm/gsm48.h"
#include "gprs_bssgp_internal.h"

Data Structures

struct  bssgp_fc_queue_element
 

Functions

static int _gprs_ns_sendmsg (void *ctx, struct msgb *msg)
 
 LLIST_HEAD (bssgp_bvc_ctxts)
 
static int _bssgp_tx_dl_ud (struct bssgp_flow_control *fc, struct msgb *msg, uint32_t llc_pdu_len, void *priv)
 
struct bssgp_bvc_ctxbtsctx_by_raid_cid (const struct gprs_ra_id *raid, uint16_t cid)
 
static int tx_bvc_reset_nsei_bvci (enum bssgp_pdu_type pdu, uint16_t nsei, uint16_t bvci, enum gprs_bssgp_cause cause, const struct gprs_ra_id *ra_id, uint16_t cell_id)
 
int bssgp_tx_bvc_reset_nsei_bvci (uint16_t nsei, uint16_t bvci, enum gprs_bssgp_cause cause, const struct gprs_ra_id *ra_id, uint16_t cell_id)
 Transmit a BVC-RESET message with a given nsei and bvci (Chapter 10.4.12) More...
 
int bssgp_tx_bvc_reset_ack_nsei_bvci (uint16_t nsei, uint16_t bvci, const struct gprs_ra_id *ra_id, uint16_t cell_id)
 Transmit a BVC-RESET-ACK message with a given nsei and bvci (Chapter 10.4.12) More...
 
int bssgp_tx_bvc_ptp_reset (uint16_t nsei, enum gprs_bssgp_cause cause)
 Initiate reset procedure for all PTP BVC on a given NSEI. More...
 
struct bssgp_bvc_ctxbtsctx_by_bvci_nsei (uint16_t bvci, uint16_t nsei)
 
void bssgp_set_bssgp_callback (bssgp_bvc_send ns_send, void *data)
 
struct bssgp_bvc_ctxbtsctx_alloc (uint16_t bvci, uint16_t nsei)
 
void bssgp_bvc_ctx_free (struct bssgp_bvc_ctx *ctx)
 
static int bssgp_tx_fc_bvc_ack (uint16_t nsei, uint8_t tag, uint16_t ns_bvci)
 
int bssgp_tx_suspend_ack (uint16_t nsei, uint32_t tlli, const struct gprs_ra_id *ra_id, uint8_t suspend_ref)
 
int bssgp_tx_suspend_nack (uint16_t nsei, uint32_t tlli, const struct gprs_ra_id *ra_id, uint8_t *cause)
 
int bssgp_tx_resume_ack (uint16_t nsei, uint32_t tlli, const struct gprs_ra_id *ra_id)
 
int bssgp_tx_resume_nack (uint16_t nsei, uint32_t tlli, const struct gprs_ra_id *ra_id, uint8_t *cause)
 
uint16_t bssgp_parse_cell_id (struct gprs_ra_id *raid, const uint8_t *buf)
 
int bssgp_create_cell_id (uint8_t *buf, const struct gprs_ra_id *raid, uint16_t cid)
 
static int bssgp_rx_bvc_reset (struct msgb *msg, struct tlv_parsed *tp, uint16_t ns_bvci)
 
static int bssgp_rx_bvc_block (struct msgb *msg, struct tlv_parsed *tp)
 
static int bssgp_rx_bvc_unblock (struct msgb *msg, struct tlv_parsed *tp)
 
static int bssgp_rx_ul_ud (struct msgb *msg, struct tlv_parsed *tp, struct bssgp_bvc_ctx *ctx)
 
static int bssgp_rx_suspend (struct msgb *msg, struct tlv_parsed *tp)
 
static int bssgp_rx_resume (struct msgb *msg, struct tlv_parsed *tp)
 
static int bssgp_rx_llc_disc (struct msgb *msg, struct tlv_parsed *tp, struct bssgp_bvc_ctx *ctx)
 
int bssgp_rx_status (struct msgb *msg, struct tlv_parsed *tp, uint16_t bvci, struct bssgp_bvc_ctx *bctx)
 
static int fc_queue_timer_cfg (struct bssgp_flow_control *fc)
 
static int bssgp_fc_needs_queueing (struct bssgp_flow_control *fc, uint32_t pdu_len)
 
static void fc_timer_cb (void *data)
 
static int fc_enqueue (struct bssgp_flow_control *fc, struct msgb *msg, uint32_t llc_pdu_len, void *priv)
 
int bssgp_fc_in (struct bssgp_flow_control *fc, struct msgb *msg, uint32_t llc_pdu_len, void *priv)
 
void bssgp_fc_init (struct bssgp_flow_control *fc, uint32_t bucket_size_max, uint32_t bucket_leak_rate, uint32_t max_queue_depth, int(*out_cb)(struct bssgp_flow_control *fc, struct msgb *msg, uint32_t llc_pdu_len, void *priv))
 
int bssgp_fc_ms_init (struct bssgp_flow_control *fc_ms, uint16_t bvci, uint16_t nsei, uint32_t max_queue_depth)
 
static int bssgp_rx_fc_bvc (struct msgb *msg, struct tlv_parsed *tp, struct bssgp_bvc_ctx *bctx)
 
static int bssgp_rx_ptp (struct msgb *msg, struct tlv_parsed *tp, struct bssgp_bvc_ctx *bctx)
 
static int bssgp_rx_sign (struct msgb *msg, struct tlv_parsed *tp, struct bssgp_bvc_ctx *bctx)
 
int bssgp_rcvmsg (struct msgb *msg)
 
int bssgp_tx_dl_ud (struct msgb *msg, uint16_t pdu_lifetime, struct bssgp_dl_ud_par *dup)
 
int bssgp_tx_paging (uint16_t nsei, uint16_t ns_bvci, struct bssgp_paging_info *pinfo)
 
void bssgp_set_log_ss (int ss)
 
void bssgp_fc_flush_queue (struct bssgp_flow_control *fc)
 Flush the queue of the bssgp_flow_control. More...
 
void bssgp_flush_all_queues (void)
 Flush the queues of all BSSGP contexts. More...
 

Variables

void * bssgp_tall_ctx = NULL
 
bssgp_bvc_send bssgp_ns_send = _gprs_ns_sendmsg
 
void * bssgp_ns_send_data = NULL
 
static const struct rate_ctr_desc bssgp_ctr_description []
 
static const struct rate_ctr_group_desc bssgp_ctrg_desc
 

Detailed Description

GPRS BSSGP protocol implementation as per 3GPP TS 08.18.

GPRS BSSGP RIM protocol implementation as per 3GPP TS 48.018.

Function Documentation

◆ _bssgp_tx_dl_ud()

static int _bssgp_tx_dl_ud ( struct bssgp_flow_control fc,
struct msgb msg,
uint32_t  llc_pdu_len,
void *  priv 
)
static

References bssgp_ns_send, bssgp_ns_send_data, and msg.

Referenced by btsctx_alloc().

◆ _gprs_ns_sendmsg()

static int _gprs_ns_sendmsg ( void *  ctx,
struct msgb msg 
)
static

◆ bssgp_bvc_ctx_free()

◆ bssgp_create_cell_id()

◆ bssgp_fc_flush_queue()

void bssgp_fc_flush_queue ( struct bssgp_flow_control fc)

Flush the queue of the bssgp_flow_control.

Parameters
[in]Theflow control object which holds the queue.

References list, bssgp_fc_queue_element::list, llist_del(), llist_for_each_entry_safe, bssgp_fc_queue_element::msg, msgb_free(), and bssgp_flow_control::queue.

Referenced by bssgp_flush_all_queues().

◆ bssgp_fc_in()

◆ bssgp_fc_init()

void bssgp_fc_init ( struct bssgp_flow_control fc,
uint32_t  bucket_size_max,
uint32_t  bucket_leak_rate,
uint32_t  max_queue_depth,
int(*)(struct bssgp_flow_control *fc, struct msgb *msg, uint32_t llc_pdu_len, void *priv)  out_cb 
)

◆ bssgp_fc_ms_init()

int bssgp_fc_ms_init ( struct bssgp_flow_control fc_ms,
uint16_t  bvci,
uint16_t  nsei,
uint32_t  max_queue_depth 
)

◆ bssgp_fc_needs_queueing()

static int bssgp_fc_needs_queueing ( struct bssgp_flow_control fc,
uint32_t  pdu_len 
)
static

◆ bssgp_flush_all_queues()

void bssgp_flush_all_queues ( void  )

Flush the queues of all BSSGP contexts.

References bssgp_bvc_ctxts, bssgp_fc_flush_queue(), bssgp_bvc_ctx::fc, list, and llist_for_each_entry.

◆ bssgp_parse_cell_id()

uint16_t bssgp_parse_cell_id ( struct gprs_ra_id raid,
const uint8_t *  buf 
)

◆ bssgp_rcvmsg()

◆ bssgp_rx_bvc_block()

◆ bssgp_rx_bvc_reset()

◆ bssgp_rx_bvc_unblock()

◆ bssgp_rx_fc_bvc()

◆ bssgp_rx_llc_disc()

◆ bssgp_rx_ptp()

◆ bssgp_rx_resume()

◆ bssgp_rx_sign()

◆ bssgp_rx_status()

◆ bssgp_rx_suspend()

◆ bssgp_rx_ul_ud()

◆ bssgp_set_bssgp_callback()

void bssgp_set_bssgp_callback ( bssgp_bvc_send  ns_send,
void *  data 
)

◆ bssgp_set_log_ss()

void bssgp_set_log_ss ( int  ss)

◆ bssgp_tx_bvc_ptp_reset()

int bssgp_tx_bvc_ptp_reset ( uint16_t  nsei,
enum gprs_bssgp_cause  cause 
)

Initiate reset procedure for all PTP BVC on a given NSEI.

This function initiates reset procedure for all PTP BVC with a given cause.

Parameters
[in]nseiNSEI to which PTP BVC should belong to
[in]causeCause of BVC RESET
Returns
0 on success, negative error code otherwise

References bssgp_bvc_ctxts, bssgp_cause_str(), bssgp_tx_bvc_reset(), bssgp_bvc_ctx::bvci, BVCI_SIGNALLING, cause, DLBSSGP, list, llist_for_each_entry, LOGL_DEBUG, LOGP, bssgp_bvc_ctx::nsei, and nsei.

◆ bssgp_tx_bvc_reset_ack_nsei_bvci()

int bssgp_tx_bvc_reset_ack_nsei_bvci ( uint16_t  nsei,
uint16_t  bvci,
const struct gprs_ra_id ra_id,
uint16_t  cell_id 
)

Transmit a BVC-RESET-ACK message with a given nsei and bvci (Chapter 10.4.12)

Parameters
[in]nseiThe NSEI to transmit over
[in]bvciBVCI of the BVC to reset
[in]ra_idPointer to the ra_id to include. If NULL no cell information will be included
[in]cell_idThe cell_id to include (if ra_id is not NULL) returns >= 0 on success, on error < 0.

References BSSGP_PDUT_BVC_RESET_ACK, bvci, nsei, ra_id, and tx_bvc_reset_nsei_bvci().

Referenced by bssgp_rx_bvc_reset().

◆ bssgp_tx_bvc_reset_nsei_bvci()

int bssgp_tx_bvc_reset_nsei_bvci ( uint16_t  nsei,
uint16_t  bvci,
enum gprs_bssgp_cause  cause,
const struct gprs_ra_id ra_id,
uint16_t  cell_id 
)

Transmit a BVC-RESET message with a given nsei and bvci (Chapter 10.4.12)

Parameters
[in]nseiThe NSEI to transmit over
[in]bvciBVCI of the BVC to reset
[in]causeThe cause of the reset
[in]ra_idPointer to the ra_id to include. If NULL no cell information will be included
[in]cell_idThe cell_id to include (if ra_id is not NULL) returns >= 0 on success, on error < 0.

References BSSGP_PDUT_BVC_RESET, bvci, cause, nsei, ra_id, and tx_bvc_reset_nsei_bvci().

Referenced by bssgp_tx_bvc_reset2().

◆ bssgp_tx_dl_ud()

◆ bssgp_tx_fc_bvc_ack()

static int bssgp_tx_fc_bvc_ack ( uint16_t  nsei,
uint8_t  tag,
uint16_t  ns_bvci 
)
static

◆ bssgp_tx_paging()

◆ bssgp_tx_resume_ack()

int bssgp_tx_resume_ack ( uint16_t  nsei,
uint32_t  tlli,
const struct gprs_ra_id ra_id 
)

◆ bssgp_tx_resume_nack()

int bssgp_tx_resume_nack ( uint16_t  nsei,
uint32_t  tlli,
const struct gprs_ra_id ra_id,
uint8_t *  cause 
)

◆ bssgp_tx_suspend_ack()

int bssgp_tx_suspend_ack ( uint16_t  nsei,
uint32_t  tlli,
const struct gprs_ra_id ra_id,
uint8_t  suspend_ref 
)

◆ bssgp_tx_suspend_nack()

int bssgp_tx_suspend_nack ( uint16_t  nsei,
uint32_t  tlli,
const struct gprs_ra_id ra_id,
uint8_t *  cause 
)

◆ btsctx_alloc()

◆ btsctx_by_bvci_nsei()

◆ btsctx_by_raid_cid()

struct bssgp_bvc_ctx * btsctx_by_raid_cid ( const struct gprs_ra_id raid,
uint16_t  cid 
)

◆ fc_enqueue()

◆ fc_queue_timer_cfg()

◆ fc_timer_cb()

◆ LLIST_HEAD()

LLIST_HEAD ( bssgp_bvc_ctxts  )

◆ tx_bvc_reset_nsei_bvci()

Variable Documentation

◆ bssgp_ctr_description

const struct rate_ctr_desc bssgp_ctr_description[]
static
Initial value:
= {
{ "packets:in", "Packets at BSSGP Level ( In)" },
{ "packets:out","Packets at BSSGP Level (Out)" },
{ "bytes:in", "Bytes at BSSGP Level ( In)" },
{ "bytes:out", "Bytes at BSSGP Level (Out)" },
{ "blocked", "BVC Blocking count" },
{ "discarded", "BVC LLC Discarded count" },
{ "status", "BVC Status count" },
}

◆ bssgp_ctrg_desc

const struct rate_ctr_group_desc bssgp_ctrg_desc
static
Initial value:
= {
.group_name_prefix = "bssgp:bss_ctx",
.group_description = "BSSGP Peer Statistics",
.ctr_desc = bssgp_ctr_description,
.class_id = OSMO_STATS_CLASS_PEER,
}
static const struct rate_ctr_desc bssgp_ctr_description[]
Definition: gprs_bssgp.c:53
OSMO_STATS_CLASS_PEER
#define ARRAY_SIZE(x)

Referenced by btsctx_alloc().

◆ bssgp_ns_send

◆ bssgp_ns_send_data

◆ bssgp_tall_ctx

void* bssgp_tall_ctx = NULL

Referenced by btsctx_alloc().