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/.
Vadim Yanitskiy gerrit-no-reply at lists.osmocom.orgVadim Yanitskiy has uploaded this change for review. ( https://gerrit.osmocom.org/13708
Change subject: common/oml.c: refactor Get Attribute Response message generation
......................................................................
common/oml.c: refactor Get Attribute Response message generation
Instead of allocating two transitional buffers (one static,
another dynamic), we can use the existing message buffer.
Both handle_attrs_bts() and handle_attrs_trx() can put (append)
the reported attributes, and push (prepend) unreported ones
as per 3GPP TS 52.021, 9.4.64 "Get Attribute Response Info".
Change-Id: I349447a43bce360f59e0c6b435906c65167d158b
---
M src/common/oml.c
1 file changed, 50 insertions(+), 40 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/08/13708/1
diff --git a/src/common/oml.c b/src/common/oml.c
index de7a0e7..caff595 100644
--- a/src/common/oml.c
+++ b/src/common/oml.c
@@ -191,64 +191,75 @@
return len + out_offset;
}
-static inline int handle_attrs_trx(uint8_t *out, const struct gsm_bts_trx *trx, const uint8_t *attr, uint16_t attr_len)
+static inline int handle_attrs_trx(struct msgb *msg, const struct gsm_bts_trx *trx,
+ const uint8_t *attr, uint16_t attr_len)
{
- uint16_t i, attr_out_index = 1; /* byte 0 is reserved for unsupported attributes counter */
- struct msgb *attr_buf = oml_msgb_alloc();
+ uint8_t num_unreported = 0;
+ uint8_t *buf;
+ int i;
- if (!attr_buf)
- return -NM_NACK_CANT_PERFORM;
+ if (!trx) {
+ LOGP(DOML, LOGL_ERROR, "O&M Get Attributes for unknown TRX\n");
+ return -NM_NACK_TRXNR_UNKN;
+ }
for (i = 0; i < attr_len; i++) {
- bool processed = false;
switch (attr[i]) {
case NM_ATT_SW_CONFIG:
- if (trx) {
- add_trx_attr(attr_buf, trx);
- processed = true;
- } else
- LOGP(DOML, LOGL_ERROR, "O&M Get Attributes [%u], %s is unhandled due to missing TRX.\n",
- i, get_value_string(abis_nm_att_names, attr[i]));
+ add_trx_attr(msg, trx);
break;
default:
LOGP(DOML, LOGL_ERROR, "O&M Get Attributes [%u], %s is unsupported by TRX.\n", i,
get_value_string(abis_nm_att_names, attr[i]));
- }
- /* assemble values of supported attributes and list of unsupported ones */
- if (!processed) {
- out[attr_out_index] = attr[i];
- attr_out_index++;
+ /* Push this tag to the list of unreported attributes */
+ buf = msgb_push(msg, 1);
+ *buf = attr[i];
+ num_unreported++;
}
}
- return cleanup_attr_msg(out, attr_out_index, attr_buf);
+ /* Push the amount of unreported attributes */
+ buf = msgb_push(msg, 1);
+ *buf = num_unreported;
+
+ return 0;
}
-static inline int handle_attrs_bts(uint8_t *out, const struct gsm_bts *bts, const uint8_t *attr, uint16_t attr_len)
+static inline int handle_attrs_bts(struct msgb *msg, const struct gsm_bts *bts,
+ const uint8_t *attr, uint16_t attr_len)
{
- uint16_t i, attr_out_index = 1; /* byte 0 is reserved for unsupported attributes counter */
- struct msgb *attr_buf = oml_msgb_alloc();
+ uint8_t num_unreported = 0;
+ uint8_t *buf;
+ int i;
- if (!attr_buf)
- return -NM_NACK_CANT_PERFORM;
+ if (!bts) {
+ LOGP(DOML, LOGL_ERROR, "O&M Get Attributes for unknown BTS\n");
+ return -NM_NACK_BTSNR_UNKN;
+ }
for (i = 0; i < attr_len; i++) {
switch (attr[i]) {
case NM_ATT_SW_CONFIG:
- add_bts_attrs(attr_buf, bts);
+ add_bts_attrs(msg, bts);
break;
case NM_ATT_MANUF_ID:
- add_bts_feat(attr_buf, bts);
+ add_bts_feat(msg, bts);
break;
default:
LOGP(DOML, LOGL_ERROR, "O&M Get Attributes [%u], %s is unsupported by BTS.\n", i,
get_value_string(abis_nm_att_names, attr[i]));
- out[attr_out_index] = attr[i]; /* assemble values of supported attributes and list of unsupported ones */
- attr_out_index++;
+ /* Push this tag to the list of unreported attributes */
+ buf = msgb_push(msg, 1);
+ *buf = attr[i];
+ num_unreported++;
}
}
- return cleanup_attr_msg(out, attr_out_index, attr_buf);
+ /* Push the amount of unreported attributes */
+ buf = msgb_push(msg, 1);
+ *buf = num_unreported;
+
+ return 0;
}
/* send 3GPP TS 52.021 §8.11.2 Get Attribute Response */
@@ -256,8 +267,7 @@
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 */
- int len;
+ int rc;
LOGP(DOML, LOGL_INFO, "%s Tx Get Attribute Response\n",
get_value_string(abis_nm_obj_class_names, mo->obj_class));
@@ -267,28 +277,28 @@
switch (mo->obj_class) {
case NM_OC_BTS:
- len = handle_attrs_bts(resp, mo->bts, attr, attr_len);
+ rc = handle_attrs_bts(nmsg, mo->bts, attr, attr_len);
break;
case NM_OC_BASEB_TRANSC:
- len = handle_attrs_trx(resp, gsm_bts_trx_num(mo->bts, mo->obj_inst.trx_nr), attr, attr_len);
+ rc = handle_attrs_trx(nmsg, gsm_bts_trx_num(mo->bts, mo->obj_inst.trx_nr), attr, attr_len);
break;
default:
LOGP(DOML, LOGL_ERROR, "Unsupported MO class %s in Get Attribute Response\n",
get_value_string(abis_nm_obj_class_names, mo->obj_class));
- len = -NM_NACK_OBJCLASS_NOTSUPP;
+ rc = -NM_NACK_OBJCLASS_NOTSUPP;
}
- if (len < 0) {
- LOGP(DOML, LOGL_ERROR, "Tx Get Attribute Response FAILED with %d\n", len);
+ if (rc < 0) {
+ LOGP(DOML, LOGL_ERROR, "Tx Get Attribute Response FAILED with rc=%d\n", rc);
msgb_free(nmsg);
- return len;
+ return rc;
}
- /* §9.4.64 Get Attribute Response Info */
- msgb_tl16v_put(nmsg, NM_ATT_GET_ARI, len, resp);
+ /* Push Get Attribute Response Info TL (actually TV where V is L) */
+ msgb_tv16_push(nmsg, NM_ATT_GET_ARI, msgb_length(nmsg));
- len = oml_mo_send_msg(mo, nmsg, NM_MT_GET_ATTR_RESP);
- return (len < 0) ? -NM_NACK_CANT_PERFORM : len;
+ rc = oml_mo_send_msg(mo, nmsg, NM_MT_GET_ATTR_RESP);
+ return (rc < 0) ? -NM_NACK_CANT_PERFORM : rc;
}
/* 8.8.1 sending State Changed Event Report */
--
To view, visit https://gerrit.osmocom.org/13708
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I349447a43bce360f59e0c6b435906c65167d158b
Gerrit-Change-Number: 13708
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190419/d8849a4e/attachment.htm>