libosmogb 1.9.0.192-1c24
Osmocom Gb library
gprs_ns_sns.c File Reference
#include <errno.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <osmocom/core/fsm.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/signal.h>
#include <osmocom/core/socket.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/gprs/gprs_msgb.h>
#include <osmocom/gprs/gprs_ns.h>
#include "common_vty.h"
#include "gb_internal.h"
#include <osmocom/vty/vty.h>
#include <osmocom/vty/misc.h>

Data Structures

struct  gprs_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)
 

Enumerations

enum  gprs_sns_bss_state {
  GPRS_SNS_ST_UNCONFIGURED ,
  GPRS_SNS_ST_BSS_SIZE ,
  GPRS_SNS_ST_BSS_CONFIG_BSS ,
  GPRS_SNS_ST_BSS_CONFIG_SGSN ,
  GPRS_SNS_ST_CONFIGURED ,
  GPRS_SNS_ST_SGSN_WAIT_CONFIG ,
  GPRS_SNS_ST_SGSN_WAIT_CONFIG_ACK ,
  GPRS_SNS_ST_LOCAL_PROCEDURE ,
  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
}
 

Functions

static struct gprs_ns_instns_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 struct gprs_nsvcnsvc_by_ip4_elem (struct gprs_ns_inst *nsi, const struct gprs_ns_ie_ip4_elem *ip4)
 
static struct gprs_nsvcgprs_nsvc_create_ip4 (struct gprs_ns_inst *nsi, const struct gprs_ns_ie_ip4_elem *ip4)
 
static int create_missing_nsvcs (struct osmo_fsm_inst *fi)
 
static int add_remote_ip4_elem (struct gprs_sns_state *gss, const struct gprs_ns_ie_ip4_elem *ip4)
 
static int remove_remote_ip4_elem (struct gprs_sns_state *gss, const struct gprs_ns_ie_ip4_elem *ip4)
 
static int update_remote_ip4_elem (struct gprs_sns_state *gss, const struct gprs_ns_ie_ip4_elem *ip4)
 
static int do_sns_change_weight (struct osmo_fsm_inst *fi, const struct gprs_ns_ie_ip4_elem *ip4)
 
static int do_sns_delete (struct osmo_fsm_inst *fi, const struct gprs_ns_ie_ip4_elem *ip4)
 
static int do_sns_add (struct osmo_fsm_inst *fi, const struct gprs_ns_ie_ip4_elem *ip4)
 
static void gprs_sns_st_unconfigured (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void gprs_sns_st_size (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void gprs_sns_st_size_onenter (struct osmo_fsm_inst *fi, uint32_t old_state)
 
static void gprs_sns_st_config_bss (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void gprs_sns_st_config_bss_onenter (struct osmo_fsm_inst *fi, uint32_t old_state)
 
static void gprs_sns_st_config_sgsn (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void gprs_sns_st_configured (struct osmo_fsm_inst *fi, uint32_t event, void *data)
 
static void gprs_sns_st_configured_onenter (struct osmo_fsm_inst *fi, uint32_t old_state)
 
static int gprs_sns_fsm_bss_timer_cb (struct osmo_fsm_inst *fi)
 
struct osmo_fsm_instgprs_sns_bss_fsm_alloc (void *ctx, struct gprs_nsvc *nsvc, const char *id)
 
int gprs_sns_bss_fsm_start (struct gprs_ns_inst *nsi)
 
int gprs_ns_rx_sns (struct gprs_ns_inst *nsi, struct msgb *msg, struct tlv_parsed *tp)
 
int gprs_sns_init (void)
 
static void vty_dump_sns_ip4 (struct vty *vty, const struct gprs_ns_ie_ip4_elem *ip4)
 
void gprs_sns_dump_vty (struct vty *vty, const struct gprs_ns_inst *nsi, bool stats)
 

Variables

static const struct value_string gprs_sns_event_names []
 
static const struct osmo_fsm_state gprs_sns_bss_states []
 
static struct osmo_fsm gprs_sns_bss_fsm
 

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)

◆ S

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

Enumeration Type Documentation

◆ gprs_sns_bss_state

Enumerator
GPRS_SNS_ST_UNCONFIGURED 
GPRS_SNS_ST_BSS_SIZE 

SNS-SIZE procedure ongoing.

GPRS_SNS_ST_BSS_CONFIG_BSS 

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

GPRS_SNS_ST_BSS_CONFIG_SGSN 

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

GPRS_SNS_ST_CONFIGURED 
GPRS_SNS_ST_SGSN_WAIT_CONFIG 
GPRS_SNS_ST_SGSN_WAIT_CONFIG_ACK 
GPRS_SNS_ST_LOCAL_PROCEDURE 

in process of a ADD/DEL/CHANGE procedure towards SGSN (BSS->SGSN)

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 

Function Documentation

◆ add_remote_ip4_elem()

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

◆ create_missing_nsvcs()

◆ do_sns_add()

◆ do_sns_change_weight()

◆ do_sns_delete()

◆ gprs_ns_rx_sns()

◆ gprs_nsvc_create_ip4()

◆ gprs_sns_bss_fsm_alloc()

◆ gprs_sns_bss_fsm_start()

int gprs_sns_bss_fsm_start ( struct gprs_ns_inst nsi)

◆ gprs_sns_dump_vty()

◆ gprs_sns_fsm_bss_timer_cb()

◆ gprs_sns_init()

int gprs_sns_init ( void  )

◆ gprs_sns_st_config_bss()

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

◆ gprs_sns_st_config_bss_onenter()

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

◆ gprs_sns_st_config_sgsn()

◆ gprs_sns_st_configured()

◆ gprs_sns_st_configured_onenter()

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

◆ gprs_sns_st_size()

◆ gprs_sns_st_size_onenter()

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

◆ gprs_sns_st_unconfigured()

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

◆ ip4_weight_sum()

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

◆ ns_inst_from_fi()

◆ nsvc_by_ip4_elem()

static struct gprs_nsvc * nsvc_by_ip4_elem ( struct gprs_ns_inst nsi,
const struct gprs_ns_ie_ip4_elem ip4 
)
static

◆ remove_remote_ip4_elem()

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

◆ update_remote_ip4_elem()

◆ vty_dump_sns_ip4()

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

Variable Documentation

◆ gprs_sns_bss_fsm

struct osmo_fsm gprs_sns_bss_fsm
static
Initial value:
= {
.name = "GPRS-SNS-BSS",
.allstate_event_mask = 0,
.allstate_action = NULL,
.cleanup = NULL,
.event_names = gprs_sns_event_names,
.pre_term = NULL,
}
static const struct osmo_fsm_state gprs_sns_bss_states[]
Definition: gprs_ns_sns.c:557
static const struct value_string gprs_sns_event_names[]
Definition: gprs_ns_sns.c:288
static int gprs_sns_fsm_bss_timer_cb(struct osmo_fsm_inst *fi)
Definition: gprs_ns_sns.c:602
#define ARRAY_SIZE(x)

Referenced by gprs_sns_bss_fsm_alloc(), and gprs_sns_init().

◆ gprs_sns_bss_states

const struct osmo_fsm_state gprs_sns_bss_states[]
static

◆ 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_ns_sns.c:282
@ GPRS_SNS_EV_SIZE_ACK
Definition: gprs_ns_sns.c:279
@ GPRS_SNS_EV_START
Definition: gprs_ns_sns.c:277
@ GPRS_SNS_EV_CONFIG_END
SNS-CONFIG with end flag received.
Definition: gprs_ns_sns.c:281
@ GPRS_SNS_EV_ADD
Definition: gprs_ns_sns.c:283
@ GPRS_SNS_EV_CONFIG
Definition: gprs_ns_sns.c:280
@ GPRS_SNS_EV_DELETE
Definition: gprs_ns_sns.c:284
@ GPRS_SNS_EV_SIZE
Definition: gprs_ns_sns.c:278
@ GPRS_SNS_EV_CHANGE_WEIGHT
Definition: gprs_ns_sns.c:285