This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Max gerrit-no-reply at lists.osmocom.orgHello Harald Welte, Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/2786
to look at the new patch set (#6).
Extend Get Attribute responder
* detect if attributes are requested for BTS or TRX and act accordingly
* report TRX phy version
Change-Id: I9f72305bbf1ab74745bffac1bee9f539f5a6de32
Related: OS#1614
---
M src/common/oml.c
1 file changed, 44 insertions(+), 28 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/86/2786/6
diff --git a/src/common/oml.c b/src/common/oml.c
index 9dddf57..5c711cf 100644
--- a/src/common/oml.c
+++ b/src/common/oml.c
@@ -46,6 +46,7 @@
#include <osmo-bts/bts_model.h>
#include <osmo-bts/bts.h>
#include <osmo-bts/signal.h>
+#include <osmo-bts/phy_link.h>
static int oml_ipa_set_attr(struct gsm_bts *bts, struct msgb *msg);
@@ -153,37 +154,60 @@
return mo_buf;
}
-static inline struct msgb *add_bts_attr(const struct gsm_bts *bts)
+static inline void add_bts_attrs(struct msgb *msg, const struct gsm_bts *bts)
{
- struct msgb *a = oml_msgb_alloc();
-
- if (!a)
- return NULL;
-
- abis_nm_put_sw_file(a, btstype2str(GSM_BTS_TYPE_OSMOBTS), PACKAGE_VERSION, true);
- abis_nm_put_sw_file(a, btsatttr2str(BTS_TYPE_VARIANT), btsvariant2str(bts->variant), true);
+ abis_nm_put_sw_file(msg, btstype2str(GSM_BTS_TYPE_OSMOBTS), PACKAGE_VERSION, true);
+ abis_nm_put_sw_file(msg, btsatttr2str(BTS_TYPE_VARIANT), btsvariant2str(bts->variant), true);
if (strlen(bts->sub_model))
- abis_nm_put_sw_file(a, btsatttr2str(BTS_SUB_MODEL), bts->sub_model, true);
-
- return a;
+ abis_nm_put_sw_file(msg, btsatttr2str(BTS_SUB_MODEL), bts->sub_model, true);
}
-static inline int handle_attr(const struct gsm_abis_mo *mo, const uint8_t *attr, uint16_t attr_len, uint8_t *out)
+static inline void add_trx_attr(struct msgb *msg, struct gsm_bts_trx *trx)
+{
+ struct phy_instance *pinst = trx_phy_instance(trx);
+
+ abis_nm_put_sw_file(msg, btsatttr2str(TRX_PHY_VERSION), strlen(pinst->version) ? pinst->version : "Unknown",
+ true);
+}
+
+/* copy all the attributes accumulated in msg to out and return the total length of out buffer */
+static inline int cleanup_attr_msg(uint8_t *out, int out_offset, struct msgb *msg)
+{
+ int len = 0;
+
+ if (msg) {
+ memcpy(out + out_offset, msgb_data(msg), msg->len);
+ len = msg->len;
+ msgb_free(msg);
+ }
+
+ return len + out_offset + 1;
+}
+
+/* assemble values of supported attributes and list of unsupported ones */
+static inline int handle_attrs(const struct gsm_bts *bts, const struct gsm_abis_mo *mo,
+ const uint8_t *attr, uint16_t attr_len, uint8_t *out)
{
uint16_t i, attr_out_index = 1; /* byte 0 is reserved for unsupported attributes counter */
- struct msgb *ba = NULL;
- int length;
+ struct msgb *attr_buf = oml_msgb_alloc();
+
+ if (!attr_buf)
+ return -ENOMEM;
for (i = 0; i < attr_len; i++) {
switch (attr[i]) {
case NM_ATT_SW_CONFIG:
switch (mo->obj_class) {
case NM_OC_BTS:
- ba = add_bts_attr(mo->bts);
+ add_bts_attrs(attr_buf, mo->bts);
+ break;
+ case NM_OC_BASEB_TRANSC:
+ add_trx_attr(attr_buf, gsm_bts_trx_num(bts, mo->obj_inst.trx_nr));
break;
default:
- LOGP(DOML, LOGL_ERROR, "Unsupported MO class %s in Get Attribute Response\n",
+ LOGP(DOML, LOGL_ERROR, "Unsupported MO class %s in Get Attribute "
+ "Response(NM_ATT_SW_CONFIG)\n",
get_value_string(abis_nm_obj_class_names, mo->obj_class));
return -EINVAL;
}
@@ -204,19 +228,11 @@
} else
out[0] = attr_out_index - 1; /* Count number of unhandled attributes */
- length = attr_out_index + 1;
-
- if (ba) {
- memcpy(out + attr_out_index, msgb_data(ba), ba->len);
- length += ba->len;
- msgb_free(ba);
- }
-
- return length;
+ return cleanup_attr_msg(out, attr_out_index, attr_buf);
}
/* send 3GPP TS 52.021 §8.11.2 Get Attribute Response */
-static int oml_tx_attr_resp(struct gsm_abis_mo *mo, const uint8_t *attr, uint16_t attr_len)
+static int oml_tx_attr_resp(const struct gsm_bts *bts, struct gsm_abis_mo *mo, const uint8_t *attr, uint16_t attr_len)
{
struct msgb *nmsg = oml_msgb_alloc();
uint8_t resp[MAX_VERSION_LENGTH * attr_len * 2]; /* heuristic for Attribute Response Info space requirements */
@@ -227,7 +243,7 @@
if (!nmsg)
return -ENOMEM;
- len = handle_attr(mo, attr, attr_len, resp);
+ len = handle_attrs(bts, mo, attr, attr_len, resp);
if (len < 0) {
LOGP(DOML, LOGL_ERROR, "Tx Get Attribute Response FAILED with %d\n", len);
msgb_free(nmsg);
@@ -489,7 +505,7 @@
return oml_fom_ack_nack(msg, NM_NACK_INCORR_STRUCT);
}
- rc = oml_tx_attr_resp(mo, TLVP_VAL(&tp, NM_ATT_LIST_REQ_ATTR), TLVP_LEN(&tp, NM_ATT_LIST_REQ_ATTR));
+ rc = oml_tx_attr_resp(bts, mo, TLVP_VAL(&tp, NM_ATT_LIST_REQ_ATTR), TLVP_LEN(&tp, NM_ATT_LIST_REQ_ATTR));
if (rc < 0) {
LOGP(DOML, LOGL_ERROR, "Failed to respond to O&M Get Attributes message: %s\n", strerror(-rc));
switch (-rc) {
--
To view, visit https://gerrit.osmocom.org/2786
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I9f72305bbf1ab74745bffac1bee9f539f5a6de32
Gerrit-PatchSet: 6
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>