tnt has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/17962 )


Change subject: om2k: Add VTY command to allow TX of arbitrary message for 
testing
......................................................................

om2k: Add VTY command to allow TX of arbitrary message for testing

Signed-off-by: Sylvain Munaut <[email protected]>
Change-Id: I5a385614fc670946f83ea79cc176c2d448675672
---
M include/osmocom/bsc/abis_om2000.h
M src/osmo-bsc/abis_om2000.c
M src/osmo-bsc/abis_om2000_vty.c
3 files changed, 43 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/62/17962/1

diff --git a/include/osmocom/bsc/abis_om2000.h 
b/include/osmocom/bsc/abis_om2000.h
index 163a49c..0d48c0c 100644
--- a/include/osmocom/bsc/abis_om2000.h
+++ b/include/osmocom/bsc/abis_om2000.h
@@ -113,6 +113,7 @@
 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 e1a526c..b221441 100644
--- a/src/osmo-bsc/abis_om2000.c
+++ b/src/osmo-bsc/abis_om2000.c
@@ -1129,6 +1129,21 @@
        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 e047fa1..e802b4f 100644
--- a/src/osmo-bsc/abis_om2000_vty.c
+++ b/src/osmo-bsc/abis_om2000_vty.c
@@ -253,6 +253,32 @@
        return CMD_SUCCESS;
 }

+DEFUN(om2k_arb, om2k_arb_cmd,
+       "arbitrary <0-65535> [HEXSTRING]",
+       "Send arbitrary OM2k message\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;
@@ -593,6 +619,7 @@
        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);

--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/17962
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I5a385614fc670946f83ea79cc176c2d448675672
Gerrit-Change-Number: 17962
Gerrit-PatchSet: 1
Gerrit-Owner: tnt <[email protected]>
Gerrit-MessageType: newchange

Reply via email to