libosmogb 1.9.0.192-1c24
Osmocom Gb library
gprs_ns_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/gsm/tlv.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/select.h>
#include <osmocom/core/rate_ctr.h>
#include <osmocom/gprs/gprs_ns.h>
#include <osmocom/gprs/gprs_bssgp.h>
#include <osmocom/core/socket.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 "common_vty.h"
#include "gb_internal.h"

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_nsvc *nsvc)
 
static int config_write_ns (struct vty *vty)
 
 DEFUN (cfg_ns, cfg_ns_cmd, "ns", "Configure the GPRS Network Service")
 
static void dump_nse (struct vty *vty, const struct gprs_nsvc *nsvc, bool stats, bool persistent_only)
 
static void dump_ns (struct vty *vty, const struct gprs_ns_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\n" "Include statistics\n")
 
 DEFUN (show_ns_pers, show_ns_pers_cmd, "show ns persistent", SHOW_STR "Display information about the NS protocol\n" "Show only persistent NS\n")
 
 DEFUN (show_nse, show_nse_cmd, "show ns (nsei|nsvc) <0-65535> [stats]", SHOW_STR "Display information about the NS protocol\n" "Select one NSE by its NSE Identifier\n" "Select one NSE by its NS-VC Identifier\n" "The Identifier of selected type\n" "Include Statistics\n")
 
 DEFUN (cfg_nse_nsvc, cfg_nse_nsvci_cmd, "nse <0-65535> nsvci <0-65534>", NSE_CMD_STR "NS Virtual Connection\n" "NS Virtual Connection ID (NSVCI)\n")
 
 DEFUN (cfg_nse_remoteip, cfg_nse_remoteip_cmd, "nse <0-65535> remote-ip A.B.C.D", NSE_CMD_STR "Remote IP Address\n" "Remote IP Address\n")
 
 DEFUN (cfg_nse_remoteport, cfg_nse_remoteport_cmd, "nse <0-65535> remote-port <0-65535>", NSE_CMD_STR "Remote UDP Port\n" "Remote UDP Port Number\n")
 
 DEFUN (cfg_nse_fr_dlci, cfg_nse_fr_dlci_cmd, "nse <0-65535> fr-dlci <16-1007>", NSE_CMD_STR "Frame Relay DLCI\n" "Frame Relay DLCI Number\n")
 
 DEFUN (cfg_nse_encaps, cfg_nse_encaps_cmd, "nse <0-65535> encapsulation (udp|framerelay-gre)", NSE_CMD_STR "Encapsulation for NS\n" "UDP/IP Encapsulation\n" "Frame-Relay/GRE/IP Encapsulation\n")
 
 DEFUN (cfg_nse_remoterole, cfg_nse_remoterole_cmd, "nse <0-65535> remote-role (sgsn|bss)", NSE_CMD_STR "Remote NSE Role\n" "Remote Peer is SGSN\n" "Remote Peer is BSS\n")
 
 DEFUN (cfg_no_nse, cfg_no_nse_cmd, "no nse <0-65535>", "Delete Persistent NS Entity\n" "Delete " NSE_CMD_STR)
 
 DEFUN (cfg_ns_timer, cfg_ns_timer_cmd, "timer " NS_TIMERS " <0-65535>", "Network Service Timer\n" NS_TIMERS_HELP "Timer Value\n")
 
 DEFUN (cfg_nsip_local_ip, cfg_nsip_local_ip_cmd, "encapsulation udp local-ip A.B.C.D", ENCAPS_STR "NS over UDP Encapsulation\n" "Set the IP address on which we listen for NS/UDP\n" "IP Address\n")
 
 DEFUN (cfg_nsip_local_port, cfg_nsip_local_port_cmd, "encapsulation udp local-port <0-65535>", ENCAPS_STR "NS over UDP Encapsulation\n" "Set the UDP port on which we listen for NS/UDP\n" "UDP port number\n")
 
 DEFUN (cfg_nsip_dscp, cfg_nsip_dscp_cmd, "encapsulation udp dscp <0-255>", ENCAPS_STR "NS over UDP Encapsulation\n" "Set DSCP/TOS on the UDP socket\n" "DSCP Value\n")
 
 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\n" "Use NS-{RESET,BLOCK,UNBLOCK} procedures in violation of 3GPP TS 48.016\n" "Enable NS-{RESET,BLOCK,UNBLOCK}\n" "Disable NS-{RESET,BLOCK,UNBLOCK}\n")
 
 DEFUN (cfg_frgre_local_ip, cfg_frgre_local_ip_cmd, "encapsulation framerelay-gre local-ip A.B.C.D", ENCAPS_STR "NS over Frame Relay over GRE Encapsulation\n" "Set the IP address on which we listen for NS/FR/GRE\n" "IP Address\n")
 
 DEFUN (cfg_frgre_enable, cfg_frgre_enable_cmd, "encapsulation framerelay-gre enabled (1|0)", ENCAPS_STR "NS over Frame Relay over GRE Encapsulation\n" "Enable or disable Frame Relay over GRE\n" "Enable\n" "Disable\n")
 
 DEFUN (nsvc_nsei, nsvc_nsei_cmd, "nsvc (nsei|nsvci) <0-65535> (block|unblock|reset)", "Perform an operation on a NSVC\n" "NSEI to identify NS-VC Identifier (NS-VCI)\n" "NS-VC Identifier (NS-VCI)\n" "The NSEI\n" "Initiate BLOCK procedure\n" "Initiate UNBLOCK procedure\n" "Initiate RESET procedure\n")
 
 DEFUN (logging_fltr_nsvc, logging_fltr_nsvc_cmd, "logging filter nsvc (nsei|nsvci) <0-65535>", LOGGING_STR FILTER_STR "Filter based on NS Virtual Connection\n" "Identify NS-VC by NSEI\n" "Identify NS-VC by NSVCI\n" "Numeric identifier\n")
 
int gprs_ns_vty_init (struct gprs_ns_inst *nsi)
 

Variables

static struct gprs_ns_instvty_nsi = NULL
 
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/21]

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

◆ DEFUN() [2/21]

DEFUN ( cfg_frgre_local_ip  ,
cfg_frgre_local_ip_cmd  ,
"encapsulation framerelay-gre local-ip A.B.C.D"  ,
ENCAPS_STR "NS over Frame Relay over GRE Encapsulation\n" "Set the IP address on which we listen for NS/FR/GRE\n" "IP Address\n  
)

◆ DEFUN() [3/21]

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

◆ DEFUN() [4/21]

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

References CMD_SUCCESS, L_NS_NODE, and vty::node.

◆ DEFUN() [5/21]

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

◆ DEFUN() [6/21]

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

◆ DEFUN() [7/21]

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

◆ DEFUN() [8/21]

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

◆ DEFUN() [9/21]

DEFUN ( cfg_nse_remoteip  ,
cfg_nse_remoteip_cmd  ,
"nse <0-65535> remote-ip A.B.C.D"  ,
NSE_CMD_STR "Remote IP Address\n" "Remote IP Address\n  
)

◆ DEFUN() [10/21]

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

◆ DEFUN() [11/21]

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

◆ DEFUN() [12/21]

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

◆ DEFUN() [13/21]

DEFUN ( cfg_nsip_local_ip  ,
cfg_nsip_local_ip_cmd  ,
"encapsulation udp local-ip A.B.C.D"  ,
ENCAPS_STR "NS over UDP Encapsulation\n" "Set the IP address on which we listen for NS/UDP\n" "IP Address\n  
)

◆ DEFUN() [14/21]

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

◆ DEFUN() [15/21]

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\n" "Use NS-{RESET,BLOCK,UNBLOCK} procedures in violation of 3GPP TS 48.016\n" "Enable NS-{RESET,BLOCK,UNBLOCK}\n" "Disable NS-{RESET,BLOCK,UNBLOCK}\n  
)

◆ DEFUN() [16/21]

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

◆ DEFUN() [17/21]

DEFUN ( nsvc_nsei  ,
nsvc_nsei_cmd  ,
"nsvc (nsei|nsvci) <0-65535> (block|unblock|reset)"  ,
"Perform an operation on a NSVC\n" "NSEI to identify NS-VC Identifier (NS-VCI)\n" "NS-VC Identifier (NS-VCI)\n" "The NSEI\n" "Initiate BLOCK procedure\n" "Initiate UNBLOCK procedure\n" "Initiate RESET procedure\n  
)

◆ DEFUN() [18/21]

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

References CMD_SUCCESS, dump_ns(), and vty_nsi.

◆ DEFUN() [19/21]

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

References CMD_SUCCESS, dump_ns(), and vty_nsi.

◆ DEFUN() [20/21]

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

References CMD_SUCCESS, dump_ns(), and vty_nsi.

◆ DEFUN() [21/21]

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

◆ dump_ns()

◆ dump_nse()

◆ gprs_ns_vty_init()

◆ log_set_nsvc_filter()

static void log_set_nsvc_filter ( struct log_target target,
struct gprs_nsvc nsvc 
)
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 }
}

Referenced by config_write_ns(), and DEFUN().

◆ ns_node

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

Referenced by gprs_ns_vty_init().

◆ vty_nsi

struct gprs_ns_inst* vty_nsi = NULL
static