Loading...
Searching...
No Matches
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_inst * | vty_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()

static int config_write_ns | ( | struct vty * | vty | ) |

static

References ARRAY_SIZE, gprs_nsvc::bts_addr, CMD_SUCCESS, gprs_ns_inst::dscp, gprs_ns_inst::enabled, gprs_ns_inst::frgre, gprs_nsvc::frgre, get_value_string(), GPRS_NS_LL_FR_GRE, GPRS_NS_LL_UDP, gprs_ns_timer_strs, gprs_ns_inst::gprs_nsvcs, gprs_nsvc::ip, gprs_nsvc::ll, llist_for_each_entry, gprs_ns_inst::local_ip, gprs_ns_inst::local_port, gprs_nsvc::nsei, gprs_ns_inst::nsip, gprs_nsvc::nsvci, osmo_htonl, osmo_ntohs, gprs_nsvc::persistent, gprs_nsvc::remote_end_is_sgsn, gprs_ns_inst::timeout, gprs_ns_inst::use_reset_block_unblock, VTY_NEWLINE, vty_nsi, and vty_out().

Referenced by gprs_ns_vty_init().

## 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" |
| ) |  |

References argv, CMD_SUCCESS, DEFUN(), gprs_ns_inst::enabled, gprs_ns_inst::frgre, and vty_nsi.

## 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" |
| ) |  |

References argv, CMD_SUCCESS, DEFUN(), gprs_ns_inst::frgre, gprs_ns_inst::local_ip, osmo_ntohl, and vty_nsi.

## DEFUN() [3/21]

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, DEFUN(), gprs_nsvc_by_nsei(), nsei, gprs_nsvc::persistent, VTY_NEWLINE, vty_nsi, and vty_out().

## DEFUN() [4/21]

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

References CMD_SUCCESS, DEFUN(), 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" |
| ) |  |

References argv, ARRAY_SIZE, CMD_SUCCESS, CMD_WARNING, DEFUN(), get_string_value(), gprs_ns_timer_strs, gprs_ns_inst::timeout, and vty_nsi.

## 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" |
| ) |  |

References argv, CMD_SUCCESS, CMD_WARNING, DEFUN(), GPRS_NS_LL_FR_GRE, GPRS_NS_LL_UDP, gprs_nsvc_by_nsei(), gprs_nsvc::ll, nsei, VTY_NEWLINE, vty_nsi, and vty_out().

## 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" |
| ) |  |

References argv, gprs_nsvc::bts_addr, CMD_SUCCESS, CMD_WARNING, DEFUN(), gprs_nsvc::frgre, GPRS_NS_LL_FR_GRE, gprs_nsvc_by_nsei(), gprs_nsvc::ll, nsei, osmo_htons, VTY_NEWLINE, vty_nsi, and vty_out().

## 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" |
| ) |  |

References argv, CMD_SUCCESS, DEFUN(), gprs_nsvc_by_nsei(), gprs_nsvc_create2(), nsei, gprs_nsvc::nsei, gprs_nsvc::nsvci, gprs_nsvc::persistent, and vty_nsi.

## 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" |
| ) |  |

References argv, gprs_nsvc::bts_addr, CMD_SUCCESS, CMD_WARNING, DEFUN(), gprs_nsvc_by_nsei(), gprs_nsvc::ip, nsei, VTY_NEWLINE, vty_nsi, and vty_out().

## 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" |
| ) |  |

References argv, gprs_nsvc::bts_addr, CMD_SUCCESS, CMD_WARNING, DEFUN(), GPRS_NS_LL_UDP, gprs_nsvc_by_nsei(), gprs_nsvc::ip, gprs_nsvc::ll, nsei, osmo_htons, VTY_NEWLINE, vty_nsi, and vty_out().

## 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" |
| ) |  |

References argv, CMD_SUCCESS, CMD_WARNING, DEFUN(), gprs_nsvc_by_nsei(), nsei, gprs_nsvc::remote_end_is_sgsn, VTY_NEWLINE, vty_nsi, and vty_out().

## 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" |
| ) |  |

References argv, CMD_SUCCESS, DEFUN(), gprs_ns_inst::dscp, gprs_ns_inst::nsip, and vty_nsi.

## 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" |
| ) |  |

References argv, CMD_SUCCESS, DEFUN(), gprs_ns_inst::local_ip, gprs_ns_inst::nsip, osmo_ntohl, and vty_nsi.

## 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" |
| ) |  |

References argv, CMD_SUCCESS, DEFUN(), gprs_ns_inst::local_port, gprs_ns_inst::nsip, and vty_nsi.

## 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" |
| ) |  |

References argv, CMD_SUCCESS, DEFUN(), gprs_ns_inst::nsip, gprs_ns_inst::use_reset_block_unblock, and vty_nsi.

## 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" |
| ) |  |

References argv, CMD_SUCCESS, CMD_WARNING, DEFUN(), gprs_nsvc_by_nsei(), gprs_nsvc_by_nsvci(), log_set_nsvc_filter(), log_tgt_mutex_lock, log_tgt_mutex_unlock, osmo_log_vty2tgt(), VTY_NEWLINE, vty_nsi, and vty_out().

## 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" |
| ) |  |

References argv, gprs_ns_inst::bss_sns_fi, CMD_SUCCESS, CMD_WARNING, DEFUN(), gprs_ns_tx_block(), gprs_ns_tx_unblock(), gprs_nsvc_by_nsei(), gprs_nsvc_by_nsvci(), gprs_nsvc_reset(), NS_CAUSE_OM_INTERVENTION, gprs_nsvc::nsi, VTY_NEWLINE, vty_nsi, and vty_out().

## DEFUN() [18/21]

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

References CMD_SUCCESS, DEFUN(), 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, DEFUN(), 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, DEFUN(), 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" |
| ) |  |

References argc, argv, CMD_SUCCESS, CMD_WARNING, DEFUN(), dump_nse(), gprs_nsvc_by_nsei(), gprs_nsvc_by_nsvci(), gprs_nsvc::nsi, VTY_NEWLINE, vty_nsi, and vty_out().

## dump_ns()

static void dump_ns | ( | struct vty * | vty,
|  | const struct gprs_ns_inst * | nsi,
|  | bool | stats,
|  | bool | persistent_only
| ) |  |

static

References dump_nse(), gprs_ns_inst::enabled, gprs_ns_inst::frgre, gprs_ns_inst::gprs_nsvcs, gprs_sns_dump_vty(), llist_for_each_entry, gprs_ns_inst::local_ip, gprs_ns_inst::local_port, gprs_ns_inst::nsip, osmo_htonl, gprs_ns_inst::unknown_nsvc, VTY_NEWLINE, vty_nsi, and vty_out().

Referenced by DEFUN(), DEFUN(), and DEFUN().

## dump_nse()

static void dump_nse | ( | struct vty * | vty,
|  | const struct gprs_nsvc * | nsvc,
|  | bool | stats,
|  | bool | persistent_only
| ) |  |

static

References gprs_nsvc::bts_addr, gprs_nsvc::ctrg, gprs_ns_ll_str(), GPRS_NS_LL_UDP, gprs_nsvc::ip, gprs_nsvc::ll, gprs_ns_inst::local_port, NS_DESC_A, NS_DESC_B, gprs_nsvc::nsei, gprs_nsvc::nsi, gprs_ns_inst::nsip, gprs_nsvc::nsvci, osmo_sock_local_ip(), gprs_nsvc::persistent, gprs_nsvc::remote_end_is_sgsn, gprs_nsvc::remote_state, gprs_nsvc::state, gprs_nsvc::statg, VTY_NEWLINE, vty_out(), vty_out_rate_ctr_group(), and vty_out_stat_item_group().

Referenced by DEFUN(), and dump_ns().

## gprs_ns_vty_init()

int gprs_ns_vty_init | ( | struct gprs_ns_inst * | nsi | ) |

References CFG_LOG_NODE, CONFIG_NODE, config_write_ns(), ENABLE_NODE, install_lib_element(), install_lib_element_ve(), install_node(), L_NS_NODE, ns_node, gprs_nsvc::nsi, and vty_nsi.

## log_set_nsvc_filter()

static void log_set_nsvc_filter | ( | struct log_target * | target,
|  | struct gprs_nsvc * | nsvc
| ) |  |

static

References log_target::filter_data, log_target::filter_map, and LOG_FLT_GB_NSVC.

Referenced by DEFUN().

## 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:
= {
L_NS_NODE,
"%s(config-ns)# ",
1,
}
L_NS_NODE
L_NS_NODE

Referenced by gprs_ns_vty_init().

## vty_nsi

struct gprs_ns_inst* vty_nsi = NULL

static

Referenced by config_write_ns(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), DEFUN(), dump_ns(), and gprs_ns_vty_init().