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

VTY interface for our GPRS Networks Service (NS) implementation. More...

#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>
#include <arpa/inet.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/byteswap.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/select.h>
#include <osmocom/core/rate_ctr.h>
#include <osmocom/core/socket.h>
#include <osmocom/core/sockaddr_str.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/gprs/gprs_ns2.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/vty/vty.h>
#include <osmocom/vty/command.h>
#include <osmocom/vty/logging.h>
#include <osmocom/vty/telnet_interface.h>
#include <osmocom/vty/misc.h>
#include "gprs_ns2_internal.h"

Data Structures

struct  ns2_vty_priv
 
struct  ns2_vty_vc
 

Macros

#define NSE_CMD_STR   "Persistent NS Entity\n" "NS Entity ID (NSEI)\n"
 
#define ENCAPS_STR   "NS encapsulation options\n"
 

Functions

static void log_set_nsvc_filter (struct log_target *target, struct gprs_ns2_vc *nsvc)
 
static struct ns2_vty_vcvtyvc_alloc (uint16_t nsei)
 
static void ns2_vc_free (struct ns2_vty_vc *vtyvc)
 
static struct ns2_vty_vcvtyvc_by_nsei (uint16_t nsei, bool alloc_missing)
 
static int config_write_ns (struct vty *vty)
 
 DEFUN (cfg_ns, cfg_ns_cmd, "ns", "Configure the GPRS Network Service")
 
static void dump_nsvc (struct vty *vty, struct gprs_ns2_vc *nsvc, bool stats)
 
static void dump_nse (struct vty *vty, const struct gprs_ns2_nse *nse, bool stats, bool persistent_only)
 
static void dump_bind (struct vty *vty, const struct gprs_ns2_vc_bind *bind, bool stats)
 
static void dump_ns (struct vty *vty, const struct gprs_ns2_inst *nsi, bool stats, bool persistent_only)
 
 DEFUN (show_ns, show_ns_cmd, "show ns", SHOW_STR "Display information about the NS protocol")
 
 DEFUN (show_ns_stats, show_ns_stats_cmd, "show ns stats", SHOW_STR "Display information about the NS protocol\ "Include statistics\")
 
 DEFUN (show_ns_pers, show_ns_pers_cmd, "show ns persistent", SHOW_STR "Display information about the NS protocol\ "Show only persistent NS\")
 
 DEFUN (show_nse, show_nse_cmd, "show ns (nsei|nsvc) <0-65535> [stats]", SHOW_STR "Display information about the NS protocol\ "Select one NSE by its NSE Identifier\" "Select one NSE by its NS-VC Identifier\" "The Identifier of selected type\" "Include Statistics\")
 
 DEFUN (cfg_nse_nsvc, cfg_nse_nsvci_cmd, "nse <0-65535> nsvci <0-65535>", NSE_CMD_STR "NS Virtual Connection\ "NS Virtual Connection ID(NSVCI)\")
 
 DEFUN (cfg_nse_remoteip, cfg_nse_remoteip_cmd, "nse <0-65535> remote-ip " VTY_IPV46_CMD, NSE_CMD_STR "Remote IP Address\ "Remote IPv4 Address\" "Remote IPv6 Address\")
 
 DEFUN (cfg_nse_remoteport, cfg_nse_remoteport_cmd, "nse <0-65535> remote-port <0-65535>", NSE_CMD_STR "Remote UDP Port\ "Remote UDP Port Number\")
 
 DEFUN (cfg_nse_fr_dlci, cfg_nse_fr_dlci_cmd, "nse <0-65535> fr-dlci <16-1007>", NSE_CMD_STR "Frame Relay DLCI\ "Frame Relay DLCI Number\")
 
 DEFUN (cfg_nse_encaps, cfg_nse_encaps_cmd, "nse <0-65535> encapsulation (udp|framerelay-gre)", NSE_CMD_STR "Encapsulation for NS\ "UDP/IP Encapsulation\" "Frame-Relay/GRE/IP Encapsulation\")
 
 DEFUN (cfg_nse_remoterole, cfg_nse_remoterole_cmd, "nse <0-65535> remote-role (sgsn|bss)", NSE_CMD_STR "Remote NSE Role\ "Remote Peer is SGSN\" "Remote Peer is BSS\")
 
 DEFUN (cfg_no_nse, cfg_no_nse_cmd, "no nse <0-65535>", "Delete Persistent NS Entity\ "Delete " NSE_CMD_STR)
 
 DEFUN (cfg_ns_timer, cfg_ns_timer_cmd, "timer " NS_TIMERS " <0-65535>", "Network Service Timer\ NS_TIMERS_HELP "Timer Value\")
 
 DEFUN (cfg_nsip_local_ip, cfg_nsip_local_ip_cmd, "encapsulation udp local-ip " VTY_IPV46_CMD, ENCAPS_STR "NS over UDP Encapsulation\ "Set the IP address on which we listen for NS/UDP\" "IPv4 Address\" "IPv6 Address\")
 
 DEFUN (cfg_nsip_local_port, cfg_nsip_local_port_cmd, "encapsulation udp local-port <0-65535>", ENCAPS_STR "NS over UDP Encapsulation\ "Set the UDP port on which we listen for NS/UDP\" "UDP port number\")
 
 DEFUN (cfg_nsip_dscp, cfg_nsip_dscp_cmd, "encapsulation udp dscp <0-255>", ENCAPS_STR "NS over UDP Encapsulation\ "Set DSCP/TOS on the UDP socket\" "DSCP Value\")
 
 DEFUN (cfg_nsip_res_block_unblock, cfg_nsip_res_block_unblock_cmd, "encapsulation udp use-reset-block-unblock (enabled|disabled)", ENCAPS_STR "NS over UDP Encapsulation\ "Use NS-{RESET, BLOCK, UNBLOCK} procedures in violation of 3GPP TS 48.016\" "Enable NS-{RESET, BLOCK, UNBLOCK}\" "Disable NS-{RESET, BLOCK, UNBLOCK}\")
 
 DEFUN (cfg_frgre_local_ip, cfg_frgre_local_ip_cmd, "encapsulation framerelay-gre local-ip " VTY_IPV46_CMD, ENCAPS_STR "NS over Frame Relay over GRE Encapsulation\ "Set the IP address on which we listen for NS/FR/GRE\" "IPv4 Address\" "IPv6 Address\")
 
 DEFUN (cfg_frgre_enable, cfg_frgre_enable_cmd, "encapsulation framerelay-gre enabled (1|0)", ENCAPS_STR "NS over Frame Relay over GRE Encapsulation\ "Enable or disable Frame Relay over GRE\" "Enable\" "Disable\")
 
 DEFUN (logging_fltr_nsvc, logging_fltr_nsvc_cmd, "logging filter nsvc nsvci <0-65535>", LOGGING_STR FILTER_STR "Filter based on NS Virtual Connection\ "Identify NS-VC by NSVCI\" "Numeric identifier\")
 
int gprs_ns2_vty_init (struct gprs_ns2_inst *nsi, const struct osmo_sockaddr_str *default_bind)
 gprs_ns2_vty_init initialize the vty More...
 
int gprs_ns2_vty_create ()
 gprs_ns2_vty_create parse the vty tree into ns nodes It has to be in different steps to ensure the bind is created before creating VCs. More...
 
void ns2_vty_bind_apply (struct gprs_ns2_vc_bind *bind)
 ns2_vty_bind_apply will be called when a new bind is created to apply vty settings More...
 
void gprs_ns2_vty_force_vc_mode (bool force, enum gprs_ns2_vc_mode mode, const char *reason)
 ns2_vty_force_vc_mode force a mode and prevents the vty from overwriting it. More...
 

Variables

static struct gprs_ns2_instvty_nsi = NULL
 
static struct ns2_vty_priv priv
 
static const struct value_string gprs_ns_timer_strs []
 
static struct cmd_node ns_node
 

Detailed Description

VTY interface for our GPRS Networks Service (NS) implementation.

Macro Definition Documentation

◆ ENCAPS_STR

#define ENCAPS_STR   "NS encapsulation options\n"

◆ NSE_CMD_STR

#define NSE_CMD_STR   "Persistent NS Entity\n" "NS Entity ID (NSEI)\n"

Function Documentation

◆ config_write_ns()

◆ DEFUN() [1/20]

DEFUN ( cfg_ns  ,
cfg_ns_cmd  ,
"ns"  ,
"Configure the GPRS Network Service"   
)

References CMD_SUCCESS, L_NS_NODE, and vty::node.

◆ DEFUN() [2/20]

DEFUN ( show_ns  ,
show_ns_cmd  ,
"show ns"  ,
SHOW_STR "Display information about the NS protocol"   
)

References CMD_SUCCESS, and dump_ns().

◆ DEFUN() [3/20]

DEFUN ( show_ns_stats  ,
show_ns_stats_cmd  ,
"show ns stats"  ,
SHOW_STR "Display information about the NS protocol\ "Include statistics\"   
)

References CMD_SUCCESS, and dump_ns().

◆ DEFUN() [4/20]

DEFUN ( show_ns_pers  ,
show_ns_pers_cmd  ,
"show ns persistent"  ,
SHOW_STR "Display information about the NS protocol\ "Show only persistent NS\"   
)

References CMD_SUCCESS, and dump_ns().

◆ DEFUN() [5/20]

DEFUN ( show_nse  ,
show_nse_cmd  ,
"show ns (nsei|nsvc) <0-65535> "  [stats],
SHOW_STR "Display information about the NS protocol\ "Select one NSE by its NSE Identifier\" "Select one NSE by its NS-VC Identifier\" "The Identifier of selected type\" "Include Statistics\"   
)

◆ DEFUN() [6/20]

DEFUN ( cfg_nse_nsvc  ,
cfg_nse_nsvci_cmd  ,
"nse <0-65535> nsvci <0-65535>"  ,
NSE_CMD_STR "NS Virtual Connection\ "NS Virtual Connection ID(NSVCI)\"   
)

◆ DEFUN() [7/20]

DEFUN ( cfg_nse_remoteip  ,
cfg_nse_remoteip_cmd  ,
"nse <0-65535> remote-ip "  VTY_IPV46_CMD,
NSE_CMD_STR "Remote IP Address\ "Remote IPv4 Address\" "Remote IPv6 Address\"   
)

◆ DEFUN() [8/20]

DEFUN ( cfg_nse_remoteport  ,
cfg_nse_remoteport_cmd  ,
"nse <0-65535> remote-port <0-65535>"  ,
NSE_CMD_STR "Remote UDP Port\ "Remote UDP Port Number\"   
)

◆ DEFUN() [9/20]

DEFUN ( cfg_nse_fr_dlci  ,
cfg_nse_fr_dlci_cmd  ,
"nse <0-65535> fr-dlci <16-1007>"  ,
NSE_CMD_STR "Frame Relay DLCI\ "Frame Relay DLCI Number\"   
)

◆ DEFUN() [10/20]

DEFUN ( cfg_nse_encaps  ,
cfg_nse_encaps_cmd  ,
"nse <0-65535> encapsulation (udp|framerelay-gre)"  ,
NSE_CMD_STR "Encapsulation for NS\ "UDP/IP Encapsulation\" "Frame-Relay/GRE/IP Encapsulation\"   
)

◆ DEFUN() [11/20]

DEFUN ( cfg_nse_remoterole  ,
cfg_nse_remoterole_cmd  ,
"nse <0-65535> remote-role (sgsn|bss)"  ,
NSE_CMD_STR "Remote NSE Role\ "Remote Peer is SGSN\" "Remote Peer is BSS\"   
)

◆ DEFUN() [12/20]

DEFUN ( cfg_no_nse  ,
cfg_no_nse_cmd  ,
"no nse <0-65535>"  ,
"Delete Persistent NS Entity\ "Delete "  NSE_CMD_STR 
)

◆ DEFUN() [13/20]

DEFUN ( cfg_ns_timer  ,
cfg_ns_timer_cmd  ,
"timer " NS_TIMERS " <0-65535>"  ,
"Network Service Timer\ NS_TIMERS_HELP "Timer Value\"   
)

◆ DEFUN() [14/20]

DEFUN ( cfg_nsip_local_ip  ,
cfg_nsip_local_ip_cmd  ,
"encapsulation udp local-ip "  VTY_IPV46_CMD,
ENCAPS_STR "NS over UDP Encapsulation\ "Set the IP address on which we listen for NS/UDP\" "IPv4 Address\" "IPv6 Address\"   
)

◆ DEFUN() [15/20]

DEFUN ( cfg_nsip_local_port  ,
cfg_nsip_local_port_cmd  ,
"encapsulation udp local-port <0-65535>"  ,
ENCAPS_STR "NS over UDP Encapsulation\ "Set the UDP port on which we listen for NS/UDP\" "UDP port number\"   
)

◆ DEFUN() [16/20]

DEFUN ( cfg_nsip_dscp  ,
cfg_nsip_dscp_cmd  ,
"encapsulation udp dscp <0-255>"  ,
ENCAPS_STR "NS over UDP Encapsulation\ "Set DSCP/TOS on the UDP socket\" "DSCP Value\"   
)

◆ DEFUN() [17/20]

DEFUN ( cfg_nsip_res_block_unblock  ,
cfg_nsip_res_block_unblock_cmd  ,
"encapsulation udp use-reset-block-unblock (enabled|disabled)"  ,
ENCAPS_STR "NS over UDP Encapsulation\ "Use NS-{RESET, BLOCK, UNBLOCK} procedures in violation of 3GPP TS 48.016\" "Enable NS-{RESET, BLOCK, UNBLOCK}\" "Disable NS-{RESET, BLOCK, UNBLOCK}\"   
)

◆ DEFUN() [18/20]

DEFUN ( cfg_frgre_local_ip  ,
cfg_frgre_local_ip_cmd  ,
"encapsulation framerelay-gre local-ip "  VTY_IPV46_CMD,
ENCAPS_STR "NS over Frame Relay over GRE Encapsulation\ "Set the IP address on which we listen for NS/FR/GRE\" "IPv4 Address\" "IPv6 Address\"   
)

◆ DEFUN() [19/20]

DEFUN ( cfg_frgre_enable  ,
cfg_frgre_enable_cmd  ,
"encapsulation framerelay-gre enabled (1|0)"  ,
ENCAPS_STR "NS over Frame Relay over GRE Encapsulation\ "Enable or disable Frame Relay over GRE\" "Enable\" "Disable\"   
)

◆ DEFUN() [20/20]

DEFUN ( logging_fltr_nsvc  ,
logging_fltr_nsvc_cmd  ,
"logging filter nsvc nsvci <0-65535>"  ,
LOGGING_STR FILTER_STR "Filter based on NS Virtual Connection\ "Identify NS-VC by NSVCI\" "Numeric identifier\"   
)

◆ dump_bind()

static void dump_bind ( struct vty vty,
const struct gprs_ns2_vc_bind bind,
bool  stats 
)
static

References gprs_ns2_vc_bind::dump_vty.

Referenced by dump_ns().

◆ dump_ns()

static void dump_ns ( struct vty vty,
const struct gprs_ns2_inst nsi,
bool  stats,
bool  persistent_only 
)
static

◆ dump_nse()

static void dump_nse ( struct vty vty,
const struct gprs_ns2_nse nse,
bool  stats,
bool  persistent_only 
)
static

◆ dump_nsvc()

◆ gprs_ns2_vty_create()

◆ gprs_ns2_vty_force_vc_mode()

void gprs_ns2_vty_force_vc_mode ( bool  force,
enum gprs_ns2_vc_mode  mode,
const char *  reason 
)

ns2_vty_force_vc_mode force a mode and prevents the vty from overwriting it.

Parameters
forceif true mode and reason will be set. false to allow modification via vty.
mode
reasonA description shown to the user when a vty command wants to change the mode.

References ns2_vty_priv::force_vc_mode, ns2_vty_priv::force_vc_mode_reason, priv, and ns2_vty_priv::vc_mode.

◆ gprs_ns2_vty_init()

int gprs_ns2_vty_init ( struct gprs_ns2_inst nsi,
const struct osmo_sockaddr_str default_bind 
)

gprs_ns2_vty_init initialize the vty

Parameters
[in,out]nsi
[in]default_bindset the default address to bind to. Can be NULL.
Returns
0 on success

References CFG_LOG_NODE, CONFIG_NODE, config_write_ns(), INIT_LLIST_HEAD, install_lib_element(), install_lib_element_ve(), install_node(), L_NS_NODE, NS2_VC_MODE_BLOCKRESET, priv, ns2_vty_priv::udp, ns2_vty_priv::vc_mode, and ns2_vty_priv::vtyvc.

◆ log_set_nsvc_filter()

static void log_set_nsvc_filter ( struct log_target target,
struct gprs_ns2_vc nsvc 
)
static

◆ ns2_vc_free()

static void ns2_vc_free ( struct ns2_vty_vc vtyvc)
static

References ns2_vty_vc::list, and llist_del().

Referenced by DEFUN().

◆ ns2_vty_bind_apply()

void ns2_vty_bind_apply ( struct gprs_ns2_vc_bind bind)

ns2_vty_bind_apply will be called when a new bind is created to apply vty settings

Parameters
bind
Returns

References gprs_ns2_bind_set_mode(), priv, and ns2_vty_priv::vc_mode.

Referenced by gprs_ns2_frgre_bind(), and gprs_ns2_ip_bind().

◆ vtyvc_alloc()

static struct ns2_vty_vc* vtyvc_alloc ( uint16_t  nsei)
static

◆ vtyvc_by_nsei()

static struct ns2_vty_vc* vtyvc_by_nsei ( uint16_t  nsei,
bool  alloc_missing 
)
static

Variable Documentation

◆ gprs_ns_timer_strs

const struct value_string gprs_ns_timer_strs[]
static
Initial value:
= {
{ 0, "tns-block" },
{ 1, "tns-block-retries" },
{ 2, "tns-reset" },
{ 3, "tns-reset-retries" },
{ 4, "tns-test" },
{ 5, "tns-alive" },
{ 6, "tns-alive-retries" },
{ 7, "tsns-prov" },
{ 0, NULL }
}

◆ ns_node

struct cmd_node ns_node
static
Initial value:
= {
"%s(config-ns)# ",
1,
}
L_NS_NODE

◆ priv

◆ vty_nsi

struct gprs_ns2_inst* vty_nsi = NULL
static

Referenced by DEFUN().