libosmogb 1.9.0.196-9975
Osmocom Gb library
gprs_ns2.h File Reference
#include <stdint.h>
#include <netinet/in.h>
#include <osmocom/core/prim.h>
#include <osmocom/gprs/protocol/gsm_08_16.h>
#include <osmocom/gprs/frame_relay.h>

Go to the source code of this file.

Data Structures

struct  osmo_gprs_ns2_prim
 

Typedefs

typedef int(* gprs_ns2_foreach_nsvc_cb) (struct gprs_ns2_vc *nsvc, void *ctx)
 a callback to iterate over all NSVC More...
 

Enumerations

enum  gprs_ns2_vc_mode {
  GPRS_NS2_VC_MODE_BLOCKRESET ,
  GPRS_NS2_VC_MODE_ALIVE
}
 
enum  gprs_ns2_dialect {
  GPRS_NS2_DIALECT_UNDEF ,
  GPRS_NS2_DIALECT_STATIC_ALIVE ,
  GPRS_NS2_DIALECT_STATIC_RESETBLOCK ,
  GPRS_NS2_DIALECT_IPACCESS ,
  GPRS_NS2_DIALECT_SNS
}
 
enum  gprs_ns2_ll {
  GPRS_NS2_LL_UNDEF ,
  GPRS_NS2_LL_UDP ,
  GPRS_NS2_LL_FR ,
  GPRS_NS2_LL_FR_GRE
}
 Osmocom NS link layer types. More...
 
enum  gprs_ns2_prim {
  GPRS_NS2_PRIM_UNIT_DATA ,
  GPRS_NS2_PRIM_CONGESTION ,
  GPRS_NS2_PRIM_STATUS
}
 Osmocom NS primitives according to 48.016 5.2 Service primitives. More...
 
enum  gprs_ns2_congestion_cause {
  GPRS_NS2_CONG_CAUSE_BACKWARD_BEGIN ,
  GPRS_NS2_CONG_CAUSE_BACKWARD_END ,
  GPRS_NS2_CONG_CAUSE_FORWARD_BEGIN ,
  GPRS_NS2_CONG_CAUSE_FORWARD_END
}
 Osmocom NS primitives according to 48.016 5.2.2.4 Service primitives. More...
 
enum  gprs_ns2_affecting_cause {
  GPRS_NS2_AFF_CAUSE_VC_FAILURE ,
  GPRS_NS2_AFF_CAUSE_VC_RECOVERY ,
  GPRS_NS2_AFF_CAUSE_FAILURE ,
  GPRS_NS2_AFF_CAUSE_RECOVERY ,
  GPRS_NS2_AFF_CAUSE_SNS_CONFIGURED ,
  GPRS_NS2_AFF_CAUSE_SNS_FAILURE ,
  GPRS_NS2_AFF_CAUSE_SNS_NO_ENDPOINTS ,
  GPRS_NS2_AFF_CAUSE_MTU_CHANGE
}
 Osmocom NS primitives according to 48.016 5.2.2.6 Service primitives. More...
 
enum  gprs_ns2_change_ip_endpoint {
  GRPS_NS2_ENDPOINT_NO_CHANGE ,
  GPRS_NS2_ENDPOINT_REQUEST_CHANGE ,
  GPRS_NS2_ENDPOINT_CONFIRM_CHANGE
}
 Osmocom NS primitives according to 48.016 5.2.2.7 Service primitives. More...
 

Functions

static const char * gprs_ns2_prim_str (enum gprs_ns2_prim val)
 Obtain a human-readable string for NS primitives. More...
 
static const char * gprs_ns2_lltype_str (enum gprs_ns2_ll val)
 Obtain a human-readable string for NS link-layer type. More...
 
static const char * gprs_ns2_aff_cause_prim_str (enum gprs_ns2_affecting_cause val)
 Obtain a human-readable string for NS affecting cause in primitives. More...
 
static const char * gprs_ns2_cause_str (enum ns_cause val)
 Obtain a human-readable string for NS primitives. 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 *inst)
 Destroy a NS Instance (including all its NSEs, binds, ...). 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...
 
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...
 
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_nsegprs_ns2_create_nse (struct gprs_ns2_inst *nsi, uint16_t nsei, enum gprs_ns2_ll linklayer, enum gprs_ns2_dialect dialect)
 Create a NS Entity within given NS instance. More...
 
struct gprs_ns2_nsegprs_ns2_create_nse2 (struct gprs_ns2_inst *nsi, uint16_t nsei, enum gprs_ns2_ll linklayer, enum gprs_ns2_dialect dialect, bool local_sgsn_role)
 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)
 
void gprs_ns2_free_nsvc (struct gprs_ns2_vc *nsvc)
 Destroy/release given NS-VC. More...
 
void gprs_ns2_free_nsvcs (struct gprs_ns2_nse *nse)
 Destroy/release all NS-VC of given NSE. 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_vc_bindgprs_ns2_bind_by_name (struct gprs_ns2_inst *nsi, const char *name)
 Search for a bind with a unique name. More...
 
int gprs_ns2_ip_bind (struct gprs_ns2_inst *nsi, const char *name, const struct osmo_sockaddr *local, int dscp, struct gprs_ns2_vc_bind **result)
 Bind to an IPv4/IPv6 address. More...
 
struct gprs_ns2_vc_bindgprs_ns2_ip_bind_by_sockaddr (struct gprs_ns2_inst *nsi, const struct osmo_sockaddr *sockaddr)
 Find NS bind for a given socket address. More...
 
struct gprs_ns2_vc_bindgprs_ns2_fr_bind_by_netif (struct gprs_ns2_inst *nsi, const char *netif)
 Find NS bind for a given network interface. More...
 
const char * gprs_ns2_fr_bind_netif (struct gprs_ns2_vc_bind *bind)
 Return the network interface of the bind. More...
 
enum osmo_fr_role gprs_ns2_fr_bind_role (struct gprs_ns2_vc_bind *bind)
 Return the frame relay role of a bind. More...
 
int gprs_ns2_fr_bind (struct gprs_ns2_inst *nsi, const char *name, const char *netif, struct osmo_fr_network *fr_network, enum osmo_fr_role fr_role, struct gprs_ns2_vc_bind **result)
 Create a new bind for NS over FR. More...
 
int gprs_ns2_is_fr_bind (struct gprs_ns2_vc_bind *bind)
 determine if given bind is for FR-GRE encapsulation. More...
 
struct gprs_ns2_vcgprs_ns2_fr_nsvc_by_dlci (struct gprs_ns2_vc_bind *bind, uint16_t dlci)
 Return the nsvc by dlci. More...
 
struct gprs_ns2_vcgprs_ns2_fr_connect (struct gprs_ns2_vc_bind *bind, struct gprs_ns2_nse *nse, uint16_t nsvci, uint16_t dlci)
 Create, connect and activate a new FR-based NS-VC. More...
 
struct gprs_ns2_vcgprs_ns2_fr_connect2 (struct gprs_ns2_vc_bind *bind, uint16_t nsei, uint16_t nsvci, uint16_t dlci)
 Create, connect and activate a new FR-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, enum gprs_ns2_dialect dialect)
 Create, connect and activate a new IP-based NS-VC. 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...
 
void gprs_ns2_ip_bind_set_sns_weight (struct gprs_ns2_vc_bind *bind, uint8_t signalling, uint8_t data)
 set the signalling and data weight for this 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)
 
int gprs_ns2_sns_count (struct gprs_ns2_nse *nse)
 gprs_ns2_sns_count More...
 
int gprs_ns2_sns_add_endpoint (struct gprs_ns2_nse *nse, const struct osmo_sockaddr *saddr)
 gprs_ns2_sns_add_endpoint More...
 
int gprs_ns2_sns_del_endpoint (struct gprs_ns2_nse *nse, const struct osmo_sockaddr *saddr)
 gprs_ns2_sns_del_endpoint More...
 
int gprs_ns2_sns_add_bind (struct gprs_ns2_nse *nse, struct gprs_ns2_vc_bind *bind)
 
int gprs_ns2_sns_del_bind (struct gprs_ns2_nse *nse, struct gprs_ns2_vc_bind *bind)
 
const struct osmo_sockaddrgprs_ns2_nse_sns_remote (struct gprs_ns2_nse *nse)
 Return the initial SNS remote socket address. More...
 
const struct osmo_sockaddrgprs_ns2_ip_vc_remote (const struct gprs_ns2_vc *nsvc)
 Return the socket address of the remote peer of a NS-VC. More...
 
const struct osmo_sockaddrgprs_ns2_ip_vc_local (const struct gprs_ns2_vc *nsvc)
 Return the socket address of the local peer of a NS-VC. More...
 
bool gprs_ns2_ip_vc_equal (const struct gprs_ns2_vc *nsvc, const struct osmo_sockaddr *local, const struct osmo_sockaddr *remote, uint16_t nsvci)
 Compare the NS-VC with the given parameter. More...
 
const struct osmo_sockaddrgprs_ns2_ip_bind_sockaddr (struct gprs_ns2_vc_bind *bind)
 Return the locally bound socket address of the bind. More...
 
int gprs_ns2_is_ip_bind (struct gprs_ns2_vc_bind *bind)
 Is the given bind an IP bind? More...
 
int gprs_ns2_ip_bind_set_dscp (struct gprs_ns2_vc_bind *bind, int dscp)
 Set the DSCP (TOS) bit value of the given bind. More...
 
int gprs_ns2_ip_bind_set_priority (struct gprs_ns2_vc_bind *bind, uint8_t priority)
 Set the socket priority of the given bind. More...
 
struct gprs_ns2_vcgprs_ns2_nsvc_by_sockaddr_bind (struct gprs_ns2_vc_bind *bind, const struct osmo_sockaddr *rem_addr)
 Find a NS-VC by its remote socket address. More...
 
int gprs_ns2_frgre_bind (struct gprs_ns2_inst *nsi, const char *name, const struct osmo_sockaddr *local, int dscp, struct gprs_ns2_vc_bind **result)
 Create a new bind for NS over FR-GRE. More...
 
int gprs_ns2_is_frgre_bind (struct gprs_ns2_vc_bind *bind)
 determine if given bind is for FR-GRE encapsulation. More...
 
uint16_t gprs_ns2_fr_nsvc_dlci (const struct gprs_ns2_vc *nsvc)
 Return the dlci of the nsvc. 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...
 
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...
 
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_buf (char *buf, size_t buf_len, struct gprs_ns2_vc *nsvc)
 string-format a given NS-VC into a user-supplied 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...
 
const char * gprs_ns2_nsvc_state_name (struct gprs_ns2_vc *nsvc)
 Return the current state name of a given NS-VC to a thread-local static buffer. More...
 
int gprs_ns2_vty_init (struct gprs_ns2_inst *nsi)
 

Variables

const struct value_string gprs_ns2_prim_strs []
 
const struct value_string gprs_ns2_lltype_strs []
 
const struct value_string gprs_ns2_aff_cause_prim_strs []
 
const struct value_string gprs_ns2_cause_strs []
 

Typedef Documentation

◆ gprs_ns2_foreach_nsvc_cb

typedef int(* gprs_ns2_foreach_nsvc_cb) (struct gprs_ns2_vc *nsvc, void *ctx)

a callback to iterate over all NSVC

Enumeration Type Documentation

◆ gprs_ns2_affecting_cause

Osmocom NS primitives according to 48.016 5.2.2.6 Service primitives.

Enumerator
GPRS_NS2_AFF_CAUSE_VC_FAILURE 
GPRS_NS2_AFF_CAUSE_VC_RECOVERY 
GPRS_NS2_AFF_CAUSE_FAILURE 
GPRS_NS2_AFF_CAUSE_RECOVERY 
GPRS_NS2_AFF_CAUSE_SNS_CONFIGURED 
GPRS_NS2_AFF_CAUSE_SNS_FAILURE 
GPRS_NS2_AFF_CAUSE_SNS_NO_ENDPOINTS 
GPRS_NS2_AFF_CAUSE_MTU_CHANGE 

◆ gprs_ns2_change_ip_endpoint

Osmocom NS primitives according to 48.016 5.2.2.7 Service primitives.

Enumerator
GRPS_NS2_ENDPOINT_NO_CHANGE 
GPRS_NS2_ENDPOINT_REQUEST_CHANGE 
GPRS_NS2_ENDPOINT_CONFIRM_CHANGE 

◆ gprs_ns2_congestion_cause

Osmocom NS primitives according to 48.016 5.2.2.4 Service primitives.

Enumerator
GPRS_NS2_CONG_CAUSE_BACKWARD_BEGIN 
GPRS_NS2_CONG_CAUSE_BACKWARD_END 
GPRS_NS2_CONG_CAUSE_FORWARD_BEGIN 
GPRS_NS2_CONG_CAUSE_FORWARD_END 

◆ gprs_ns2_dialect

Enumerator
GPRS_NS2_DIALECT_UNDEF 
GPRS_NS2_DIALECT_STATIC_ALIVE 
GPRS_NS2_DIALECT_STATIC_RESETBLOCK 
GPRS_NS2_DIALECT_IPACCESS 
GPRS_NS2_DIALECT_SNS 

◆ gprs_ns2_ll

Osmocom NS link layer types.

Enumerator
GPRS_NS2_LL_UNDEF 

undefined, used by vty

GPRS_NS2_LL_UDP 

NS/UDP/IP.

GPRS_NS2_LL_FR 

NS/FR.

GPRS_NS2_LL_FR_GRE 

NS/FR/GRE/IP.

◆ gprs_ns2_prim

Osmocom NS primitives according to 48.016 5.2 Service primitives.

Enumerator
GPRS_NS2_PRIM_UNIT_DATA 
GPRS_NS2_PRIM_CONGESTION 
GPRS_NS2_PRIM_STATUS 

◆ gprs_ns2_vc_mode

Enumerator
GPRS_NS2_VC_MODE_BLOCKRESET 

The VC will use RESET/BLOCK/UNBLOCK to start the connection and do ALIVE/ACK.

This is what is needed for Frame Relay transport, and if you use a R97/R99 Gb interface over an IP transport (never standardized by 3GPP)

GPRS_NS2_VC_MODE_ALIVE 

The VC will only use ALIVE/ACK (no RESET/BLOCK/UNBLOCK), which is for Gb-IP interface compliant to 3GPP Rel=4 or later.

Function Documentation

◆ gprs_ns2_aff_cause_prim_str()

static const char * gprs_ns2_aff_cause_prim_str ( enum gprs_ns2_affecting_cause  val)
inlinestatic

Obtain a human-readable string for NS affecting cause in primitives.

References get_value_string(), and gprs_ns2_aff_cause_prim_strs.

Referenced by ns2_prim_status_ind().

◆ gprs_ns2_cause_str()

static const char * gprs_ns2_cause_str ( enum ns_cause  val)
inlinestatic

◆ gprs_ns2_fr_bind()

int gprs_ns2_fr_bind ( struct gprs_ns2_inst nsi,
const char *  name,
const char *  netif,
struct osmo_fr_network fr_network,
enum osmo_fr_role  fr_role,
struct gprs_ns2_vc_bind **  result 
)

◆ gprs_ns2_fr_bind_by_netif()

struct gprs_ns2_vc_bind * gprs_ns2_fr_bind_by_netif ( struct gprs_ns2_inst nsi,
const char *  netif 
)

Find NS bind for a given network interface.

Parameters
[in]nsiNS instance
[in]netifthe network interface to search for
Returns
the bind or NULL if not found

References gprs_ns2_inst::binding, gprs_ns2_fr_bind_netif(), gprs_ns2_is_fr_bind(), list, llist_for_each_entry, gprs_ns2_vc_bind::nsi, and OSMO_ASSERT.

Referenced by DEFUN().

◆ gprs_ns2_fr_bind_netif()

const char * gprs_ns2_fr_bind_netif ( struct gprs_ns2_vc_bind bind)

Return the network interface of the bind.

Parameters
[in]bindThe bind
Returns
the network interface

References gprs_ns2_vc_bind::driver, priv_bind::netif, gprs_ns2_vc_bind::priv, and vc_driver_fr.

Referenced by config_write_nsvc(), config_write_vbind(), gprs_ns2_fr_bind_by_netif(), and gprs_ns2_ll_str_buf().

◆ gprs_ns2_fr_bind_role()

enum osmo_fr_role gprs_ns2_fr_bind_role ( struct gprs_ns2_vc_bind bind)

Return the frame relay role of a bind.

Parameters
[in]bindThe bind
Returns
the frame relay role or -EINVAL if bind is not frame relay

References gprs_ns2_vc_bind::driver, priv_bind::link, gprs_ns2_vc_bind::priv, osmo_fr_link::role, and vc_driver_fr.

Referenced by config_write_vbind().

◆ gprs_ns2_fr_connect()

struct gprs_ns2_vc * gprs_ns2_fr_connect ( struct gprs_ns2_vc_bind bind,
struct gprs_ns2_nse nse,
uint16_t  nsvci,
uint16_t  dlci 
)

Create, connect and activate a new FR-based NS-VC.

Parameters
[in]bindbind in which the new NS-VC is to be created
[in]nseiNSEI of the NS Entity in which the NS-VC is to be created
[in]dlciData Link connection identifier
Returns
pointer to newly-allocated, connected and activated NS-VC; NULL on error

References priv_bind::dlci, fr_alloc_vc(), gprs_ns2_fr_nsvc_by_dlci(), gprs_ns2_free_nsvc(), gprs_ns2_is_fr_bind(), gprs_ns2_lltype_str(), GPRS_NS2_VC_MODE_BLOCKRESET, gprs_ns2_nse::ll, priv_bind::netif, ns2_vc_alloc(), gprs_ns2_nse::nsei, gprs_ns2_vc::nsvci, gprs_ns2_vc::nsvci_is_valid, OSMO_ASSERT, osmo_identifier_sanitize_buf(), gprs_ns2_vc::priv, and gprs_ns2_vc_bind::priv.

Referenced by DEFUN(), and gprs_ns2_fr_connect2().

◆ gprs_ns2_fr_connect2()

struct gprs_ns2_vc * gprs_ns2_fr_connect2 ( struct gprs_ns2_vc_bind bind,
uint16_t  nsei,
uint16_t  nsvci,
uint16_t  dlci 
)

Create, connect and activate a new FR-based NS-VC.

Parameters
[in]bindbind in which the new NS-VC is to be created
[in]nseiNSEI of the NS Entity in which the NS-VC is to be created
[in]dlciData Link connection identifier
Returns
pointer to newly-allocated, connected and activated NS-VC; NULL on error

References gprs_ns2_create_nse(), GPRS_NS2_DIALECT_STATIC_RESETBLOCK, gprs_ns2_fr_connect(), gprs_ns2_free_nse(), gprs_ns2_is_fr_bind(), GPRS_NS2_LL_FR, gprs_ns2_nse_by_nsei(), nsei, gprs_ns2_vc_bind::nsi, gprs_ns2_nse::nsvc, and OSMO_ASSERT.

◆ gprs_ns2_fr_nsvc_by_dlci()

struct gprs_ns2_vc * gprs_ns2_fr_nsvc_by_dlci ( struct gprs_ns2_vc_bind bind,
uint16_t  dlci 
)

Return the nsvc by dlci.

Parameters
[in]bind
[in]dlciData Link connection identifier
Returns
the nsvc or NULL if not found

References priv_vc::dlci, gprs_ns2_is_fr_bind(), llist_for_each_entry, gprs_ns2_vc_bind::nsvc, OSMO_ASSERT, and gprs_ns2_vc::priv.

Referenced by DEFUN(), and gprs_ns2_fr_connect().

◆ gprs_ns2_fr_nsvc_dlci()

uint16_t gprs_ns2_fr_nsvc_dlci ( const struct gprs_ns2_vc nsvc)

Return the dlci of the nsvc.

Parameters
[in]nsvc
Returns
the dlci or 0 on error. 0 is not a valid dlci.

References gprs_ns2_vc::bind, priv_vc::dlci, gprs_ns2_vc_bind::driver, gprs_ns2_vc::priv, and vc_driver_fr.

Referenced by config_write_nsvc(), and gprs_ns2_ll_str_buf().

◆ gprs_ns2_frgre_bind()

int gprs_ns2_frgre_bind ( struct gprs_ns2_inst nsi,
const char *  name,
const struct osmo_sockaddr local,
int  dscp,
struct gprs_ns2_vc_bind **  result 
)

Create a new bind for NS over FR-GRE.

Parameters
[in]nsiNS instance in which to create the bind
[in]locallocal address on which to bind
[in]dscpDSCP/TOS bits to use for transmitted data on this bind
[out]resultpointer to the created bind or if a bind with the name exists return the bind.
Returns
0 on success; negative on error. -EALREADY returned in case a bind with the name exists

References priv_bind::addr, osmo_fd::cb, osmo_fd::data, gprs_ns2_vc_bind::driver, priv_bind::dscp, priv_bind::fd, FRAME_RELAY_SDU, free_vc(), gprs_ns2_vc_bind::free_vc, frgre_fd_cb(), frgre_vc_sendmsg(), gprs_ns2_bind_by_name(), gprs_ns2_free_bind(), GPRS_NS2_LL_FR_GRE, INIT_LLIST_HEAD, IPPROTO_GRE, gprs_ns2_vc_bind::ll, gprs_ns2_vc_bind::mtu, name, ns2_bind_alloc(), gprs_ns2_vc_bind::nsi, gprs_ns2_vc_bind::nsvc, OSMO_SOCK_F_BIND, OSMO_SOCK_F_DSCP, osmo_sock_init_osa_ofd(), gprs_ns2_vc_bind::priv, osmo_sockaddr::sa, gprs_ns2_vc_bind::send_vc, gprs_ns2_vc_bind::transfer_capability, osmo_sockaddr::u, and vc_driver_frgre.

◆ gprs_ns2_ip_bind()

int gprs_ns2_ip_bind ( struct gprs_ns2_inst nsi,
const char *  name,
const struct osmo_sockaddr local,
int  dscp,
struct gprs_ns2_vc_bind **  result 
)

◆ gprs_ns2_ip_bind_by_sockaddr()

struct gprs_ns2_vc_bind * gprs_ns2_ip_bind_by_sockaddr ( struct gprs_ns2_inst nsi,
const struct osmo_sockaddr sockaddr 
)

Find NS bind for a given socket address.

Parameters
[in]nsiNS instance
[in]sockaddrsocket address to search for
Returns

References gprs_ns2_inst::binding, gprs_ns2_ip_bind_sockaddr(), gprs_ns2_is_ip_bind(), list, llist_for_each_entry, OSMO_ASSERT, and osmo_sockaddr_cmp().

Referenced by DEFUN(), and gprs_ns2_ip_bind().

◆ gprs_ns2_ip_bind_set_dscp()

int gprs_ns2_ip_bind_set_dscp ( struct gprs_ns2_vc_bind bind,
int  dscp 
)

Set the DSCP (TOS) bit value of the given bind.

References priv_bind::dscp, gprs_ns2_is_ip_bind(), priv_bind::iofd, LOGBIND, LOGL_ERROR, OSMO_ASSERT, osmo_iofd_get_fd(), osmo_sock_set_dscp(), and gprs_ns2_vc_bind::priv.

Referenced by DEFUN().

◆ gprs_ns2_ip_bind_set_priority()

int gprs_ns2_ip_bind_set_priority ( struct gprs_ns2_vc_bind bind,
uint8_t  priority 
)

◆ gprs_ns2_ip_bind_set_sns_weight()

void gprs_ns2_ip_bind_set_sns_weight ( struct gprs_ns2_vc_bind bind,
uint8_t  signalling,
uint8_t  data 
)

set the signalling and data weight for this bind

Parameters
[in]bind
[in]signallingthe signalling weight
[in]datathe data weight

References data, gprs_ns2_is_ip_bind(), ns2_sns_update_weights(), OSMO_ASSERT, gprs_ns2_vc_bind::sns_data_weight, and gprs_ns2_vc_bind::sns_sig_weight.

Referenced by DEFUN().

◆ gprs_ns2_ip_bind_sockaddr()

◆ gprs_ns2_ip_vc_equal()

bool gprs_ns2_ip_vc_equal ( const struct gprs_ns2_vc nsvc,
const struct osmo_sockaddr local,
const struct osmo_sockaddr remote,
uint16_t  nsvci 
)

Compare the NS-VC with the given parameter.

Parameters
[in]nsvcNS-VC to compare with
[in]localThe local address
[in]remoteThe remote address
[in]nsvciNS-VCI will only be used if the NS-VC in BLOCKRESET mode otherwise NS-VCI isn't applicable.
Returns
true if the NS-VC has the same properties as given

References priv_bind::addr, gprs_ns2_vc::bind, gprs_ns2_vc_bind::driver, GPRS_NS2_VC_MODE_BLOCKRESET, gprs_ns2_vc::mode, gprs_ns2_vc::nsvci, osmo_sockaddr_cmp(), gprs_ns2_vc::priv, gprs_ns2_vc_bind::priv, priv_vc::remote, and vc_driver_ip.

◆ gprs_ns2_ip_vc_local()

const struct osmo_sockaddr * gprs_ns2_ip_vc_local ( const struct gprs_ns2_vc nsvc)

Return the socket address of the local peer of a NS-VC.

Parameters
[in]nsvcNS-VC whose local peer we want to know
Returns
address of the local peer; NULL in case of error

References priv_bind::addr, gprs_ns2_vc::bind, gprs_ns2_vc_bind::driver, gprs_ns2_vc_bind::priv, and vc_driver_ip.

◆ gprs_ns2_ip_vc_remote()

const struct osmo_sockaddr * gprs_ns2_ip_vc_remote ( const struct gprs_ns2_vc nsvc)

Return the socket address of the remote peer of a NS-VC.

Parameters
[in]nsvcNS-VC whose remote peer we want to know
Returns
address of the remote peer; NULL in case of error

References gprs_ns2_vc::bind, gprs_ns2_vc_bind::driver, gprs_ns2_vc::priv, priv_vc::remote, and vc_driver_ip.

Referenced by config_write_nsvc(), do_sns_change_weight(), do_sns_delete(), gprs_ns2_ll_str_buf(), gprs_ns2_nsvc_by_sockaddr_nse(), ns2_sns_compute_local_ep_from_binds(), and nsvc_for_bind_and_remote().

◆ gprs_ns2_is_fr_bind()

int gprs_ns2_is_fr_bind ( struct gprs_ns2_vc_bind bind)

◆ gprs_ns2_is_frgre_bind()

int gprs_ns2_is_frgre_bind ( struct gprs_ns2_vc_bind bind)

determine if given bind is for FR-GRE encapsulation.

References gprs_ns2_vc_bind::driver, and vc_driver_frgre.

◆ gprs_ns2_is_ip_bind()

◆ gprs_ns2_lltype_str()

static const char * gprs_ns2_lltype_str ( enum gprs_ns2_ll  val)
inlinestatic

Obtain a human-readable string for NS link-layer type.

References get_value_string(), and gprs_ns2_lltype_strs.

Referenced by dump_nse(), gprs_ns2_fr_connect(), ns2_create_vc(), ns2_create_vc_sns(), and ns2_ip_bind_connect().

◆ gprs_ns2_nse_sns_remote()

const struct osmo_sockaddr * gprs_ns2_nse_sns_remote ( struct gprs_ns2_nse nse)

Return the initial SNS remote socket address.

Parameters
nseNS Entity
Returns
address of the initial SNS connection; NULL in case of error

References gprs_ns2_nse::bss_sns_fi, ns2_sns_state::initial, ns2_sns_state::nse, osmo_fsm_inst::priv, and sns_endpoint::saddr.

◆ gprs_ns2_nsvc_by_sockaddr_bind()

struct gprs_ns2_vc * gprs_ns2_nsvc_by_sockaddr_bind ( struct gprs_ns2_vc_bind bind,
const struct osmo_sockaddr rem_addr 
)

Find a NS-VC by its remote socket address.

Parameters
[in]bindin which to search
[in]rem_addrremote peer socket address to search
Returns
NS-VC matching sockaddr; NULL if none found

References gprs_ns2_is_ip_bind(), llist_for_each_entry, gprs_ns2_vc_bind::nsvc, OSMO_ASSERT, osmo_sockaddr_cmp(), gprs_ns2_vc::priv, priv_vc::remote, osmo_sockaddr::sa, and osmo_sockaddr::u.

Referenced by DEFUN(), handle_nsip_recvfrom(), handle_nsip_sendto(), ns2_create_vc_sns(), ns2_ip_bind_connect(), and ns_nse_nsvc_udp_cmds().

◆ gprs_ns2_prim_str()

static const char * gprs_ns2_prim_str ( enum gprs_ns2_prim  val)
inlinestatic

Obtain a human-readable string for NS primitives.

References get_value_string(), and gprs_ns2_prim_strs.

◆ gprs_ns2_sns_add_bind()

◆ gprs_ns2_sns_add_endpoint()

◆ gprs_ns2_sns_count()

int gprs_ns2_sns_count ( struct gprs_ns2_nse nse)

gprs_ns2_sns_count

Parameters
[in]nseNS Entity whose IP-SNS endpoints shall be printed
Returns
the count of endpoints or < 0 if NSE doesn't contain sns.

References gprs_ns2_nse::bss_sns_fi, gprs_ns2_nse::dialect, GPRS_NS2_DIALECT_SNS, GPRS_NS2_LL_UDP, list, gprs_ns2_nse::ll, llist_for_each_entry, osmo_fsm_inst::priv, and ns2_sns_state::sns_endpoints.

Referenced by vty_nse_check_sns().

◆ gprs_ns2_sns_del_bind()

◆ gprs_ns2_sns_del_endpoint()

int gprs_ns2_sns_del_endpoint ( struct gprs_ns2_nse nse,
const struct osmo_sockaddr saddr 
)

◆ gprs_ns2_vty_init()