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.orgMax has uploaded this change for review. ( https://gerrit.osmocom.org/13354
Change subject: trxcon: use helper to add l1ctl_info_dl
......................................................................
trxcon: use helper to add l1ctl_info_dl
Use static helpers to add l1ctl_info_dl to msgb - this simplifies
l1ctl_* routines and reduce code duplication.
Change-Id: I0b5b81f1fcd2984136e553a93735ea5456d2b3df
---
M src/host/trxcon/l1ctl.c
1 file changed, 18 insertions(+), 24 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/54/13354/1
diff --git a/src/host/trxcon/l1ctl.c b/src/host/trxcon/l1ctl.c
index eb14832..0541f58 100644
--- a/src/host/trxcon/l1ctl.c
+++ b/src/host/trxcon/l1ctl.c
@@ -138,13 +138,24 @@
return l1ctl_link_send(l1l, msg);
}
+static struct l1ctl_info_dl *add_info_dl(struct msgb *msg, struct l1ctl_info_dl *dl_info)
+{
+ size_t len = sizeof(struct l1ctl_info_dl);
+ struct l1ctl_info_dl *dl = (struct l1ctl_info_dl *) msgb_put(msg, len);
+
+ if (dl_info) /* Copy DL info provided by handler */
+ memcpy(dl, dl_info, len);
+ else /* Compose DL info header */
+ memset(dl, 0x00, len);
+
+ return dl;
+}
+
int l1ctl_tx_fbsb_conf(struct l1ctl_link *l1l, uint8_t result,
struct l1ctl_info_dl *dl_info, uint8_t bsic)
{
struct l1ctl_fbsb_conf *conf;
- struct l1ctl_info_dl *dl;
struct msgb *msg;
- size_t len;
msg = l1ctl_alloc_msg(L1CTL_FBSB_CONF);
if (msg == NULL)
@@ -153,10 +164,7 @@
LOGP(DL1C, LOGL_DEBUG, "Send FBSB Conf (result=%u, bsic=%u)\n",
result, bsic);
- /* Copy DL info provided by handler */
- len = sizeof(struct l1ctl_info_dl);
- dl = (struct l1ctl_info_dl *) msgb_put(msg, len);
- memcpy(dl, dl_info, len);
+ add_info_dl(msg, dl_info);
talloc_free(dl_info);
/* Fill in FBSB payload: BSIC and sync result */
@@ -198,7 +206,6 @@
int l1ctl_tx_dt_ind(struct l1ctl_link *l1l, struct l1ctl_info_dl *data,
uint8_t *l2, size_t l2_len, bool traffic)
{
- struct l1ctl_info_dl *dl;
struct msgb *msg;
uint8_t *msg_l2;
@@ -207,9 +214,7 @@
if (msg == NULL)
return -ENOMEM;
- /* Copy DL header */
- dl = (struct l1ctl_info_dl *) msgb_put(msg, sizeof(*dl));
- memcpy(dl, data, sizeof(*dl));
+ add_info_dl(msg, data);
/* Copy the L2 payload if preset */
if (l2 && l2_len > 0) {
@@ -225,16 +230,13 @@
{
struct l1ctl_info_dl *dl;
struct msgb *msg;
- size_t len;
msg = l1ctl_alloc_msg(L1CTL_RACH_CONF);
if (msg == NULL)
return -ENOMEM;
- len = sizeof(struct l1ctl_info_dl);
- dl = (struct l1ctl_info_dl *) msgb_put(msg, len);
+ dl = add_info_dl(msg, NULL);
- memset(dl, 0x00, len);
dl->band_arfcn = htons(l1l->trx->band_arfcn);
dl->frame_nr = htonl(fn);
@@ -248,9 +250,7 @@
int l1ctl_tx_dt_conf(struct l1ctl_link *l1l,
struct l1ctl_info_dl *data, bool traffic)
{
- struct l1ctl_info_dl *dl;
struct msgb *msg;
- size_t len;
msg = l1ctl_alloc_msg(traffic ?
L1CTL_TRAFFIC_CONF : L1CTL_DATA_CONF);
@@ -258,9 +258,7 @@
return -ENOMEM;
/* Copy DL frame header from source message */
- len = sizeof(struct l1ctl_info_dl);
- dl = (struct l1ctl_info_dl *) msgb_put(msg, len);
- memcpy(dl, data, len);
+ add_info_dl(msg, data);
return l1ctl_link_send(l1l, msg);
}
@@ -292,7 +290,6 @@
struct l1ctl_fbsb_conf *conf;
struct l1ctl_info_dl *dl;
struct msgb *msg;
- size_t len;
msg = l1ctl_alloc_msg(L1CTL_FBSB_CONF);
if (msg == NULL)
@@ -300,10 +297,7 @@
LOGP(DL1C, LOGL_DEBUG, "Send FBSB Conf (result=255, bsic=0)\n");
- /* Compose DL info header */
- len = sizeof(struct l1ctl_info_dl);
- dl = (struct l1ctl_info_dl *) msgb_put(msg, len);
- memset(dl, 0x00, len);
+ dl = add_info_dl(msg, NULL);
/* Fill in current ARFCN */
dl->band_arfcn = htons(l1l->trx->band_arfcn);
--
To view, visit https://gerrit.osmocom.org/13354
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0b5b81f1fcd2984136e553a93735ea5456d2b3df
Gerrit-Change-Number: 13354
Gerrit-PatchSet: 1
Gerrit-Owner: Max <msuraev at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190321/3ef6ac71/attachment.htm>