libosmogb  0.12.0.47-7c74
Osmocom Gb library
Libgb

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) More...

Files

file  gprs_ns.h
 
file  gprs_ns.c
 GPRS Networks Service (NS) messages on the Gb interface.
 

Data Structures

struct  gprs_ns_hdr
 Common header of GPRS NS. More...
 

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 CHECK_TX_RC(rc, nsvc)
 

Enumerations

enum  ns_pdu_type {
  NS_PDUT_UNITDATA = 0x00,
  NS_PDUT_RESET = 0x02,
  NS_PDUT_RESET_ACK = 0x03,
  NS_PDUT_BLOCK = 0x04,
  NS_PDUT_BLOCK_ACK = 0x05,
  NS_PDUT_UNBLOCK = 0x06,
  NS_PDUT_UNBLOCK_ACK = 0x07,
  NS_PDUT_STATUS = 0x08,
  NS_PDUT_ALIVE = 0x0a,
  NS_PDUT_ALIVE_ACK = 0x0b,
  SNS_PDUT_ACK = 0x0c,
  SNS_PDUT_ADD = 0x0d,
  SNS_PDUT_CHANGE_WEIGHT = 0x0e,
  SNS_PDUT_CONFIG = 0x0f,
  SNS_PDUT_CONFIG_ACK = 0x10,
  SNS_PDUT_DELETE = 0x11,
  SNS_PDUT_SIZE = 0x12,
  SNS_PDUT_SIZE_ACK = 0x13
}
 NS PDU Type (TS 08.16, Section 10.3.7, Table 14) More...
 
enum  ns_ctrl_ie {
  NS_IE_CAUSE = 0x00,
  NS_IE_VCI = 0x01,
  NS_IE_PDU = 0x02,
  NS_IE_BVCI = 0x03,
  NS_IE_NSEI = 0x04,
  NS_IE_IPv4_LIST = 0x05,
  NS_IE_IPv6_LIST = 0x06,
  NS_IE_MAX_NR_NSVC = 0x07,
  NS_IE_IPv4_EP_NR = 0x08,
  NS_IE_IPv6_EP_NR = 0x09,
  NS_IE_RESET_FLAG = 0x0a,
  NS_IE_IP_ADDR = 0x0b
}
 NS Control IE (TS 08.16, Section 10.3, Table 12) More...
 
enum  ns_cause {
  NS_CAUSE_TRANSIT_FAIL = 0x00,
  NS_CAUSE_OM_INTERVENTION = 0x01,
  NS_CAUSE_EQUIP_FAIL = 0x02,
  NS_CAUSE_NSVC_BLOCKED = 0x03,
  NS_CAUSE_NSVC_UNKNOWN = 0x04,
  NS_CAUSE_BVCI_UNKNOWN = 0x05,
  NS_CAUSE_SEM_INCORR_PDU = 0x08,
  NS_CAUSE_PDU_INCOMP_PSTATE = 0x0a,
  NS_CAUSE_PROTO_ERR_UNSPEC = 0x0b,
  NS_CAUSE_INVAL_ESSENT_IE = 0x0c,
  NS_CAUSE_MISSING_ESSENT_IE = 0x0d,
  NS_CAUSE_INVAL_NR_IPv4_EP = 0x0e,
  NS_CAUSE_INVAL_NR_IPv6_EP = 0x0f,
  NS_CAUSE_INVAL_NR_NS_VC = 0x10,
  NS_CAUSE_INVAL_WEIGH = 0x11,
  NS_CAUSE_UNKN_IP_EP = 0x12,
  NS_CAUSE_UNKN_IP_ADDR = 0x13,
  NS_CAUSE_UNKN_IP_TEST_FAILED = 0x14
}
 NS Cause (TS 08.16, Section 10.3.2, Table 13) More...
 
enum  ns_ctr {
  NS_CTR_PKTS_IN,
  NS_CTR_PKTS_OUT,
  NS_CTR_BYTES_IN,
  NS_CTR_BYTES_OUT,
  NS_CTR_BLOCKED,
  NS_CTR_DEAD,
  NS_CTR_REPLACED,
  NS_CTR_NSEI_CHG,
  NS_CTR_INV_VCI,
  NS_CTR_INV_NSEI,
  NS_CTR_LOST_ALIVE,
  NS_CTR_LOST_RESET
}
 
enum  ns_stat { NS_STAT_ALIVE_DELAY }
 

Functions

struct gprs_ns_hdr __attribute__ ((packed))
 
struct msgbgprs_ns_msgb_alloc (void)
 
static void ns_set_state_with_log (struct gprs_nsvc *nsvc, uint32_t state, bool is_remote, const char *file, unsigned line)
 
struct gprs_nsvcgprs_nsvc_by_nsvci (struct gprs_ns_inst *nsi, uint16_t nsvci)
 Lookup struct gprs_nsvc based on NSVCI. More...
 
struct gprs_nsvcgprs_nsvc_by_nsei (struct gprs_ns_inst *nsi, uint16_t nsei)
 Lookup struct gprs_nsvc based on NSEI. More...
 
static struct gprs_nsvcgprs_active_nsvc_by_nsei (struct gprs_ns_inst *nsi, uint16_t nsei)
 
static struct gprs_nsvcnsvc_by_rem_addr (struct gprs_ns_inst *nsi, struct sockaddr_in *sin)
 
static void gprs_ns_timer_cb (void *data)
 
struct gprs_nsvcgprs_nsvc_create (struct gprs_ns_inst *nsi, uint16_t nsvci)
 
void gprs_nsvc_delete (struct gprs_nsvc *nsvc)
 Delete given NS-VC. More...
 
static void ns_osmo_signal_dispatch (struct gprs_nsvc *nsvc, unsigned int signal, uint8_t cause)
 
static void ns_osmo_signal_dispatch_mismatch (struct gprs_nsvc *nsvc, struct msgb *msg, uint8_t pdu_type, uint8_t ie_type)
 
static void ns_osmo_signal_dispatch_replaced (struct gprs_nsvc *nsvc, struct gprs_nsvc *old_nsvc)
 
const char * gprs_ns_cause_str (enum ns_cause cause)
 Obtain a human-readable string for NS cause value. More...
 
static int nsip_sendmsg (struct gprs_nsvc *nsvc, struct msgb *msg)
 
int grps_ns_frgre_sendmsg (struct gprs_nsvc *nsvc, struct msgb *msg)
 
static int gprs_ns_tx (struct gprs_nsvc *nsvc, struct msgb *msg)
 
static int gprs_ns_tx_simple (struct gprs_nsvc *nsvc, uint8_t pdu_type)
 
int gprs_ns_tx_reset (struct gprs_nsvc *nsvc, uint8_t cause)
 Transmit a NS-RESET on a given NSVC. More...
 
int gprs_ns_tx_status (struct gprs_nsvc *nsvc, uint8_t cause, uint16_t bvci, struct msgb *orig_msg)
 Transmit a NS-STATUS on a given NSVC. More...
 
int gprs_ns_tx_block (struct gprs_nsvc *nsvc, uint8_t cause)
 Transmit a NS-BLOCK on a tiven NS-VC. More...
 
int gprs_ns_tx_unblock (struct gprs_nsvc *nsvc)
 Transmit a NS-UNBLOCK on a given NS-VC. More...
 
int gprs_ns_tx_alive (struct gprs_nsvc *nsvc)
 Transmit a NS-ALIVE on a given NS-VC. More...
 
int gprs_ns_tx_alive_ack (struct gprs_nsvc *nsvc)
 Transmit a NS-ALIVE-ACK on a given NS-VC. More...
 
static void nsvc_start_timer (struct gprs_nsvc *nsvc, enum nsvc_timer_mode mode)
 
static int nsvc_timer_elapsed_ms (struct gprs_nsvc *nsvc)
 
static int gprs_ns_tx_reset_ack (struct gprs_nsvc *nsvc)
 
int gprs_ns_sendmsg (struct gprs_ns_inst *nsi, struct msgb *msg)
 High-level function for transmitting a NS-UNITDATA messsage. More...
 
static int gprs_ns_rx_unitdata (struct gprs_nsvc *nsvc, struct msgb *msg)
 
static int gprs_ns_rx_status (struct gprs_nsvc *nsvc, struct msgb *msg)
 
static int gprs_nsvc_replace_if_found (uint16_t nsvci, struct gprs_nsvc **nsvc, struct gprs_nsvc **old_nsvc)
 
static int gprs_ns_rx_reset (struct gprs_nsvc **nsvc, struct msgb *msg)
 
static int gprs_ns_rx_reset_ack (struct gprs_nsvc **nsvc, struct msgb *msg)
 
static int gprs_ns_rx_block (struct gprs_nsvc *nsvc, struct msgb *msg)
 
int gprs_ns_vc_create (struct gprs_ns_inst *nsi, struct msgb *msg, struct gprs_nsvc *fallback_nsvc, struct gprs_nsvc **new_nsvc)
 Create/get NS-VC independently from underlying transport layer. More...
 
int gprs_ns_process_msg (struct gprs_ns_inst *nsi, struct msgb *msg, struct gprs_nsvc **nsvc)
 Process NS message independently from underlying transport layer. More...
 
int gprs_ns_rcvmsg (struct gprs_ns_inst *nsi, struct msgb *msg, struct sockaddr_in *saddr, enum gprs_ns_ll ll)
 Receive incoming NS message from underlying transport layer. More...
 
const char * gprs_ns_ll_str (const struct gprs_nsvc *nsvc)
 
void gprs_ns_ll_copy (struct gprs_nsvc *nsvc, struct gprs_nsvc *other)
 
void gprs_ns_ll_clear (struct gprs_nsvc *nsvc)
 
struct gprs_ns_instgprs_ns_instantiate (gprs_ns_cb_t *cb, void *ctx)
 Create a new GPRS NS instance. More...
 
void gprs_ns_close (struct gprs_ns_inst *nsi)
 
void gprs_ns_destroy (struct gprs_ns_inst *nsi)
 Destroy an entire NS instance. More...
 
static struct msgbread_nsip_msg (struct osmo_fd *bfd, int *error, struct sockaddr_in *saddr)
 
static int handle_nsip_read (struct osmo_fd *bfd)
 
static int handle_nsip_write (struct osmo_fd *bfd)
 
static int nsip_fd_cb (struct osmo_fd *bfd, unsigned int what)
 
int gprs_ns_nsip_listen (struct gprs_ns_inst *nsi)
 Create a listening socket for GPRS NS/UDP/IP. More...
 
int gprs_nsvc_reset (struct gprs_nsvc *nsvc, uint8_t cause)
 Initiate a RESET procedure. More...
 
struct gprs_nsvcgprs_ns_nsip_connect (struct gprs_ns_inst *nsi, struct sockaddr_in *dest, uint16_t nsei, uint16_t nsvci)
 Establish a NS connection (from the BSS) to the SGSN. More...
 
void gprs_ns_set_log_ss (int ss)
 
char * gprs_nsvc_state_append (char *s, struct gprs_nsvc *nsvc)
 Append the nsvc state to a talloc string. More...
 

Variables

uint8_t gprs_ns_hdr::pdu_type
 NS PDU type. More...
 
uint8_t gprs_ns_hdr::data [0]
 variable-length payload More...
 
uint8_t pdu_type
 NS PDU type. More...
 
uint8_t data [0]
 variable-length payload More...
 
const struct value_string gprs_ns_pdu_strings []
 
enum ns_pdu_type __attribute__
 
static const struct tlv_definition ns_att_tlvdef
 
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_ns_signal_ns_names []
 
const struct value_string gprs_ns_pdu_strings []
 
static const struct value_string ns_cause_str []
 
static enum ns_timeout timer_mode_tout [_NSVC_TIMER_NR]
 
static const struct value_string timer_mode_strs []
 

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)

Some introduction into NS: NS is used typically on top of frame relay, but in the ip.access world it is encapsulated in UDP packets. It serves as an intermediate shim betwen BSSGP and the underlying medium. It doesn't do much, apart from providing congestion notification and status indication.

Terms:

    NS              Network Service
    NSVC            NS Virtual Connection
    NSEI            NS Entity Identifier
    NSVL            NS Virtual Link
    NSVLI           NS Virtual Link Identifier
    BVC             BSSGP Virtual Connection
    BVCI            BSSGP Virtual Connection Identifier
    NSVCG           NS Virtual Connection Goup
    Blocked         NS-VC cannot be used for user traffic
    Alive           Ability of a NS-VC to provide communication

There can be multiple BSSGP virtual connections over one (group of) NSVC's. BSSGP will therefore identify the BSSGP virtual connection by a BVCI passed down to NS. NS then has to firgure out which NSVC's are responsible for this BVCI. Those mappings are administratively configured.

This implementation has the following limitations:

Macro Definition Documentation

◆ CHECK_TX_RC

#define CHECK_TX_RC (   rc,
  nsvc 
)
Value:
if (rc < 0) \
LOGP(DNS, LOGL_ERROR, "TX failed (%d) to peer %s\n", \
rc, gprs_ns_ll_str(nsvc));
const char * gprs_ns_ll_str(const struct gprs_nsvc *nsvc)
Definition: gprs_ns.c:1176
int DNS
Definition: common_vty.c:60

Referenced by gprs_ns_rx_reset(), gprs_ns_rx_reset_ack(), and gprs_ns_vc_create().

◆ ns_mark_blocked

#define ns_mark_blocked (   ns_)    ns_set_state(ns_, (ns_)->state | NSE_S_BLOCKED)

◆ ns_mark_unblocked

#define ns_mark_unblocked (   ns_)    ns_set_state(ns_, (ns_)->state & (~NSE_S_BLOCKED));

Referenced by gprs_ns_process_msg().

◆ ns_set_remote_state

#define ns_set_remote_state (   ns_,
  st_ 
)    ns_set_state_with_log(ns_, st_, true, __FILE__, __LINE__)

◆ ns_set_state

#define ns_set_state (   ns_,
  st_ 
)    ns_set_state_with_log(ns_, st_, false, __FILE__, __LINE__)

Enumeration Type Documentation

◆ ns_cause

enum ns_cause

NS Cause (TS 08.16, Section 10.3.2, Table 13)

Enumerator
NS_CAUSE_TRANSIT_FAIL 
NS_CAUSE_OM_INTERVENTION 
NS_CAUSE_EQUIP_FAIL 
NS_CAUSE_NSVC_BLOCKED 
NS_CAUSE_NSVC_UNKNOWN 
NS_CAUSE_BVCI_UNKNOWN 
NS_CAUSE_SEM_INCORR_PDU 
NS_CAUSE_PDU_INCOMP_PSTATE 
NS_CAUSE_PROTO_ERR_UNSPEC 
NS_CAUSE_INVAL_ESSENT_IE 
NS_CAUSE_MISSING_ESSENT_IE 
NS_CAUSE_INVAL_NR_IPv4_EP 
NS_CAUSE_INVAL_NR_IPv6_EP 
NS_CAUSE_INVAL_NR_NS_VC 
NS_CAUSE_INVAL_WEIGH 
NS_CAUSE_UNKN_IP_EP 
NS_CAUSE_UNKN_IP_ADDR 
NS_CAUSE_UNKN_IP_TEST_FAILED 

◆ ns_ctr

enum ns_ctr
Enumerator
NS_CTR_PKTS_IN 
NS_CTR_PKTS_OUT 
NS_CTR_BYTES_IN 
NS_CTR_BYTES_OUT 
NS_CTR_BLOCKED 
NS_CTR_DEAD 
NS_CTR_REPLACED 
NS_CTR_NSEI_CHG 
NS_CTR_INV_VCI 
NS_CTR_INV_NSEI 
NS_CTR_LOST_ALIVE 
NS_CTR_LOST_RESET 

◆ ns_ctrl_ie

enum ns_ctrl_ie

NS Control IE (TS 08.16, Section 10.3, Table 12)

Enumerator
NS_IE_CAUSE 
NS_IE_VCI 
NS_IE_PDU 
NS_IE_BVCI 
NS_IE_NSEI 
NS_IE_IPv4_LIST 
NS_IE_IPv6_LIST 
NS_IE_MAX_NR_NSVC 
NS_IE_IPv4_EP_NR 
NS_IE_IPv6_EP_NR 
NS_IE_RESET_FLAG 
NS_IE_IP_ADDR 

◆ ns_pdu_type

NS PDU Type (TS 08.16, Section 10.3.7, Table 14)

Enumerator
NS_PDUT_UNITDATA 
NS_PDUT_RESET 
NS_PDUT_RESET_ACK 
NS_PDUT_BLOCK 
NS_PDUT_BLOCK_ACK 
NS_PDUT_UNBLOCK 
NS_PDUT_UNBLOCK_ACK 
NS_PDUT_STATUS 
NS_PDUT_ALIVE 
NS_PDUT_ALIVE_ACK 
SNS_PDUT_ACK 
SNS_PDUT_ADD 
SNS_PDUT_CHANGE_WEIGHT 
SNS_PDUT_CONFIG 
SNS_PDUT_CONFIG_ACK 
SNS_PDUT_DELETE 
SNS_PDUT_SIZE 
SNS_PDUT_SIZE_ACK 

◆ ns_stat

enum ns_stat
Enumerator
NS_STAT_ALIVE_DELAY 

Function Documentation

◆ __attribute__()

struct gprs_ns_hdr __attribute__ ( (packed)  )

◆ gprs_active_nsvc_by_nsei()

static struct gprs_nsvc* gprs_active_nsvc_by_nsei ( struct gprs_ns_inst nsi,
uint16_t  nsei 
)
static

◆ gprs_ns_cause_str()

const char* gprs_ns_cause_str ( enum ns_cause  cause)

Obtain a human-readable string for NS cause value.

References get_value_string(), grps_ns_frgre_sendmsg(), and nsip_sendmsg().

Referenced by gprs_ns_rx_reset(), gprs_ns_rx_status(), gprs_ns_tx_block(), gprs_ns_tx_reset(), and gprs_ns_tx_status().

◆ gprs_ns_close()

◆ gprs_ns_destroy()

void gprs_ns_destroy ( struct gprs_ns_inst nsi)

Destroy an entire NS instance.

Parameters
nsigprs_ns_inst that is to be destroyed

This function releases all resources associated with the NS-instance.

References gprs_ns_close().

◆ gprs_ns_instantiate()

◆ gprs_ns_ll_clear()

void gprs_ns_ll_clear ( struct gprs_nsvc nsvc)

◆ gprs_ns_ll_copy()

void gprs_ns_ll_copy ( struct gprs_nsvc nsvc,
struct gprs_nsvc other 
)

◆ gprs_ns_ll_str()

◆ gprs_ns_msgb_alloc()

◆ gprs_ns_nsip_connect()

struct gprs_nsvc* gprs_ns_nsip_connect ( struct gprs_ns_inst nsi,
struct sockaddr_in *  dest,
uint16_t  nsei,
uint16_t  nsvci 
)

Establish a NS connection (from the BSS) to the SGSN.

Parameters
nsiNS-instance
[in]destDestination IP/Port
[in]nseiNSEI of the to-be-established NS-VC
[in]nsvciNSVCI of the to-be-established NS-VC
Returns
struct gprs_nsvc representing the new NS-VC

This function will establish a single NS/UDP/IP connection in uplink (BSS to SGSN) direction.

References gprs_nsvc_create(), gprs_nsvc_reset(), gprs_nsvc::ip, NS_CAUSE_OM_INTERVENTION, nsei, gprs_nsvc::nsei, nsvc_by_rem_addr(), and gprs_nsvc::remote_end_is_sgsn.

◆ gprs_ns_nsip_listen()

int gprs_ns_nsip_listen ( struct gprs_ns_inst nsi)

Create a listening socket for GPRS NS/UDP/IP.

Parameters
[in]nsiNS protocol instance to listen
Returns
>=0 (fd) in case of success, negative in case of error

A call to this function will create a UDP socket bound to the port number and IP address specified in the NS protocol instance. The file descriptor of the socket will be stored in nsi->nsip.fd.

References osmo_fd::cb, osmo_fd::data, DNS, gprs_ns_inst::dscp, osmo_fd::fd, gprs_ns_inst::fd, gprs_ns_inst::local_ip, gprs_ns_inst::local_port, LOGL_ERROR, LOGL_NOTICE, LOGP, gprs_ns_inst::nsip, nsip_fd_cb(), osmo_htonl, OSMO_SOCK_F_BIND, OSMO_SOCK_F_CONNECT, osmo_sock_init2_ofd(), osmo_sock_init_ofd(), gprs_ns_inst::remote_ip, and gprs_ns_inst::remote_port.

◆ gprs_ns_process_msg()

int gprs_ns_process_msg ( struct gprs_ns_inst nsi,
struct msgb msg,
struct gprs_nsvc **  nsvc 
)

◆ gprs_ns_rcvmsg()

int gprs_ns_rcvmsg ( struct gprs_ns_inst nsi,
struct msgb msg,
struct sockaddr_in *  saddr,
enum gprs_ns_ll  ll 
)

Receive incoming NS message from underlying transport layer.

Parameters
nsiNS instance to which the data belongs
[in]msgmessage buffer containing newly-received data
[in]saddrsocketaddr from which data was received
[in]lllink-layer type in which data was received
Returns
0 in case of success, < 0 in case of error

This is the main entry point int othe NS imlementation where frames from the underlying transport (normally UDP) enter.

References gprs_ns_process_msg(), gprs_ns_vc_create(), gprs_nsvc::ip, gprs_nsvc::ll, LOG_CTX_GB_NSVC, log_set_context(), nsvc_by_rem_addr(), and gprs_ns_inst::unknown_nsvc.

Referenced by handle_nsfrgre_read(), handle_nsip_read(), and read_nsfrgre_msg().

◆ gprs_ns_rx_block()

◆ gprs_ns_rx_reset()

◆ gprs_ns_rx_reset_ack()

◆ gprs_ns_rx_status()

static int gprs_ns_rx_status ( struct gprs_nsvc nsvc,
struct msgb msg 
)
static

◆ gprs_ns_rx_unitdata()

◆ gprs_ns_sendmsg()

int gprs_ns_sendmsg ( struct gprs_ns_inst nsi,
struct msgb msg 
)

High-level function for transmitting a NS-UNITDATA messsage.

Parameters
[in]nsiNS-instance on which we shall transmit
[in]msgstruct msgb to be trasnmitted

This function obtains the NS-VC by the msgb_nsei(msg) and then checks if the NS-VC is ALIVEV and not BLOCKED. After that, it adds a NS header for the NS-UNITDATA message type and sends it off.

Section 9.2.10: transmit side / NS-UNITDATA-REQUEST primitive

References bvci, gprs_ns_hdr::data, DNS, gprs_active_nsvc_by_nsei(), gprs_ns_tx(), gprs_nsvc_by_nsei(), msgb::l2h, LOG_CTX_GB_NSVC, log_set_context(), LOGL_ERROR, LOGP, msgb_bvci, msgb_free(), msgb_nsei, msgb_push(), NS_PDUT_UNITDATA, and gprs_ns_hdr::pdu_type.

Referenced by _bssgp_tx_dl_ud(), bssgp_tx_bvc_block(), bssgp_tx_bvc_reset(), bssgp_tx_bvc_unblock(), bssgp_tx_fc_bvc(), bssgp_tx_fc_bvc_ack(), bssgp_tx_fc_ms(), bssgp_tx_flush_ll_ack(), bssgp_tx_llc_discarded(), bssgp_tx_paging(), bssgp_tx_ra_capa_upd(), bssgp_tx_resume(), bssgp_tx_resume_ack(), bssgp_tx_resume_nack(), bssgp_tx_simple_bvci(), bssgp_tx_status(), bssgp_tx_suspend(), bssgp_tx_suspend_ack(), bssgp_tx_suspend_nack(), bssgp_tx_ul_ud(), and common_tx_radio_status2().

◆ gprs_ns_set_log_ss()

void gprs_ns_set_log_ss ( int  ss)

References DNS.

◆ gprs_ns_timer_cb()

◆ gprs_ns_tx()

◆ gprs_ns_tx_alive()

int gprs_ns_tx_alive ( struct gprs_nsvc nsvc)

Transmit a NS-ALIVE on a given NS-VC.

Parameters
[in]nsvcNS-VC on which the NS-ALIVE is to be transmitted
Returns
0 in case of success

References DNS, gprs_ns_tx_simple(), LOG_CTX_GB_NSVC, log_set_context(), LOGL_DEBUG, LOGP, NS_PDUT_ALIVE, gprs_nsvc::nsei, and gprs_nsvc::nsvci.

Referenced by gprs_ns_timer_cb().

◆ gprs_ns_tx_alive_ack()

int gprs_ns_tx_alive_ack ( struct gprs_nsvc nsvc)

Transmit a NS-ALIVE-ACK on a given NS-VC.

Parameters
[in]nsvcNS-VC on which the NS-ALIVE-ACK is to be transmitted
Returns
0 in case of success

References DNS, gprs_ns_tx_simple(), LOG_CTX_GB_NSVC, log_set_context(), LOGL_DEBUG, LOGP, NS_PDUT_ALIVE_ACK, gprs_nsvc::nsei, and gprs_nsvc::nsvci.

Referenced by gprs_ns_process_msg().

◆ gprs_ns_tx_block()

int gprs_ns_tx_block ( struct gprs_nsvc nsvc,
uint8_t  cause 
)

Transmit a NS-BLOCK on a tiven NS-VC.

Parameters
[in]nsvcNS-VC on which the NS-BLOCK is to be transmitted
[in]causeNumeric NS Cause value
Returns
0 in case of success

References rate_ctr_group::ctr, gprs_nsvc::ctrg, DNS, gprs_ns_cause_str(), gprs_ns_msgb_alloc(), gprs_ns_tx(), msgb::l2h, LOG_CTX_GB_NSVC, log_set_context(), LOGL_INFO, LOGP, msgb_put(), NS_CTR_BLOCKED, NS_IE_CAUSE, NS_IE_VCI, ns_mark_blocked, NS_PDUT_BLOCK, gprs_nsvc::nsei, gprs_nsvc::nsvci, osmo_htons, gprs_ns_hdr::pdu_type, and rate_ctr_inc().

Referenced by DEFUN().

◆ gprs_ns_tx_reset()

int gprs_ns_tx_reset ( struct gprs_nsvc nsvc,
uint8_t  cause 
)

Transmit a NS-RESET on a given NSVC.

Parameters
[in]nsvcNS-VC used for transmission [in] cause Numeric NS cause value

References DNS, gprs_ns_cause_str(), gprs_ns_msgb_alloc(), gprs_ns_tx(), msgb::l2h, LOG_CTX_GB_NSVC, log_set_context(), LOGL_INFO, LOGP, msgb_put(), NS_IE_CAUSE, NS_IE_NSEI, NS_IE_VCI, NS_PDUT_RESET, nsei, gprs_nsvc::nsei, gprs_nsvc::nsvci, osmo_htons, and gprs_ns_hdr::pdu_type.

Referenced by gprs_ns_timer_cb(), and gprs_nsvc_reset().

◆ gprs_ns_tx_reset_ack()

◆ gprs_ns_tx_simple()

◆ gprs_ns_tx_status()

int gprs_ns_tx_status ( struct gprs_nsvc nsvc,
uint8_t  cause,
uint16_t  bvci,
struct msgb orig_msg 
)

◆ gprs_ns_tx_unblock()

int gprs_ns_tx_unblock ( struct gprs_nsvc nsvc)

Transmit a NS-UNBLOCK on a given NS-VC.

Parameters
[in]nsvcNS-VC on which the NS-UNBLOCK is to be transmitted
Returns
0 in case of success

References DNS, gprs_ns_tx_simple(), LOG_CTX_GB_NSVC, log_set_context(), LOGL_INFO, LOGP, NS_PDUT_UNBLOCK, gprs_nsvc::nsei, and gprs_nsvc::nsvci.

Referenced by DEFUN(), and gprs_ns_process_msg().

◆ gprs_ns_vc_create()

int gprs_ns_vc_create ( struct gprs_ns_inst nsi,
struct msgb msg,
struct gprs_nsvc fallback_nsvc,
struct gprs_nsvc **  new_nsvc 
)

Create/get NS-VC independently from underlying transport layer.

Parameters
nsiNS instance to which the data belongs
[in]msgmessage buffer containing newly-received data
[in]fallback_nsvcis used to send error messages back to the peer and to initialise the ll info of a created NS-VC object
[out]new_nsvccontains a pointer to a NS-VC object if one has been created or found
Returns
< 0 in case of error, GPRS_NS_CS_SKIPPED if a message has been skipped, GPRS_NS_CS_REJECTED if a message has been rejected and answered accordingly, GPRS_NS_CS_CREATED if a new NS-VC object has been created and registered, and GPRS_NS_CS_FOUND if an existing NS-VC object has been found with the same NSEI.

This contains the initial NS automaton state (NS-VC not yet attached).

References CHECK_TX_RC, gprs_ns_hdr::data, DNS, get_value_string(), GPRS_NS_CS_CREATED, GPRS_NS_CS_FOUND, GPRS_NS_CS_REJECTED, GPRS_NS_CS_SKIPPED, gprs_ns_ll_copy(), gprs_ns_ll_str(), gprs_ns_tx_status(), gprs_nsvc_by_nsvci(), gprs_nsvc_create(), msgb::l2h, LOG_CTX_GB_NSVC, log_set_context(), LOGL_ERROR, LOGL_INFO, LOGL_NOTICE, LOGP, msgb_l2len(), ns_att_tlvdef, NS_CAUSE_MISSING_ESSENT_IE, NS_CAUSE_PDU_INCOMP_PSTATE, NS_CTR_NSEI_CHG, NS_IE_CAUSE, NS_IE_NSEI, NS_IE_VCI, NS_PDUT_ALIVE_ACK, NS_PDUT_RESET, NS_PDUT_RESET_ACK, NS_PDUT_STATUS, ns_set_state, NSE_S_ALIVE, nsei, gprs_nsvc::nsei, gprs_nsvc::nsvci, gprs_nsvc::nsvci_is_valid, gprs_ns_hdr::pdu_type, and rate_ctr_inc().

Referenced by gprs_ns_rcvmsg(), and gprs_ns_rx_block().

◆ gprs_nsvc_by_nsei()

struct gprs_nsvc* gprs_nsvc_by_nsei ( struct gprs_ns_inst nsi,
uint16_t  nsei 
)

Lookup struct gprs_nsvc based on NSEI.

Parameters
[in]nsiNS instance in which to search
[in]nseiNSEI to be searched
Returns
first gprs_nsvc of respective NSEI

References gprs_ns_inst::gprs_nsvcs, gprs_nsvc::list, llist_for_each_entry, and gprs_nsvc::nsei.

Referenced by DEFUN(), and gprs_ns_sendmsg().

◆ gprs_nsvc_by_nsvci()

struct gprs_nsvc* gprs_nsvc_by_nsvci ( struct gprs_ns_inst nsi,
uint16_t  nsvci 
)

Lookup struct gprs_nsvc based on NSVCI.

Parameters
[in]nsiNS instance in which to search
[in]nsvciNSVCI to be searched
Returns
gprs_nsvc of respective NSVCI

References gprs_ns_inst::gprs_nsvcs, gprs_nsvc::list, llist_for_each_entry, and gprs_nsvc::nsvci.

Referenced by DEFUN(), gprs_ns_vc_create(), and gprs_nsvc_replace_if_found().

◆ gprs_nsvc_create()

◆ gprs_nsvc_delete()

void gprs_nsvc_delete ( struct gprs_nsvc nsvc)

◆ gprs_nsvc_replace_if_found()

static int gprs_nsvc_replace_if_found ( uint16_t  nsvci,
struct gprs_nsvc **  nsvc,
struct gprs_nsvc **  old_nsvc 
)
static

◆ gprs_nsvc_reset()

int gprs_nsvc_reset ( struct gprs_nsvc nsvc,
uint8_t  cause 
)

Initiate a RESET procedure.

Parameters
[in]nsvcNS-VC in which to start the procedure
[in]causeNumeric NS cause value

This is a high-level function initiating a NS-RESET procedure. It will not only send a NS-RESET, but also set the state to BLOCKED and start the Tns-reset timer.

References DNS, gprs_ns_tx_reset(), LOGL_ERROR, LOGL_INFO, LOGP, ns_set_state, NSE_S_BLOCKED, NSE_S_RESET, gprs_nsvc::nsei, nsvc_start_timer(), and NSVC_TIMER_TNS_RESET.

Referenced by DEFUN(), gprs_ns_nsip_connect(), and gprs_ns_process_msg().

◆ gprs_nsvc_state_append()

char* gprs_nsvc_state_append ( char *  s,
struct gprs_nsvc nsvc 
)

Append the nsvc state to a talloc string.

Parameters
sThe string to append to (allocated with talloc)
[in]nsvcThe NS-VC to print the state of
Returns
The new string with state information appended to it

This function will append a comma-separated state of the NS-VC to the string. The string needs to be allocated with talloc (e.g. talloc_strdup)

References NS_DESC_A, NS_DESC_B, gprs_nsvc::nsei, gprs_nsvc::nsvci, gprs_nsvc::remote_end_is_sgsn, gprs_nsvc::remote_state, and gprs_nsvc::state.

◆ grps_ns_frgre_sendmsg()

int grps_ns_frgre_sendmsg ( struct gprs_nsvc nsvc,
struct msgb msg 
)

Referenced by gprs_ns_cause_str().

◆ handle_nsip_read()

static int handle_nsip_read ( struct osmo_fd bfd)
static

◆ handle_nsip_write()

static int handle_nsip_write ( struct osmo_fd bfd)
static

Referenced by nsip_fd_cb().

◆ ns_osmo_signal_dispatch()

static void ns_osmo_signal_dispatch ( struct gprs_nsvc nsvc,
unsigned int  signal,
uint8_t  cause 
)
static

◆ ns_osmo_signal_dispatch_mismatch()

static void ns_osmo_signal_dispatch_mismatch ( struct gprs_nsvc nsvc,
struct msgb msg,
uint8_t  pdu_type,
uint8_t  ie_type 
)
static

◆ ns_osmo_signal_dispatch_replaced()

static void ns_osmo_signal_dispatch_replaced ( struct gprs_nsvc nsvc,
struct gprs_nsvc old_nsvc 
)
static

◆ ns_set_state_with_log()

static void ns_set_state_with_log ( struct gprs_nsvc nsvc,
uint32_t  state,
bool  is_remote,
const char *  file,
unsigned  line 
)
inlinestatic

◆ nsip_fd_cb()

static int nsip_fd_cb ( struct osmo_fd bfd,
unsigned int  what 
)
static

◆ nsip_sendmsg()

static int nsip_sendmsg ( struct gprs_nsvc nsvc,
struct msgb msg 
)
static

◆ nsvc_by_rem_addr()

static struct gprs_nsvc* nsvc_by_rem_addr ( struct gprs_ns_inst nsi,
struct sockaddr_in *  sin 
)
static

◆ nsvc_start_timer()

◆ nsvc_timer_elapsed_ms()

static int nsvc_timer_elapsed_ms ( struct gprs_nsvc nsvc)
static

◆ read_nsip_msg()

static struct msgb* read_nsip_msg ( struct osmo_fd bfd,
int *  error,
struct sockaddr_in *  saddr 
)
static

Variable Documentation

◆ __attribute__

enum ns_pdu_type __attribute__

◆ data [1/2]

◆ data [2/2]

uint8_t data[0]

variable-length payload

Referenced by fc_timer_cb(), gprs_ns_timer_cb(), and nsvc_by_rem_addr().

◆ gprs_ns_pdu_strings [1/2]

const struct value_string gprs_ns_pdu_strings[]

◆ gprs_ns_pdu_strings [2/2]

const struct value_string gprs_ns_pdu_strings[]
Initial value:
= {
{ NS_PDUT_UNITDATA, "NS-UNITDATA" },
{ NS_PDUT_RESET, "NS-RESET" },
{ NS_PDUT_RESET_ACK, "NS-RESET-ACK" },
{ NS_PDUT_BLOCK, "NS-BLOCK" },
{ NS_PDUT_BLOCK_ACK, "NS-BLOCK-ACK" },
{ NS_PDUT_UNBLOCK, "NS-UNBLOCK" },
{ NS_PDUT_UNBLOCK_ACK, "NS-UNBLOCK-ACK" },
{ NS_PDUT_STATUS, "NS-STATUS" },
{ NS_PDUT_ALIVE, "NS-ALIVE" },
{ NS_PDUT_ALIVE_ACK, "NS-ALIVE-ACK" },
{ SNS_PDUT_ACK, "SNS-ACK" },
{ SNS_PDUT_ADD, "SNS-ADD" },
{ SNS_PDUT_CHANGE_WEIGHT, "SNS-CHANGEWEIGHT" },
{ SNS_PDUT_CONFIG, "SNS-CONFIG" },
{ SNS_PDUT_CONFIG_ACK, "SNS-CONFIG-ACK" },
{ SNS_PDUT_DELETE, "SNS-DELETE" },
{ SNS_PDUT_SIZE, "SNS-SIZE" },
{ SNS_PDUT_SIZE_ACK, "SNS-SIZE-ACK" },
{ 0, NULL }
}
Definition: gsm_08_16.h:37
Definition: gsm_08_16.h:33
Definition: gsm_08_16.h:40
Definition: gsm_08_16.h:30
Definition: gsm_08_16.h:32
Definition: gsm_08_16.h:27
Definition: gsm_08_16.h:26
Definition: gsm_08_16.h:31
Definition: gsm_08_16.h:25
Definition: gsm_08_16.h:39
Definition: gsm_08_16.h:36
Definition: gsm_08_16.h:42
Definition: gsm_08_16.h:28
Definition: gsm_08_16.h:41
Definition: gsm_08_16.h:24
Definition: gsm_08_16.h:35
Definition: gsm_08_16.h:38
Definition: gsm_08_16.h:29

◆ gprs_ns_signal_ns_names

const struct value_string gprs_ns_signal_ns_names[]
Initial value:
= {
{ S_NS_RESET, "NS-RESET" },
{ S_NS_BLOCK, "NS-BLOCK" },
{ S_NS_UNBLOCK, "NS-UNBLOCK" },
{ S_NS_ALIVE_EXP, "NS-ALIVE expired" },
{ S_NS_REPLACED, "NSVC replaced" },
{ S_NS_MISMATCH, "Unexpected IE" },
{ 0, NULL }
}
Definition: gprs_ns.h:213
Definition: gprs_ns.h:211
Definition: gprs_ns.h:209
Definition: gprs_ns.h:208
Definition: gprs_ns.h:210
Definition: gprs_ns.h:212

◆ ns_att_tlvdef

const struct tlv_definition ns_att_tlvdef
static
Initial value:
= {
.def = {
[NS_IE_CAUSE] = { TLV_TYPE_TvLV, 0 },
[NS_IE_VCI] = { TLV_TYPE_TvLV, 0 },
[NS_IE_PDU] = { TLV_TYPE_TvLV, 0 },
[NS_IE_BVCI] = { TLV_TYPE_TvLV, 0 },
[NS_IE_NSEI] = { TLV_TYPE_TvLV, 0 },
},
}
Definition: gsm_08_16.h:51
Definition: gsm_08_16.h:47
Definition: gsm_08_16.h:50
Definition: gsm_08_16.h:49
Definition: gsm_08_16.h:48

Referenced by gprs_ns_rx_block(), gprs_ns_rx_reset(), gprs_ns_rx_reset_ack(), gprs_ns_rx_status(), and gprs_ns_vc_create().

◆ ns_cause_str

const struct value_string ns_cause_str[]
static
Initial value:
= {
{ NS_CAUSE_TRANSIT_FAIL, "Transit network failure" },
{ NS_CAUSE_OM_INTERVENTION, "O&M intervention" },
{ NS_CAUSE_EQUIP_FAIL, "Equipment failure" },
{ NS_CAUSE_NSVC_BLOCKED, "NS-VC blocked" },
{ NS_CAUSE_NSVC_UNKNOWN, "NS-VC unknown" },
{ NS_CAUSE_BVCI_UNKNOWN, "BVCI unknown" },
{ NS_CAUSE_SEM_INCORR_PDU, "Semantically incorrect PDU" },
{ NS_CAUSE_PDU_INCOMP_PSTATE, "PDU not compatible with protocol state" },
{ NS_CAUSE_PROTO_ERR_UNSPEC, "Protocol error, unspecified" },
{ NS_CAUSE_INVAL_ESSENT_IE, "Invalid essential IE" },
{ NS_CAUSE_MISSING_ESSENT_IE, "Missing essential IE" },
{ 0, NULL }
}
Definition: gsm_08_16.h:70
Definition: gsm_08_16.h:74
Definition: gsm_08_16.h:68
Definition: gsm_08_16.h:66
Definition: gsm_08_16.h:64
Definition: gsm_08_16.h:69
Definition: gsm_08_16.h:65
Definition: gsm_08_16.h:67
Definition: gsm_08_16.h:71
Definition: gsm_08_16.h:73
Definition: gsm_08_16.h:72

◆ nsvc_ctr_description

const struct rate_ctr_desc nsvc_ctr_description[]
static
Initial value:
= {
{ "packets:in", "Packets at NS Level ( In)" },
{ "packets:out","Packets at NS Level (Out)" },
{ "bytes:in", "Bytes at NS Level ( In)" },
{ "bytes:out", "Bytes at NS Level (Out)" },
{ "blocked", "NS-VC Block count " },
{ "dead", "NS-VC gone dead count " },
{ "replaced", "NS-VC replaced other count" },
{ "nsei-chg", "NS-VC changed NSEI count " },
{ "inv-nsvci", "NS-VCI was invalid count " },
{ "inv-nsei", "NSEI was invalid count " },
{ "lost:alive", "ALIVE ACK missing count " },
{ "lost:reset", "RESET ACK missing count " },
}

◆ nsvc_ctrg_desc

const struct rate_ctr_group_desc nsvc_ctrg_desc
static
Initial value:
= {
.group_name_prefix = "ns:nsvc",
.group_description = "NSVC Peer Statistics",
.ctr_desc = nsvc_ctr_description,
.class_id = OSMO_STATS_CLASS_PEER,
}
static const struct rate_ctr_desc nsvc_ctr_description[]
Definition: gprs_ns.c:120
OSMO_STATS_CLASS_PEER
#define ARRAY_SIZE(x)

◆ nsvc_stat_description

const struct osmo_stat_item_desc nsvc_stat_description[]
static
Initial value:
= {
{ "alive.delay", "ALIVE response time ", "ms", 16, 0 },
}

◆ nsvc_statg_desc

const struct osmo_stat_item_group_desc nsvc_statg_desc
static
Initial value:
= {
.group_name_prefix = "ns.nsvc",
.group_description = "NSVC Peer Statistics",
.item_desc = nsvc_stat_description,
.class_id = OSMO_STATS_CLASS_PEER,
}
OSMO_STATS_CLASS_PEER
static const struct osmo_stat_item_desc nsvc_stat_description[]
Definition: gprs_ns.c:147
#define ARRAY_SIZE(x)

◆ pdu_type [1/2]

◆ pdu_type [2/2]

◆ timer_mode_strs

const struct value_string timer_mode_strs[]
static
Initial value:
= {
{ NSVC_TIMER_TNS_RESET, "tns-reset" },
{ NSVC_TIMER_TNS_ALIVE, "tns-alive" },
{ NSVC_TIMER_TNS_TEST, "tns-test" },
{ 0, NULL }
}
Definition: gprs_ns.h:109
Definition: gprs_ns.h:111
Definition: gprs_ns.h:110

◆ timer_mode_tout

enum ns_timeout timer_mode_tout[_NSVC_TIMER_NR]
static
Initial value:
= {
}
Definition: gprs_ns.h:109
Definition: gprs_ns.h:111
Definition: gprs_ns.h:110
Definition: gprs_ns.h:37
Definition: gprs_ns.h:35
Definition: gprs_ns.h:38

Referenced by gprs_ns_timer_cb(), and nsvc_start_timer().