libosmogb
1.4.0.160-7619
Osmocom Gb library
|
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_vc * | vtyvc_alloc (uint16_t nsei) |
static void | ns2_vc_free (struct ns2_vty_vc *vtyvc) |
static struct ns2_vty_vc * | vtyvc_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\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-65535>", 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 " VTY_IPV46_CMD, NSE_CMD_STR "Remote IP Address\n" "Remote IPv4 Address\n" "Remote IPv6 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 " VTY_IPV46_CMD, ENCAPS_STR "NS over UDP Encapsulation\n" "Set the IP address on which we listen for NS/UDP\n" "IPv4 Address\n" "IPv6 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 " VTY_IPV46_CMD, ENCAPS_STR "NS over Frame Relay over GRE Encapsulation\n" "Set the IP address on which we listen for NS/FR/GRE\n" "IPv4 Address\n" "IPv6 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 (logging_fltr_nsvc, logging_fltr_nsvc_cmd, "logging filter nsvc nsvci <0-65535>", LOGGING_STR FILTER_STR "Filter based on NS Virtual Connection\n" "Identify NS-VC by NSVCI\n" "Numeric identifier\n") | |
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_inst * | vty_nsi = NULL |
static struct ns2_vty_priv | priv |
static const struct value_string | gprs_ns_timer_strs [] |
static struct cmd_node | ns_node |
VTY interface for our GPRS Networks Service (NS) implementation.
#define ENCAPS_STR "NS encapsulation options\n" |
|
static |
References ARRAY_SIZE, CMD_SUCCESS, ns2_vty_priv::dscp, ns2_vty_vc::frdlci, ns2_vty_priv::frgre, ns2_vty_priv::frgreaddr, get_value_string(), GPRS_NS_LL_FR_GRE, GPRS_NS_LL_UDP, gprs_ns_timer_strs, osmo_sockaddr_str::ip, list, ns2_vty_vc::ll, llist_for_each_entry, NS2_VC_MODE_BLOCKRESET, ns2_vty_vc::nsei, ns2_vty_vc::nsvci, osmo_sockaddr_str::port, priv, ns2_vty_vc::remote, ns2_vty_vc::remote_end_is_sgsn, gprs_ns2_inst::timeout, ns2_vty_priv::udp, ns2_vty_priv::vc_mode, VTY_NEWLINE, vty_nsi, vty_out(), and ns2_vty_priv::vtyvc.
Referenced by gprs_ns2_vty_init().
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" | |||
) |
References argv, CMD_SUCCESS, ns2_vty_priv::frgre, and priv.
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\n" "Set the IP address on which we listen for NS/FR/GRE\n" "IPv4 Address\n" "IPv6 Address\n" | |||
) |
References argv, CMD_SUCCESS, ns2_vty_priv::frgreaddr, osmo_sockaddr_str_from_str2(), and priv.
DEFUN | ( | cfg_no_nse | , |
cfg_no_nse_cmd | , | ||
"no nse <0-65535>" | , | ||
"Delete Persistent NS Entity\n" "Delete " | NSE_CMD_STR | ||
) |
References argv, CMD_SUCCESS, CMD_WARNING, ns2_vc_free(), nsei, VTY_NEWLINE, vty_out(), and vtyvc_by_nsei().
DEFUN | ( | cfg_ns | , |
cfg_ns_cmd | , | ||
"ns" | , | ||
"Configure the GPRS Network Service" | |||
) |
References CMD_SUCCESS, L_NS_NODE, and vty::node.
DEFUN | ( | cfg_ns_timer | , |
cfg_ns_timer_cmd | , | ||
"timer " NS_TIMERS " <0-65535>" | , | ||
"Network Service Timer\n" NS_TIMERS_HELP "Timer Value\n" | |||
) |
References argv, ARRAY_SIZE, CMD_SUCCESS, CMD_WARNING, get_string_value(), gprs_ns_timer_strs, gprs_ns2_inst::timeout, and vty_nsi.
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" | |||
) |
References argv, CMD_SUCCESS, CMD_WARNING, GPRS_NS_LL_FR_GRE, GPRS_NS_LL_UDP, ns2_vty_vc::ll, nsei, VTY_NEWLINE, vty_out(), and vtyvc_by_nsei().
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" | |||
) |
References argv, CMD_SUCCESS, CMD_WARNING, ns2_vty_vc::frdlci, GPRS_NS_LL_FR_GRE, ns2_vty_vc::ll, nsei, VTY_NEWLINE, vty_out(), and vtyvc_by_nsei().
DEFUN | ( | cfg_nse_nsvc | , |
cfg_nse_nsvci_cmd | , | ||
"nse <0-65535> nsvci <0-65535>" | , | ||
NSE_CMD_STR "NS Virtual Connection\n" "NS Virtual Connection ID (NSVCI)\n" | |||
) |
References argv, CMD_SUCCESS, CMD_WARNING, nsei, ns2_vty_vc::nsvci, VTY_NEWLINE, vty_out(), and vtyvc_by_nsei().
DEFUN | ( | cfg_nse_remoteip | , |
cfg_nse_remoteip_cmd | , | ||
"nse <0-65535> remote-ip " | VTY_IPV46_CMD, | ||
NSE_CMD_STR "Remote IP Address\n" "Remote IPv4 Address\n" "Remote IPv6 Address\n" | |||
) |
References argv, CMD_SUCCESS, CMD_WARNING, nsei, osmo_sockaddr_str_from_str2(), ns2_vty_vc::remote, VTY_NEWLINE, vty_out(), and vtyvc_by_nsei().
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" | |||
) |
References argv, CMD_SUCCESS, CMD_WARNING, nsei, osmo_sockaddr_str::port, ns2_vty_vc::remote, VTY_NEWLINE, vty_out(), and vtyvc_by_nsei().
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" | |||
) |
References argv, CMD_SUCCESS, CMD_WARNING, nsei, ns2_vty_vc::remote_end_is_sgsn, VTY_NEWLINE, vty_out(), and vtyvc_by_nsei().
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_local_ip | , |
cfg_nsip_local_ip_cmd | , | ||
"encapsulation udp local-ip " | VTY_IPV46_CMD, | ||
ENCAPS_STR "NS over UDP Encapsulation\n" "Set the IP address on which we listen for NS/UDP\n" "IPv4 Address\n" "IPv6 Address\n" | |||
) |
References argv, CMD_SUCCESS, osmo_sockaddr_str_from_str2(), priv, and ns2_vty_priv::udp.
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" | |||
) |
References argv, CMD_SUCCESS, osmo_sockaddr_str::port, priv, and ns2_vty_priv::udp.
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" | |||
) |
References argv, gprs_ns2_inst::binding, CMD_SUCCESS, CMD_WARNING, ns2_vty_priv::force_vc_mode, ns2_vty_priv::force_vc_mode_reason, gprs_ns2_bind_set_mode(), list, llist_for_each_entry, NS2_VC_MODE_ALIVE, NS2_VC_MODE_BLOCKRESET, priv, gprs_ns2_vc_bind::vc_mode, ns2_vty_priv::vc_mode, VTY_NEWLINE, vty_nsi, and vty_out().
DEFUN | ( | logging_fltr_nsvc | , |
logging_fltr_nsvc_cmd | , | ||
"logging filter nsvc nsvci <0-65535>" | , | ||
LOGGING_STR FILTER_STR "Filter based on NS Virtual Connection\n" "Identify NS-VC by NSVCI\n" "Numeric identifier\n" | |||
) |
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 | ( | 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 | ( | 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 | ( | 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" | |||
) |
References argc, argv, CMD_SUCCESS, CMD_WARNING, dump_nse(), dump_nsvc(), gprs_ns2_nse_by_nsei(), gprs_ns2_nsvc_by_nsvci(), gprs_ns2_vc::nse, VTY_NEWLINE, vty_nsi, and vty_out().
|
static |
References gprs_ns2_vc::bind, and gprs_ns2_vc_bind::dump_vty.
Referenced by dump_ns().
|
static |
References gprs_ns2_inst::binding, dump_bind(), dump_nse(), list, llist_for_each_entry, gprs_ns2_inst::nse, and gprs_ns2_nse::nsi.
Referenced by DEFUN().
|
static |
|
static |
References gprs_ns2_vc::ctrg, gprs_ns2_ip_vc_remote(), gprs_ns2_ll_str(), GPRS_NS_LL_E1, GPRS_NS_LL_FR_GRE, GPRS_NS_LL_UDP, osmo_sockaddr_str::ip, gprs_ns2_vc::ll, osmo_sockaddr_str_from_sockaddr(), osmo_sockaddr_str::port, osmo_sockaddr::sas, gprs_ns2_vc::statg, osmo_sockaddr::u, VTY_NEWLINE, vty_out(), vty_out_rate_ctr_group(), and vty_out_stat_item_group().
Referenced by DEFUN(), and dump_nse().
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.
References ns2_vty_priv::dscp, ns2_vty_priv::frgre, gprs_ns2_bind_set_mode(), gprs_ns2_create_nse(), gprs_ns2_ip_bind(), gprs_ns2_ip_connect(), gprs_ns2_nse_by_nsei(), osmo_sockaddr_str::ip, list, llist_for_each_entry, ns2_vty_vc::nsei, ns2_vty_vc::nsvci, osmo_sockaddr_str_to_sockaddr(), gprs_ns2_nse::persistent, gprs_ns2_vc::persistent, osmo_sockaddr_str::port, priv, ns2_vty_vc::remote, osmo_sockaddr::sas, osmo_sockaddr::u, ns2_vty_priv::udp, ns2_vty_priv::vc_mode, vty_nsi, and ns2_vty_priv::vtyvc.
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.
force | if true mode and reason will be set. false to allow modification via vty. |
mode | |
reason | A description shown to the user when a vty command wants to change the mode. |
int gprs_ns2_vty_init | ( | struct gprs_ns2_inst * | nsi, |
const struct osmo_sockaddr_str * | default_bind | ||
) |
gprs_ns2_vty_init initialize the vty
[in,out] | nsi | |
[in] | default_bind | set the default address to bind to. Can be NULL. |
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, ns_node, priv, ns2_vty_priv::udp, ns2_vty_priv::vc_mode, vty_nsi, and ns2_vty_priv::vtyvc.
|
static |
References log_target::filter_data, log_target::filter_map, and LOG_FLT_GB_NSVC.
Referenced by DEFUN().
|
static |
References ns2_vty_vc::list, and llist_del().
Referenced by DEFUN().
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
bind |
References gprs_ns2_bind_set_mode(), priv, and ns2_vty_priv::vc_mode.
Referenced by gprs_ns2_frgre_bind(), and gprs_ns2_ip_bind().
|
static |
References ns2_vty_vc::list, llist_add(), nsei, ns2_vty_vc::nsei, priv, vty_nsi, and ns2_vty_priv::vtyvc.
Referenced by vtyvc_by_nsei().
|
static |
References list, llist_for_each_entry, nsei, ns2_vty_vc::nsei, priv, ns2_vty_priv::vtyvc, and vtyvc_alloc().
Referenced by DEFUN().
|
static |
Referenced by config_write_ns(), and DEFUN().
|
static |
Referenced by gprs_ns2_vty_init().
|
static |
Referenced by alive_timeout_handler(), alive_timer_elapsed_ms(), bssgp_fc_in(), config_write_ns(), DEFUN(), dump_vty(), fc_enqueue(), free_bind(), frgre_alloc_vc(), frgre_sendmsg(), gprs_ns2_frgre_bind(), gprs_ns2_ip_bind(), gprs_ns2_ip_bind_connect(), gprs_ns2_ip_bind_set_dscp(), gprs_ns2_ip_bind_sockaddr(), gprs_ns2_ip_vc_local(), gprs_ns2_ip_vc_remote(), gprs_ns2_recv_unitdata(), gprs_ns2_st_alive_onenter(), gprs_ns2_st_blocked(), gprs_ns2_st_blocked_onenter(), gprs_ns2_st_reset(), gprs_ns2_st_reset_onenter(), gprs_ns2_st_unblocked(), gprs_ns2_st_unblocked_on_enter(), gprs_ns2_st_unconfigured(), gprs_ns2_vc_fsm_alloc(), gprs_ns2_vc_fsm_timer_cb(), gprs_ns2_vty_create(), gprs_ns2_vty_init(), handle_rx_gre_ipv4(), handle_rx_gre_ipv6(), ns2_driver_alloc_vc(), ns2_vty_bind_apply(), ns_inst_from_fi(), nsip_sendmsg(), nsip_vc_sendmsg(), recv_test_procedure(), start_test_procedure(), stop_test_procedure(), vtyvc_alloc(), and vtyvc_by_nsei().
|
static |
Referenced by config_write_ns(), DEFUN(), gprs_ns2_vty_create(), gprs_ns2_vty_init(), and vtyvc_alloc().