libosmogb 1.13.1.1-afb4 Osmocom Gb library

Data Structures | Typedefs | Enumerations | Functions | Variables
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_inst * | gprs_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_nse * | gprs_ns2_nse_by_nsei (struct gprs_ns2_inst *nsi, uint16_t nsei)
| Resolve a NS Entity based on its NSEI. More...
struct gprs_ns2_nse * | gprs_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_nse * | gprs_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_vc * | gprs_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_bind * | gprs_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_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. More...
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. 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_vc * | gprs_ns2_fr_nsvc_by_dlci (struct gprs_ns2_vc_bind *bind, uint16_t dlci)
| Return the nsvc by dlci. More...
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. More...
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. More...
struct gprs_ns2_vc * | gprs_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_vc * | gprs_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_vc * | gprs_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_sockaddr * | gprs_ns2_nse_sns_remote (struct gprs_ns2_nse *nse)
| Return the initial SNS remote socket address. More...
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. More...
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. 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_sockaddr * | gprs_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_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. 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_vc * | gprs_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

enum 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

enum 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

enum 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

enum 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

enum 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

enum 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

enum 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 | ) |
| inline static

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 | ) |
| inline static

Obtain a human-readable string for NS primitives.

References get_value_string(), and gprs_ns2_cause_strs.

Referenced by ns2_sns_st_bss_config_bss(), ns2_sns_st_bss_size(), ns2_sns_st_sgsn_wait_config_ack(), ns2_tx_block(), ns2_tx_reset(), ns2_tx_sns_ack(), ns2_tx_sns_config_ack(), ns2_tx_sns_size_ack(), ns2_tx_status(), and reject_status_msg().

## ◆ 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
| ) |  |

Create a new bind for NS over FR.

Parameters

  [in] | nsi | NS instance in which to create the bind
  [in] | netif | Network interface to bind to
  [in] | fr_network |
  [in] | fr_role |
  [out] | result | pointer 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::backlog, osmo_fr_link::cb_data, devname2ifindex(), gprs_ns2_vc_bind::driver, dump_vty(), gprs_ns2_vc_bind::dump_vty, osmo_fd::fd, fr_backlog_timer_cb(), fr_netif_ofd_cb(), fr_tx_cb(), fr_vc_sendmsg(), FRAME_RELAY_SDU, free_vc(), gprs_ns2_vc_bind::free_vc, gprs_n2_fr_ifupdown_ind_cb(), gprs_n2_fr_mtu_chg_cb(), gprs_ns2_bind_by_name(), gprs_ns2_free_bind(), GPRS_NS2_LL_FR, priv_bind::ifindex, INIT_LLIST_HEAD, priv_bind::link, priv_bind::list, gprs_ns2_vc_bind::ll, LOGBIND, LOGL_ERROR, gprs_ns2_vc_bind::mtu, name, priv_bind::netdev, priv_bind::netif, ns2_bind_alloc(), priv_bind::ofd, open_socket(), OSMO_FD_READ, osmo_fd_register(), osmo_fd_setup(), osmo_fr_link_alloc(), osmo_fr_link_free(), osmo_netdev_alloc(), osmo_netdev_free(), osmo_netdev_register(), osmo_netdev_set_ifindex(), osmo_netdev_set_ifupdown_ind_cb(), osmo_netdev_set_mtu_chg_cb(), osmo_netdev_set_priv_data(), OSMO_STRLCPY_ARRAY, osmo_timer_setup(), gprs_ns2_vc_bind::priv, priv_bind::retry_us, gprs_ns2_vc_bind::send_vc, setup_device(), priv_bind::timer, gprs_ns2_vc_bind::transfer_capability, osmo_fr_link::tx_cb, and vc_driver_fr.

Referenced by DEFUN().

## ◆ 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] | nsi | NS instance
  [in] | netif | the 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] | bind | The 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] | bind | The 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] | bind | bind in which the new NS-VC is to be created
  [in] | nsei | NSEI of the NS Entity in which the NS-VC is to be created
  [in] | dlci | Data 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] | bind | bind in which the new NS-VC is to be created
  [in] | nsei | NSEI of the NS Entity in which the NS-VC is to be created
  [in] | dlci | Data 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] | dlci | Data 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] | nsi | NS instance in which to create the bind
  [in] | local | local address on which to bind
  [in] | dscp | DSCP/TOS bits to use for transmitted data on this bind
  [out] | result | pointer 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
| ) |  |

Bind to an IPv4/IPv6 address.

Parameters

  [in] | nsi | NS Instance in which to create the NSVC
  [in] | local | the local address to bind to
  [in] | dscp | the DSCP/TOS bits used for transmitted data
  [out] | result | pointer 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, gprs_ns2_vc_bind::driver, priv_bind::dscp, dump_vty(), gprs_ns2_vc_bind::dump_vty, free_vc(), gprs_ns2_vc_bind::free_vc, gprs_ns2_free_bind(), gprs_ns2_ip_bind_by_sockaddr(), GPRS_NS2_LL_UDP, handle_nsip_recvfrom(), handle_nsip_sendto(), priv_bind::iofd, gprs_ns2_vc_bind::ll, gprs_ns2_vc_bind::mtu, name, ns2_bind_alloc(), nsip_vc_sendmsg(), OSMO_IO_FD_MODE_RECVFROM_SENDTO, osmo_iofd_register(), osmo_iofd_set_alloc_info(), osmo_iofd_set_txqueue_max_length(), osmo_iofd_setup(), OSMO_SOCK_F_BIND, OSMO_SOCK_F_DSCP, osmo_sock_init_osa(), gprs_ns2_vc_bind::priv, osmo_sockaddr::sa, gprs_ns2_vc_bind::send_vc, osmo_io_ops::sendto_cb, gprs_ns2_vc_bind::transfer_capability, gprs_ns2_inst::txqueue_max_length, osmo_sockaddr::u, and vc_driver_ip.

Referenced by DEFUN().

## ◆ 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] | nsi | NS instance
  [in] | sockaddr | socket 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
| ) |  |

Set the socket priority of the given bind.

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

Referenced by DEFUN().

## ◆ 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] | signalling | the signalling weight
  [in] | data | the 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()

const struct osmo_sockaddr * gprs_ns2_ip_bind_sockaddr | ( | struct gprs_ns2_vc_bind * | bind | ) |

Return the locally bound socket address of the bind.

Parameters

  [in] | bind | The bind whose local address we want to know

Returns
  address of the local bind

References priv_bind::addr, gprs_ns2_is_ip_bind(), OSMO_ASSERT, and gprs_ns2_vc_bind::priv.

Referenced by config_write_vbind(), gprs_ns2_ip_bind_by_sockaddr(), gprs_ns2_ll_str_buf(), ns2_add_procedure(), ns2_create_vc(), ns2_get_sbind_ip4_entry(), ns2_get_sbind_ip6_entry(), ns2_ip_bind_connect(), ns2_ip_count_bind(), ns2_ip_get_bind_by_index(), ns2_sns_add_elements(), ns2_sns_bss_valid_configuration(), ns2_sns_compute_local_ep_from_binds(), ns2_sns_count_num_local_ep(), ns2_sns_update_weights(), and remove_bind_elem().

## ◆ 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] | nsvc | NS-VC to compare with
  [in] | local | The local address
  [in] | remote | The remote address
  [in] | nsvci | NS-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] | nsvc | NS-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] | nsvc | NS-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 | ) |

determine if given bind is for FR-GRE encapsulation.

References gprs_ns2_vc_bind::driver, and vc_driver_fr.

Referenced by fr_alloc_vc(), free_bind(), free_vc(), gprs_ns2_find_vc_by_dlci(), gprs_ns2_fr_bind_by_netif(), gprs_ns2_fr_connect(), gprs_ns2_fr_connect2(), and gprs_ns2_fr_nsvc_by_dlci().

## ◆ 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()

int gprs_ns2_is_ip_bind | ( | struct gprs_ns2_vc_bind * | bind | ) |

Is the given bind an IP bind?

References gprs_ns2_vc_bind::driver, and vc_driver_ip.

Referenced by DEFUN(), free_bind(), free_vc(), gprs_ns2_free_bind(), gprs_ns2_ip_bind_by_sockaddr(), gprs_ns2_ip_bind_set_dscp(), gprs_ns2_ip_bind_set_priority(), gprs_ns2_ip_bind_set_sns_weight(), gprs_ns2_ip_bind_sockaddr(), gprs_ns2_ll_str_buf(), gprs_ns2_nsvc_by_sockaddr_bind(), gprs_ns2_sns_add_bind(), ns2_ip_bind_connect(), ns2_ip_count_bind(), ns2_ip_get_bind_by_index(), and ns2_ip_set_txqueue_max_length().

## ◆ gprs_ns2_lltype_str()

static const char * gprs_ns2_lltype_str | ( | enum gprs_ns2_ll | val | ) |
| inline static

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

  nse | NS 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] | bind | in which to search
  [in] | rem_addr | remote 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 | ) |
| inline static

Obtain a human-readable string for NS primitives.

References get_value_string(), and gprs_ns2_prim_strs.

## ◆ gprs_ns2_sns_add_bind()

int gprs_ns2_sns_add_bind | ( | struct gprs_ns2_nse * | nse,
|  | struct gprs_ns2_vc_bind * | bind
| ) |  |

References ns2_sns_bind::bind, ns2_sns_state::binds, gprs_ns2_nse::bss_sns_fi, gprs_ns2_is_ip_bind(), list, ns2_sns_bind::list, llist_add_tail(), llist_empty(), llist_for_each_entry, NS2_SNS_EV_REQ_ADD_BIND, OSMO_ASSERT, osmo_fsm_inst_dispatch, and osmo_fsm_inst::priv.

Referenced by DEFUN(), ns2_create_vc_sns(), and ns2_sns_add_sns_default_binds().

## ◆ gprs_ns2_sns_add_endpoint()

int gprs_ns2_sns_add_endpoint | ( | struct gprs_ns2_nse * | nse,
|  | const struct osmo_sockaddr * | saddr
| ) |  |

gprs_ns2_sns_add_endpoint

Parameters

  [in] | nse |
  [in] | sockaddr |

Returns

References gprs_ns2_nse::bss_sns_fi, gprs_ns2_nse::dialect, GPRS_NS2_DIALECT_SNS, GPRS_NS2_LL_UDP, sns_endpoint::list, gprs_ns2_nse::ll, llist_add_tail(), llist_empty(), ns2_get_sns_endpoint(), NS2_SNS_EV_REQ_SELECT_ENDPOINT, osmo_fsm_inst_dispatch, osmo_fsm_inst::priv, sns_endpoint::saddr, and ns2_sns_state::sns_endpoints.

Referenced by DEFUN().

## ◆ gprs_ns2_sns_count()

int gprs_ns2_sns_count | ( | struct gprs_ns2_nse * | nse | ) |

gprs_ns2_sns_count

Parameters

  [in] | nse | NS 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()

int gprs_ns2_sns_del_bind | ( | struct gprs_ns2_nse * | nse,
|  | struct gprs_ns2_vc_bind * | bind
| ) |  |

References ns2_sns_bind::bind, ns2_sns_state::binds, gprs_ns2_nse::bss_sns_fi, ns2_sns_state::initial_bind, list, ns2_sns_bind::list, llist_del(), llist_entry, llist_for_each_entry_safe, NS2_SNS_EV_REQ_DELETE_BIND, osmo_fsm_inst_dispatch, llist_head::prev, and osmo_fsm_inst::priv.

Referenced by DEFUN(), and gprs_ns2_free_bind().

## ◆ gprs_ns2_sns_del_endpoint()

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

gprs_ns2_sns_del_endpoint

Parameters

  [in] | nse |
  [in] | sockaddr |

Returns
  0 on success, otherwise < 0

References gprs_ns2_nse::bss_sns_fi, gprs_ns2_nse::dialect, GPRS_NS2_DIALECT_SNS, gprs_ns2_free_nsvcs(), GPRS_NS2_LL_UDP, ns2_sns_state::initial, list, sns_endpoint::list, gprs_ns2_nse::ll, llist_del(), llist_entry, LOGL_INFO, LOGNSE, llist_head::next, ns2_get_sns_endpoint(), llist_head::prev, osmo_fsm_inst::priv, sns_endpoint::saddr, and ns2_sns_state::sns_endpoints.

Referenced by DEFUN().

## ◆ gprs_ns2_vty_init()

int gprs_ns2_vty_init | ( | struct gprs_ns2_inst * | nsi | ) |

References gprs_ns2_vty_init_reduced(), install_lib_element(), install_node(), L_NS_BIND_NODE, L_NS_NODE, L_NS_NSE_NODE, ns_bind_node, and ns_nse_node.