Loading...
Searching...
No Matches
gprs_ns2_internal.h File Reference
`#include <stdbool.h>`
`#include <stdint.h>`
`#include <osmocom/core/logging.h>`
`#include <osmocom/core/rate_ctr.h>`
`#include <osmocom/gprs/protocol/gsm_08_16.h>`
`#include <osmocom/gprs/gprs_ns2.h>`

Go to the source code of this file.

## Data Structures

struct | gprs_ns2_inst
| An instance of the NS protocol stack. More...
struct | gprs_ns2_nse
| Structure repesenting a NSE. More...
struct | gprs_ns2_vc
| Structure representing a single NS-VC. More...
struct | gprs_ns2_vc_bind
| Structure repesenting a bind instance. More...
struct | gprs_ns2_vc_driver

## Macros

#define | LOGNSE(nse, lvl, fmt, args ...)
#define | LOGBIND(bind, lvl, fmt, args ...)
#define | LOGNSVC_SS(ss, nsvc, lvl, fmt, args ...)
#define | LOGNSVC(nsvc, lvl, fmt, args ...)
#define | LOG_NS_SIGNAL(nsvc, direction, pdu_type, lvl, fmt, args ...)
#define | LOG_NS_DATA(nsvc, direction, pdu_type, lvl, fmt, args ...)
#define | LOG_NS_RX_SIGNAL(nsvc, pdu_type)
#define | LOG_NS_TX_SIGNAL(nsvc, pdu_type)
#define | RATE_CTR_INC_NS(nsvc, ctr)
#define | RATE_CTR_ADD_NS(nsvc, ctr, val)
#define | NS_TIMERS_COUNT 11
#define | TNS_BLOCK_STR "tns-block"
#define | TNS_BLOCK_RETRIES_STR "tns-block-retries"
#define | TNS_RESET_STR "tns-reset"
#define | TNS_RESET_RETRIES_STR "tns-reset-retries"
#define | TNS_TEST_STR "tns-test"
#define | TNS_ALIVE_STR "tns-alive"
#define | TNS_ALIVE_RETRIES_STR "tns-alive-retries"
#define | TSNS_PROV_STR "tsns-prov"
#define | TSNS_SIZE_RETRIES_STR "tsns-size-retries"
#define | TSNS_CONFIG_RETRIES_STR "tsns-config-retries"
#define | TSNS_PROCEDURES_RETRIES_STR "tsns-procedures-retries"
#define | NS_TIMERS
#define | NS_TIMERS_HELP
#define | NS_ALLOC_SIZE 3072
#define | NS_ALLOC_HEADROOM 20
#define | NS_DEFAULT_TXQUEUE_MAX_LENGTH 128
#define | NSE_S_BLOCKED 0x0001
#define | NSE_S_ALIVE 0x0002
#define | NSE_S_RESET 0x0004
#define | NS_DESC_B(st)
#define | NS_DESC_A(st)
#define | NS_DESC_R(st)

## Enumerations

enum | ns2_timeout { NS_TOUT_TNS_BLOCK , NS_TOUT_TNS_BLOCK_RETRIES , NS_TOUT_TNS_RESET , NS_TOUT_TNS_RESET_RETRIES , NS_TOUT_TNS_TEST , NS_TOUT_TNS_ALIVE , NS_TOUT_TNS_ALIVE_RETRIES , NS_TOUT_TSNS_PROV , NS_TOUT_TSNS_SIZE_RETRIES , NS_TOUT_TSNS_CONFIG_RETRIES , NS_TOUT_TSNS_PROCEDURES_RETRIES }
enum | nsvc_timer_mode { NSVC_TIMER_TNS_TEST , NSVC_TIMER_TNS_ALIVE , NSVC_TIMER_TNS_RESET , _NSVC_TIMER_NR }
enum | ns2_vc_stat { NS_STAT_ALIVE_DELAY }
enum | ns2_bind_stat { NS2_BIND_STAT_BACKLOG_LEN }
enum | ns2_cs { NS2_CS_CREATED , NS2_CS_FOUND , NS2_CS_REJECTED , NS2_CS_SKIPPED , NS2_CS_ERROR }
| Osmocom NS2 VC create status. More...
enum | ns_ctr { NS_CTR_PKTS_IN , NS_CTR_PKTS_OUT , NS_CTR_PKTS_OUT_DROP , NS_CTR_BYTES_IN , NS_CTR_BYTES_OUT , NS_CTR_BYTES_OUT_DROP , NS_CTR_BLOCKED , NS_CTR_UNBLOCKED , 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

ns2_sns_event {
NS2_SNS_EV_REQ_SELECT_ENDPOINT ,
NS2_SNS_EV_RX_SIZE ,
NS2_SNS_EV_RX_SIZE_ACK ,
NS2_SNS_EV_RX_CONFIG ,
NS2_SNS_EV_RX_CONFIG_END ,
NS2_SNS_EV_RX_CONFIG_ACK ,
NS2_SNS_EV_RX_ADD ,
NS2_SNS_EV_RX_DELETE ,
NS2_SNS_EV_RX_CHANGE_WEIGHT ,
NS2_SNS_EV_RX_ACK ,
NS2_SNS_EV_REQ_NO_NSVC ,
NS2_SNS_EV_REQ_FREE_NSVCS ,
NS2_SNS_EV_REQ_NSVC_ALIVE ,
NS2_SNS_EV_REQ_ADD_BIND ,
NS2_SNS_EV_REQ_DELETE_BIND ,
NS2_SNS_EV_REQ_CHANGE_WEIGHT
}

## Functions

enum ns2_cs | ns2_create_vc (struct gprs_ns2_vc_bind *bind, struct msgb *msg, const struct osmo_sockaddr *remote, const char *logname, struct msgb **reject, struct gprs_ns2_vc **success)
| Create a new NS-VC based on a [received] message.
int | ns2_recv_vc (struct gprs_ns2_vc *nsvc, struct msgb *msg)
| Bottom-side entry-point for received NS PDU from the driver/bind.
struct gprs_ns2_vc * | ns2_vc_alloc (struct gprs_ns2_vc_bind *bind, struct gprs_ns2_nse *nse, bool initiater, enum gprs_ns2_vc_mode vc_mode, const char *id)
| Allocate a NS-VC within the given bind + NSE.
void | ns2_free_nsvcs (struct gprs_ns2_nse *nse)
int | ns2_bind_alloc (struct gprs_ns2_inst *nsi, const char *name, struct gprs_ns2_vc_bind **result)
| common allocation + low-level initialization of a bind.
struct msgb * | ns2_msgb_alloc (void)
| Allocate a message buffer for use with the NS2 stack.
void | ns2_sns_write_vty (struct vty *vty, const struct gprs_ns2_nse *nse)
| write IP-SNS to a vty
void | ns2_sns_dump_vty (struct vty *vty, const char *prefix, const struct gprs_ns2_nse *nse, bool stats)
| Dump the IP-SNS state to a vty.
void | ns2_prim_status_ind (struct gprs_ns2_nse *nse, struct gprs_ns2_vc *nsvc, uint16_t bvci, enum gprs_ns2_affecting_cause cause)
| Send a STATUS.ind primitive to the specified NS instance user.
void | ns2_nse_notify_alive (struct gprs_ns2_vc *nsvc, bool alive)
void | ns2_nse_update_mtu (struct gprs_ns2_nse *nse)
int | ns2_nse_set_dialect (struct gprs_ns2_nse *nse, enum gprs_ns2_dialect dialect)
int | ns2_validate (struct gprs_ns2_vc *nsvc, uint8_t pdu_type, struct msgb *msg, struct tlv_parsed *tp, uint8_t *cause)
int | ns2_tx_sns_ack (struct gprs_ns2_vc *nsvc, uint8_t trans_id, uint8_t *cause, const struct gprs_ns_ie_ip4_elem *ip4_elems, unsigned int num_ip4_elems, const struct gprs_ns_ie_ip6_elem *ip6_elems, unsigned int num_ip6_elems)
| Encode + Transmit a SNS-ACK as per Section 9.3.1.
int | ns2_tx_sns_config (struct gprs_ns2_vc *nsvc, bool end_flag, const struct gprs_ns_ie_ip4_elem *ip4_elems, unsigned int num_ip4_elems, const struct gprs_ns_ie_ip6_elem *ip6_elems, unsigned int num_ip6_elems)
| Encode + Transmit a SNS-CONFIG as per Section 9.3.4.
int | ns2_tx_sns_config_ack (struct gprs_ns2_vc *nsvc, uint8_t *cause)
| Encode + Transmit a SNS-CONFIG-ACK as per Section 9.3.5.
int | ns2_tx_sns_size (struct gprs_ns2_vc *nsvc, bool reset_flag, uint16_t max_nr_nsvc, int ip4_ep_nr, int ip6_ep_nr)
| Encode + transmit a SNS-SIZE as per Section 9.3.7.
int | ns2_tx_sns_size_ack (struct gprs_ns2_vc *nsvc, uint8_t *cause)
| Encode + Transmit a SNS-SIZE-ACK as per Section 9.3.8.
int | ns2_tx_sns_add (struct gprs_ns2_vc *nsvc, uint8_t trans_id, const struct gprs_ns_ie_ip4_elem *ip4_elems, unsigned int num_ip4_elems, const struct gprs_ns_ie_ip6_elem *ip6_elems, unsigned int num_ip6_elems)
| Encode + Transmit a SNS-ADD as per Section 9.3.2.
int | ns2_tx_sns_change_weight (struct gprs_ns2_vc *nsvc, uint8_t trans_id, const struct gprs_ns_ie_ip4_elem *ip4_elems, unsigned int num_ip4_elems, const struct gprs_ns_ie_ip6_elem *ip6_elems, unsigned int num_ip6_elems)
| Encode + Transmit a SNS-CHANGE-WEIGHT as per Section 9.3.3.
int | ns2_tx_sns_del (struct gprs_ns2_vc *nsvc, uint8_t trans_id, const struct gprs_ns_ie_ip4_elem *ip4_elems, unsigned int num_ip4_elems, const struct gprs_ns_ie_ip6_elem *ip6_elems, unsigned int num_ip6_elems)
| Encode + Transmit a SNS-DEL as per Section 9.3.6.
int | ns2_tx_block (struct gprs_ns2_vc *nsvc, uint8_t cause, uint16_t *nsvci)
| Transmit a NS-BLOCK on a given NS-VC.
int | ns2_tx_block_ack (struct gprs_ns2_vc *nsvc, uint16_t *nsvci)
| Transmit a NS-BLOCK-ACK on a given NS-VC.
int | ns2_tx_reset (struct gprs_ns2_vc *nsvc, uint8_t cause)
| Transmit a NS-RESET on a given NS-VC.
int | ns2_tx_reset_ack (struct gprs_ns2_vc *nsvc)
| Transmit a NS-RESET-ACK on a given NS-VC.
int | ns2_tx_unblock (struct gprs_ns2_vc *nsvc)
| Transmit a NS-UNBLOCK on a given NS-VC.
int | ns2_tx_unblock_ack (struct gprs_ns2_vc *nsvc)
| Transmit a NS-UNBLOCK-ACK on a given NS-VC.
int | ns2_tx_alive (struct gprs_ns2_vc *nsvc)
| Transmit a NS-ALIVE on a given NS-VC.
int | ns2_tx_alive_ack (struct gprs_ns2_vc *nsvc)
| Transmit a NS-ALIVE-ACK on a given NS-VC.
int | ns2_tx_unit_data (struct gprs_ns2_vc *nsvc, uint16_t bvci, uint8_t sducontrol, struct msgb *msg)
| Transmit NS-UNITDATA on a given NS-VC.
int | ns2_tx_status (struct gprs_ns2_vc *nsvc, uint8_t cause, uint16_t bvci, struct msgb *orig_msg, uint16_t *nsvci)
| Transmit a NS-STATUS on a given NS-VC.
struct gprs_ns2_vc * | ns2_ip_bind_connect (struct gprs_ns2_vc_bind *bind, struct gprs_ns2_nse *nse, const struct osmo_sockaddr *remote)
| Create new NS-VC to a given remote address.
int | ns2_ip_count_bind (struct gprs_ns2_inst *nsi, struct osmo_sockaddr *remote)
| Count UDP binds compatible with remote.
struct gprs_ns2_vc_bind * | ns2_ip_get_bind_by_index (struct gprs_ns2_inst *nsi, struct osmo_sockaddr *remote, int index)
void | ns2_ip_set_txqueue_max_length (struct gprs_ns2_vc_bind *bind, unsigned int max_length)
int | ns2_sns_rx (struct gprs_ns2_vc *nsvc, struct msgb *msg, struct tlv_parsed *tp)
| main entry point for receiving SNS messages from the network.
struct osmo_fsm_inst * | ns2_sns_bss_fsm_alloc (struct gprs_ns2_nse *nse, const char *id)
| Allocate an IP-SNS FSM for the BSS side.
struct osmo_fsm_inst * | ns2_sns_sgsn_fsm_alloc (struct gprs_ns2_nse *nse, const char *id)
| Allocate an IP-SNS FSM for the SGSN side.
void | ns2_sns_replace_nsvc (struct gprs_ns2_vc *nsvc)
| called when a nsvc is beeing freed or the nsvc became dead
void | ns2_sns_notify_alive (struct gprs_ns2_nse *nse, struct gprs_ns2_vc *nsvc, bool alive)
void | ns2_sns_update_weights (struct gprs_ns2_vc_bind *bind)
struct osmo_fsm_inst * | ns2_vc_fsm_alloc (struct gprs_ns2_vc *nsvc, const char *id, bool initiate)
| gprs_ns2_vc_fsm_alloc
int | ns2_vc_fsm_start (struct gprs_ns2_vc *nsvc)
| Start a NS-VC FSM.
int | ns2_vc_force_unconfigured (struct gprs_ns2_vc *nsvc)
| Reset a NS-VC FSM.
int | ns2_vc_rx (struct gprs_ns2_vc *nsvc, struct msgb *msg, struct tlv_parsed *tp)
| entry point for messages from the driver/VL
int | ns2_vc_is_alive (struct gprs_ns2_vc *nsvc)
int | ns2_vc_is_unblocked (struct gprs_ns2_vc *nsvc)
| is the given NS-VC unblocked?
int | ns2_vc_block (struct gprs_ns2_vc *nsvc)
| Block a NS-VC.
int | ns2_vc_reset (struct gprs_ns2_vc *nsvc)
| Reset a NS-VC.
int | ns2_vc_unblock (struct gprs_ns2_vc *nsvc)
| Unblock a NS-VC.
void | ns2_vty_dump_nsvc (struct vty *vty, struct gprs_ns2_vc *nsvc, bool stats)
void | ns2_nse_notify_unblocked (struct gprs_ns2_vc *nsvc, bool unblocked)
| Notify a nse about the change of a NS-VC.
enum gprs_ns2_vc_mode | ns2_dialect_to_vc_mode (enum gprs_ns2_dialect dialect)
int | ns2_count_transfer_cap (struct gprs_ns2_nse *nse, uint16_t bvci)
| calculate the transfer capabilities for a nse
int | ns2_sns_add_sns_default_binds (struct gprs_ns2_nse *nse)

## Macro Definition Documentation

## LOG_NS_DATA

#define LOG_NS_DATA | ( |  | nsvc,
|  |  | direction,
|  |  | pdu_type,
|  |  | lvl,
|  |  | fmt,
|  |  | args ... )

Value:
LOGNSVC_SS(DLNSDATA, nsvc, lvl, "%s %s" fmt, direction, get_value_string(gprs_ns_pdu_strings, pdu_type), ## args)
LOGNSVC_SS
#define LOGNSVC_SS(ss, nsvc, lvl, fmt, args ...)
Definition gprs_ns2_internal.h:19
pdu_type
uint8_t pdu_type
NS PDU type.
Definition gsm_08_16.h:0
gprs_ns_pdu_strings
const struct value_string gprs_ns_pdu_strings[]
Definition gprs_ns.c:397
DLNSDATA
#define DLNSDATA
get_value_string
const char * get_value_string(const struct value_string *vs, uint32_t val)

Referenced by ns2_recv_vc(), ns2_tx_unit_data(), and ns2_vc_fsm_allstate_action().

## LOG_NS_RX_SIGNAL

#define LOG_NS_RX_SIGNAL | ( |  | nsvc,
|  |  | pdu_type )

Value:
LOG_NS_SIGNAL(nsvc, "Rx", pdu_type, LOGL_INFO, "\n")
LOG_NS_SIGNAL
#define LOG_NS_SIGNAL(nsvc, direction, pdu_type, lvl, fmt, args ...)
Definition gprs_ns2_internal.h:33
LOGL_INFO
#define LOGL_INFO

Referenced by ns2_recv_vc().

## LOG_NS_SIGNAL

#define LOG_NS_SIGNAL | ( |  | nsvc,
|  |  | direction,
|  |  | pdu_type,
|  |  | lvl,
|  |  | fmt,
|  |  | args ... )

Value:
LOGNSVC_SS(DLNSSIGNAL, nsvc, lvl, "%s %s" fmt, direction, get_value_string(gprs_ns_pdu_strings, pdu_type), ## args)
DLNSSIGNAL
#define DLNSSIGNAL

Referenced by ns2_tx_block(), ns2_tx_reset(), ns2_tx_sns_ack(), ns2_tx_sns_config(), ns2_tx_sns_size(), ns2_tx_sns_size_ack(), ns2_tx_status(), ns2_vc_fsm_allstate_action(), and ns2_vc_rx().

## LOG_NS_TX_SIGNAL

#define LOG_NS_TX_SIGNAL | ( |  | nsvc,
|  |  | pdu_type )

Value:
LOG_NS_SIGNAL(nsvc, "Tx", pdu_type, LOGL_INFO, "\n")

Referenced by ns2_tx_block_ack(), ns2_tx_reset_ack(), ns2_tx_simple(), and ns2_tx_sns_config_ack().

## LOGBIND

#define LOGBIND | ( |  | bind,
|  |  | lvl,
|  |  | fmt,
|  |  | args ... )

Value:
LOGP(DLNS, lvl, "BIND(%s) " fmt, (bind)->name, ## args)
DLNS
#define DLNS
LOGP
#define LOGP(ss, level, fmt, args...)
name
char name[32]

Referenced by fr_netif_ofd_cb(), fr_netif_write_one(), gprs_n2_fr_ifupdown_ind_cb(), gprs_n2_fr_mtu_chg_cb(), gprs_ns2_fr_bind(), gprs_ns2_ip_bind_set_dscp(), gprs_ns2_ip_bind_set_priority(), handle_nsfrgre_read(), handle_rx_gre_ipv4(), handle_rx_gre_ipv6(), open_socket(), read_nsfrgre_msg(), and setup_device().

## LOGNSE

#define LOGNSE | ( |  | nse,
|  |  | lvl,
|  |  | fmt,
|  |  | args ... )

Value:
LOGP(DLNS, lvl, "NSE(%05u) " fmt, (nse)->nsei, ## args)
nsei
uint16_t nsei
Identifiers of a BTS, equal to 'struct bssgp_bts_ctx'.
Definition gprs_msgb.h:7

Referenced by gprs_ns2_create_nse2(), gprs_ns2_sns_del_endpoint(), ns2_create_vc(), ns2_create_vc_sns(), ns2_ip_bind_connect(), and ns2_prim_status_ind().

## LOGNSVC

#define LOGNSVC | ( |  | nsvc,
|  |  | lvl,
|  |  | fmt,
|  |  | args ... )

Value:
LOGNSVC_SS(DLNS, nsvc, lvl, fmt, ## args)

Referenced by ns2_create_vc(), ns2_prim_status_ind(), ns2_sns_rx(), ns2_tx_sns_ack(), ns2_tx_sns_config(), ns2_tx_sns_config_ack(), ns2_tx_sns_procedure(), ns2_tx_sns_size(), ns2_tx_sns_size_ack(), and ns2_tx_unit_data().

## LOGNSVC_SS

#define LOGNSVC_SS | ( |  | ss,
|  |  | nsvc,
|  |  | lvl,
|  |  | fmt,
|  |  | args ... )

Value:
do { \
if ((nsvc)->nsvci_is_valid) { \
LOGP(ss, lvl, "NSE(%05u)-NSVC(%05u) " fmt, \
(nsvc)->nse->nsei, (nsvc)->nsvci, ## args); \
} else { \
LOGP(ss, lvl, "NSE(%05u)-NSVC(none) " fmt, \
(nsvc)->nse->nsei, ## args); \
} \
} while (0)

## NS_ALLOC_HEADROOM

#define NS_ALLOC_HEADROOM 20

## NS_ALLOC_SIZE

#define NS_ALLOC_SIZE 3072

## NS_DEFAULT_TXQUEUE_MAX_LENGTH

#define NS_DEFAULT_TXQUEUE_MAX_LENGTH 128

Referenced by config_write_ns(), and gprs_ns2_instantiate().

## NS_DESC_A

#define NS_DESC_A | ( |  | st | ) |

Value:
((st) & NSE_S_ALIVE ? "ALIVE" : "DEAD")
NSE_S_ALIVE
#define NSE_S_ALIVE
Definition gprs_ns.h:45

## NS_DESC_B

#define NS_DESC_B | ( |  | st | ) |

Value:
((st) & NSE_S_BLOCKED ? "BLOCKED" : "UNBLOCKED")
NSE_S_BLOCKED
#define NSE_S_BLOCKED
Definition gprs_ns.h:44

## NS_DESC_R

#define NS_DESC_R | ( |  | st | ) |

Value:
((st) & NSE_S_RESET ? "RESET" : "UNRESET")
NSE_S_RESET
#define NSE_S_RESET
Definition gprs_ns.h:46

## NS_TIMERS

#define NS_TIMERS

Value:
"(" TNS_BLOCK_STR "|" TNS_BLOCK_RETRIES_STR "|" TNS_RESET_STR "|" TNS_RESET_RETRIES_STR "|" TNS_TEST_STR "|"\
TNS_ALIVE_STR "|" TNS_ALIVE_RETRIES_STR "|" TSNS_PROV_STR "|" TSNS_SIZE_RETRIES_STR "|" TSNS_CONFIG_RETRIES_STR "|"\
TSNS_PROCEDURES_RETRIES_STR ")"
TNS_ALIVE_STR
#define TNS_ALIVE_STR
Definition gprs_ns2_internal.h:71
TNS_RESET_RETRIES_STR
#define TNS_RESET_RETRIES_STR
Definition gprs_ns2_internal.h:69
TNS_TEST_STR
#define TNS_TEST_STR
Definition gprs_ns2_internal.h:70
TSNS_CONFIG_RETRIES_STR
#define TSNS_CONFIG_RETRIES_STR
Definition gprs_ns2_internal.h:75
TSNS_SIZE_RETRIES_STR
#define TSNS_SIZE_RETRIES_STR
Definition gprs_ns2_internal.h:74
TNS_BLOCK_STR
#define TNS_BLOCK_STR
Definition gprs_ns2_internal.h:66
TNS_BLOCK_RETRIES_STR
#define TNS_BLOCK_RETRIES_STR
Definition gprs_ns2_internal.h:67
TNS_RESET_STR
#define TNS_RESET_STR
Definition gprs_ns2_internal.h:68
TSNS_PROV_STR
#define TSNS_PROV_STR
Definition gprs_ns2_internal.h:73
TNS_ALIVE_RETRIES_STR
#define TNS_ALIVE_RETRIES_STR
Definition gprs_ns2_internal.h:72
TSNS_PROCEDURES_RETRIES_STR
#define TSNS_PROCEDURES_RETRIES_STR
Definition gprs_ns2_internal.h:76

## NS_TIMERS_COUNT

#define NS_TIMERS_COUNT 11

## NS_TIMERS_HELP

#define NS_TIMERS_HELP

Value:
"(un)blocking Timer (Tns-block) timeout\n" \
"(un)blocking Timer (Tns-block) number of retries\n" \
"Reset Timer (Tns-reset) timeout\n" \
"Reset Timer (Tns-reset) number of retries\n" \
"Test Timer (Tns-test) timeout\n" \
"Alive Timer (Tns-alive) timeout\n" \
"Alive Timer (Tns-alive) number of retries\n" \
"SNS Provision Timer (Tsns-prov) timeout\n" \
"SNS Size number of retries\n" \
"SNS Config number of retries\n" \
"SNS Procedures number of retries\n" \

## NSE_S_ALIVE

#define NSE_S_ALIVE 0x0002

## NSE_S_BLOCKED

#define NSE_S_BLOCKED 0x0001

## NSE_S_RESET

#define NSE_S_RESET 0x0004

## RATE_CTR_ADD_NS

#define RATE_CTR_ADD_NS | ( |  | nsvc,
|  |  | ctr,
|  |  | val )

Value:
do { \
struct gprs_ns2_vc *_nsvc = (nsvc); \
rate_ctr_add(rate_ctr_group_get_ctr(_nsvc->ctrg, ctr), val); \
rate_ctr_add(rate_ctr_group_get_ctr(_nsvc->nse->ctrg, ctr), val); \
} while (0)
rate_ctr_group_get_ctr
struct rate_ctr * rate_ctr_group_get_ctr(struct rate_ctr_group *grp, unsigned int idx)
gprs_ns2_nse::ctrg
struct rate_ctr_group * ctrg
NSE-wide statistics.
Definition gprs_ns2_internal.h:236
gprs_ns2_vc
Structure representing a single NS-VC.
Definition gprs_ns2_internal.h:246
gprs_ns2_vc::nse
struct gprs_ns2_nse * nse
pointer to NS Instance
Definition gprs_ns2_internal.h:254
gprs_ns2_vc::ctrg
struct rate_ctr_group * ctrg
Definition gprs_ns2_internal.h:281

Referenced by fr_vc_sendmsg(), frgre_vc_sendmsg(), handle_nsip_sendto(), and ns2_recv_vc().

## RATE_CTR_INC_NS

#define RATE_CTR_INC_NS | ( |  | nsvc,
|  |  | ctr )

Value:
do { \
struct gprs_ns2_vc *_nsvc = (nsvc); \
rate_ctr_inc(rate_ctr_group_get_ctr(_nsvc->ctrg, ctr)); \
rate_ctr_inc(rate_ctr_group_get_ctr(_nsvc->nse->ctrg, ctr)); \
} while (0)

Referenced by alive_timeout_handler(), fr_vc_sendmsg(), frgre_vc_sendmsg(), handle_nsip_sendto(), ns2_recv_vc(), ns2_st_blocked_onenter(), ns2_st_unblocked_on_enter(), and ns2_vc_fsm_timer_cb().

## TNS_ALIVE_RETRIES_STR

#define TNS_ALIVE_RETRIES_STR "tns-alive-retries"

## TNS_ALIVE_STR

#define TNS_ALIVE_STR "tns-alive"

## TNS_BLOCK_RETRIES_STR

#define TNS_BLOCK_RETRIES_STR "tns-block-retries"

## TNS_BLOCK_STR

#define TNS_BLOCK_STR "tns-block"

## TNS_RESET_RETRIES_STR

#define TNS_RESET_RETRIES_STR "tns-reset-retries"

## TNS_RESET_STR

#define TNS_RESET_STR "tns-reset"

## TNS_TEST_STR

#define TNS_TEST_STR "tns-test"

## TSNS_CONFIG_RETRIES_STR

#define TSNS_CONFIG_RETRIES_STR "tsns-config-retries"

## TSNS_PROCEDURES_RETRIES_STR

#define TSNS_PROCEDURES_RETRIES_STR "tsns-procedures-retries"

## TSNS_PROV_STR

#define TSNS_PROV_STR "tsns-prov"

## TSNS_SIZE_RETRIES_STR

#define TSNS_SIZE_RETRIES_STR "tsns-size-retries"

## Enumeration Type Documentation

## ns2_bind_stat

enum ns2_bind_stat

Enumerator
NS2_BIND_STAT_BACKLOG_LEN |

## ns2_cs

enum ns2_cs

Osmocom NS2 VC create status.

Enumerator
NS2_CS_CREATED | A NSVC object has been created.
NS2_CS_FOUND | A NSVC object has been found.
NS2_CS_REJECTED | Rejected and answered message.
NS2_CS_SKIPPED | Skipped message.
NS2_CS_ERROR | Failed to process message.

## ns2_sns_event

enum ns2_sns_event

Enumerator
NS2_SNS_EV_REQ_SELECT_ENDPOINT | Select a SNS endpoint from the list.
NS2_SNS_EV_RX_SIZE |
NS2_SNS_EV_RX_SIZE_ACK |
NS2_SNS_EV_RX_CONFIG |
NS2_SNS_EV_RX_CONFIG_END | SNS-CONFIG with end flag received.
NS2_SNS_EV_RX_CONFIG_ACK |
NS2_SNS_EV_RX_ADD |
NS2_SNS_EV_RX_DELETE |
NS2_SNS_EV_RX_CHANGE_WEIGHT |
NS2_SNS_EV_RX_ACK | Rx of SNS-ACK (response to ADD/DELETE/CHG_WEIGHT.
NS2_SNS_EV_REQ_NO_NSVC | no more NS-VC remaining (all dead)
NS2_SNS_EV_REQ_FREE_NSVCS | free all NS-VCs
NS2_SNS_EV_REQ_NSVC_ALIVE | a NS-VC became alive
NS2_SNS_EV_REQ_ADD_BIND | add a new local bind to this NSE
NS2_SNS_EV_REQ_DELETE_BIND | remove a local bind from this NSE
NS2_SNS_EV_REQ_CHANGE_WEIGHT | a bind changed its weight

## ns2_timeout

enum ns2_timeout

Enumerator
NS_TOUT_TNS_BLOCK |
NS_TOUT_TNS_BLOCK_RETRIES |
NS_TOUT_TNS_RESET |
NS_TOUT_TNS_RESET_RETRIES |
NS_TOUT_TNS_TEST |
NS_TOUT_TNS_ALIVE |
NS_TOUT_TNS_ALIVE_RETRIES |
NS_TOUT_TSNS_PROV |
NS_TOUT_TSNS_SIZE_RETRIES |
NS_TOUT_TSNS_CONFIG_RETRIES |
NS_TOUT_TSNS_PROCEDURES_RETRIES |

## ns2_vc_stat

enum ns2_vc_stat

Enumerator
NS_STAT_ALIVE_DELAY |

## ns_ctr

enum ns_ctr

Enumerator
NS_CTR_PKTS_IN |
NS_CTR_PKTS_OUT |
NS_CTR_PKTS_OUT_DROP |
NS_CTR_BYTES_IN |
NS_CTR_BYTES_OUT |
NS_CTR_BYTES_OUT_DROP |
NS_CTR_BLOCKED |
NS_CTR_UNBLOCKED |
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 |

## nsvc_timer_mode

enum nsvc_timer_mode

Enumerator
NSVC_TIMER_TNS_TEST |
NSVC_TIMER_TNS_ALIVE |
NSVC_TIMER_TNS_RESET |
_NSVC_TIMER_NR |

## Function Documentation

## ns2_ip_bind_connect()

struct gprs_ns2_vc * ns2_ip_bind_connect | ( | struct gprs_ns2_vc_bind * | bind,
|  | struct gprs_ns2_nse * | nse,
|  | const struct osmo_sockaddr * | remote )

Create new NS-VC to a given remote address.

Parameters

  [in] | bind | the bind we want to connect
  [in] | nse | NS entity to be used for the new NS-VC
  [in] | remote | remote address to connect to

Returns
  pointer to newly-allocated and connected NS-VC; NULL on error

References gprs_ns2_nse::dialect, gprs_ns2_free_nsvc(), gprs_ns2_ip_bind_sockaddr(), gprs_ns2_is_ip_bind(), gprs_ns2_lltype_str(), gprs_ns2_nsvc_by_sockaddr_bind(), gprs_ns2_nse::ll, LOGNSE, ns2_dialect_to_vc_mode(), ns2_vc_alloc(), gprs_ns2_nse::nsei, gprs_ns2_vc::priv, and priv_vc::remote.

Referenced by gprs_ns2_ip_connect_inactive(), ns2_create_vc_sns(), and ns2_sns_st_bss_size_onenter().

## ns2_ip_count_bind()

int ns2_ip_count_bind | ( | struct gprs_ns2_inst * | nsi,
|  | struct osmo_sockaddr * | remote )

Count UDP binds compatible with remote.

References gprs_ns2_inst::binding, gprs_ns2_ip_bind_sockaddr(), gprs_ns2_is_ip_bind(), osmo_sockaddr::sa, and osmo_sockaddr::u.

## ns2_ip_get_bind_by_index()

struct gprs_ns2_vc_bind * ns2_ip_get_bind_by_index | ( | struct gprs_ns2_inst * | nsi,
|  | struct osmo_sockaddr * | remote,
|  | int | index )

References gprs_ns2_inst::binding, gprs_ns2_ip_bind_sockaddr(), gprs_ns2_is_ip_bind(), osmo_sockaddr::sa, and osmo_sockaddr::u.

## ns2_ip_set_txqueue_max_length()

void ns2_ip_set_txqueue_max_length | ( | struct gprs_ns2_vc_bind * | bind,
|  | unsigned int | max_length )

References gprs_ns2_is_ip_bind(), priv_bind::iofd, and gprs_ns2_vc_bind::priv.

Referenced by DEFUN().

## ns2_nse_notify_alive()

void ns2_nse_notify_alive | ( | struct gprs_ns2_vc * | nsvc,
|  | bool | alive )

References bvci, and pdu_type.

## ns2_sns_add_sns_default_binds()

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

References gprs_ns2_nse::dialect, gprs_ns2_bind_by_name(), GPRS_NS2_DIALECT_SNS, GPRS_NS2_LL_UDP, gprs_ns2_sns_add_bind(), ip_sns_default_binds, vty_nse_bind::list, gprs_ns2_nse::ll, vty_bind::name, vty_nse_bind::vbind, and vty_nsi.

Referenced by ns2_create_vc_sns().

## ns2_sns_bss_fsm_alloc()

struct osmo_fsm_inst * ns2_sns_bss_fsm_alloc | ( | struct gprs_ns2_nse * | nse,
|  | const char * | id )

Allocate an IP-SNS FSM for the BSS side.

Parameters

  [in] | nse | NS Entity in which the FSM runs
  [in] | id | string identifier

Returns
  FSM instance on success; NULL on error

References ns2_sns_state::binds, gprs_ns2_sns_bss_fsm, GPRS_SNS_ROLE_BSS, ns2_sns_state::nse, ns2_sns_state::num_max_ip4_remote, ns2_sns_state::num_max_ip6_remote, osmo_fsm_inst::priv, ns2_sns_state::procedures, ns2_sns_state::role, and ns2_sns_state::sns_endpoints.

Referenced by ns2_nse_set_dialect().

## ns2_sns_dump_vty()

void ns2_sns_dump_vty | ( | struct vty * | vty,
|  | const char * | prefix,
|  | const struct gprs_ns2_nse * | nse,
|  | bool | stats )

Dump the IP-SNS state to a vty.

Parameters

  [in] | vty | VTY to which the state shall be printed
  [in] | prefix | prefix to print at start of each line (typically indenting)
  [in] | nse | NS Entity whose IP-SNS state shall be printed
  [in] | stats | Whether or not statistics shall also be printed

References gprs_ns2_nse::bss_sns_fi, ns2_sns_elems::ip4, ns2_sns_elems::ip6, ns2_sns_state::local, ns2_sns_state::nse, ns2_sns_elems::num_ip4, ns2_sns_elems::num_ip6, ns2_sns_state::num_max_ip4_remote, ns2_sns_state::num_max_ip6_remote, ns2_sns_state::num_max_nsvcs, osmo_fsm_inst::priv, ns2_sns_state::remote, vty_dump_sns_ip4(), and vty_dump_sns_ip6().

Referenced by dump_nse().

## ns2_sns_notify_alive()

void ns2_sns_notify_alive | ( | struct gprs_ns2_nse * | nse,
|  | struct gprs_ns2_vc * | nsvc,
|  | bool | alive )

References ns2_sns_state::alive, ns2_sns_state::block_no_nsvc_events, gprs_ns2_nse::bss_sns_fi, GPRS_SNS_ST_CONFIGURED, GPRS_SNS_ST_LOCAL_PROCEDURE, gprs_ns2_vc::list, NS2_SNS_EV_REQ_NO_NSVC, NS2_SNS_EV_REQ_NSVC_ALIVE, ns2_sns_replace_nsvc(), ns2_vc_is_unblocked(), gprs_ns2_vc::nse, gprs_ns2_nse::nsvc, osmo_fsm_inst::priv, sns_failed, ns2_sns_state::sns_nsvc, osmo_fsm_inst::state, and gprs_ns2_nse::sum_sig_weight.

Referenced by ns2_nse_notify_unblocked().

## ns2_sns_replace_nsvc()

void ns2_sns_replace_nsvc | ( | struct gprs_ns2_vc * | nsvc | ) |

called when a nsvc is beeing freed or the nsvc became dead

References ns2_sns_state::alive, ns2_sns_state::block_no_nsvc_events, gprs_ns2_nse::bss_sns_fi, NS2_SNS_EV_REQ_NO_NSVC, ns2_vc_is_unblocked(), ns2_sns_state::nse, gprs_ns2_nse::nsvc, osmo_fsm_inst::priv, and ns2_sns_state::sns_nsvc.

Referenced by gprs_ns2_free_nsvc(), and ns2_sns_notify_alive().

## ns2_sns_rx()

int ns2_sns_rx | ( | struct gprs_ns2_vc * | nsvc,
|  | struct msgb * | msg,
|  | struct tlv_parsed * | tp )

main entry point for receiving SNS messages from the network.

Parameters

  [in] | nsvc | NS-VC on which the message was received
  [in] | msg | message buffer of the IP-SNS message
  [in] | tp | parsed TLV structure of message

Returns
  0 on success; negative on error

References gprs_ns2_nse::bss_sns_fi, gprs_ns_hdr::data, gprs_ns_pdu_strings, LOGNSVC, NS2_SNS_EV_RX_ACK, NS2_SNS_EV_RX_ADD, NS2_SNS_EV_RX_CHANGE_WEIGHT, NS2_SNS_EV_RX_CONFIG, NS2_SNS_EV_RX_CONFIG_ACK, NS2_SNS_EV_RX_CONFIG_END, NS2_SNS_EV_RX_DELETE, NS2_SNS_EV_RX_SIZE, NS2_SNS_EV_RX_SIZE_ACK, gprs_ns2_vc::nse, gprs_ns2_nse::nsei, nsei, gprs_ns2_nse::nsvc, gprs_ns_hdr::pdu_type, osmo_fsm_inst::priv, ns2_sns_state::sns_nsvc, SNS_PDUT_ACK, SNS_PDUT_ADD, SNS_PDUT_CHANGE_WEIGHT, SNS_PDUT_CONFIG, SNS_PDUT_CONFIG_ACK, SNS_PDUT_DELETE, SNS_PDUT_SIZE, and SNS_PDUT_SIZE_ACK.

Referenced by ns2_recv_vc().

## ns2_sns_sgsn_fsm_alloc()

struct osmo_fsm_inst * ns2_sns_sgsn_fsm_alloc | ( | struct gprs_ns2_nse * | nse,
|  | const char * | id )

Allocate an IP-SNS FSM for the SGSN side.

Parameters

  [in] | nse | NS Entity in which the FSM runs
  [in] | id | string identifier

Returns
  FSM instance on success; NULL on error

References ns2_sns_state::binds, gprs_ns2_sns_sgsn_fsm, GPRS_SNS_ROLE_SGSN, ns2_sns_state::nse, osmo_fsm_inst::priv, ns2_sns_state::procedures, ns2_sns_state::role, and ns2_sns_state::sns_endpoints.

Referenced by ns2_nse_set_dialect().

## ns2_sns_update_weights()

void ns2_sns_update_weights | ( | struct gprs_ns2_vc_bind * | bind | ) |

References ns2_sns_bind::bind, ns2_sns_state::binds, gprs_ns2_nse::bss_sns_fi, ns2_sns_state::family, gprs_ns2_ip_bind_sockaddr(), NS2_SNS_EV_REQ_CHANGE_WEIGHT, gprs_ns2_inst::nse, ns2_sns_state::nse, gprs_ns2_vc_bind::nsi, osmo_fsm_inst::priv, osmo_sockaddr::sa, and osmo_sockaddr::u.

Referenced by gprs_ns2_ip_bind_set_sns_weight().

## ns2_sns_write_vty()

void ns2_sns_write_vty | ( | struct vty * | vty,
|  | const struct gprs_ns2_nse * | nse )

write IP-SNS to a vty

Parameters

  [in] | vty | VTY to which the state shall be printed
  [in] | nse | NS Entity whose IP-SNS state shall be printed

References gprs_ns2_nse::bss_sns_fi, osmo_sockaddr_str::ip, ns2_sns_state::nse, osmo_sockaddr_str::port, osmo_fsm_inst::priv, sns_endpoint::saddr, osmo_sockaddr::sas, ns2_sns_state::sns_endpoints, and osmo_sockaddr::u.

Referenced by _config_write_ns_nse().

## ns2_tx_alive()

int ns2_tx_alive | ( | struct gprs_ns2_vc * | nsvc | ) |

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

Parameters

  [in] | nsvc | NS-VC on which the NS-ALIVE is to be transmitted

Returns
  0 in case of success

References ns2_tx_simple(), NS_PDUT_ALIVE, and gprs_ns2_vc::nse.

Referenced by alive_timeout_handler(), and start_test_procedure().

## ns2_tx_alive_ack()

int ns2_tx_alive_ack | ( | struct gprs_ns2_vc * | nsvc | ) |

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

Parameters

  [in] | nsvc | NS-VC on which the NS-ALIVE-ACK is to be transmitted

Returns
  0 in case of success

References ns2_tx_simple(), NS_PDUT_ALIVE_ACK, and gprs_ns2_vc::nse.

Referenced by ns2_vc_fsm_allstate_action().

## ns2_tx_block()

int ns2_tx_block | ( | struct gprs_ns2_vc * | nsvc,
|  | uint8_t | cause,
|  | uint16_t * | nsvci )

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

Parameters

  [in] | vc | NS-VC on which the NS-BLOCK is to be transmitted
  [in] | cause | Numeric NS Cause value
  [in] | nsvci | if given this NSVCI will be encoded. If NULL the nsvc->nsvci will be used.

Returns
  0 in case of success

References gprs_ns2_vc::ctrg, ERR_IF_NSVC_USES_SNS, gprs_ns2_cause_str(), LOG_NS_SIGNAL, ns2_msgb_alloc(), NS_CTR_BLOCKED, NS_IE_CAUSE, NS_IE_VCI, NS_PDUT_BLOCK, ns_vc_tx(), gprs_ns2_vc::nse, gprs_ns2_vc::nsvci, and gprs_ns_hdr::pdu_type.

Referenced by ns2_st_blocked(), and ns2_st_blocked_onenter().

## ns2_tx_block_ack()

int ns2_tx_block_ack | ( | struct gprs_ns2_vc * | nsvc,
|  | uint16_t * | nsvci )

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

Parameters

  [in] | nsvc | NS-VC on which the NS-BLOCK is to be transmitted
  [in] | nsvci | if given this NSVCI will be encoded. If NULL the nsvc->nsvci will be used.

Returns
  0 in case of success

References ERR_IF_NSVC_USES_SNS, LOG_NS_TX_SIGNAL, ns2_msgb_alloc(), NS_IE_VCI, NS_PDUT_BLOCK_ACK, ns_vc_tx(), gprs_ns2_vc::nse, gprs_ns2_vc::nsvci, and gprs_ns_hdr::pdu_type.

Referenced by ns2_st_blocked(), ns2_st_unblocked(), and ns2_vc_rx().

## ns2_tx_reset()

int ns2_tx_reset | ( | struct gprs_ns2_vc * | nsvc,
|  | uint8_t | cause )

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

Parameters

  [in] | nsvc | NS-VC used for transmission
  [in] | cause | Numeric NS cause value

Returns
  0 in case of success

References ERR_IF_NSVC_USES_SNS, gprs_ns2_cause_str(), LOG_NS_SIGNAL, ns2_msgb_alloc(), NS_IE_CAUSE, NS_IE_NSEI, NS_IE_VCI, NS_PDUT_RESET, ns_vc_tx(), gprs_ns2_vc::nse, gprs_ns2_nse::nsei, nsei, gprs_ns2_vc::nsvci, and gprs_ns_hdr::pdu_type.

Referenced by ns2_st_reset_onenter().

## ns2_tx_reset_ack()

int ns2_tx_reset_ack | ( | struct gprs_ns2_vc * | nsvc | ) |

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

Parameters

  [in] | nsvc | NS-VC used for transmission

Returns
  0 in case of success

References ERR_IF_NSVC_USES_SNS, LOG_NS_TX_SIGNAL, ns2_msgb_alloc(), NS_IE_NSEI, NS_IE_VCI, NS_PDUT_RESET_ACK, ns_vc_tx(), gprs_ns2_vc::nse, gprs_ns2_nse::nsei, nsei, gprs_ns2_vc::nsvci, and gprs_ns_hdr::pdu_type.

Referenced by ns2_st_reset(), and ns2_vc_rx().

## ns2_tx_sns_ack()

int ns2_tx_sns_ack | ( | struct gprs_ns2_vc * | nsvc,
|  | uint8_t | trans_id,
|  | uint8_t * | cause,
|  | const struct gprs_ns_ie_ip4_elem * | ip4_elems,
|  | unsigned int | num_ip4_elems,
|  | const struct gprs_ns_ie_ip6_elem * | ip6_elems,
|  | unsigned int | num_ip6_elems )

Encode + Transmit a SNS-ACK as per Section 9.3.1.

Parameters

  [in] | nsvc | NS-VC through which to transmit the ACK
  [in] | trans_id | Transaction ID which to acknowledge
  [in] | cause | Pointer to cause value (NULL if no cause to be sent)
  [in] | ip4_elems | Array of IPv4 Elements
  [in] | num_ip4_elems | number of ip4_elems

Returns
  0 on success; negative in case of error

References gprs_ns2_nse::bss_sns_fi, gprs_ns2_cause_str(), LOG_NS_SIGNAL, LOGNSVC, ns2_msgb_alloc(), NS_IE_CAUSE, NS_IE_IPv4_LIST, NS_IE_IPv6_LIST, NS_IE_NSEI, ns_vc_tx(), gprs_ns2_vc::nse, gprs_ns2_nse::nsei, nsei, gprs_ns_hdr::pdu_type, and SNS_PDUT_ACK.

Referenced by ns2_sns_st_configured_add(), ns2_sns_st_configured_change(), and ns2_sns_st_configured_delete().

## ns2_tx_sns_add()

int ns2_tx_sns_add | ( | struct gprs_ns2_vc * | nsvc,
|  | uint8_t | trans_id,
|  | const struct gprs_ns_ie_ip4_elem * | ip4_elems,
|  | unsigned int | num_ip4_elems,
|  | const struct gprs_ns_ie_ip6_elem * | ip6_elems,
|  | unsigned int | num_ip6_elems )

Encode + Transmit a SNS-ADD as per Section 9.3.2.

Parameters

  [in] | nsvc | NS-VC through which to transmit the SNS-CONFIG
  [in] | trans_id | The transaction id
  [in] | ip4_elems | Array of IPv4 Elements
  [in] | num_ip4_elems | number of ip4_elems
  [in] | ip6_elems | Array of IPv6 Elements
  [in] | num_ip6_elems | number of ip6_elems

Returns
  0 on success; negative in case of error

References ns2_tx_sns_procedure(), and SNS_PDUT_ADD.

Referenced by ns2_sns_st_local_procedure_onenter().

## ns2_tx_sns_change_weight()

int ns2_tx_sns_change_weight | ( | struct gprs_ns2_vc * | nsvc,
|  | uint8_t | trans_id,
|  | const struct gprs_ns_ie_ip4_elem * | ip4_elems,
|  | unsigned int | num_ip4_elems,
|  | const struct gprs_ns_ie_ip6_elem * | ip6_elems,
|  | unsigned int | num_ip6_elems )

Encode + Transmit a SNS-CHANGE-WEIGHT as per Section 9.3.3.

Parameters

  [in] | nsvc | NS-VC through which to transmit the SNS-CONFIG
  [in] | trans_id | The transaction id
  [in] | ip4_elems | Array of IPv4 Elements
  [in] | num_ip4_elems | number of ip4_elems
  [in] | ip6_elems | Array of IPv6 Elements
  [in] | num_ip6_elems | number of ip6_elems

Returns
  0 on success; negative in case of error

References ns2_tx_sns_procedure(), and SNS_PDUT_CHANGE_WEIGHT.

Referenced by ns2_sns_st_local_procedure_onenter().

## ns2_tx_sns_config()

int ns2_tx_sns_config | ( | struct gprs_ns2_vc * | nsvc,
|  | bool | end_flag,
|  | const struct gprs_ns_ie_ip4_elem * | ip4_elems,
|  | unsigned int | num_ip4_elems,
|  | const struct gprs_ns_ie_ip6_elem * | ip6_elems,
|  | unsigned int | num_ip6_elems )

Encode + Transmit a SNS-CONFIG as per Section 9.3.4.

Parameters

  [in] | nsvc | NS-VC through which to transmit the SNS-CONFIG
  [in] | end_flag | Whether or not this is the last SNS-CONFIG
  [in] | ip4_elems | Array of IPv4 Elements
  [in] | num_ip4_elems | number of ip4_elems

Returns
  0 on success; negative in case of error

References gprs_ns2_nse::bss_sns_fi, LOG_NS_SIGNAL, LOGNSVC, ns2_msgb_alloc(), NS_IE_IPv4_LIST, NS_IE_IPv6_LIST, NS_IE_NSEI, ns_vc_tx(), gprs_ns2_vc::nse, gprs_ns2_nse::nsei, nsei, gprs_ns_hdr::pdu_type, and SNS_PDUT_CONFIG.

Referenced by ns2_sns_st_bss_config_bss_onenter(), and ns2_sns_st_sgsn_wait_config_ack_onenter().

## ns2_tx_sns_config_ack()

int ns2_tx_sns_config_ack | ( | struct gprs_ns2_vc * | nsvc,
|  | uint8_t * | cause )

Encode + Transmit a SNS-CONFIG-ACK as per Section 9.3.5.

Parameters

  [in] | nsvc | NS-VC through which to transmit the SNS-CONFIG-ACK
  [in] | cause | Pointer to cause value (NULL if no cause to be sent)

Returns
  0 on success; negative in case of error

References gprs_ns2_nse::bss_sns_fi, gprs_ns2_cause_str(), LOG_NS_TX_SIGNAL, LOGNSVC, ns2_msgb_alloc(), NS_IE_CAUSE, NS_IE_NSEI, ns_vc_tx(), gprs_ns2_vc::nse, gprs_ns2_nse::nsei, nsei, gprs_ns_hdr::pdu_type, and SNS_PDUT_CONFIG_ACK.

Referenced by ns2_sns_st_bss_config_sgsn(), and ns2_sns_st_sgsn_wait_config().

## ns2_tx_sns_del()

int ns2_tx_sns_del | ( | struct gprs_ns2_vc * | nsvc,
|  | uint8_t | trans_id,
|  | const struct gprs_ns_ie_ip4_elem * | ip4_elems,
|  | unsigned int | num_ip4_elems,
|  | const struct gprs_ns_ie_ip6_elem * | ip6_elems,
|  | unsigned int | num_ip6_elems )

Encode + Transmit a SNS-DEL as per Section 9.3.6.

Parameters

  [in] | nsvc | NS-VC through which to transmit the SNS-CONFIG
  [in] | trans_id | The transaction id
  [in] | ip4_elems | Array of IPv4 Elements
  [in] | num_ip4_elems | number of ip4_elems
  [in] | ip6_elems | Array of IPv6 Elements
  [in] | num_ip6_elems | number of ip6_elems

Returns
  0 on success; negative in case of error

References ns2_tx_sns_procedure(), and SNS_PDUT_DELETE.

Referenced by ns2_sns_st_local_procedure_onenter().

## ns2_tx_sns_size()

int ns2_tx_sns_size | ( | struct gprs_ns2_vc * | nsvc,
|  | bool | reset_flag,
|  | uint16_t | max_nr_nsvc,
|  | int | ip4_ep_nr,
|  | int | ip6_ep_nr )

Encode + transmit a SNS-SIZE as per Section 9.3.7.

Parameters

  [in] | nsvc | NS-VC through which to transmit the SNS-SIZE
  [in] | reset_flag | Whether or not to add a RESET flag
  [in] | max_nr_nsvc | Maximum number of NS-VCs
  [in] | ip4_ep_nr | Number of IPv4 endpoints (< 0 will omit the TLV)
  [in] | ip6_ep_nr | Number of IPv6 endpoints (< 0 will omit the TLV)

Returns
  0 on success; negative in case of error

References gprs_ns2_nse::bss_sns_fi, LOG_NS_SIGNAL, LOGNSVC, ns2_msgb_alloc(), NS_IE_IPv4_EP_NR, NS_IE_IPv6_EP_NR, NS_IE_MAX_NR_NSVC, NS_IE_NSEI, NS_IE_RESET_FLAG, ns_vc_tx(), gprs_ns2_vc::nse, gprs_ns2_nse::nsei, nsei, gprs_ns_hdr::pdu_type, and SNS_PDUT_SIZE.

Referenced by ns2_sns_st_bss_size_onenter().

## ns2_tx_sns_size_ack()

int ns2_tx_sns_size_ack | ( | struct gprs_ns2_vc * | nsvc,
|  | uint8_t * | cause )

Encode + Transmit a SNS-SIZE-ACK as per Section 9.3.8.

Parameters

  [in] | nsvc | NS-VC through which to transmit the SNS-SIZE-ACK
  [in] | cause | Pointer to cause value (NULL if no cause to be sent)

Returns
  0 on success; negative in case of error

References gprs_ns2_nse::bss_sns_fi, gprs_ns2_cause_str(), LOG_NS_SIGNAL, LOGNSVC, ns2_msgb_alloc(), NS_IE_CAUSE, NS_IE_NSEI, ns_vc_tx(), gprs_ns2_vc::nse, gprs_ns2_nse::nsei, nsei, gprs_ns_hdr::pdu_type, and SNS_PDUT_SIZE_ACK.

Referenced by ns2_sns_st_all_action_sgsn().

## ns2_tx_status()

int ns2_tx_status | ( | struct gprs_ns2_vc * | nsvc,
|  | uint8_t | cause,
|  | uint16_t | bvci,
|  | struct msgb * | orig_msg,
|  | uint16_t * | nsvci )

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

Parameters

  [in] | nsvc | NS-VC to be used for transmission
  [in] | cause | Numeric NS cause value
  [in] | bvci | BVCI to be reset within NSVC
  [in] | orig_msg | message causing the STATUS
  [in] | nsvci | if given this NSVCI will be encoded. If NULL the nsvc->nsvci will be used.

Returns
  0 in case of success

References gprs_ns2_vc::bind, bvci, gprs_ns2_cause_str(), msgb::l2h, LOG_NS_SIGNAL, gprs_ns2_vc_bind::mtu, ns2_msgb_alloc(), NS_CAUSE_BVCI_UNKNOWN, NS_CAUSE_INVAL_ESSENT_IE, NS_CAUSE_MISSING_ESSENT_IE, NS_CAUSE_NSVC_BLOCKED, NS_CAUSE_NSVC_UNKNOWN, NS_CAUSE_PDU_INCOMP_PSTATE, NS_CAUSE_PROTO_ERR_UNSPEC, NS_CAUSE_SEM_INCORR_PDU, NS_IE_CAUSE, NS_IE_PDU, NS_IE_VCI, NS_PDUT_STATUS, ns_vc_tx(), gprs_ns2_vc::nse, gprs_ns2_vc::nsvci, and gprs_ns_hdr::pdu_type.

Referenced by ns2_recv_vc(), ns2_vc_fsm_allstate_action(), and ns2_vc_rx().

## ns2_tx_unblock()

int ns2_tx_unblock | ( | struct gprs_ns2_vc * | nsvc | ) |

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

Parameters

  [in] | nsvc | NS-VC on which the NS-UNBLOCK is to be transmitted

Returns
  0 in case of success

References ERR_IF_NSVC_USES_SNS, ns2_tx_simple(), NS_PDUT_UNBLOCK, and gprs_ns2_vc::nse.

Referenced by ns2_st_blocked_onenter().

## ns2_tx_unblock_ack()

int ns2_tx_unblock_ack | ( | struct gprs_ns2_vc * | nsvc | ) |

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

Parameters

  [in] | nsvc | NS-VC on which the NS-UNBLOCK-ACK is to be transmitted

Returns
  0 in case of success

References ERR_IF_NSVC_USES_SNS, ns2_tx_simple(), NS_PDUT_UNBLOCK_ACK, and gprs_ns2_vc::nse.

Referenced by ns2_st_blocked(), and ns2_st_unblocked().

## ns2_tx_unit_data()

int ns2_tx_unit_data | ( | struct gprs_ns2_vc * | nsvc,
|  | uint16_t | bvci,
|  | uint8_t | sducontrol,
|  | struct msgb * | msg )

Transmit NS-UNITDATA on a given NS-VC.

Parameters

  [in] | nsvc | NS-VC on which the NS-UNITDATA is to be transmitted
  [in] | bvci | BVCI to encode in NS-UNITDATA header
  [in] | sducontrol | SDU control octet of NS header
  [in] | msg | message buffer containing payload

Returns
  0 in case of success

References bvci, gprs_ns_hdr::data, LOG_NS_DATA, LOGNSVC, NS_PDUT_UNITDATA, ns_vc_tx(), gprs_ns2_vc::nse, and gprs_ns_hdr::pdu_type.

Referenced by gprs_ns2_recv_prim().

## ns2_validate()

int ns2_validate | ( | struct gprs_ns2_vc * | nsvc,
|  | uint8_t | pdu_type,
|  | struct msgb * | msg,
|  | struct tlv_parsed * | tp,
|  | uint8_t * | cause )

References ns2_validate_block(), ns2_validate_block_ack(), ns2_validate_reset(), ns2_validate_reset_ack(), ns2_validate_status(), NS_CAUSE_PROTO_ERR_UNSPEC, NS_PDUT_ALIVE, NS_PDUT_ALIVE_ACK, NS_PDUT_BLOCK, NS_PDUT_BLOCK_ACK, NS_PDUT_RESET, NS_PDUT_RESET_ACK, NS_PDUT_STATUS, NS_PDUT_UNBLOCK, NS_PDUT_UNBLOCK_ACK, and pdu_type.

Referenced by ns2_vc_rx().

## ns2_vc_block()

int ns2_vc_block | ( | struct gprs_ns2_vc * | nsvc | ) |

Block a NS-VC.

Parameters

  nsvc | the virtual circuit

Returns
  0 on success; negative on error

References gprs_ns2_vc::fi, GPRS_NS2_EV_REQ_OM_BLOCK, gprs_ns2_vc_priv::nsvc, gprs_ns2_vc::om_blocked, and osmo_fsm_inst::priv.

Referenced by DEFUN().

## ns2_vc_force_unconfigured()

int ns2_vc_force_unconfigured | ( | struct gprs_ns2_vc * | nsvc | ) |

Reset a NS-VC FSM.

Parameters

  nsvc | the virtual circuit

Returns
  0 on success; negative on error

References gprs_ns2_vc::fi, GPRS_NS2_EV_REQ_FORCE_UNCONFIGURED, and gprs_ns2_vc_priv::nsvc.

Referenced by fr_dlci_status_cb(), ns2_sns_st_all_action_sgsn(), and nsvc_force_unconf_cb().

## ns2_vc_fsm_alloc()

struct osmo_fsm_inst * ns2_vc_fsm_alloc | ( | struct gprs_ns2_vc * | nsvc,
|  | const char * | id,
|  | bool | initiator )

gprs_ns2_vc_fsm_alloc

Parameters

  ctx |
  vc |
  id | a char representation of the virtual curcuit
  initiator | initiator is the site which starts the connection. Usually the BSS.

Returns
  NULL on error, otherwise the fsm

References gprs_ns2_vc_priv::alive, alive_timeout_handler(), gprs_ns2_vc::fi, gprs_ns2_vc_priv::initiator, ns2_vc_fsm, gprs_ns2_vc_priv::nsvc, osmo_fsm_inst::priv, and gprs_ns2_vc_priv::timer.

Referenced by ns2_vc_alloc().

## ns2_vc_fsm_start()

int ns2_vc_fsm_start | ( | struct gprs_ns2_vc * | nsvc | ) |

Start a NS-VC FSM.

Parameters

  nsvc | the virtual circuit

Returns
  0 on success; negative on error

References gprs_ns2_vc::fi, GPRS_NS2_EV_REQ_START, GPRS_NS2_ST_UNCONFIGURED, gprs_ns2_vc_priv::nsvc, and osmo_fsm_inst::state.

Referenced by fr_dlci_status_cb(), gprs_ns2_ip_connect(), gprs_ns2_start_alive_all_nsvcs(), handle_nsfrgre_read(), handle_nsip_recvfrom(), and nsvc_force_unconf_cb().

## ns2_vc_is_alive()

int ns2_vc_is_alive | ( | struct gprs_ns2_vc * | nsvc | ) |

References bvci.

## ns2_vc_is_unblocked()

int ns2_vc_is_unblocked | ( | struct gprs_ns2_vc * | nsvc | ) |

is the given NS-VC unblocked?

References gprs_ns2_vc::fi, GPRS_NS2_ST_UNBLOCKED, and osmo_fsm_inst::state.

Referenced by ns2_count_transfer_cap(), ns2_load_sharing_first(), ns2_load_sharing_modulo(), ns2_load_sharing_signal(), ns2_load_sharing_weight_modulo(), ns2_nse_data_sum(), ns2_sns_notify_alive(), ns2_sns_replace_nsvc(), ns2_sns_st_configured_onenter(), and ns2_vty_dump_nsvc().

## ns2_vc_reset()

int ns2_vc_reset | ( | struct gprs_ns2_vc * | nsvc | ) |

Reset a NS-VC.

Parameters

  nsvc | the virtual circuit

Returns
  0 on success; negative on error

References gprs_ns2_vc::fi, GPRS_NS2_EV_REQ_OM_RESET, and gprs_ns2_vc_priv::nsvc.

Referenced by DEFUN().

## ns2_vc_rx()

int ns2_vc_rx | ( | struct gprs_ns2_vc * | nsvc,
|  | struct msgb * | msg,
|  | struct tlv_parsed * | tp )

entry point for messages from the driver/VL

Parameters

  nsvc | virtual circuit on which the message was received
  msg | message that was received
  tp | parsed TLVs of the received message

Returns
  0 on success; negative on error

References gprs_ns2_vc::fi, GPRS_NS2_EV_RX_ALIVE, GPRS_NS2_EV_RX_ALIVE_ACK, GPRS_NS2_EV_RX_BLOCK, GPRS_NS2_EV_RX_BLOCK_ACK, GPRS_NS2_EV_RX_BLOCK_FOREIGN, GPRS_NS2_EV_RX_RESET, GPRS_NS2_EV_RX_RESET_ACK, GPRS_NS2_EV_RX_STATUS, GPRS_NS2_EV_RX_UNBLOCK, GPRS_NS2_EV_RX_UNBLOCK_ACK, GPRS_NS2_EV_RX_UNITDATA, gprs_ns2_nsvc_by_nsvci(), gprs_ns_pdu_strings, LOG_NS_SIGNAL, ns2_tx_block_ack(), ns2_tx_reset_ack(), ns2_tx_status(), ns2_validate(), NS_CAUSE_NSVC_UNKNOWN, NS_IE_NSEI, NS_IE_VCI, NS_PDUT_ALIVE, NS_PDUT_ALIVE_ACK, NS_PDUT_BLOCK, NS_PDUT_BLOCK_ACK, NS_PDUT_RESET, NS_PDUT_RESET_ACK, NS_PDUT_STATUS, NS_PDUT_UNBLOCK, NS_PDUT_UNBLOCK_ACK, NS_PDUT_UNITDATA, gprs_ns2_vc::nse, gprs_ns2_nse::nsei, nsei, gprs_ns2_nse::nsi, gprs_ns2_vc::nsvci, gprs_ns2_vc::nsvci_is_valid, and gprs_ns_hdr::pdu_type.

Referenced by ns2_recv_vc().

## ns2_vc_unblock()

int ns2_vc_unblock | ( | struct gprs_ns2_vc * | nsvc | ) |

Unblock a NS-VC.

Parameters

  nsvc | the virtual circuit

Returns
  0 on success; negative on error

References gprs_ns2_vc::fi, GPRS_NS2_EV_REQ_OM_UNBLOCK, gprs_ns2_vc_priv::nsvc, gprs_ns2_vc::om_blocked, and osmo_fsm_inst::priv.

Referenced by DEFUN().

## ns2_vty_dump_nsvc()

void ns2_vty_dump_nsvc | ( | struct vty * | vty,
|  | struct gprs_ns2_vc * | nsvc,
|  | bool | stats )

References gprs_ns2_vc::ctrg, gprs_ns2_vc::data_weight, gprs_ns2_vc::fi, gprs_ns2_ll_str(), ns2_vc_is_unblocked(), gprs_ns2_vc::nsvci, gprs_ns2_vc::nsvci_is_valid, gprs_ns2_vc::om_blocked, gprs_ns2_vc::persistent, gprs_ns2_vc::sig_weight, gprs_ns2_vc::statg, and gprs_ns2_vc::ts_alive_change.

Referenced by DEFUN(), dump_nse(), dump_vty(), and dump_vty().