libosmogb  1.4.0.160-7619
Osmocom Gb library
gprs_ns2_sns.c File Reference

NS Sub-Network Service Protocol implementation 3GPP TS 08.16 version 8.0.1 Release 1999 / ETSI TS 101 299 V8.0.1 (2002-05) as well as its successor 3GPP TS 48.016. More...

#include <errno.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdint.h>
#include <osmocom/core/fsm.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/socket.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/gprs/gprs_msgb.h>
#include <osmocom/gprs/gprs_ns2.h>
#include <osmocom/gprs/protocol/gsm_08_16.h>
#include "gprs_ns2_internal.h"
#include <osmocom/vty/vty.h>
#include <osmocom/vty/misc.h>

Data Structures

struct  ns2_sns_state
 

Macros

#define S(x)   (1 << (x))
 
#define ip4_weight_sum_data(x, y)   ip4_weight_sum(x, y, true)
 
#define ip4_weight_sum_sig(x, y)   ip4_weight_sum(x, y, false)
 
#define ip6_weight_sum_data(x, y)   ip6_weight_sum(x, y, true)
 
#define ip6_weight_sum_sig(x, y)   ip6_weight_sum(x, y, false)
 

Enumerations

enum  ns2_sns_type {
  IPv4 ,
  IPv6
}
 
enum  gprs_sns_bss_state {
  GPRS_SNS_ST_UNCONFIGURED ,
  GPRS_SNS_ST_SIZE ,
  GPRS_SNS_ST_CONFIG_BSS ,
  GPRS_SNS_ST_CONFIG_SGSN ,
  GPRS_SNS_ST_CONFIGURED ,
  GPRS_SNS_ST_UNCONFIGURED ,
  GPRS_SNS_ST_SIZE ,
  GPRS_SNS_ST_CONFIG_BSS ,
  GPRS_SNS_ST_CONFIG_SGSN ,
  GPRS_SNS_ST_CONFIGURED
}
 
enum  gprs_sns_event {
  GPRS_SNS_EV_START ,
  GPRS_SNS_EV_SIZE ,
  GPRS_SNS_EV_SIZE_ACK ,
  GPRS_SNS_EV_CONFIG ,
  GPRS_SNS_EV_CONFIG_END ,
  GPRS_SNS_EV_CONFIG_ACK ,
  GPRS_SNS_EV_ADD ,
  GPRS_SNS_EV_DELETE ,
  GPRS_SNS_EV_CHANGE_WEIGHT ,
  GPRS_SNS_EV_NO_NSVC ,
  GPRS_SNS_EV_START ,
  GPRS_SNS_EV_SIZE ,
  GPRS_SNS_EV_SIZE_ACK ,
  GPRS_SNS_EV_CONFIG ,
  GPRS_SNS_EV_CONFIG_END ,
  GPRS_SNS_EV_CONFIG_ACK ,
  GPRS_SNS_EV_ADD ,
  GPRS_SNS_EV_DELETE ,
  GPRS_SNS_EV_CHANGE_WEIGHT
}
 

Functions

static struct gprs_ns2_nsense_inst_from_fi (struct osmo_fsm_inst *fi)
 
static int ip4_weight_sum (const struct gprs_ns_ie_ip4_elem *ip4, unsigned int num, bool data_weight)
 
static int ip6_weight_sum (const struct gprs_ns_ie_ip6_elem *ip6, unsigned int num, bool data_weight)
 
static struct gprs_ns2_vcnsvc_by_ip4_elem (struct gprs_ns2_nse *nse, const struct gprs_ns_ie_ip4_elem *ip4)
 
static struct gprs_ns2_vcnsvc_by_ip6_elem (struct gprs_ns2_nse *nse, const struct gprs_ns_ie_ip6_elem *ip6)
 
const struct osmo_sockaddrgprs_ns2_nse_sns_remote (struct gprs_ns2_nse *nse)
 Return the initial SNS remote socket address. More...
 
void ns2_sns_free_nsvc (struct gprs_ns2_vc *nsvc)
 called when a nsvc is beeing freed More...
 
static void ns2_nsvc_create_ip4 (struct osmo_fsm_inst *fi, struct gprs_ns2_nse *nse, const struct gprs_ns_ie_ip4_elem *ip4)
 
static void ns2_nsvc_create_ip6 (struct osmo_fsm_inst *fi, struct gprs_ns2_nse *nse, const struct gprs_ns_ie_ip6_elem *ip6)
 
static int create_missing_nsvcs (struct osmo_fsm_inst *fi)
 
static int add_remote_ip4_elem (struct ns2_sns_state *gss, const struct gprs_ns_ie_ip4_elem *ip4)
 
static int remove_remote_ip4_elem (struct ns2_sns_state *gss, const struct gprs_ns_ie_ip4_elem *ip4)
 
static int update_remote_ip4_elem (struct ns2_sns_state *gss, const struct gprs_ns_ie_ip4_elem *ip4)
 
static int add_remote_ip6_elem (struct ns2_sns_state *gss, const struct gprs_ns_ie_ip6_elem *ip6)
 
static int remove_remote_ip6_elem (struct ns2_sns_state *gss, const struct gprs_ns_ie_ip6_elem *ip6)
 
static int update_remote_ip6_elem (struct ns2_sns_state *gss, const struct gprs_ns_ie_ip6_elem *ip6)
 
static int do_sns_change_weight (struct osmo_fsm_inst *fi, const struct gprs_ns_ie_ip4_elem *ip4, const struct gprs_ns_ie_ip6_elem *ip6)
 
static int do_sns_delete (struct osmo_fsm_inst *fi, const struct gprs_ns_ie_ip4_elem *ip4, const struct gprs_ns_ie_ip6_elem *ip6)
 
static int do_sns_add (struct osmo_fsm_inst *fi, const struct gprs_ns_ie_ip4_elem *ip4, const struct gprs_ns_ie_ip6_elem *ip6)
 
static void ns2_sns_st_unconfigured (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void ns2_sns_st_size (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void ns2_sns_st_size_onenter (struct osmo_fsm_inst *fi, uint32_t old_state)
 
static void ns2_sns_st_config_bss (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void ns2_sns_st_config_bss_onenter (struct osmo_fsm_inst *fi, uint32_t old_state)
 
static void ns_sns_st_config_sgsn_ip4 (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void ns_sns_st_config_sgsn_ip6 (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void ns2_sns_st_config_sgsn (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void ns2_sns_st_configured_add (struct osmo_fsm_inst *fi, struct ns2_sns_state *gss, struct tlv_parsed *tp)
 
static void ns2_sns_st_configured_delete (struct osmo_fsm_inst *fi, struct ns2_sns_state *gss, struct tlv_parsed *tp)
 
static void ns2_sns_st_configured_change (struct osmo_fsm_inst *fi, struct ns2_sns_state *gss, struct tlv_parsed *tp)
 
static void ns2_sns_st_configured (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void ns2_sns_st_configured_onenter (struct osmo_fsm_inst *fi, uint32_t old_state)
 
static int ns2_sns_fsm_bss_timer_cb (struct osmo_fsm_inst *fi)
 
static void ns2_sns_st_all_action (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
struct osmo_fsm_instns2_sns_bss_fsm_alloc (struct gprs_ns2_nse *nse, const char *id)
 Allocate an IP-SNS FSM for the BSS side. More...
 
int ns2_sns_bss_fsm_start (struct gprs_ns2_nse *nse, struct gprs_ns2_vc *nsvc, const struct osmo_sockaddr *remote)
 Start an IP-SNS FSM. More...
 
int gprs_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. More...
 
static void vty_dump_sns_ip4 (struct vty *vty, const struct gprs_ns_ie_ip4_elem *ip4)
 
static void vty_dump_sns_ip6 (struct vty *vty, const struct gprs_ns_ie_ip6_elem *ip6)
 
void gprs_ns2_sns_dump_vty (struct vty *vty, const struct gprs_ns2_nse *nse, bool stats)
 Dump the IP-SNS state to a vty. More...
 
static __attribute__ ((constructor))
 

Variables

static const struct value_string gprs_sns_event_names []
 
static const struct osmo_fsm_state ns2_sns_bss_states []
 
static struct osmo_fsm gprs_ns2_sns_bss_fsm
 

Detailed Description

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

Macro Definition Documentation

◆ ip4_weight_sum_data

#define ip4_weight_sum_data (   x,
 
)    ip4_weight_sum(x, y, true)

◆ ip4_weight_sum_sig

#define ip4_weight_sum_sig (   x,
 
)    ip4_weight_sum(x, y, false)

◆ ip6_weight_sum_data

#define ip6_weight_sum_data (   x,
 
)    ip6_weight_sum(x, y, true)

◆ ip6_weight_sum_sig

#define ip6_weight_sum_sig (   x,
 
)    ip6_weight_sum(x, y, false)

◆ S

#define S (   x)    (1 << (x))

Enumeration Type Documentation

◆ gprs_sns_bss_state

Enumerator
GPRS_SNS_ST_UNCONFIGURED 
GPRS_SNS_ST_SIZE 

SNS-SIZE procedure ongoing.

GPRS_SNS_ST_CONFIG_BSS 

SNS-CONFIG procedure (BSS->SGSN) ongoing.

GPRS_SNS_ST_CONFIG_SGSN 

SNS-CONFIG procedure (SGSN->BSS) ongoing.

GPRS_SNS_ST_CONFIGURED 
GPRS_SNS_ST_UNCONFIGURED 
GPRS_SNS_ST_SIZE 

SNS-SIZE procedure ongoing.

GPRS_SNS_ST_CONFIG_BSS 

SNS-CONFIG procedure (BSS->SGSN) ongoing.

GPRS_SNS_ST_CONFIG_SGSN 

SNS-CONFIG procedure (SGSN->BSS) ongoing.

GPRS_SNS_ST_CONFIGURED 

◆ gprs_sns_event

Enumerator
GPRS_SNS_EV_START 
GPRS_SNS_EV_SIZE 
GPRS_SNS_EV_SIZE_ACK 
GPRS_SNS_EV_CONFIG 
GPRS_SNS_EV_CONFIG_END 

SNS-CONFIG with end flag received.

GPRS_SNS_EV_CONFIG_ACK 
GPRS_SNS_EV_ADD 
GPRS_SNS_EV_DELETE 
GPRS_SNS_EV_CHANGE_WEIGHT 
GPRS_SNS_EV_NO_NSVC 
GPRS_SNS_EV_START 
GPRS_SNS_EV_SIZE 
GPRS_SNS_EV_SIZE_ACK 
GPRS_SNS_EV_CONFIG 
GPRS_SNS_EV_CONFIG_END 

SNS-CONFIG with end flag received.

GPRS_SNS_EV_CONFIG_ACK 
GPRS_SNS_EV_ADD 
GPRS_SNS_EV_DELETE 
GPRS_SNS_EV_CHANGE_WEIGHT 

◆ ns2_sns_type

Enumerator
IPv4 
IPv6 

Function Documentation

◆ __attribute__()

static __attribute__ ( (constructor)  )
static

◆ add_remote_ip4_elem()

static int add_remote_ip4_elem ( struct ns2_sns_state gss,
const struct gprs_ns_ie_ip4_elem ip4 
)
static

◆ add_remote_ip6_elem()

static int add_remote_ip6_elem ( struct ns2_sns_state gss,
const struct gprs_ns_ie_ip6_elem ip6 
)
static

◆ create_missing_nsvcs()

◆ do_sns_add()

◆ do_sns_change_weight()

◆ do_sns_delete()

◆ gprs_ns2_nse_sns_remote()

const struct osmo_sockaddr* gprs_ns2_nse_sns_remote ( struct gprs_ns2_nse nse)

Return the initial SNS remote socket address.

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

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

◆ gprs_ns2_sns_dump_vty()

void gprs_ns2_sns_dump_vty ( struct vty vty,
const struct gprs_ns2_nse nse,
bool  stats 
)

◆ gprs_ns2_sns_rx()

int gprs_ns2_sns_rx ( struct gprs_ns2_vc nsvc,
struct msgb msg,
struct tlv_parsed tp 
)

◆ ip4_weight_sum()

static int ip4_weight_sum ( const struct gprs_ns_ie_ip4_elem ip4,
unsigned int  num,
bool  data_weight 
)
static

◆ ip6_weight_sum()

static int ip6_weight_sum ( const struct gprs_ns_ie_ip6_elem ip6,
unsigned int  num,
bool  data_weight 
)
static

◆ ns2_nsvc_create_ip4()

◆ ns2_nsvc_create_ip6()

◆ 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]nseNS Entity in which the FSM runs
[in]idstring identifier \retruns FSM instance on success; NULL on error

References gprs_ns2_sns_bss_fsm, LOGL_DEBUG, ns2_sns_state::nse, osmo_fsm_inst_alloc(), osmo_fsm_inst_term, OSMO_FSM_TERM_ERROR, and osmo_fsm_inst::priv.

Referenced by gprs_ns2_ip_connect_sns().

◆ ns2_sns_bss_fsm_start()

◆ ns2_sns_free_nsvc()

◆ ns2_sns_fsm_bss_timer_cb()

◆ ns2_sns_st_all_action()

static void ns2_sns_st_all_action ( struct osmo_fsm_inst fi,
uint32_t  event,
void *  data 
)
static

◆ ns2_sns_st_config_bss()

static void ns2_sns_st_config_bss ( struct osmo_fsm_inst fi,
uint32_t  event,
void *  data 
)
static

◆ ns2_sns_st_config_bss_onenter()

◆ ns2_sns_st_config_sgsn()

◆ ns2_sns_st_configured()

static void ns2_sns_st_configured ( struct osmo_fsm_inst fi,
uint32_t  event,
void *  data 
)
static

◆ ns2_sns_st_configured_add()

◆ ns2_sns_st_configured_change()

static void ns2_sns_st_configured_change ( struct osmo_fsm_inst fi,
struct ns2_sns_state gss,
struct tlv_parsed tp 
)
static

◆ ns2_sns_st_configured_delete()

◆ ns2_sns_st_configured_onenter()

static void ns2_sns_st_configured_onenter ( struct osmo_fsm_inst fi,
uint32_t  old_state 
)
static

◆ ns2_sns_st_size()

◆ ns2_sns_st_size_onenter()

◆ ns2_sns_st_unconfigured()

static void ns2_sns_st_unconfigured ( struct osmo_fsm_inst fi,
uint32_t  event,
void *  data 
)
static

◆ ns_sns_st_config_sgsn_ip4()

◆ ns_sns_st_config_sgsn_ip6()

◆ nse_inst_from_fi()

◆ nsvc_by_ip4_elem()

static struct gprs_ns2_vc* nsvc_by_ip4_elem ( struct gprs_ns2_nse nse,
const struct gprs_ns_ie_ip4_elem ip4 
)
static

◆ nsvc_by_ip6_elem()

static struct gprs_ns2_vc* nsvc_by_ip6_elem ( struct gprs_ns2_nse nse,
const struct gprs_ns_ie_ip6_elem ip6 
)
static

◆ remove_remote_ip4_elem()

static int remove_remote_ip4_elem ( struct ns2_sns_state gss,
const struct gprs_ns_ie_ip4_elem ip4 
)
static

◆ remove_remote_ip6_elem()

static int remove_remote_ip6_elem ( struct ns2_sns_state gss,
const struct gprs_ns_ie_ip6_elem ip6 
)
static

◆ update_remote_ip4_elem()

◆ update_remote_ip6_elem()

◆ vty_dump_sns_ip4()

static void vty_dump_sns_ip4 ( struct vty vty,
const struct gprs_ns_ie_ip4_elem ip4 
)
static

◆ vty_dump_sns_ip6()

Variable Documentation

◆ gprs_ns2_sns_bss_fsm

struct osmo_fsm gprs_ns2_sns_bss_fsm
static
Initial value:
= {
.name = "GPRS-NS2-SNS-BSS",
.states = ns2_sns_bss_states,
.allstate_event_mask = GPRS_SNS_EV_NO_NSVC,
.allstate_action = ns2_sns_st_all_action,
.cleanup = NULL,
.event_names = gprs_sns_event_names,
.pre_term = NULL,
.log_subsys = DLNS,
}
static int ns2_sns_fsm_bss_timer_cb(struct osmo_fsm_inst *fi)
Definition: gprs_ns2_sns.c:1178
static const struct value_string gprs_sns_event_names[]
Definition: gprs_ns2_sns.c:84
@ GPRS_SNS_EV_NO_NSVC
Definition: gprs_ns2_sns.c:81
static const struct osmo_fsm_state ns2_sns_bss_states[]
Definition: gprs_ns2_sns.c:1131
static void ns2_sns_st_all_action(struct osmo_fsm_inst *fi, uint32_t event, void *data)
Definition: gprs_ns2_sns.c:1194
#define DLNS
#define ARRAY_SIZE(x)

Referenced by __attribute__(), and ns2_sns_bss_fsm_alloc().

◆ gprs_sns_event_names

const struct value_string gprs_sns_event_names[]
static
Initial value:
= {
{ GPRS_SNS_EV_START, "START" },
{ GPRS_SNS_EV_SIZE, "SIZE" },
{ GPRS_SNS_EV_SIZE_ACK, "SIZE_ACK" },
{ GPRS_SNS_EV_CONFIG, "CONFIG" },
{ GPRS_SNS_EV_CONFIG_END, "CONFIG_END" },
{ GPRS_SNS_EV_CONFIG_ACK, "CONFIG_ACK" },
{ GPRS_SNS_EV_ADD, "ADD" },
{ GPRS_SNS_EV_DELETE, "DELETE" },
{ GPRS_SNS_EV_CHANGE_WEIGHT, "CHANGE_WEIGHT" },
{ 0, NULL }
}
@ GPRS_SNS_EV_CONFIG_ACK
Definition: gprs_ns2_sns.c:77
@ GPRS_SNS_EV_SIZE_ACK
Definition: gprs_ns2_sns.c:74
@ GPRS_SNS_EV_START
Definition: gprs_ns2_sns.c:72
@ GPRS_SNS_EV_CONFIG_END
SNS-CONFIG with end flag received.
Definition: gprs_ns2_sns.c:76
@ GPRS_SNS_EV_ADD
Definition: gprs_ns2_sns.c:78
@ GPRS_SNS_EV_CONFIG
Definition: gprs_ns2_sns.c:75
@ GPRS_SNS_EV_DELETE
Definition: gprs_ns2_sns.c:79
@ GPRS_SNS_EV_SIZE
Definition: gprs_ns2_sns.c:73
@ GPRS_SNS_EV_CHANGE_WEIGHT
Definition: gprs_ns2_sns.c:80

◆ ns2_sns_bss_states

const struct osmo_fsm_state ns2_sns_bss_states[]
static