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/.
Kévin Redon gerrit-no-reply at lists.osmocom.orgKévin Redon has uploaded this change for review. ( https://gerrit.osmocom.org/10218
Change subject: remsim: add msg payload after header
......................................................................
remsim: add msg payload after header
before the message header was written over the payload,
leading to corrupted data.
Change-Id: If971699993617fc50557d20582c344ea06645a3f
---
M host/simtrace2-remsim.c
1 file changed, 26 insertions(+), 19 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/18/10218/1
diff --git a/host/simtrace2-remsim.c b/host/simtrace2-remsim.c
index 462f73e..5304e6f 100644
--- a/host/simtrace2-remsim.c
+++ b/host/simtrace2-remsim.c
@@ -153,33 +153,40 @@
return rc;
}
-static struct simtrace_msg_hdr *st_push_hdr(struct msgb *msg, uint8_t msg_class, uint8_t msg_type,
- uint8_t slot_nr)
-{
- struct simtrace_msg_hdr *sh;
-
- sh = (struct simtrace_msg_hdr *) msgb_push(msg, sizeof(*sh));
- memset(sh, 0, sizeof(*sh));
- sh->msg_class = msg_class;
- sh->msg_type = msg_type;
- sh->slot_nr = slot_nr;
- sh->msg_len = msgb_length(msg);
-
- return sh;
-}
-
/* transmit a given message to a specified slot. Expects all headers
* present before calling the function */
int st_slot_tx_msg(struct st_slot *slot, struct msgb *msg,
uint8_t msg_class, uint8_t msg_type)
{
- struct simtrace_msg_hdr *sh = (struct simtrace_msg_hdr *) msg->data;
+ int rc = 0;
+ struct msgb *st = st_msgb_alloc();
+ if (!st) {
+ rc = ENOMEM;
+ goto error;
+ }
+ st->l1h = msgb_put(st, sizeof(struct simtrace_msg_hdr*));
+ struct simtrace_msg_hdr *sh = (struct simtrace_msg_hdr*) st->l1h;
+ if (!sh) {
+ rc = ENOMEM;
+ goto error;
+ }
+ memset(sh, 0, sizeof(*sh));
+ sh->msg_class = msg_class;
+ sh->msg_type = msg_type;
sh->slot_nr = slot->slot_nr;
+ st->l2h = msgb_put(st, msgb_length(msg));
+ if (!st->l2h) {
+ rc = ENOMEM;
+ goto error;
+ }
+ memcpy(st->l2h, msg->data, msgb_length(msg));
+ sh->msg_len = msgb_length(st);
+ rc = st_transp_tx_msg(slot->transp, st);
- st_push_hdr(msg, msg_class, msg_type, slot->slot_nr);
-
- return st_transp_tx_msg(slot->transp, msg);
+error:
+ msgb_free(msg);
+ return rc;
}
--
To view, visit https://gerrit.osmocom.org/10218
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: If971699993617fc50557d20582c344ea06645a3f
Gerrit-Change-Number: 10218
Gerrit-PatchSet: 1
Gerrit-Owner: Kévin Redon <kredon at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180729/3a42b7ef/attachment.htm>