aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2020-04-28 09:30:52 +0200
committerSylvain Munaut <tnt@246tNt.com>2020-04-28 09:50:59 +0200
commite55e76f4c7774d29da445c8e6f73966edbbda57b (patch)
treed765136df091dd3513016b1ee55350d995a9691a
parentd9fe61c43f73eb98d6f9c0238a0495b585b5d80c (diff)
om2k: Add VTY command to allow TX of arbitrary message for testing
Signed-off-by: Sylvain Munaut <tnt@246tNt.com> Change-Id: I5a385614fc670946f83ea79cc176c2d448675672
-rw-r--r--include/osmocom/bsc/abis_om2000.h1
-rw-r--r--src/osmo-bsc/abis_om2000.c15
-rw-r--r--src/osmo-bsc/abis_om2000_vty.c29
3 files changed, 45 insertions, 0 deletions
diff --git a/include/osmocom/bsc/abis_om2000.h b/include/osmocom/bsc/abis_om2000.h
index 163a49ccf..0d48c0c2f 100644
--- a/include/osmocom/bsc/abis_om2000.h
+++ b/include/osmocom/bsc/abis_om2000.h
@@ -113,6 +113,7 @@ int abis_om2k_tx_test_req(struct gsm_bts *bts, const struct abis_om2k_mo *mo);
int abis_om2k_tx_op_info(struct gsm_bts *bts, const struct abis_om2k_mo *mo,
uint8_t operational);
int abis_om2k_tx_cap_req(struct gsm_bts *bts, const struct abis_om2k_mo *mo);
+int abis_om2k_tx_arb(struct gsm_bts *bts, struct abis_om2k_mo *mo, uint16_t req, uint8_t *buf, int buf_len);
int abis_om2k_tx_is_conf_req(struct gsm_bts *bts);
int abis_om2k_tx_con_conf_req(struct gsm_bts *bts);
int abis_om2k_tx_tf_conf_req(struct gsm_bts *bts);
diff --git a/src/osmo-bsc/abis_om2000.c b/src/osmo-bsc/abis_om2000.c
index e1a526ce0..b221441ff 100644
--- a/src/osmo-bsc/abis_om2000.c
+++ b/src/osmo-bsc/abis_om2000.c
@@ -1129,6 +1129,21 @@ int abis_om2k_tx_cap_req(struct gsm_bts *bts, const struct abis_om2k_mo *mo)
return abis_om2k_tx_simple(bts, mo, OM2K_MSGT_CAPA_REQ);
}
+int abis_om2k_tx_arb(struct gsm_bts *bts, struct abis_om2k_mo *mo,
+ uint16_t req, uint8_t *buf, int buf_len)
+{
+ struct msgb *msg = om2k_msgb_alloc();
+ struct abis_om2k_hdr *o2k;
+
+ o2k = (struct abis_om2k_hdr *) msgb_put(msg, sizeof(*o2k));
+ fill_om2k_hdr(o2k, mo, req);
+
+ if (buf_len)
+ memcpy(msgb_put(msg, buf_len), buf, buf_len);
+
+ return abis_om2k_sendmsg(bts, msg);
+}
+
static void om2k_fill_is_conn_grp(struct om2k_is_conn_grp *grp, uint16_t icp1,
uint16_t icp2, uint8_t cont_idx)
{
diff --git a/src/osmo-bsc/abis_om2000_vty.c b/src/osmo-bsc/abis_om2000_vty.c
index 5404d6289..972fff04a 100644
--- a/src/osmo-bsc/abis_om2000_vty.c
+++ b/src/osmo-bsc/abis_om2000_vty.c
@@ -255,6 +255,34 @@ DEFUN(om2k_cap_req, om2k_cap_req_cmd,
return CMD_SUCCESS;
}
+DEFUN(om2k_arb, om2k_arb_cmd,
+ "arbitrary <0-65535> [HEXSTRING]",
+ "Send arbitrary OM2k message\n"
+ "Command identifier\n"
+ "Hex Encoded payload\n")
+{
+ struct oml_node_state *oms = vty->index;
+ uint8_t buf[128];
+ int rc;
+ int cmd = atoi(argv[0]);
+
+ if (argc >= 2) {
+ rc = osmo_hexparse(argv[1], buf, sizeof(buf));
+ if (rc < 0 || rc > sizeof(buf)) {
+ vty_out(vty, "Error parsing HEXSTRING%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ } else {
+ rc = 0;
+ }
+
+ abis_om2k_tx_arb(oms->bts, &oms->mo, cmd, buf, rc);
+
+ return CMD_SUCCESS;
+}
+
+
+
static struct con_group *con_group_find_or_create(struct gsm_bts *bts, uint8_t cg)
{
struct con_group *ent;
@@ -595,6 +623,7 @@ int abis_om2k_vty_init(void)
install_element(OM2K_NODE, &om2k_test_cmd);
install_element(OM2K_NODE, &om2k_cap_req_cmd);
install_element(OM2K_NODE, &om2k_conf_req_cmd);
+ install_element(OM2K_NODE, &om2k_arb_cmd);
install_node(&om2k_con_group_node, dummy_config_write);
install_element(OM2K_CON_GROUP_NODE, &cfg_om2k_con_path_dec_cmd);