mirror of
				https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
				synced 2025-11-03 21:43:32 +00:00 
			
		
		
		
	OML: Introduce minimal VTY command set to interact with OML managed objects
Conflicts: openbsc/include/openbsc/abis_nm.h openbsc/src/Makefile.am openbsc/src/vty_interface.c
This commit is contained in:
		@@ -55,6 +55,8 @@ struct ipac_bcch_info {
 | 
			
		||||
	u_int8_t ca_list_si1[16];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
extern const struct value_string abis_nm_adm_state_names[];
 | 
			
		||||
extern const struct value_string abis_nm_obj_class_names[];
 | 
			
		||||
extern const struct tlv_definition nm_att_tlvdef;
 | 
			
		||||
 | 
			
		||||
/* PUBLIC */
 | 
			
		||||
@@ -172,4 +174,7 @@ const char *nm_avail_name(u_int8_t avail);
 | 
			
		||||
int nm_is_running(struct gsm_nm_state *s);
 | 
			
		||||
void abis_nm_clear_queue(struct gsm_bts *bts);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
int abis_nm_vty_init(void);
 | 
			
		||||
 | 
			
		||||
#endif /* _NM_H */
 | 
			
		||||
 
 | 
			
		||||
@@ -107,6 +107,7 @@ enum node_type {
 | 
			
		||||
	TS_NODE,
 | 
			
		||||
	SUBSCR_NODE,
 | 
			
		||||
	MGCP_NODE,
 | 
			
		||||
	OML_NODE,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* Node which has some commands and prompt string and configuration
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,7 @@ bscdir = $(libdir)
 | 
			
		||||
bsc_LIBRARIES = libsccp.a
 | 
			
		||||
 | 
			
		||||
libbsc_a_SOURCES = abis_rsl.c abis_nm.c gsm_data.c gsm_04_08_utils.c \
 | 
			
		||||
		chan_alloc.c debug.c \
 | 
			
		||||
		chan_alloc.c debug.c abis_nm_vty.c \
 | 
			
		||||
		gsm_subscriber_base.c subchan_demux.c bsc_rll.c transaction.c \
 | 
			
		||||
		trau_frame.c trau_mux.c paging.c e1_config.c e1_input.c \
 | 
			
		||||
		input/misdn.c input/ipaccess.c \
 | 
			
		||||
 
 | 
			
		||||
@@ -439,30 +439,30 @@ static int abis_nm_sendmsg_direct(struct gsm_bts *bts, struct msgb *msg)
 | 
			
		||||
 | 
			
		||||
static int abis_nm_rcvmsg_sw(struct msgb *mb);
 | 
			
		||||
 | 
			
		||||
static struct value_string obj_class_names[] = {
 | 
			
		||||
	{ NM_OC_SITE_MANAGER,	"SITE MANAGER" },
 | 
			
		||||
const struct value_string abis_nm_obj_class_names[] = {
 | 
			
		||||
	{ NM_OC_SITE_MANAGER,	"SITE-MANAGER" },
 | 
			
		||||
	{ NM_OC_BTS,		"BTS" },
 | 
			
		||||
	{ NM_OC_RADIO_CARRIER,	"RADIO CARRIER" },
 | 
			
		||||
	{ NM_OC_BASEB_TRANSC,	"BASEBAND TRANSCEIVER" },
 | 
			
		||||
	{ NM_OC_RADIO_CARRIER,	"RADIO-CARRIER" },
 | 
			
		||||
	{ NM_OC_BASEB_TRANSC,	"BASEBAND-TRANSCEIVER" },
 | 
			
		||||
	{ NM_OC_CHANNEL,	"CHANNEL" },
 | 
			
		||||
	{ NM_OC_BS11_ADJC,	"ADJC" },
 | 
			
		||||
	{ NM_OC_BS11_HANDOVER,	"HANDOVER" },
 | 
			
		||||
	{ NM_OC_BS11_PWR_CTRL,	"POWER CONTROL" },
 | 
			
		||||
	{ NM_OC_BS11_PWR_CTRL,	"POWER-CONTROL" },
 | 
			
		||||
	{ NM_OC_BS11_BTSE,	"BTSE" },
 | 
			
		||||
	{ NM_OC_BS11_RACK,	"RACK" },
 | 
			
		||||
	{ NM_OC_BS11_TEST,	"TEST" },
 | 
			
		||||
	{ NM_OC_BS11_ENVABTSE,	"ENVABTSE" },
 | 
			
		||||
	{ NM_OC_BS11_BPORT,	"BPORT" },
 | 
			
		||||
	{ NM_OC_GPRS_NSE,	"GPRS NSE" },
 | 
			
		||||
	{ NM_OC_GPRS_CELL,	"GPRS CELL" },
 | 
			
		||||
	{ NM_OC_GPRS_NSVC,	"GPRS NSVC" },
 | 
			
		||||
	{ NM_OC_GPRS_NSE,	"GPRS-NSE" },
 | 
			
		||||
	{ NM_OC_GPRS_CELL,	"GPRS-CELL" },
 | 
			
		||||
	{ NM_OC_GPRS_NSVC,	"GPRS-NSVC" },
 | 
			
		||||
	{ NM_OC_BS11,		"SIEMENSHW" },
 | 
			
		||||
	{ 0,			NULL }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static const char *obj_class_name(u_int8_t oc)
 | 
			
		||||
{
 | 
			
		||||
	return get_value_string(obj_class_names, oc);
 | 
			
		||||
	return get_value_string(abis_nm_obj_class_names, oc);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char *nm_opstate_name(u_int8_t os)
 | 
			
		||||
@@ -510,18 +510,17 @@ static struct value_string test_names[] = {
 | 
			
		||||
	{ 0, NULL }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const struct value_string abis_nm_adm_state_names[] = {
 | 
			
		||||
	{ NM_STATE_LOCKED,	"Locked" },
 | 
			
		||||
	{ NM_STATE_UNLOCKED,	"Unlocked" },
 | 
			
		||||
	{ NM_STATE_SHUTDOWN,	"Shutdown" },
 | 
			
		||||
	{ NM_STATE_NULL,	"NULL" },
 | 
			
		||||
	{ 0, NULL }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const char *nm_adm_name(u_int8_t adm)
 | 
			
		||||
{
 | 
			
		||||
	switch (adm) {
 | 
			
		||||
	case 1:
 | 
			
		||||
		return "Locked";
 | 
			
		||||
	case 2:
 | 
			
		||||
		return "Unlocked";
 | 
			
		||||
	case 3:
 | 
			
		||||
		return "Shutdown";
 | 
			
		||||
	default:
 | 
			
		||||
		return "<not used>";
 | 
			
		||||
	}
 | 
			
		||||
	return get_value_string(abis_nm_adm_state_names, adm);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int nm_is_running(struct gsm_nm_state *s) {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										194
									
								
								openbsc/src/abis_nm_vty.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										194
									
								
								openbsc/src/abis_nm_vty.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,194 @@
 | 
			
		||||
/* VTY interface for A-bis OML (Netowrk Management) */
 | 
			
		||||
 | 
			
		||||
/* (C) 2009-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 General Public License as published by
 | 
			
		||||
 * the Free Software Foundation; either version 2 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 General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License along
 | 
			
		||||
 * with this program; if not, write to the Free Software Foundation, Inc.,
 | 
			
		||||
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <unistd.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
#include <arpa/inet.h>
 | 
			
		||||
 | 
			
		||||
#include <openbsc/gsm_data.h>
 | 
			
		||||
#include <osmocore/msgb.h>
 | 
			
		||||
#include <osmocore/tlv.h>
 | 
			
		||||
#include <osmocore/talloc.h>
 | 
			
		||||
#include <openbsc/debug.h>
 | 
			
		||||
#include <openbsc/signal.h>
 | 
			
		||||
#include <openbsc/abis_nm.h>
 | 
			
		||||
#include <openbsc/vty.h>
 | 
			
		||||
 | 
			
		||||
#include <vty/command.h>
 | 
			
		||||
 | 
			
		||||
extern struct gsm_network *bsc_gsmnet;
 | 
			
		||||
 | 
			
		||||
static struct cmd_node oml_node = {
 | 
			
		||||
	OML_NODE,
 | 
			
		||||
	"%s(oml)# ",
 | 
			
		||||
	1,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct oml_node_state {
 | 
			
		||||
	struct gsm_bts *bts;
 | 
			
		||||
	uint8_t obj_class;
 | 
			
		||||
	uint8_t obj_inst[3];
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static int dummy_config_write(struct vty *v)
 | 
			
		||||
{
 | 
			
		||||
	return CMD_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* FIXME: auto-generate those strings from the value_string lists */
 | 
			
		||||
#define NM_OBJCLASS_VTY "(site-manager|bts|radio-carrier|baseband-transceiver|channel|adjc|handover|power-contorl|btse|rack|test|envabtse|bport|gprs-nse|gprs-cell|gprs-nsvc|siemenshw)"
 | 
			
		||||
#define NM_OBJCLASS_VTY_HELP "FIXME"
 | 
			
		||||
 | 
			
		||||
DEFUN(oml_class_inst, oml_class_inst_cmd,
 | 
			
		||||
	"bts <0-255> oml class " NM_OBJCLASS_VTY
 | 
			
		||||
					" instance <0-255> <0-255> <0-255>",
 | 
			
		||||
	"BTS related commands\n" "BTS Number\n"
 | 
			
		||||
	"Manipulate the OML managed objects\n"
 | 
			
		||||
	"Object Class\n" 	NM_OBJCLASS_VTY_HELP
 | 
			
		||||
	"Object Instance\n" "BTS Number\n" "TRX Number\n" "TS Number\n")
 | 
			
		||||
{
 | 
			
		||||
	struct gsm_bts *bts;
 | 
			
		||||
	struct oml_node_state *oms;
 | 
			
		||||
	int bts_nr = atoi(argv[0]);
 | 
			
		||||
 | 
			
		||||
	bts = gsm_bts_num(bsc_gsmnet, bts_nr);
 | 
			
		||||
	if (!bts) {
 | 
			
		||||
		vty_out(vty, "%% No such BTS (%d)%s", bts_nr, VTY_NEWLINE);
 | 
			
		||||
		return CMD_WARNING;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	oms = talloc_zero(tall_bsc_ctx, struct oml_node_state);
 | 
			
		||||
	if (!oms)
 | 
			
		||||
		return CMD_WARNING;
 | 
			
		||||
 | 
			
		||||
	oms->bts = bts;
 | 
			
		||||
	oms->obj_class = get_string_value(abis_nm_obj_class_names, argv[1]);
 | 
			
		||||
	oms->obj_inst[0] = atoi(argv[2]);
 | 
			
		||||
	oms->obj_inst[1] = atoi(argv[3]);
 | 
			
		||||
	oms->obj_inst[2] = atoi(argv[4]);
 | 
			
		||||
 | 
			
		||||
	vty->index = oms;
 | 
			
		||||
	vty->node = OML_NODE;
 | 
			
		||||
 | 
			
		||||
	return CMD_SUCCESS;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
DEFUN(oml_classnum_inst, oml_classnum_inst_cmd,
 | 
			
		||||
	"bts <0-255> oml class <0-255> instance <0-255> <0-255> <0-255>",
 | 
			
		||||
	"BTS related commands\n" "BTS Number\n"
 | 
			
		||||
	"Manipulate the OML managed objects\n"
 | 
			
		||||
	"Object Class\n" "Object Class\n"
 | 
			
		||||
	"Object Instance\n" "BTS Number\n" "TRX Number\n" "TS Number\n")
 | 
			
		||||
{
 | 
			
		||||
	struct gsm_bts *bts;
 | 
			
		||||
	struct oml_node_state *oms;
 | 
			
		||||
	int bts_nr = atoi(argv[0]);
 | 
			
		||||
 | 
			
		||||
	bts = gsm_bts_num(bsc_gsmnet, bts_nr);
 | 
			
		||||
	if (!bts) {
 | 
			
		||||
		vty_out(vty, "%% No such BTS (%d)%s", bts_nr, VTY_NEWLINE);
 | 
			
		||||
		return CMD_WARNING;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	oms = talloc_zero(tall_bsc_ctx, struct oml_node_state);
 | 
			
		||||
	if (!oms)
 | 
			
		||||
		return CMD_WARNING;
 | 
			
		||||
 | 
			
		||||
	oms->bts = bts;
 | 
			
		||||
	oms->obj_class = atoi(argv[1]);
 | 
			
		||||
	oms->obj_inst[0] = atoi(argv[2]);
 | 
			
		||||
	oms->obj_inst[1] = atoi(argv[3]);
 | 
			
		||||
	oms->obj_inst[2] = atoi(argv[4]);
 | 
			
		||||
 | 
			
		||||
	vty->index = oms;
 | 
			
		||||
	vty->node = OML_NODE;
 | 
			
		||||
 | 
			
		||||
	return CMD_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
DEFUN(oml_attrib_get, oml_attrib_get_cmd,
 | 
			
		||||
	"attribute get <0-255>",
 | 
			
		||||
	"OML Attribute Actions\n" "Get a single OML Attribute\n"
 | 
			
		||||
	"OML Attribute Number\n")
 | 
			
		||||
{
 | 
			
		||||
	struct oml_node_state *oms = vty->index;
 | 
			
		||||
 | 
			
		||||
	/* FIXME */
 | 
			
		||||
	return CMD_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
DEFUN(oml_attrib_set, oml_attrib_set_cmd,
 | 
			
		||||
	"attribute set <0-255> .HEX",
 | 
			
		||||
	"OML Attribute Actions\n" "Set a single OML Attribute\n"
 | 
			
		||||
	"OML Attribute Number\n")
 | 
			
		||||
{
 | 
			
		||||
	struct oml_node_state *oms = vty->index;
 | 
			
		||||
 | 
			
		||||
	/* FIXME */
 | 
			
		||||
	return CMD_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
DEFUN(oml_chg_adm_state, oml_chg_adm_state_cmd,
 | 
			
		||||
	"change-adm-state (locked|unlocked|shutdown|null)",
 | 
			
		||||
	"Change the Administrative State\n"
 | 
			
		||||
	"Locked\n" "Unlocked\n" "Shutdown\n" "NULL\n")
 | 
			
		||||
{
 | 
			
		||||
	struct oml_node_state *oms = vty->index;
 | 
			
		||||
	enum abis_nm_adm_state state;
 | 
			
		||||
 | 
			
		||||
	state = get_string_value(abis_nm_adm_state_names, argv[0]);
 | 
			
		||||
 | 
			
		||||
	abis_nm_chg_adm_state(oms->bts, oms->obj_class, oms->obj_inst[0],
 | 
			
		||||
			      oms->obj_inst[1], oms->obj_inst[2], state);
 | 
			
		||||
 | 
			
		||||
	return CMD_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
DEFUN(oml_opstart, oml_opstart_cmd,
 | 
			
		||||
	"opstart", "Send an OPSTART message to the object")
 | 
			
		||||
{
 | 
			
		||||
	struct oml_node_state *oms = vty->index;
 | 
			
		||||
 | 
			
		||||
	abis_nm_opstart(oms->bts, oms->obj_class, oms->obj_inst[0],
 | 
			
		||||
			oms->obj_inst[1], oms->obj_inst[2]);
 | 
			
		||||
 | 
			
		||||
	return CMD_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int abis_nm_vty_init(void)
 | 
			
		||||
{
 | 
			
		||||
	install_element(ENABLE_NODE, &oml_class_inst_cmd);
 | 
			
		||||
	install_element(ENABLE_NODE, &oml_classnum_inst_cmd);
 | 
			
		||||
	install_node(&oml_node, dummy_config_write);
 | 
			
		||||
 | 
			
		||||
	install_default(OML_NODE);
 | 
			
		||||
	install_element(OML_NODE, &oml_attrib_get_cmd);
 | 
			
		||||
	install_element(OML_NODE, &oml_attrib_set_cmd);
 | 
			
		||||
	install_element(OML_NODE, &oml_chg_adm_state_cmd);
 | 
			
		||||
	install_element(OML_NODE, &oml_opstart_cmd);
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
@@ -1949,6 +1949,11 @@ enum node_type vty_go_parent(struct vty *vty)
 | 
			
		||||
		subscr_put(vty->index);
 | 
			
		||||
		vty->index = NULL;
 | 
			
		||||
		break;
 | 
			
		||||
	case OML_NODE:
 | 
			
		||||
		vty->node = ENABLE_NODE;
 | 
			
		||||
		talloc_free(vty->index);
 | 
			
		||||
		vty->index = NULL;
 | 
			
		||||
		break;
 | 
			
		||||
	default:
 | 
			
		||||
		vty->node = CONFIG_NODE;
 | 
			
		||||
	}
 | 
			
		||||
@@ -2365,7 +2370,12 @@ DEFUN(config_exit,
 | 
			
		||||
	case MGCP_NODE:
 | 
			
		||||
		vty->node = CONFIG_NODE;
 | 
			
		||||
		vty->index = NULL;
 | 
			
		||||
 | 
			
		||||
		break;
 | 
			
		||||
	case OML_NODE:
 | 
			
		||||
		vty->node = ENABLE_NODE;
 | 
			
		||||
		talloc_free(vty->index);
 | 
			
		||||
		vty->index = NULL;
 | 
			
		||||
		break;
 | 
			
		||||
	default:
 | 
			
		||||
		break;
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -2338,6 +2338,8 @@ int bsc_vty_init(struct gsm_network *net)
 | 
			
		||||
	install_element(TS_NODE, &cfg_ts_pchan_cmd);
 | 
			
		||||
	install_element(TS_NODE, &cfg_ts_e1_subslot_cmd);
 | 
			
		||||
 | 
			
		||||
	abis_nm_vty_init();
 | 
			
		||||
 | 
			
		||||
	bsc_vty_init_extra(net);
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user