libosmogb  1.4.0.171-b3b83
Osmocom Gb library
gprs_ns2.c File Reference

GPRS Networks Service (NS) messages on the Gb interface. More...

#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <osmocom/core/fsm.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/rate_ctr.h>
#include <osmocom/core/socket.h>
#include <osmocom/core/sockaddr_str.h>
#include <osmocom/core/stats.h>
#include <osmocom/core/stat_item.h>
#include <osmocom/core/talloc.h>
#include <osmocom/gprs/gprs_msgb.h>
#include <osmocom/gsm/prim.h>
#include <osmocom/gsm/tlv.h>
#include "gprs_ns2_internal.h"

Macros

#define ns_set_state(ns_, st_)   ns_set_state_with_log(ns_, st_, false, __FILE__, __LINE__)
 
#define ns_set_remote_state(ns_, st_)   ns_set_state_with_log(ns_, st_, true, __FILE__, __LINE__)
 
#define ns_mark_blocked(ns_)   ns_set_state(ns_, (ns_)->state | NSE_S_BLOCKED)
 
#define ns_mark_unblocked(ns_)   ns_set_state(ns_, (ns_)->state & (~NSE_S_BLOCKED));
 
#define ns_mark_alive(ns_)   ns_set_state(ns_, (ns_)->state | NSE_S_ALIVE)
 
#define ns_mark_dead(ns_)   ns_set_state(ns_, (ns_)->state & (~NSE_S_ALIVE));
 
#define NS2_LL_MAX_STR   4+2*(INET6_ADDRSTRLEN+9)+8
 

Functions

char * gprs_ns2_ll_str_buf (char *buf, size_t buf_len, struct gprs_ns2_vc *nsvc)
 string-format a given NS-VC into a user-supplied buffer. More...
 
const char * gprs_ns2_ll_str (struct gprs_ns2_vc *nsvc)
 string-format a given NS-VC to a thread-local static buffer. More...
 
char * gprs_ns2_ll_str_c (const void *ctx, struct gprs_ns2_vc *nsvc)
 string-format a given NS-VC to a dynamically allocated string. More...
 
int gprs_ns2_recv_prim (struct gprs_ns2_inst *nsi, struct osmo_prim_hdr *oph)
 Receive a primitive from the NS User (Gb). More...
 
void ns2_prim_status_ind (struct gprs_ns2_nse *nse, uint16_t bvci, enum gprs_ns2_affecting_cause cause)
 Send a STATUS.ind primitive to the specified NS instance user. More...
 
struct gprs_ns2_vcns2_vc_alloc (struct gprs_ns2_vc_bind *bind, struct gprs_ns2_nse *nse, bool initiater)
 Allocate a NS-VC within the given bind + NSE. More...
 
void gprs_ns2_free_nsvc (struct gprs_ns2_vc *nsvc)
 Destroy/release given NS-VC. More...
 
struct msgbgprs_ns2_msgb_alloc (void)
 Allocate a message buffer for use with the NS2 stack. More...
 
static int reject_status_msg (struct msgb *orig_msg, struct tlv_parsed *tp, struct msgb **reject, enum ns_cause cause)
 Create a status message to be sent over a new connection. More...
 
struct gprs_ns2_nsegprs_ns2_nse_by_nsei (struct gprs_ns2_inst *nsi, uint16_t nsei)
 Resolve a NS Entity based on its NSEI. More...
 
struct gprs_ns2_vcgprs_ns2_nsvc_by_nsvci (struct gprs_ns2_inst *nsi, uint16_t nsvci)
 Resolve a NS-VC Entity based on its NS-VCI. More...
 
struct gprs_ns2_nsegprs_ns2_create_nse (struct gprs_ns2_inst *nsi, uint16_t nsei)
 Create a NS Entity within given NS instance. More...
 
uint16_t gprs_ns2_nse_nsei (struct gprs_ns2_nse *nse)
 Return the NSEI. More...
 
void gprs_ns2_free_nse (struct gprs_ns2_nse *nse)
 Destroy given NS Entity. More...
 
void gprs_ns2_free_nses (struct gprs_ns2_inst *nsi)
 
static int ns2_tlv_parse (struct tlv_parsed *dec, const uint8_t *buf, int buf_len, uint8_t lv_tag, uint8_t lv_tag2)
 
enum gprs_ns2_cs ns2_create_vc (struct gprs_ns2_vc_bind *bind, struct msgb *msg, const char *logname, struct msgb **reject, struct gprs_ns2_vc **success)
 Create a new NS-VC based on a [received] message. More...
 
struct gprs_ns2_vcgprs_ns2_ip_connect_inactive (struct gprs_ns2_vc_bind *bind, const struct osmo_sockaddr *remote, struct gprs_ns2_nse *nse, uint16_t nsvci)
 Create, and connect an inactive, new IP-based NS-VC. More...
 
struct gprs_ns2_vcgprs_ns2_ip_connect (struct gprs_ns2_vc_bind *bind, const struct osmo_sockaddr *remote, struct gprs_ns2_nse *nse, uint16_t nsvci)
 Create, connect and activate a new IP-based NS-VC. More...
 
struct gprs_ns2_vcgprs_ns2_ip_connect2 (struct gprs_ns2_vc_bind *bind, const struct osmo_sockaddr *remote, uint16_t nsei, uint16_t nsvci)
 Create, connect and activate a new IP-based NS-VC. More...
 
int gprs_ns2_ip_connect_sns (struct gprs_ns2_vc_bind *bind, const struct osmo_sockaddr *remote, uint16_t nsei)
 Create, connect and activate a new IP-SNS NSE. More...
 
struct gprs_ns2_vcgprs_ns2_nsvc_by_sockaddr_nse (struct gprs_ns2_nse *nse, const struct osmo_sockaddr *sockaddr)
 Find NS-VC for given socket address. More...
 
int gprs_ns2_nse_foreach_nsvc (struct gprs_ns2_nse *nse, gprs_ns2_foreach_nsvc_cb cb, void *cb_data)
 Iterate over all nsvc of a NS Entity and call the callback. More...
 
int ns2_recv_vc (struct gprs_ns2_vc *nsvc, struct msgb *msg)
 Bottom-side entry-point for received NS PDU from the driver/bind. More...
 
void ns2_nse_notify_unblocked (struct gprs_ns2_vc *nsvc, bool unblocked)
 Notify a nse about the change of a NS-VC. More...
 
struct gprs_ns2_instgprs_ns2_instantiate (void *ctx, osmo_prim_cb cb, void *cb_data)
 Create a new GPRS NS instance. More...
 
void gprs_ns2_free (struct gprs_ns2_inst *nsi)
 Destroy a NS Instance (including all its NSEs, binds, ...). More...
 
int gprs_ns2_dynamic_create_nse (struct gprs_ns2_inst *nsi, bool create_nse)
 Configure whether a NS Instance should dynamically create NSEs based on incoming traffic. More...
 
void gprs_ns2_start_alive_all_nsvcs (struct gprs_ns2_nse *nse)
 Start the NS-ALIVE FSM in all NS-VCs of given NSE. More...
 
void gprs_ns2_bind_set_mode (struct gprs_ns2_vc_bind *bind, enum gprs_ns2_vc_mode mode)
 Set the mode of given bind. More...
 
void gprs_ns2_free_bind (struct gprs_ns2_vc_bind *bind)
 Destroy a given bind. More...
 
void gprs_ns2_free_binds (struct gprs_ns2_inst *nsi)
 

Variables

static const struct tlv_definition ns_att_tlvdef1
 
static const struct tlv_definition ns_att_tlvdef2
 
const struct value_string gprs_ns2_cause_strs []
 
static const struct rate_ctr_desc nsvc_ctr_description []
 
static const struct rate_ctr_group_desc nsvc_ctrg_desc
 
static const struct osmo_stat_item_desc nsvc_stat_description []
 
static const struct osmo_stat_item_group_desc nsvc_statg_desc
 
const struct value_string gprs_ns2_aff_cause_prim_strs []
 
const struct value_string ns2_prim_str []
 

Detailed Description

GPRS Networks Service (NS) messages on the Gb interface.

3GPP TS 08.16 version 8.0.1 Release 1999 / ETSI TS 101 299 V8.0.1 (2002-05) as well as its successor 3GPP TS 48.016