diff options
author | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2016-03-04 14:37:31 +0100 |
---|---|---|
committer | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2016-03-04 14:57:09 +0100 |
commit | a4198d192234a8180a89be8b91e867a1cbc1f512 (patch) | |
tree | d75d1d9d2fb9e50b94927a85161eab59489e1f86 | |
parent | 544a203f677d0f060d2d1bd31f72f9ae450e138f (diff) |
create libxsc and move some code, never link libbsc and libmsc
libbsc and libmsc have conflicting definitions of gsm_subscriber_connection
and do no longer belong together anyway.
Create libxsc, meaning 'lib[bm]sc', to hold all code used by both libmsc
and libbsc, and make sure gsm_subscriber_connection isn't used there.
In various binaries and tests, do not link libbsc and libmsc.
(Note: this commit was reshaped out of a large wip chunk, it may not
compile properly without the subsequent commits)
26 files changed, 863 insertions, 785 deletions
diff --git a/openbsc/configure.ac b/openbsc/configure.ac index a6c9ac5b7..9d739392a 100644 --- a/openbsc/configure.ac +++ b/openbsc/configure.ac @@ -195,6 +195,7 @@ AC_OUTPUT( src/libcommon/Makefile src/libfilter/Makefile src/libiu/Makefile + src/libxsc/Makefile src/osmo-cscn/Makefile src/osmo-bsc/Makefile src/osmo-bsc_nat/Makefile diff --git a/openbsc/include/openbsc/Makefile.am b/openbsc/include/openbsc/Makefile.am index 2a855d039..475e82771 100644 --- a/openbsc/include/openbsc/Makefile.am +++ b/openbsc/include/openbsc/Makefile.am @@ -20,7 +20,7 @@ noinst_HEADERS = abis_nm.h abis_rsl.h db.h gsm_04_08.h gsm_data.h \ oap.h oap_messages.h \ gtphub.h \ msc_api.h msc_ifaces.h iu.h iu_cs.h \ - common.h + xsc.h openbsc_HEADERS = gsm_04_08.h meas_rep.h bsc_api.h openbscdir = $(includedir)/openbsc diff --git a/openbsc/include/openbsc/bss.h b/openbsc/include/openbsc/bss.h index 8705443e1..39957ab7c 100644 --- a/openbsc/include/openbsc/bss.h +++ b/openbsc/include/openbsc/bss.h @@ -1,7 +1,7 @@ #ifndef _BSS_H_ #define _BSS_H_ -#include <openbsc/common.h> +#include <openbsc/xsc.h> struct gsm_network; struct msgb; diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index c2c7f2f43..4b0f37245 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -7,7 +7,7 @@ #include <osmocom/core/select.h> #include <openbsc/rest_octets.h> -#include <openbsc/common.h> +#include <openbsc/xsc.h> /** annotations for msgb ownership */ #define __uses diff --git a/openbsc/include/openbsc/gsm_data_shared.h b/openbsc/include/openbsc/gsm_data_shared.h index d4891a988..e7372ab88 100644 --- a/openbsc/include/openbsc/gsm_data_shared.h +++ b/openbsc/include/openbsc/gsm_data_shared.h @@ -24,7 +24,7 @@ #include <osmocom/gsm/lapdm.h> #endif -#include <openbsc/common.h> +#include <openbsc/xsc.h> struct osmo_bsc_data; diff --git a/openbsc/include/openbsc/common.h b/openbsc/include/openbsc/xsc.h index 2a396f3db..b301d5018 100644 --- a/openbsc/include/openbsc/common.h +++ b/openbsc/include/openbsc/xsc.h @@ -4,6 +4,8 @@ struct msgb; struct gsm_network; +struct log_info; +struct ctrl_handle; typedef int (*mncc_recv_cb_t)(struct gsm_network *, struct msgb *); @@ -15,3 +17,7 @@ struct gsm_encr { uint8_t key[MAX_A5_KEY_LEN]; }; +extern struct gsm_network *vty_global_gsm_network; + +int xsc_vty_init(struct gsm_network *network); + diff --git a/openbsc/src/Makefile.am b/openbsc/src/Makefile.am index 19196c902..2f20e5cb7 100644 --- a/openbsc/src/Makefile.am +++ b/openbsc/src/Makefile.am @@ -2,7 +2,7 @@ AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir) AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(COVERAGE_CFLAGS) AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(COVERAGE_LDFLAGS) -SUBDIRS = libcommon libmgcp libbsc libiu libmsc libtrau libfilter osmo-cscn osmo-bsc_mgcp utils ipaccess gprs +SUBDIRS = libcommon libmgcp libbsc libiu libmsc libtrau libfilter libxsc osmo-cscn osmo-bsc_mgcp utils ipaccess gprs # Conditional modules if BUILD_NAT diff --git a/openbsc/src/ipaccess/Makefile.am b/openbsc/src/ipaccess/Makefile.am index 9a71529cb..e69a591e7 100644 --- a/openbsc/src/ipaccess/Makefile.am +++ b/openbsc/src/ipaccess/Makefile.am @@ -6,8 +6,7 @@ OSMO_LIBS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOABIS_LIBS) bin_PROGRAMS = abisip-find ipaccess-config ipaccess-proxy abisip_find_LDADD = $(top_builddir)/src/libbsc/libbsc.a \ - $(top_builddir)/src/libmsc/libmsc.a \ - $(top_builddir)/src/libbsc/libbsc.a \ + $(top_builddir)/src/libxsc/libxsc.a \ $(top_builddir)/src/libtrau/libtrau.a \ $(top_builddir)/src/libcommon/libcommon.a \ $(OSMO_LIBS) @@ -17,15 +16,14 @@ ipaccess_config_SOURCES = ipaccess-config.c ipaccess-firmware.c network_listen.c # FIXME: resolve the bogus dependencies patched around here: ipaccess_config_LDADD = $(top_builddir)/src/libbsc/libbsc.a \ - $(top_builddir)/src/libbsc/libbsc.a \ + $(top_builddir)/src/libxsc/libxsc.a \ $(top_builddir)/src/libtrau/libtrau.a \ $(top_builddir)/src/libcommon/libcommon.a \ $(LIBCRYPT) $(OSMO_LIBS) ipaccess_proxy_SOURCES = ipaccess-proxy.c ipaccess_proxy_LDADD = $(top_builddir)/src/libbsc/libbsc.a \ - $(top_builddir)/src/libmsc/libmsc.a \ - $(top_builddir)/src/libbsc/libbsc.a \ + $(top_builddir)/src/libxsc/libxsc.a \ $(top_builddir)/src/libtrau/libtrau.a \ $(top_builddir)/src/libcommon/libcommon.a \ $(OSMO_LIBS) diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c index 89e44d796..049f73a62 100644 --- a/openbsc/src/libbsc/bsc_vty.c +++ b/openbsc/src/libbsc/bsc_vty.c @@ -53,15 +53,13 @@ #include <openbsc/osmo_msc_data.h> #include <openbsc/osmo_bsc_rf.h> +#include <openbsc/xsc.h> + #include <inttypes.h> #include "../../bscconfig.h" -#define NETWORK_STR "Configure the GSM network\n" -#define CODE_CMD_STR "Code commands\n" -#define NAME_CMD_STR "Name Commands\n" -#define NAME_STR "Name to use\n" #define LCHAN_NR_STR "Logical Channel Number\n" @@ -106,12 +104,6 @@ const struct value_string bts_loc_fix_names[] = { { 0, NULL } }; -struct cmd_node net_node = { - GSMNET_NODE, - "%s(config-net)# ", - 1, -}; - struct cmd_node bts_node = { BTS_NODE, "%s(config-net-bts)# ", @@ -130,23 +122,6 @@ struct cmd_node ts_node = { 1, }; -static struct gsm_network *vty_global_gsm_network = 0; - -struct gsm_network *gsmnet_from_vty(struct vty *v) -{ - /* In case we read from the config file, the vty->priv cannot - * point to a struct telnet_connection, and thus conn->priv - * will not point to the gsm_network structure. - * It can't hurt to force callers to continue to pass the vty instance - * to this function, in case we'd like to retrieve the global - * gsm_network instance from the vty at some point in the future. But - * until then, just return the global pointer, which should have been - * initialized by bsc_vty_init(). - */ - OSMO_ASSERT(vty_global_gsm_network); - return vty_global_gsm_network; -} - static int dummy_config_write(struct vty *v) { return CMD_SUCCESS; @@ -180,57 +155,6 @@ static void dump_pchan_load_vty(struct vty *vty, char *prefix, } } -static void net_dump_vty(struct vty *vty, struct gsm_network *net) -{ - struct pchan_load pl; - - vty_out(vty, "BSC is on Country Code %u, Network Code %u " - "and has %u BTS%s", net->country_code, net->network_code, - net->num_bts, VTY_NEWLINE); - vty_out(vty, " Long network name: '%s'%s", - net->name_long, VTY_NEWLINE); - vty_out(vty, " Short network name: '%s'%s", - net->name_short, VTY_NEWLINE); - vty_out(vty, " Authentication policy: %s%s", - gsm_auth_policy_name(net->auth_policy), VTY_NEWLINE); - vty_out(vty, " Location updating reject cause: %u%s", - net->reject_cause, VTY_NEWLINE); - vty_out(vty, " Encryption: A5/%u%s", net->a5_encryption, - VTY_NEWLINE); - vty_out(vty, " NECI (TCH/H): %u%s", net->neci, - VTY_NEWLINE); - vty_out(vty, " Use TCH for Paging any: %d%s", net->pag_any_tch, - VTY_NEWLINE); - vty_out(vty, " RRLP Mode: %s%s", rrlp_mode_name(net->rrlp.mode), - VTY_NEWLINE); - vty_out(vty, " MM Info: %s%s", net->send_mm_info ? "On" : "Off", - VTY_NEWLINE); - vty_out(vty, " Handover: %s%s", net->handover.active ? "On" : "Off", - VTY_NEWLINE); - network_chan_load(&pl, net); - vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE); - dump_pchan_load_vty(vty, " ", &pl); - - /* show rf */ - if (net->bsc_data) - vty_out(vty, " Last RF Command: %s%s", - net->bsc_data->rf_ctrl->last_state_command, - VTY_NEWLINE); - if (net->bsc_data) - vty_out(vty, " Last RF Lock Command: %s%s", - net->bsc_data->rf_ctrl->last_rf_lock_ctrl_command, - VTY_NEWLINE); -} - -DEFUN(show_net, show_net_cmd, "show network", - SHOW_STR "Display information about a GSM NETWORK\n") -{ - struct gsm_network *net = gsmnet_from_vty(vty); - net_dump_vty(vty, net); - - return CMD_SUCCESS; -} - static void e1isl_dump_vty(struct vty *vty, struct e1inp_sign_link *e1l) { struct e1inp_line *line; @@ -730,72 +654,6 @@ static int config_write_bts(struct vty *v) return CMD_SUCCESS; } -static int config_write_net(struct vty *vty) -{ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - - vty_out(vty, "network%s", VTY_NEWLINE); - vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE); - vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE); - vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE); - vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE); - vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE); - vty_out(vty, " location updating reject cause %u%s", - gsmnet->reject_cause, VTY_NEWLINE); - vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE); - vty_out(vty, " neci %u%s", gsmnet->neci, VTY_NEWLINE); - vty_out(vty, " paging any use tch %d%s", gsmnet->pag_any_tch, VTY_NEWLINE); - vty_out(vty, " rrlp mode %s%s", rrlp_mode_name(gsmnet->rrlp.mode), - VTY_NEWLINE); - vty_out(vty, " mm info %u%s", gsmnet->send_mm_info, VTY_NEWLINE); - vty_out(vty, " handover %u%s", gsmnet->handover.active, VTY_NEWLINE); - vty_out(vty, " handover window rxlev averaging %u%s", - gsmnet->handover.win_rxlev_avg, VTY_NEWLINE); - vty_out(vty, " handover window rxqual averaging %u%s", - gsmnet->handover.win_rxqual_avg, VTY_NEWLINE); - vty_out(vty, " handover window rxlev neighbor averaging %u%s", - gsmnet->handover.win_rxlev_avg_neigh, VTY_NEWLINE); - vty_out(vty, " handover power budget interval %u%s", - gsmnet->handover.pwr_interval, VTY_NEWLINE); - vty_out(vty, " handover power budget hysteresis %u%s", - gsmnet->handover.pwr_hysteresis, VTY_NEWLINE); - vty_out(vty, " handover maximum distance %u%s", - gsmnet->handover.max_distance, VTY_NEWLINE); - vty_out(vty, " timer t3101 %u%s", gsmnet->T3101, VTY_NEWLINE); - vty_out(vty, " timer t3103 %u%s", gsmnet->T3103, VTY_NEWLINE); - vty_out(vty, " timer t3105 %u%s", gsmnet->T3105, VTY_NEWLINE); - vty_out(vty, " timer t3107 %u%s", gsmnet->T3107, VTY_NEWLINE); - vty_out(vty, " timer t3109 %u%s", gsmnet->T3109, VTY_NEWLINE); - vty_out(vty, " timer t3111 %u%s", gsmnet->T3111, VTY_NEWLINE); - vty_out(vty, " timer t3113 %u%s", gsmnet->T3113, VTY_NEWLINE); - vty_out(vty, " timer t3115 %u%s", gsmnet->T3115, VTY_NEWLINE); - vty_out(vty, " timer t3117 %u%s", gsmnet->T3117, VTY_NEWLINE); - vty_out(vty, " timer t3119 %u%s", gsmnet->T3119, VTY_NEWLINE); - vty_out(vty, " timer t3122 %u%s", gsmnet->T3122, VTY_NEWLINE); - vty_out(vty, " timer t3141 %u%s", gsmnet->T3141, VTY_NEWLINE); - vty_out(vty, " dtx-used %u%s", gsmnet->dtx_enabled, VTY_NEWLINE); - vty_out(vty, " subscriber-keep-in-ram %d%s", - gsmnet->subscr_group->keep_subscr, VTY_NEWLINE); - if (gsmnet->tz.override != 0) { - if (gsmnet->tz.dst) - vty_out(vty, " timezone %d %d %d%s", - gsmnet->tz.hr, gsmnet->tz.mn, gsmnet->tz.dst, - VTY_NEWLINE); - else - vty_out(vty, " timezone %d %d%s", - gsmnet->tz.hr, gsmnet->tz.mn, VTY_NEWLINE); - } - - if (gsmnet->t3212 == 0) - vty_out(vty, " no periodic location update%s", VTY_NEWLINE); - else - vty_out(vty, " periodic location update %u%s", - gsmnet->t3212 * 6, VTY_NEWLINE); - - - return CMD_SUCCESS; -} - static void trx_dump_vty(struct vty *vty, struct gsm_bts_trx *trx) { vty_out(vty, "TRX %u of BTS %u is on ARFCN %u%s", @@ -1300,321 +1158,6 @@ DEFUN(show_paging_group, return CMD_SUCCESS; } -DEFUN(cfg_net, - cfg_net_cmd, - "network", NETWORK_STR) -{ - vty->index = gsmnet_from_vty(vty); - vty->node = GSMNET_NODE; - - return CMD_SUCCESS; -} - -DEFUN(cfg_net_ncc, - cfg_net_ncc_cmd, - "network country code <1-999>", - "Set the GSM network country code\n" - "Country commands\n" - CODE_CMD_STR - "Network Country Code to use\n") -{ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - - gsmnet->country_code = atoi(argv[0]); - - return CMD_SUCCESS; -} - -DEFUN(cfg_net_mnc, - cfg_net_mnc_cmd, - "mobile network code <0-999>", - "Set the GSM mobile network code\n" - "Network Commands\n" - CODE_CMD_STR - "Mobile Network Code to use\n") -{ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - - gsmnet->network_code = atoi(argv[0]); - - return CMD_SUCCESS; -} - -DEFUN(cfg_net_name_short, - cfg_net_name_short_cmd, - "short name NAME", - "Set the short GSM network name\n" NAME_CMD_STR NAME_STR) -{ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - - bsc_replace_string(gsmnet, &gsmnet->name_short, argv[0]); - return CMD_SUCCESS; -} - -DEFUN(cfg_net_name_long, - cfg_net_name_long_cmd, - "long name NAME", - "Set the long GSM network name\n" NAME_CMD_STR NAME_STR) -{ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - - bsc_replace_string(gsmnet, &gsmnet->name_long, argv[0]); - return CMD_SUCCESS; -} - -DEFUN(cfg_net_auth_policy, - cfg_net_auth_policy_cmd, - "auth policy (closed|accept-all|token)", - "Authentication (not cryptographic)\n" - "Set the GSM network authentication policy\n" - "Require the MS to be activated in HLR\n" - "Accept all MS, whether in HLR or not\n" - "Use SMS-token based authentication\n") -{ - enum gsm_auth_policy policy = gsm_auth_policy_parse(argv[0]); - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - - gsmnet->auth_policy = policy; - - return CMD_SUCCESS; -} - -DEFUN(cfg_net_reject_cause, - cfg_net_reject_cause_cmd, - "location updating reject cause <2-111>", - "Set the reject cause of location updating reject\n" - "Set the reject cause of location updating reject\n" - "Set the reject cause of location updating reject\n" - "Set the reject cause of location updating reject\n" - "Cause Value as Per GSM TS 04.08\n") -{ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - - gsmnet->reject_cause = atoi(argv[0]); - - return CMD_SUCCESS; -} - -DEFUN(cfg_net_encryption, - cfg_net_encryption_cmd, - "encryption a5 (0|1|2|3)", - "Encryption options\n" - "A5 encryption\n" "A5/0: No encryption\n" - "A5/1: Encryption\n" "A5/2: Export-grade Encryption\n" - "A5/3: 'New' Secure Encryption\n") -{ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - - gsmnet->a5_encryption= atoi(argv[0]); - - return CMD_SUCCESS; -} - -DEFUN(cfg_net_neci, - cfg_net_neci_cmd, - "neci (0|1)", - "New Establish Cause Indication\n" - "Don't set the NECI bit\n" "Set the NECI bit\n") -{ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - - gsmnet->neci = atoi(argv[0]); - gsm_net_update_ctype(gsmnet); - return CMD_SUCCESS; -} - -DEFUN(cfg_net_rrlp_mode, cfg_net_rrlp_mode_cmd, - "rrlp mode (none|ms-based|ms-preferred|ass-preferred)", - "Radio Resource Location Protocol\n" - "Set the Radio Resource Location Protocol Mode\n" - "Don't send RRLP request\n" - "Request MS-based location\n" - "Request any location, prefer MS-based\n" - "Request any location, prefer MS-assisted\n") -{ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - - gsmnet->rrlp.mode = rrlp_mode_parse(argv[0]); - - return CMD_SUCCESS; -} - -DEFUN(cfg_net_mm_info, cfg_net_mm_info_cmd, - "mm info (0|1)", - "Mobility Management\n" - "Send MM INFO after LOC UPD ACCEPT\n" - "Disable\n" "Enable\n") -{ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - - gsmnet->send_mm_info = atoi(argv[0]); - - return CMD_SUCCESS; -} - -#define HANDOVER_STR "Handover Options\n" - -DEFUN(cfg_net_handover, cfg_net_handover_cmd, - "handover (0|1)", - HANDOVER_STR - "Don't perform in-call handover\n" - "Perform in-call handover\n") -{ - int enable = atoi(argv[0]); - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - - if (enable && ipacc_rtp_direct) { - vty_out(vty, "%% Cannot enable handover unless RTP Proxy mode " - "is enabled by using the -P command line option%s", - VTY_NEWLINE); - return CMD_WARNING; - } - gsmnet->handover.active = enable; - - return CMD_SUCCESS; -} - -#define HO_WIN_STR HANDOVER_STR "Measurement Window\n" -#define HO_WIN_RXLEV_STR HO_WIN_STR "Received Level Averaging\n" -#define HO_WIN_RXQUAL_STR HO_WIN_STR "Received Quality Averaging\n" -#define HO_PBUDGET_STR HANDOVER_STR "Power Budget\n" -#define HO_AVG_COUNT_STR "Amount to use for Averaging\n" - -DEFUN(cfg_net_ho_win_rxlev_avg, cfg_net_ho_win_rxlev_avg_cmd, - "handover window rxlev averaging <1-10>", - HO_WIN_RXLEV_STR - "How many RxLev measurements are used for averaging\n" - HO_AVG_COUNT_STR) -{ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - gsmnet->handover.win_rxlev_avg = atoi(argv[0]); - return CMD_SUCCESS; -} - -DEFUN(cfg_net_ho_win_rxqual_avg, cfg_net_ho_win_rxqual_avg_cmd, - "handover window rxqual averaging <1-10>", - HO_WIN_RXQUAL_STR - "How many RxQual measurements are used for averaging\n" - HO_AVG_COUNT_STR) -{ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - gsmnet->handover.win_rxqual_avg = atoi(argv[0]); - return CMD_SUCCESS; -} - -DEFUN(cfg_net_ho_win_rxlev_neigh_avg, cfg_net_ho_win_rxlev_avg_neigh_cmd, - "handover window rxlev neighbor averaging <1-10>", - HO_WIN_RXLEV_STR "Neighbor\n" - "How many RxQual measurements are used for averaging\n" - HO_AVG_COUNT_STR) -{ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - gsmnet->handover.win_rxlev_avg_neigh = atoi(argv[0]); - return CMD_SUCCESS; -} - -DEFUN(cfg_net_ho_pwr_interval, cfg_net_ho_pwr_interval_cmd, - "handover power budget interval <1-99>", - HO_PBUDGET_STR - "How often to check if we have a better cell (SACCH frames)\n" - "Interval\n" "Number\n") -{ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - gsmnet->handover.pwr_interval = atoi(argv[0]); - return CMD_SUCCESS; -} - -DEFUN(cfg_net_ho_pwr_hysteresis, cfg_net_ho_pwr_hysteresis_cmd, - "handover power budget hysteresis <0-999>", - HO_PBUDGET_STR - "How many dB does a neighbor to be stronger to become a HO candidate\n" - "Hysteresis\n" "Number\n") -{ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - gsmnet->handover.pwr_hysteresis = atoi(argv[0]); - return CMD_SUCCESS; -} - -DEFUN(cfg_net_ho_max_distance, cfg_net_ho_max_distance_cmd, - "handover maximum distance <0-9999>", - HANDOVER_STR - "How big is the maximum timing advance before HO is forced\n" - "Distance\n" "Number\n") -{ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - gsmnet->handover.max_distance = atoi(argv[0]); - return CMD_SUCCESS; -} - -DEFUN(cfg_net_pag_any_tch, - cfg_net_pag_any_tch_cmd, - "paging any use tch (0|1)", - "Assign a TCH when receiving a Paging Any request\n" - "Any Channel\n" "Use\n" "TCH\n" - "Do not use TCH for Paging Request Any\n" - "Do use TCH for Paging Request Any\n") -{ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - gsmnet->pag_any_tch = atoi(argv[0]); - gsm_net_update_ctype(gsmnet); - return CMD_SUCCESS; -} - -#define DECLARE_TIMER(number, doc) \ - DEFUN(cfg_net_T##number, \ - cfg_net_T##number##_cmd, \ - "timer t" #number " <0-65535>", \ - "Configure GSM Timers\n" \ - doc "Timer Value in seconds\n") \ -{ \ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); \ - int value = atoi(argv[0]); \ - \ - if (value < 0 || value > 65535) { \ - vty_out(vty, "Timer value %s out of range.%s", \ - argv[0], VTY_NEWLINE); \ - return CMD_WARNING; \ - } \ - \ - gsmnet->T##number = value; \ - return CMD_SUCCESS; \ -} - -DECLARE_TIMER(3101, "Set the timeout value for IMMEDIATE ASSIGNMENT.\n") -DECLARE_TIMER(3103, "Set the timeout value for HANDOVER.\n") -DECLARE_TIMER(3105, "Set the timer for repetition of PHYSICAL INFORMATION.\n") -DECLARE_TIMER(3107, "Currently not used.\n") -DECLARE_TIMER(3109, "Set the RSL SACCH deactivation timeout.\n") -DECLARE_TIMER(3111, "Set the RSL timeout to wait before releasing the RF Channel.\n") -DECLARE_TIMER(3113, "Set the time to try paging a subscriber.\n") -DECLARE_TIMER(3115, "Currently not used.\n") -DECLARE_TIMER(3117, "Currently not used.\n") -DECLARE_TIMER(3119, "Currently not used.\n") -DECLARE_TIMER(3122, "Waiting time (seconds) after IMM ASS REJECT\n") -DECLARE_TIMER(3141, "Currently not used.\n") - -DEFUN(cfg_net_dtx, - cfg_net_dtx_cmd, - "dtx-used (0|1)", - "Enable the usage of DTX.\n" - "DTX is disabled\n" "DTX is enabled\n") -{ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - gsmnet->dtx_enabled = atoi(argv[0]); - return CMD_SUCCESS; -} - -DEFUN(cfg_net_subscr_keep, - cfg_net_subscr_keep_cmd, - "subscriber-keep-in-ram (0|1)", - "Keep unused subscribers in RAM.\n" - "Delete unused subscribers\n" "Keep unused subscribers\n") -{ - struct gsm_network *gsmnet = gsmnet_from_vty(vty); - gsmnet->subscr_group->keep_subscr = atoi(argv[0]); - return CMD_SUCCESS; -} - /* per-BTS configuration */ DEFUN(cfg_bts, cfg_bts_cmd, @@ -1756,67 +1299,6 @@ DEFUN(cfg_bts_bsic, return CMD_SUCCESS; } -DEFUN(cfg_net_timezone, - cfg_net_timezone_cmd, - "timezone <-19-19> (0|15|30|45)", - "Set the Timezone Offset of the network\n" - "Timezone offset (hours)\n" - "Timezone offset (00 minutes)\n" - "Timezone offset (15 minutes)\n" - "Timezone offset (30 minutes)\n" - "Timezone offset (45 minutes)\n" - ) -{ - struct gsm_network *net = vty->index; - int tzhr = atoi(argv[0]); - int tzmn = atoi(argv[1]); - - net->tz.hr = tzhr; - net->tz.mn = tzmn; - net->tz.dst = 0; - net->tz.override = 1; - - return CMD_SUCCESS; -} - -DEFUN(cfg_net_timezone_dst, - cfg_net_timezone_dst_cmd, - "timezone <-19-19> (0|15|30|45) <0-2>", - "Set the Timezone Offset of the network\n" - "Timezone offset (hours)\n" - "Timezone offset (00 minutes)\n" - "Timezone offset (15 minutes)\n" - "Timezone offset (30 minutes)\n" - "Timezone offset (45 minutes)\n" - "DST offset (hours)\n" - ) -{ - struct gsm_network *net = vty->index; - int tzhr = atoi(argv[0]); - int tzmn = atoi(argv[1]); - int tzdst = atoi(argv[2]); - - net->tz.hr = tzhr; - net->tz.mn = tzmn; - net->tz.dst = tzdst; - net->tz.override = 1; - - return CMD_SUCCESS; -} - -DEFUN(cfg_net_no_timezone, - cfg_net_no_timezone_cmd, - "no timezone", - NO_STR - "Disable network timezone override, use system tz\n") -{ - struct gsm_network *net = vty->index; - - net->tz.override = 0; - - return CMD_SUCCESS; -} - DEFUN(cfg_bts_unit_id, cfg_bts_unit_id_cmd, "ip.access unit_id <0-65534> <0-255>", @@ -2312,6 +1794,33 @@ DEFUN(cfg_bts_penalty_time_rsvd, cfg_bts_penalty_time_rsvd_cmd, return CMD_SUCCESS; } +DEFUN(cfg_net_pag_any_tch, + cfg_net_pag_any_tch_cmd, + "paging any use tch (0|1)", + "Assign a TCH when receiving a Paging Any request\n" + "Any Channel\n" "Use\n" "TCH\n" + "Do not use TCH for Paging Request Any\n" + "Do use TCH for Paging Request Any\n") +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + gsmnet->pag_any_tch = atoi(argv[0]); + gsm_net_update_ctype(gsmnet); + return CMD_SUCCESS; +} + +DEFUN(cfg_net_neci, + cfg_net_neci_cmd, + "neci (0|1)", + "New Establish Cause Indication\n" + "Don't set the NECI bit\n" "Set the NECI bit\n") +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + + gsmnet->neci = atoi(argv[0]); + gsm_net_update_ctype(gsmnet); + return CMD_SUCCESS; +} + DEFUN(cfg_net_per_loc_upd, cfg_net_per_loc_upd_cmd, "periodic location update <6-1530>", "Periodic Location Updating Interval\n" @@ -3713,8 +3222,6 @@ extern int bsc_vty_init_extra(void); int bsc_vty_init(const struct log_info *cat, struct gsm_network *network) { - vty_global_gsm_network = network; - cfg_ts_pchan_cmd.string = vty_cmd_string_from_valstr(tall_bsc_ctx, gsm_pchant_names, @@ -3737,8 +3244,16 @@ int bsc_vty_init(const struct log_info *cat, struct gsm_network *network) "BTS Vendor/Type\n", "\n", "", 0); + logging_vty_add_cmds(cat); + xsc_vty_init(network); + + install_element(GSMNET_NODE, &cfg_net_neci_cmd); + install_element(GSMNET_NODE, &cfg_net_pag_any_tch_cmd); + install_element(GSMNET_NODE, &cfg_net_per_loc_upd_cmd); + install_element(GSMNET_NODE, &cfg_net_no_per_loc_upd_cmd); + + gsm_net_update_ctype(network); - install_element_ve(&show_net_cmd); install_element_ve(&show_bts_cmd); install_element_ve(&show_trx_cmd); install_element_ve(&show_ts_cmd); @@ -3748,50 +3263,6 @@ int bsc_vty_init(const struct log_info *cat, struct gsm_network *network) install_element_ve(&show_paging_cmd); install_element_ve(&show_paging_group_cmd); - logging_vty_add_cmds(cat); - osmo_stats_vty_add_cmds(); - - install_element(CONFIG_NODE, &cfg_net_cmd); - install_node(&net_node, config_write_net); - vty_install_default(GSMNET_NODE); - install_element(GSMNET_NODE, &cfg_net_ncc_cmd); - install_element(GSMNET_NODE, &cfg_net_mnc_cmd); - install_element(GSMNET_NODE, &cfg_net_name_short_cmd); - install_element(GSMNET_NODE, &cfg_net_name_long_cmd); - install_element(GSMNET_NODE, &cfg_net_auth_policy_cmd); - install_element(GSMNET_NODE, &cfg_net_reject_cause_cmd); - install_element(GSMNET_NODE, &cfg_net_encryption_cmd); - install_element(GSMNET_NODE, &cfg_net_neci_cmd); - install_element(GSMNET_NODE, &cfg_net_rrlp_mode_cmd); - install_element(GSMNET_NODE, &cfg_net_mm_info_cmd); - install_element(GSMNET_NODE, &cfg_net_handover_cmd); - install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_cmd); - install_element(GSMNET_NODE, &cfg_net_ho_win_rxqual_avg_cmd); - install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_neigh_cmd); - install_element(GSMNET_NODE, &cfg_net_ho_pwr_interval_cmd); - install_element(GSMNET_NODE, &cfg_net_ho_pwr_hysteresis_cmd); - install_element(GSMNET_NODE, &cfg_net_ho_max_distance_cmd); - install_element(GSMNET_NODE, &cfg_net_T3101_cmd); - install_element(GSMNET_NODE, &cfg_net_T3103_cmd); - install_element(GSMNET_NODE, &cfg_net_T3105_cmd); - install_element(GSMNET_NODE, &cfg_net_T3107_cmd); - install_element(GSMNET_NODE, &cfg_net_T3109_cmd); - install_element(GSMNET_NODE, &cfg_net_T3111_cmd); - install_element(GSMNET_NODE, &cfg_net_T3113_cmd); - install_element(GSMNET_NODE, &cfg_net_T3115_cmd); - install_element(GSMNET_NODE, &cfg_net_T3117_cmd); - install_element(GSMNET_NODE, &cfg_net_T3119_cmd); - install_element(GSMNET_NODE, &cfg_net_T3122_cmd); - install_element(GSMNET_NODE, &cfg_net_T3141_cmd); - install_element(GSMNET_NODE, &cfg_net_dtx_cmd); - install_element(GSMNET_NODE, &cfg_net_subscr_keep_cmd); - install_element(GSMNET_NODE, &cfg_net_pag_any_tch_cmd); - install_element(GSMNET_NODE, &cfg_net_timezone_cmd); - install_element(GSMNET_NODE, &cfg_net_timezone_dst_cmd); - install_element(GSMNET_NODE, &cfg_net_no_timezone_cmd); - install_element(GSMNET_NODE, &cfg_net_per_loc_upd_cmd); - install_element(GSMNET_NODE, &cfg_net_no_per_loc_upd_cmd); - install_element(GSMNET_NODE, &cfg_bts_cmd); install_node(&bts_node, config_write_bts); vty_install_default(BTS_NODE); diff --git a/openbsc/src/libbsc/chan_alloc.c b/openbsc/src/libbsc/chan_alloc.c index de9da810d..ca2a93c47 100644 --- a/openbsc/src/libbsc/chan_alloc.c +++ b/openbsc/src/libbsc/chan_alloc.c @@ -329,39 +329,6 @@ int lchan_release(struct gsm_lchan *lchan, int sacch_deact, enum rsl_rel_mode mo return 1; } -static struct gsm_lchan* lchan_find(struct gsm_bts *bts, struct gsm_subscriber *subscr) { - struct gsm_bts_trx *trx; - int ts_no, lchan_no; - - llist_for_each_entry(trx, &bts->trx_list, list) { - for (ts_no = 0; ts_no < 8; ++ts_no) { - for (lchan_no = 0; lchan_no < TS_MAX_LCHAN; ++lchan_no) { - struct gsm_lchan *lchan = - &trx->ts[ts_no].lchan[lchan_no]; - if (lchan->conn && subscr == lchan->conn->subscr) - return lchan; - } - } - } - - return NULL; -} - -struct gsm_subscriber_connection *connection_for_subscr(struct gsm_subscriber *subscr) -{ - struct gsm_bts *bts; - struct gsm_network *net = subscr->group->net; - struct gsm_lchan *lchan; - - llist_for_each_entry(bts, &net->bts_list, list) { - lchan = lchan_find(bts, subscr); - if (lchan) - return lchan->conn; - } - - return NULL; -} - void bts_chan_load(struct pchan_load *cl, const struct gsm_bts *bts) { struct gsm_bts_trx *trx; diff --git a/openbsc/src/libbsc/gsm_04_08_utils.c b/openbsc/src/libbsc/gsm_04_08_utils.c index 8c6dbef9b..68315db21 100644 --- a/openbsc/src/libbsc/gsm_04_08_utils.c +++ b/openbsc/src/libbsc/gsm_04_08_utils.c @@ -258,30 +258,6 @@ int send_siemens_mrpci(struct gsm_lchan *lchan, return rsl_siemens_mrpci(lchan, &mrpci); } -int gsm48_extract_mi(uint8_t *classmark2_lv, int length, char *mi_string, uint8_t *mi_type) -{ - /* Check the size for the classmark */ - if (length < 1 + *classmark2_lv) - return -1; - - uint8_t *mi_lv = classmark2_lv + *classmark2_lv + 1; - if (length < 2 + *classmark2_lv + mi_lv[0]) - return -2; - - *mi_type = mi_lv[1] & GSM_MI_TYPE_MASK; - return gsm48_mi_to_string(mi_string, GSM48_MI_SIZE, mi_lv+1, *mi_lv); -} - -int gsm48_paging_extract_mi(struct gsm48_pag_resp *resp, int length, - char *mi_string, uint8_t *mi_type) -{ - static const uint32_t classmark_offset = - offsetof(struct gsm48_pag_resp, classmark2); - uint8_t *classmark2_lv = (uint8_t *) &resp->classmark2; - return gsm48_extract_mi(classmark2_lv, length - classmark_offset, - mi_string, mi_type); -} - int gsm48_handle_paging_resp(struct gsm_subscriber_connection *conn, struct msgb *msg, struct gsm_subscriber *subscr) { @@ -645,39 +621,6 @@ int gsm48_parse_meas_rep(struct gsm_meas_rep *rep, struct msgb *msg) return 0; } -struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value value) -{ - struct msgb *msg; - struct gsm48_hdr *gh; - - msg = gsm48_msgb_alloc_name("GSM 04.08 SERV REJ"); - if (!msg) - return NULL; - - gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh) + 1); - gh->proto_discr = GSM48_PDISC_MM; - gh->msg_type = GSM48_MT_MM_CM_SERV_REJ; - gh->data[0] = value; - - return msg; -} - -struct msgb *gsm48_create_loc_upd_rej(uint8_t cause) -{ - struct gsm48_hdr *gh; - struct msgb *msg; - - msg = gsm48_msgb_alloc_name("GSM 04.08 LOC UPD REJ"); - if (!msg) - return NULL; - - gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh) + 1); - gh->proto_discr = GSM48_PDISC_MM; - gh->msg_type = GSM48_MT_MM_LOC_UPD_REJECT; - gh->data[0] = cause; - return msg; -} - /* 9.2.5 CM service accept */ int gsm48_tx_mm_serv_ack(struct gsm_subscriber_connection *conn) { diff --git a/openbsc/src/libbsc/net_init.c b/openbsc/src/libbsc/net_init.c index 9aba4a0b7..014ba89a6 100644 --- a/openbsc/src/libbsc/net_init.c +++ b/openbsc/src/libbsc/net_init.c @@ -17,102 +17,3 @@ * */ -#include <openbsc/gsm_data.h> -#include <openbsc/osmo_msc_data.h> -#include <openbsc/gsm_subscriber.h> - -struct gsm_network *gsm_network_init(void *ctx, - uint16_t country_code, - uint16_t network_code, - mncc_recv_cb_t mncc_recv) -{ - struct gsm_network *net; - - net = talloc_zero(ctx, struct gsm_network); - if (!net) - return NULL; - - net->bsc_data = talloc_zero(net, struct osmo_bsc_data); - if (!net->bsc_data) { - talloc_free(net); - return NULL; - } - - net->subscr_group = talloc_zero(net, struct gsm_subscriber_group); - if (!net->subscr_group) { - talloc_free(net); - return NULL; - } - - /* Init back pointer */ - net->bsc_data->auto_off_timeout = -1; - net->bsc_data->network = net; - INIT_LLIST_HEAD(&net->bsc_data->mscs); - - net->subscr_group->net = net; - net->create_subscriber = 1; - - net->country_code = country_code; - net->network_code = network_code; - net->num_bts = 0; - net->reject_cause = GSM48_REJECT_ROAMING_NOT_ALLOWED; - net->T3101 = GSM_T3101_DEFAULT; - net->T3105 = GSM_T3105_DEFAULT; - net->T3113 = GSM_T3113_DEFAULT; - net->T3122 = GSM_T3122_DEFAULT; - /* FIXME: initialize all other timers! */ - - /* default set of handover parameters */ - net->handover.win_rxlev_avg = 10; - net->handover.win_rxqual_avg = 1; - net->handover.win_rxlev_avg_neigh = 10; - net->handover.pwr_interval = 6; - net->handover.pwr_hysteresis = 3; - net->handover.max_distance = 9999; - - /* Use 30 min periodic update interval as sane default */ - net->t3212 = 5; - - INIT_LLIST_HEAD(&net->trans_list); - INIT_LLIST_HEAD(&net->upqueue); - INIT_LLIST_HEAD(&net->bts_list); - INIT_LLIST_HEAD(&net->subscr_conns); - - net->stats.chreq.total = osmo_counter_alloc("net.chreq.total"); - net->stats.chreq.no_channel = osmo_counter_alloc("net.chreq.no_channel"); - net->stats.handover.attempted = osmo_counter_alloc("net.handover.attempted"); - net->stats.handover.no_channel = osmo_counter_alloc("net.handover.no_channel"); - net->stats.handover.timeout = osmo_counter_alloc("net.handover.timeout"); - net->stats.handover.completed = osmo_counter_alloc("net.handover.completed"); - net->stats.handover.failed = osmo_counter_alloc("net.handover.failed"); - net->stats.loc_upd_type.attach = osmo_counter_alloc("net.loc_upd_type.attach"); - net->stats.loc_upd_type.normal = osmo_counter_alloc("net.loc_upd_type.normal"); - net->stats.loc_upd_type.periodic = osmo_counter_alloc("net.loc_upd_type.periodic"); - net->stats.loc_upd_type.detach = osmo_counter_alloc("net.imsi_detach.count"); - net->stats.loc_upd_resp.reject = osmo_counter_alloc("net.loc_upd_resp.reject"); - net->stats.loc_upd_resp.accept = osmo_counter_alloc("net.loc_upd_resp.accept"); - net->stats.paging.attempted = osmo_counter_alloc("net.paging.attempted"); - net->stats.paging.detached = osmo_counter_alloc("net.paging.detached"); - net->stats.paging.completed = osmo_counter_alloc("net.paging.completed"); - net->stats.paging.expired = osmo_counter_alloc("net.paging.expired"); - net->stats.sms.submitted = osmo_counter_alloc("net.sms.submitted"); - net->stats.sms.no_receiver = osmo_counter_alloc("net.sms.no_receiver"); - net->stats.sms.delivered = osmo_counter_alloc("net.sms.delivered"); - net->stats.sms.rp_err_mem = osmo_counter_alloc("net.sms.rp_err_mem"); - net->stats.sms.rp_err_other = osmo_counter_alloc("net.sms.rp_err_other"); - net->stats.call.mo_setup = osmo_counter_alloc("net.call.mo_setup"); - net->stats.call.mo_connect_ack = osmo_counter_alloc("net.call.mo_connect_ack"); - net->stats.call.mt_setup = osmo_counter_alloc("net.call.mt_setup"); - net->stats.call.mt_connect = osmo_counter_alloc("net.call.mt_connect"); - net->stats.chan.rf_fail = osmo_counter_alloc("net.chan.rf_fail"); - net->stats.chan.rll_err = osmo_counter_alloc("net.chan.rll_err"); - net->stats.bts.oml_fail = osmo_counter_alloc("net.bts.oml_fail"); - net->stats.bts.rsl_fail = osmo_counter_alloc("net.bts.rsl_fail"); - - net->mncc_recv = mncc_recv; - - gsm_net_update_ctype(net); - - return net; -} - diff --git a/openbsc/src/libxsc/Makefile.am b/openbsc/src/libxsc/Makefile.am new file mode 100644 index 000000000..d73eb4e2d --- /dev/null +++ b/openbsc/src/libxsc/Makefile.am @@ -0,0 +1,7 @@ +AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir) +AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) \ + $(LIBOSMOVTY_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(COVERAGE_CFLAGS) + +noinst_LIBRARIES = libxsc.a + +libxsc_a_SOURCES = xsc.c xsc_vty.c diff --git a/openbsc/src/libxsc/xsc.c b/openbsc/src/libxsc/xsc.c new file mode 100644 index 000000000..7cf502689 --- /dev/null +++ b/openbsc/src/libxsc/xsc.c @@ -0,0 +1,202 @@ +/* Code used by both libbsc and libmsc (xsc means "BSC or MSC"). + * + * (C) 2016 by sysmocom s.m.f.c. <info@sysmocom.de> + * (C) 2008-2010 by Harald Welte <laforge@gnumonks.org> + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +/* TODO: this file was created during the MSCSPLIT, separating the BSC from the + * NITB to create a standalone MSC. Things from libbsc that are needed from + * libmsc have been moved here, probably taking along some stuff not actually + * needed by the MSC. It may make sense to move things to more appropriate + * places or implement things differently when they become more obvious. I'm + * taking that as an excuse to make a mess of this file in the sense of keeping + * #includes close to their use, and not caring much about mixing things. */ + +/* FIXME parts of the gsm_network are BSC specific and don't belong here. */ + +#include <openbsc/gsm_data.h> +#include <openbsc/osmo_msc_data.h> +#include <openbsc/gsm_subscriber.h> + +struct gsm_network *gsm_network_init(void *ctx, + uint16_t country_code, + uint16_t network_code, + mncc_recv_cb_t mncc_recv) +{ + struct gsm_network *net; + + net = talloc_zero(ctx, struct gsm_network); + if (!net) + return NULL; + + net->bsc_data = talloc_zero(net, struct osmo_bsc_data); + if (!net->bsc_data) { + talloc_free(net); + return NULL; + } + + net->subscr_group = talloc_zero(net, struct gsm_subscriber_group); + if (!net->subscr_group) { + talloc_free(net); + return NULL; + } + + /* Init back pointer */ + net->bsc_data->auto_off_timeout = -1; + net->bsc_data->network = net; + INIT_LLIST_HEAD(&net->bsc_data->mscs); + + net->subscr_group->net = net; + net->create_subscriber = 1; + + net->country_code = country_code; + net->network_code = network_code; + net->num_bts = 0; + net->reject_cause = GSM48_REJECT_ROAMING_NOT_ALLOWED; + net->T3101 = GSM_T3101_DEFAULT; + net->T3105 = GSM_T3105_DEFAULT; + net->T3113 = GSM_T3113_DEFAULT; + net->T3122 = GSM_T3122_DEFAULT; + /* FIXME: initialize all other timers! */ + + /* default set of handover parameters */ + net->handover.win_rxlev_avg = 10; + net->handover.win_rxqual_avg = 1; + net->handover.win_rxlev_avg_neigh = 10; + net->handover.pwr_interval = 6; + net->handover.pwr_hysteresis = 3; + net->handover.max_distance = 9999; + + /* Use 30 min periodic update interval as sane default */ + net->t3212 = 5; + + INIT_LLIST_HEAD(&net->trans_list); + INIT_LLIST_HEAD(&net->upqueue); + INIT_LLIST_HEAD(&net->bts_list); + INIT_LLIST_HEAD(&net->subscr_conns); + + net->stats.chreq.total = osmo_counter_alloc("net.chreq.total"); + net->stats.chreq.no_channel = osmo_counter_alloc("net.chreq.no_channel"); + net->stats.handover.attempted = osmo_counter_alloc("net.handover.attempted"); + net->stats.handover.no_channel = osmo_counter_alloc("net.handover.no_channel"); + net->stats.handover.timeout = osmo_counter_alloc("net.handover.timeout"); + net->stats.handover.completed = osmo_counter_alloc("net.handover.completed"); + net->stats.handover.failed = osmo_counter_alloc("net.handover.failed"); + net->stats.loc_upd_type.attach = osmo_counter_alloc("net.loc_upd_type.attach"); + net->stats.loc_upd_type.normal = osmo_counter_alloc("net.loc_upd_type.normal"); + net->stats.loc_upd_type.periodic = osmo_counter_alloc("net.loc_upd_type.periodic"); + net->stats.loc_upd_type.detach = osmo_counter_alloc("net.imsi_detach.count"); + net->stats.loc_upd_resp.reject = osmo_counter_alloc("net.loc_upd_resp.reject"); + net->stats.loc_upd_resp.accept = osmo_counter_alloc("net.loc_upd_resp.accept"); + net->stats.paging.attempted = osmo_counter_alloc("net.paging.attempted"); + net->stats.paging.detached = osmo_counter_alloc("net.paging.detached"); + net->stats.paging.completed = osmo_counter_alloc("net.paging.completed"); + net->stats.paging.expired = osmo_counter_alloc("net.paging.expired"); + net->stats.sms.submitted = osmo_counter_alloc("net.sms.submitted"); + net->stats.sms.no_receiver = osmo_counter_alloc("net.sms.no_receiver"); + net->stats.sms.delivered = osmo_counter_alloc("net.sms.delivered"); + net->stats.sms.rp_err_mem = osmo_counter_alloc("net.sms.rp_err_mem"); + net->stats.sms.rp_err_other = osmo_counter_alloc("net.sms.rp_err_other"); + net->stats.call.mo_setup = osmo_counter_alloc("net.call.mo_setup"); + net->stats.call.mo_connect_ack = osmo_counter_alloc("net.call.mo_connect_ack"); + net->stats.call.mt_setup = osmo_counter_alloc("net.call.mt_setup"); + net->stats.call.mt_connect = osmo_counter_alloc("net.call.mt_connect"); + net->stats.chan.rf_fail = osmo_counter_alloc("net.chan.rf_fail"); + net->stats.chan.rll_err = osmo_counter_alloc("net.chan.rll_err"); + net->stats.bts.oml_fail = osmo_counter_alloc("net.bts.oml_fail"); + net->stats.bts.rsl_fail = osmo_counter_alloc("net.bts.rsl_fail"); + + net->mncc_recv = mncc_recv; + + return net; +} + +struct gsm_subscriber_connection *connection_for_subscr(struct gsm_subscriber *subscr) +{ + /* FIXME: replace this with a backpointer in gsm_subscriber? */ + struct gsm_network *net = subscr->group->net; + struct gsm_subscriber_connection *conn; + + llist_for_each_entry(conn, &net->subscr_conns, entry) { + if (conn->subscr == subscr) + return conn; + } + + return NULL; +} + + +/* from gsm_04_08_utils.c *****/ + +struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value value) +{ + struct msgb *msg; + struct gsm48_hdr *gh; + + msg = gsm48_msgb_alloc_name("GSM 04.08 SERV REJ"); + if (!msg) + return NULL; + + gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh) + 1); + gh->proto_discr = GSM48_PDISC_MM; + gh->msg_type = GSM48_MT_MM_CM_SERV_REJ; + gh->data[0] = value; + + return msg; +} + +struct msgb *gsm48_create_loc_upd_rej(uint8_t cause) +{ + struct gsm48_hdr *gh; + struct msgb *msg; + + msg = gsm48_msgb_alloc_name("GSM 04.08 LOC UPD REJ"); + if (!msg) + return NULL; + + gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh) + 1); + gh->proto_discr = GSM48_PDISC_MM; + gh->msg_type = GSM48_MT_MM_LOC_UPD_REJECT; + gh->data[0] = cause; + return msg; +} + +int gsm48_extract_mi(uint8_t *classmark2_lv, int length, char *mi_string, uint8_t *mi_type) +{ + /* Check the size for the classmark */ + if (length < 1 + *classmark2_lv) + return -1; + + uint8_t *mi_lv = classmark2_lv + *classmark2_lv + 1; + if (length < 2 + *classmark2_lv + mi_lv[0]) + return -2; + + *mi_type = mi_lv[1] & GSM_MI_TYPE_MASK; + return gsm48_mi_to_string(mi_string, GSM48_MI_SIZE, mi_lv+1, *mi_lv); +} + +int gsm48_paging_extract_mi(struct gsm48_pag_resp *resp, int length, + char *mi_string, uint8_t *mi_type) +{ + static const uint32_t classmark_offset = + offsetof(struct gsm48_pag_resp, classmark2); + uint8_t *classmark2_lv = (uint8_t *) &resp->classmark2; + return gsm48_extract_mi(classmark2_lv, length - classmark_offset, + mi_string, mi_type); +} + diff --git a/openbsc/src/libxsc/xsc_vty.c b/openbsc/src/libxsc/xsc_vty.c new file mode 100644 index 000000000..93be5d6fb --- /dev/null +++ b/openbsc/src/libxsc/xsc_vty.c @@ -0,0 +1,587 @@ +/* Code used by both libbsc and libmsc (xsc means "BSC or MSC"). + * + * (C) 2016 by sysmocom s.m.f.c. <info@sysmocom.de> + * (C) 2008-2010 by Harald Welte <laforge@gnumonks.org> + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +/* FIXME parts of the gsm_network VTY commands are BSC specific and don't + * belong here. */ + +#include <osmocom/core/utils.h> + +#include <osmocom/vty/command.h> +#include <osmocom/vty/logging.h> +#include <osmocom/vty/stats.h> + +#include <openbsc/vty.h> + +#include <openbsc/gsm_data.h> +#include <openbsc/gsm_subscriber.h> + +struct cmd_node net_node = { + GSMNET_NODE, + "%s(config-net)# ", + 1, +}; + +struct gsm_network *vty_global_gsm_network = 0; + +struct gsm_network *gsmnet_from_vty(struct vty *v) +{ + /* In case we read from the config file, the vty->priv cannot + * point to a struct telnet_connection, and thus conn->priv + * will not point to the gsm_network structure. + * It can't hurt to force callers to continue to pass the vty instance + * to this function, in case we'd like to retrieve the global + * gsm_network instance from the vty at some point in the future. But + * until then, just return the global pointer, which should have been + * initialized by bsc_vty_init(). + */ + OSMO_ASSERT(vty_global_gsm_network); + return vty_global_gsm_network; +} + +static void net_dump_vty(struct vty *vty, struct gsm_network *net) +{ + vty_out(vty, "BSC is on Country Code %u, Network Code %u " + "and has %u BTS%s", net->country_code, net->network_code, + net->num_bts, VTY_NEWLINE); + vty_out(vty, " Long network name: '%s'%s", + net->name_long, VTY_NEWLINE); + vty_out(vty, " Short network name: '%s'%s", + net->name_short, VTY_NEWLINE); + vty_out(vty, " Authentication policy: %s%s", + gsm_auth_policy_name(net->auth_policy), VTY_NEWLINE); + vty_out(vty, " Location updating reject cause: %u%s", + net->reject_cause, VTY_NEWLINE); + vty_out(vty, " Encryption: A5/%u%s", net->a5_encryption, + VTY_NEWLINE); + vty_out(vty, " NECI (TCH/H): %u%s", net->neci, + VTY_NEWLINE); + vty_out(vty, " Use TCH for Paging any: %d%s", net->pag_any_tch, + VTY_NEWLINE); + vty_out(vty, " RRLP Mode: %s%s", rrlp_mode_name(net->rrlp.mode), + VTY_NEWLINE); + vty_out(vty, " MM Info: %s%s", net->send_mm_info ? "On" : "Off", + VTY_NEWLINE); + vty_out(vty, " Handover: %s%s", net->handover.active ? "On" : "Off", + VTY_NEWLINE); +#if BEFORE_MSCSPLIT + struct pchan_load pl; + network_chan_load(&pl, net); + vty_out(vty, " Current Channel Load:%s", VTY_NEWLINE); + dump_pchan_load_vty(vty, " ", &pl); + + /* show rf */ + if (net->bsc_data) + vty_out(vty, " Last RF Command: %s%s", + net->bsc_data->rf_ctrl->last_state_command, + VTY_NEWLINE); + if (net->bsc_data) + vty_out(vty, " Last RF Lock Command: %s%s", + net->bsc_data->rf_ctrl->last_rf_lock_ctrl_command, + VTY_NEWLINE); +#endif +} + +DEFUN(show_net, show_net_cmd, "show network", + SHOW_STR "Display information about a GSM NETWORK\n") +{ + struct gsm_network *net = gsmnet_from_vty(vty); + net_dump_vty(vty, net); + + return CMD_SUCCESS; +} + +static int config_write_net(struct vty *vty) +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + + vty_out(vty, "network%s", VTY_NEWLINE); + vty_out(vty, " network country code %u%s", gsmnet->country_code, VTY_NEWLINE); + vty_out(vty, " mobile network code %u%s", gsmnet->network_code, VTY_NEWLINE); + vty_out(vty, " short name %s%s", gsmnet->name_short, VTY_NEWLINE); + vty_out(vty, " long name %s%s", gsmnet->name_long, VTY_NEWLINE); + vty_out(vty, " auth policy %s%s", gsm_auth_policy_name(gsmnet->auth_policy), VTY_NEWLINE); + vty_out(vty, " location updating reject cause %u%s", + gsmnet->reject_cause, VTY_NEWLINE); + vty_out(vty, " encryption a5 %u%s", gsmnet->a5_encryption, VTY_NEWLINE); + vty_out(vty, " neci %u%s", gsmnet->neci, VTY_NEWLINE); + vty_out(vty, " paging any use tch %d%s", gsmnet->pag_any_tch, VTY_NEWLINE); + vty_out(vty, " rrlp mode %s%s", rrlp_mode_name(gsmnet->rrlp.mode), + VTY_NEWLINE); + vty_out(vty, " mm info %u%s", gsmnet->send_mm_info, VTY_NEWLINE); + vty_out(vty, " handover %u%s", gsmnet->handover.active, VTY_NEWLINE); + vty_out(vty, " handover window rxlev averaging %u%s", + gsmnet->handover.win_rxlev_avg, VTY_NEWLINE); + vty_out(vty, " handover window rxqual averaging %u%s", + gsmnet->handover.win_rxqual_avg, VTY_NEWLINE); + vty_out(vty, " handover window rxlev neighbor averaging %u%s", + gsmnet->handover.win_rxlev_avg_neigh, VTY_NEWLINE); + vty_out(vty, " handover power budget interval %u%s", + gsmnet->handover.pwr_interval, VTY_NEWLINE); + vty_out(vty, " handover power budget hysteresis %u%s", + gsmnet->handover.pwr_hysteresis, VTY_NEWLINE); + vty_out(vty, " handover maximum distance %u%s", + gsmnet->handover.max_distance, VTY_NEWLINE); + vty_out(vty, " timer t3101 %u%s", gsmnet->T3101, VTY_NEWLINE); + vty_out(vty, " timer t3103 %u%s", gsmnet->T3103, VTY_NEWLINE); + vty_out(vty, " timer t3105 %u%s", gsmnet->T3105, VTY_NEWLINE); + vty_out(vty, " timer t3107 %u%s", gsmnet->T3107, VTY_NEWLINE); + vty_out(vty, " timer t3109 %u%s", gsmnet->T3109, VTY_NEWLINE); + vty_out(vty, " timer t3111 %u%s", gsmnet->T3111, VTY_NEWLINE); + vty_out(vty, " timer t3113 %u%s", gsmnet->T3113, VTY_NEWLINE); + vty_out(vty, " timer t3115 %u%s", gsmnet->T3115, VTY_NEWLINE); + vty_out(vty, " timer t3117 %u%s", gsmnet->T3117, VTY_NEWLINE); + vty_out(vty, " timer t3119 %u%s", gsmnet->T3119, VTY_NEWLINE); + vty_out(vty, " timer t3122 %u%s", gsmnet->T3122, VTY_NEWLINE); + vty_out(vty, " timer t3141 %u%s", gsmnet->T3141, VTY_NEWLINE); + vty_out(vty, " dtx-used %u%s", gsmnet->dtx_enabled, VTY_NEWLINE); + vty_out(vty, " subscriber-keep-in-ram %d%s", + gsmnet->subscr_group->keep_subscr, VTY_NEWLINE); + if (gsmnet->tz.override != 0) { + if (gsmnet->tz.dst) + vty_out(vty, " timezone %d %d %d%s", + gsmnet->tz.hr, gsmnet->tz.mn, gsmnet->tz.dst, + VTY_NEWLINE); + else + vty_out(vty, " timezone %d %d%s", + gsmnet->tz.hr, gsmnet->tz.mn, VTY_NEWLINE); + } + + if (gsmnet->t3212 == 0) + vty_out(vty, " no periodic location update%s", VTY_NEWLINE); + else + vty_out(vty, " periodic location update %u%s", + gsmnet->t3212 * 6, VTY_NEWLINE); + + + return CMD_SUCCESS; +} + +#define NETWORK_STR "Configure the GSM network\n" +#define CODE_CMD_STR "Code commands\n" +#define NAME_CMD_STR "Name Commands\n" +#define NAME_STR "Name to use\n" + +DEFUN(cfg_net, + cfg_net_cmd, + "network", NETWORK_STR) +{ + vty->index = gsmnet_from_vty(vty); + vty->node = GSMNET_NODE; + + return CMD_SUCCESS; +} + +DEFUN(cfg_net_ncc, + cfg_net_ncc_cmd, + "network country code <1-999>", + "Set the GSM network country code\n" + "Country commands\n" + CODE_CMD_STR + "Network Country Code to use\n") +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + + gsmnet->country_code = atoi(argv[0]); + + return CMD_SUCCESS; +} + +DEFUN(cfg_net_mnc, + cfg_net_mnc_cmd, + "mobile network code <0-999>", + "Set the GSM mobile network code\n" + "Network Commands\n" + CODE_CMD_STR + "Mobile Network Code to use\n") +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + + gsmnet->network_code = atoi(argv[0]); + + return CMD_SUCCESS; +} + +DEFUN(cfg_net_name_short, + cfg_net_name_short_cmd, + "short name NAME", + "Set the short GSM network name\n" NAME_CMD_STR NAME_STR) +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + + bsc_replace_string(gsmnet, &gsmnet->name_short, argv[0]); + return CMD_SUCCESS; +} + +DEFUN(cfg_net_name_long, + cfg_net_name_long_cmd, + "long name NAME", + "Set the long GSM network name\n" NAME_CMD_STR NAME_STR) +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + + bsc_replace_string(gsmnet, &gsmnet->name_long, argv[0]); + return CMD_SUCCESS; +} + +DEFUN(cfg_net_auth_policy, + cfg_net_auth_policy_cmd, + "auth policy (closed|accept-all|token)", + "Authentication (not cryptographic)\n" + "Set the GSM network authentication policy\n" + "Require the MS to be activated in HLR\n" + "Accept all MS, whether in HLR or not\n" + "Use SMS-token based authentication\n") +{ + enum gsm_auth_policy policy = gsm_auth_policy_parse(argv[0]); + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + + gsmnet->auth_policy = policy; + + return CMD_SUCCESS; +} + +DEFUN(cfg_net_reject_cause, + cfg_net_reject_cause_cmd, + "location updating reject cause <2-111>", + "Set the reject cause of location updating reject\n" + "Set the reject cause of location updating reject\n" + "Set the reject cause of location updating reject\n" + "Set the reject cause of location updating reject\n" + "Cause Value as Per GSM TS 04.08\n") +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + + gsmnet->reject_cause = atoi(argv[0]); + + return CMD_SUCCESS; +} + +DEFUN(cfg_net_encryption, + cfg_net_encryption_cmd, + "encryption a5 (0|1|2|3)", + "Encryption options\n" + "A5 encryption\n" "A5/0: No encryption\n" + "A5/1: Encryption\n" "A5/2: Export-grade Encryption\n" + "A5/3: 'New' Secure Encryption\n") +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + + gsmnet->a5_encryption= atoi(argv[0]); + + return CMD_SUCCESS; +} + +DEFUN(cfg_net_rrlp_mode, cfg_net_rrlp_mode_cmd, + "rrlp mode (none|ms-based|ms-preferred|ass-preferred)", + "Radio Resource Location Protocol\n" + "Set the Radio Resource Location Protocol Mode\n" + "Don't send RRLP request\n" + "Request MS-based location\n" + "Request any location, prefer MS-based\n" + "Request any location, prefer MS-assisted\n") +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + + gsmnet->rrlp.mode = rrlp_mode_parse(argv[0]); + + return CMD_SUCCESS; +} + +DEFUN(cfg_net_mm_info, cfg_net_mm_info_cmd, + "mm info (0|1)", + "Mobility Management\n" + "Send MM INFO after LOC UPD ACCEPT\n" + "Disable\n" "Enable\n") +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + + gsmnet->send_mm_info = atoi(argv[0]); + + return CMD_SUCCESS; +} + +#define HANDOVER_STR "Handover Options\n" + +DEFUN(cfg_net_handover, cfg_net_handover_cmd, + "handover (0|1)", + HANDOVER_STR + "Don't perform in-call handover\n" + "Perform in-call handover\n") +{ + int enable = atoi(argv[0]); + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + +#if BEFORE_MSCSPLIT + if (enable && ipacc_rtp_direct) { + vty_out(vty, "%% Cannot enable handover unless RTP Proxy mode " + "is enabled by using the -P command line option%s", + VTY_NEWLINE); + return CMD_WARNING; + } +#endif + gsmnet->handover.active = enable; + + return CMD_SUCCESS; +} + +#define HO_WIN_STR HANDOVER_STR "Measurement Window\n" +#define HO_WIN_RXLEV_STR HO_WIN_STR "Received Level Averaging\n" +#define HO_WIN_RXQUAL_STR HO_WIN_STR "Received Quality Averaging\n" +#define HO_PBUDGET_STR HANDOVER_STR "Power Budget\n" +#define HO_AVG_COUNT_STR "Amount to use for Averaging\n" + +DEFUN(cfg_net_ho_win_rxlev_avg, cfg_net_ho_win_rxlev_avg_cmd, + "handover window rxlev averaging <1-10>", + HO_WIN_RXLEV_STR + "How many RxLev measurements are used for averaging\n" + HO_AVG_COUNT_STR) +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + gsmnet->handover.win_rxlev_avg = atoi(argv[0]); + return CMD_SUCCESS; +} + +DEFUN(cfg_net_ho_win_rxqual_avg, cfg_net_ho_win_rxqual_avg_cmd, + "handover window rxqual averaging <1-10>", + HO_WIN_RXQUAL_STR + "How many RxQual measurements are used for averaging\n" + HO_AVG_COUNT_STR) +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + gsmnet->handover.win_rxqual_avg = atoi(argv[0]); + return CMD_SUCCESS; +} + +DEFUN(cfg_net_ho_win_rxlev_neigh_avg, cfg_net_ho_win_rxlev_avg_neigh_cmd, + "handover window rxlev neighbor averaging <1-10>", + HO_WIN_RXLEV_STR "Neighbor\n" + "How many RxQual measurements are used for averaging\n" + HO_AVG_COUNT_STR) +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + gsmnet->handover.win_rxlev_avg_neigh = atoi(argv[0]); + return CMD_SUCCESS; +} + +DEFUN(cfg_net_ho_pwr_interval, cfg_net_ho_pwr_interval_cmd, + "handover power budget interval <1-99>", + HO_PBUDGET_STR + "How often to check if we have a better cell (SACCH frames)\n" + "Interval\n" "Number\n") +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + gsmnet->handover.pwr_interval = atoi(argv[0]); + return CMD_SUCCESS; +} + +DEFUN(cfg_net_ho_pwr_hysteresis, cfg_net_ho_pwr_hysteresis_cmd, + "handover power budget hysteresis <0-999>", + HO_PBUDGET_STR + "How many dB does a neighbor to be stronger to become a HO candidate\n" + "Hysteresis\n" "Number\n") +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + gsmnet->handover.pwr_hysteresis = atoi(argv[0]); + return CMD_SUCCESS; +} + +DEFUN(cfg_net_ho_max_distance, cfg_net_ho_max_distance_cmd, + "handover maximum distance <0-9999>", + HANDOVER_STR + "How big is the maximum timing advance before HO is forced\n" + "Distance\n" "Number\n") +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + gsmnet->handover.max_distance = atoi(argv[0]); + return CMD_SUCCESS; +} + +#define DECLARE_TIMER(number, doc) \ + DEFUN(cfg_net_T##number, \ + cfg_net_T##number##_cmd, \ + "timer t" #number " <0-65535>", \ + "Configure GSM Timers\n" \ + doc "Timer Value in seconds\n") \ +{ \ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); \ + int value = atoi(argv[0]); \ + \ + if (value < 0 || value > 65535) { \ + vty_out(vty, "Timer value %s out of range.%s", \ + argv[0], VTY_NEWLINE); \ + return CMD_WARNING; \ + } \ + \ + gsmnet->T##number = value; \ + return CMD_SUCCESS; \ +} + +DECLARE_TIMER(3101, "Set the timeout value for IMMEDIATE ASSIGNMENT.\n") +DECLARE_TIMER(3103, "Set the timeout value for HANDOVER.\n") +DECLARE_TIMER(3105, "Set the timer for repetition of PHYSICAL INFORMATION.\n") +DECLARE_TIMER(3107, "Currently not used.\n") +DECLARE_TIMER(3109, "Set the RSL SACCH deactivation timeout.\n") +DECLARE_TIMER(3111, "Set the RSL timeout to wait before releasing the RF Channel.\n") +DECLARE_TIMER(3113, "Set the time to try paging a subscriber.\n") +DECLARE_TIMER(3115, "Currently not used.\n") +DECLARE_TIMER(3117, "Currently not used.\n") +DECLARE_TIMER(3119, "Currently not used.\n") +DECLARE_TIMER(3122, "Waiting time (seconds) after IMM ASS REJECT\n") +DECLARE_TIMER(3141, "Currently not used.\n") + +DEFUN(cfg_net_dtx, + cfg_net_dtx_cmd, + "dtx-used (0|1)", + "Enable the usage of DTX.\n" + "DTX is disabled\n" "DTX is enabled\n") +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + gsmnet->dtx_enabled = atoi(argv[0]); + return CMD_SUCCESS; +} + +DEFUN(cfg_net_subscr_keep, + cfg_net_subscr_keep_cmd, + "subscriber-keep-in-ram (0|1)", + "Keep unused subscribers in RAM.\n" + "Delete unused subscribers\n" "Keep unused subscribers\n") +{ + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + gsmnet->subscr_group->keep_subscr = atoi(argv[0]); + return CMD_SUCCESS; +} + +DEFUN(cfg_net_timezone, + cfg_net_timezone_cmd, + "timezone <-19-19> (0|15|30|45)", + "Set the Timezone Offset of the network\n" + "Timezone offset (hours)\n" + "Timezone offset (00 minutes)\n" + "Timezone offset (15 minutes)\n" + "Timezone offset (30 minutes)\n" + "Timezone offset (45 minutes)\n" + ) +{ + struct gsm_network *net = vty->index; + int tzhr = atoi(argv[0]); + int tzmn = atoi(argv[1]); + + net->tz.hr = tzhr; + net->tz.mn = tzmn; + net->tz.dst = 0; + net->tz.override = 1; + + return CMD_SUCCESS; +} + +DEFUN(cfg_net_timezone_dst, + cfg_net_timezone_dst_cmd, + "timezone <-19-19> (0|15|30|45) <0-2>", + "Set the Timezone Offset of the network\n" + "Timezone offset (hours)\n" + "Timezone offset (00 minutes)\n" + "Timezone offset (15 minutes)\n" + "Timezone offset (30 minutes)\n" + "Timezone offset (45 minutes)\n" + "DST offset (hours)\n" + ) +{ + struct gsm_network *net = vty->index; + int tzhr = atoi(argv[0]); + int tzmn = atoi(argv[1]); + int tzdst = atoi(argv[2]); + + net->tz.hr = tzhr; + net->tz.mn = tzmn; + net->tz.dst = tzdst; + net->tz.override = 1; + + return CMD_SUCCESS; +} + +DEFUN(cfg_net_no_timezone, + cfg_net_no_timezone_cmd, + "no timezone", + NO_STR + "Disable network timezone override, use system tz\n") +{ + struct gsm_network *net = vty->index; + + net->tz.override = 0; + + return CMD_SUCCESS; +} + + +int gsmnet_vty_init(struct gsm_network *network) +{ + vty_global_gsm_network = network; + + install_element_ve(&show_net_cmd); + + install_element(CONFIG_NODE, &cfg_net_cmd); + install_node(&net_node, config_write_net); + vty_install_default(GSMNET_NODE); + install_element(GSMNET_NODE, &cfg_net_ncc_cmd); + install_element(GSMNET_NODE, &cfg_net_mnc_cmd); + install_element(GSMNET_NODE, &cfg_net_name_short_cmd); + install_element(GSMNET_NODE, &cfg_net_name_long_cmd); + install_element(GSMNET_NODE, &cfg_net_auth_policy_cmd); + install_element(GSMNET_NODE, &cfg_net_reject_cause_cmd); + install_element(GSMNET_NODE, &cfg_net_encryption_cmd); + install_element(GSMNET_NODE, &cfg_net_rrlp_mode_cmd); + install_element(GSMNET_NODE, &cfg_net_mm_info_cmd); + install_element(GSMNET_NODE, &cfg_net_handover_cmd); + install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_cmd); + install_element(GSMNET_NODE, &cfg_net_ho_win_rxqual_avg_cmd); + install_element(GSMNET_NODE, &cfg_net_ho_win_rxlev_avg_neigh_cmd); + install_element(GSMNET_NODE, &cfg_net_ho_pwr_interval_cmd); + install_element(GSMNET_NODE, &cfg_net_ho_pwr_hysteresis_cmd); + install_element(GSMNET_NODE, &cfg_net_ho_max_distance_cmd); + install_element(GSMNET_NODE, &cfg_net_T3101_cmd); + install_element(GSMNET_NODE, &cfg_net_T3103_cmd); + install_element(GSMNET_NODE, &cfg_net_T3105_cmd); + install_element(GSMNET_NODE, &cfg_net_T3107_cmd); + install_element(GSMNET_NODE, &cfg_net_T3109_cmd); + install_element(GSMNET_NODE, &cfg_net_T3111_cmd); + install_element(GSMNET_NODE, &cfg_net_T3113_cmd); + install_element(GSMNET_NODE, &cfg_net_T3115_cmd); + install_element(GSMNET_NODE, &cfg_net_T3117_cmd); + install_element(GSMNET_NODE, &cfg_net_T3119_cmd); + install_element(GSMNET_NODE, &cfg_net_T3122_cmd); + install_element(GSMNET_NODE, &cfg_net_T3141_cmd); + install_element(GSMNET_NODE, &cfg_net_dtx_cmd); + install_element(GSMNET_NODE, &cfg_net_subscr_keep_cmd); + install_element(GSMNET_NODE, &cfg_net_timezone_cmd); + install_element(GSMNET_NODE, &cfg_net_timezone_dst_cmd); + install_element(GSMNET_NODE, &cfg_net_no_timezone_cmd); + + return CMD_SUCCESS; +} + +/* VTY elements used in both BSC and MSC */ +int xsc_vty_init(struct gsm_network *network) +{ + osmo_stats_vty_add_cmds(); + + gsmnet_vty_init(network); + return CMD_SUCCESS; +} diff --git a/openbsc/src/osmo-bsc/Makefile.am b/openbsc/src/osmo-bsc/Makefile.am index 69b363b45..ed69c0ab9 100644 --- a/openbsc/src/osmo-bsc/Makefile.am +++ b/openbsc/src/osmo-bsc/Makefile.am @@ -12,11 +12,9 @@ osmo_bsc_SOURCES = osmo_bsc_main.c osmo_bsc_vty.c osmo_bsc_api.c \ osmo_bsc_LDADD = \ $(top_builddir)/src/libfilter/libfilter.a \ $(top_builddir)/src/libbsc/libbsc.a \ - $(top_builddir)/src/libmsc/libmsc.a \ - $(top_builddir)/src/libbsc/libbsc.a \ + $(top_builddir)/src/libmsc/libxsc.a \ $(top_builddir)/src/libtrau/libtrau.a \ $(top_builddir)/src/libcommon/libcommon.a \ - $(top_builddir)/src/libcommon/libcommon.a \ $(LIBOSMOSCCP_LIBS) $(LIBOSMOCORE_LIBS) \ $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOCTRL_LIBS) \ $(COVERAGE_LDFLAGS) $(LIBOSMOABIS_LIBS) diff --git a/openbsc/src/osmo-cscn/Makefile.am b/openbsc/src/osmo-cscn/Makefile.am index 3a1021304..66109ff38 100644 --- a/openbsc/src/osmo-cscn/Makefile.am +++ b/openbsc/src/osmo-cscn/Makefile.am @@ -11,12 +11,11 @@ bin_PROGRAMS = osmo-cscn osmo_cscn_SOURCES = cscn_main.c osmo_cscn_LDADD = \ - $(top_builddir)/src/libbsc/libbsc.a \ $(top_builddir)/src/libiu/libiu.a \ $(top_builddir)/src/libmsc/libmsc.a \ - $(top_builddir)/src/libbsc/libbsc.a \ $(top_builddir)/src/libtrau/libtrau.a \ $(top_builddir)/src/libcommon/libcommon.a \ + $(top_builddir)/src/libxsc/libxsc.a \ -ldbi $(LIBCRYPT) \ $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOCORE_LIBS) \ $(LIBOSMOCTRL_LIBS) $(LIBOSMOABIS_LIBS) $(LIBSMPP34_LIBS) $(LIBCRYPTO_LIBS) \ diff --git a/openbsc/src/osmo-cscn/cscn_main.c b/openbsc/src/osmo-cscn/cscn_main.c index 463b7f141..374f9bd82 100644 --- a/openbsc/src/osmo-cscn/cscn_main.c +++ b/openbsc/src/osmo-cscn/cscn_main.c @@ -344,7 +344,8 @@ int main(int argc, char **argv) vty_init(&cscn_vty_info); ctrl_vty_init(tall_cscn_ctx); - bsc_vty_init(&log_info, cscn_network); + logging_vty_add_cmds(&log_info); + xsc_vty_init(cscn_network); rc = vty_read_config_file(cscn_cmdline_config.config_file, NULL); if (rc < 0) { LOGP(DNM, LOGL_FATAL, "Failed to parse the config file: '%s'\n", diff --git a/openbsc/src/utils/Makefile.am b/openbsc/src/utils/Makefile.am index 4521130be..486a878b8 100644 --- a/openbsc/src/utils/Makefile.am +++ b/openbsc/src/utils/Makefile.am @@ -1,5 +1,5 @@ AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir) -AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(COVERAGE_CFLAGS) $(SQLITE3_CFLAGS) \ +AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(COVERAGE_CFLAGS) $(SQLITE3_CFLAGS) \ $(LIBSMPP34_CFLAGS) AM_LDFLAGS = $(COVERAGE_LDFLAGS) @@ -21,6 +21,7 @@ bs11_config_SOURCES = bs11_config.c bs11_config_LDADD = $(top_builddir)/src/libbsc/libbsc.a \ $(top_builddir)/src/libtrau/libtrau.a \ $(top_builddir)/src/libcommon/libcommon.a \ + $(top_builddir)/src/libxsc/libxsc.a \ $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOABIS_LIBS) isdnsync_SOURCES = isdnsync.c diff --git a/openbsc/tests/bsc/Makefile.am b/openbsc/tests/bsc/Makefile.am index 8b786ff51..18baf3632 100644 --- a/openbsc/tests/bsc/Makefile.am +++ b/openbsc/tests/bsc/Makefile.am @@ -9,7 +9,7 @@ noinst_PROGRAMS = bsc_test bsc_test_SOURCES = bsc_test.c \ $(top_srcdir)/src/osmo-bsc/osmo_bsc_filter.c bsc_test_LDADD = $(top_builddir)/src/libbsc/libbsc.a \ - $(top_builddir)/src/libmsc/libmsc.a \ + $(top_builddir)/src/libxsc/libxsc.a \ $(top_builddir)/src/libmgcp/libmgcp.a \ $(top_builddir)/src/libtrau/libtrau.a \ $(top_builddir)/src/libcommon/libcommon.a \ diff --git a/openbsc/tests/channel/Makefile.am b/openbsc/tests/channel/Makefile.am index 51b2f83cb..549bbb9d7 100644 --- a/openbsc/tests/channel/Makefile.am +++ b/openbsc/tests/channel/Makefile.am @@ -8,7 +8,7 @@ noinst_PROGRAMS = channel_test channel_test_SOURCES = channel_test.c channel_test_LDADD = \ $(top_builddir)/src/libbsc/libbsc.a \ - $(top_builddir)/src/libmsc/libmsc.a \ + $(top_builddir)/src/libxsc/libxsc.a \ $(top_builddir)/src/libcommon/libcommon.a \ $(LIBOSMOCORE_LIBS) \ -ldbi $(LIBOSMOGSM_LIBS) $(LIBCRYPTO_LIBS) diff --git a/openbsc/tests/db/Makefile.am b/openbsc/tests/db/Makefile.am index 1b250da31..f8a340266 100644 --- a/openbsc/tests/db/Makefile.am +++ b/openbsc/tests/db/Makefile.am @@ -7,9 +7,8 @@ EXTRA_DIST = db_test.ok db_test.err hlr.sqlite3 noinst_PROGRAMS = db_test db_test_SOURCES = db_test.c -db_test_LDADD = $(top_builddir)/src/libbsc/libbsc.a \ - $(top_builddir)/src/libmsc/libmsc.a \ - $(top_builddir)/src/libbsc/libbsc.a \ +db_test_LDADD = $(top_builddir)/src/libmsc/libmsc.a \ + $(top_builddir)/src/libxsc/libxsc.a \ $(top_builddir)/src/libtrau/libtrau.a \ $(top_builddir)/src/libcommon/libcommon.a \ $(top_builddir)/tests/libiudummy/libiudummy.a \ diff --git a/openbsc/tests/gsm0408/Makefile.am b/openbsc/tests/gsm0408/Makefile.am index 1c29ece12..619618652 100644 --- a/openbsc/tests/gsm0408/Makefile.am +++ b/openbsc/tests/gsm0408/Makefile.am @@ -6,7 +6,6 @@ EXTRA_DIST = gsm0408_test.ok gsm0408_test_SOURCES = gsm0408_test.c gsm0408_test_LDADD = $(top_builddir)/src/libbsc/libbsc.a \ - $(top_builddir)/src/libmsc/libmsc.a \ - $(top_builddir)/src/libbsc/libbsc.a \ + $(top_builddir)/src/libxsc/libxsc.a \ $(top_builddir)/src/libcommon/libcommon.a \ $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) -ldbi diff --git a/openbsc/tests/sgsn/Makefile.am b/openbsc/tests/sgsn/Makefile.am index 2a37db3b8..477658c01 100644 --- a/openbsc/tests/sgsn/Makefile.am +++ b/openbsc/tests/sgsn/Makefile.am @@ -31,8 +31,8 @@ sgsn_test_LDADD = \ $(top_builddir)/src/gprs/gprs_gb_parse.o \ $(top_builddir)/src/gprs/oap.o \ $(top_builddir)/src/gprs/oap_messages.o \ - $(top_builddir)/src/libcommon/libcommon.a \ $(top_builddir)/src/libiu/libiu.a \ + $(top_builddir)/src/libcommon/libcommon.a \ $(LIBOSMOABIS_LIBS) \ $(LIBOSMOCORE_LIBS) \ $(LIBOSMOGSM_LIBS) \ diff --git a/openbsc/tests/subscr/Makefile.am b/openbsc/tests/subscr/Makefile.am index 4f96dc9d0..d31846fb8 100644 --- a/openbsc/tests/subscr/Makefile.am +++ b/openbsc/tests/subscr/Makefile.am @@ -8,8 +8,7 @@ noinst_PROGRAMS = subscr_test subscr_test_SOURCES = subscr_test.c subscr_test_LDADD = $(top_builddir)/src/libbsc/libbsc.a \ - $(top_builddir)/src/libmsc/libmsc.a \ - $(top_builddir)/src/libbsc/libbsc.a \ + $(top_builddir)/src/libxsc/libxsc.a \ $(top_builddir)/src/libtrau/libtrau.a \ $(top_builddir)/src/libcommon/libcommon.a \ $(LIBOSMOCORE_LIBS) $(LIBOSMOABIS_LIBS) \ diff --git a/openbsc/tests/trau/Makefile.am b/openbsc/tests/trau/Makefile.am index cc1b4ef1b..a63878905 100644 --- a/openbsc/tests/trau/Makefile.am +++ b/openbsc/tests/trau/Makefile.am @@ -8,8 +8,7 @@ noinst_PROGRAMS = trau_test trau_test_SOURCES = trau_test.c trau_test_LDADD = $(top_builddir)/src/libbsc/libbsc.a \ - $(top_builddir)/src/libmsc/libmsc.a \ - $(top_builddir)/src/libbsc/libbsc.a \ + $(top_builddir)/src/libxsc/libxsc.a \ $(top_builddir)/src/libtrau/libtrau.a \ $(top_builddir)/src/libcommon/libcommon.a \ $(LIBOSMOCORE_LIBS) $(LIBOSMOABIS_LIBS) \ |