diff options
author | Vadim Yanitskiy <axilirator@gmail.com> | 2018-05-12 02:04:53 +0700 |
---|---|---|
committer | Vadim Yanitskiy <axilirator@gmail.com> | 2018-11-05 05:13:57 +0000 |
commit | 219ed20cb5cbda05d5480d7486b228b994e50b9d (patch) | |
tree | 34629be7f718d39c3a11614d4cd2222469009b11 /src/host/layer23/src/common/l1ctl.c | |
parent | d350e9f30c3b5f77363124308dfdfbc0ef3bd35c (diff) |
l1ctl_proto.h: use flexible array member for traffic messages
Unlike the DATA messages, traffic frames may have different length.
Instead of having fixed payload (i.e. TCH frame) length, let's
introduce a flexible array member. This would allow one to
calculate the frame length using the MSGB API.
Change-Id: I119fa36c84e95c3003d57c19e25f8146ed45c3c6
Diffstat (limited to 'src/host/layer23/src/common/l1ctl.c')
-rw-r--r-- | src/host/layer23/src/common/l1ctl.c | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/src/host/layer23/src/common/l1ctl.c b/src/host/layer23/src/common/l1ctl.c index 96db52fb..5d6d9c0c 100644 --- a/src/host/layer23/src/common/l1ctl.c +++ b/src/host/layer23/src/common/l1ctl.c @@ -762,6 +762,8 @@ static int rx_l1_traffic_ind(struct osmocom_ms *ms, struct msgb *msg) { struct l1ctl_info_dl *dl; struct l1ctl_traffic_ind *ti; + size_t frame_len; + uint8_t *frame; if (msgb_l1len(msg) < sizeof(*dl)) { LOGP(DL1C, LOGL_ERROR, "TRAFFIC IND MSG too short " @@ -771,10 +773,17 @@ static int rx_l1_traffic_ind(struct osmocom_ms *ms, struct msgb *msg) /* Header handling */ dl = (struct l1ctl_info_dl *) msg->l1h; + ti = (struct l1ctl_traffic_ind *) dl->payload; + frame = (uint8_t *) ti->data; + msg->l2h = dl->payload; - ti = (struct l1ctl_traffic_ind *) msg->l2h; + msg->l3h = frame; + + /* Calculate the frame length */ + frame_len = msgb_l3len(msg); - DEBUGP(DL1C, "TRAFFIC IND (%s)\n", osmo_hexdump(ti->data, 33)); + DEBUGP(DL1C, "TRAFFIC IND len=%zu (%s)\n", frame_len, + osmo_hexdump(frame, frame_len)); /* distribute or drop */ if (ms->l1_entity.l1_traffic_ind) @@ -791,28 +800,28 @@ int l1ctl_tx_traffic_req(struct osmocom_ms *ms, struct msgb *msg, struct l1ctl_hdr *l1h; struct l1ctl_info_ul *l1i_ul; struct l1ctl_traffic_req *tr; + size_t frame_len; + uint8_t *frame; /* Header handling */ tr = (struct l1ctl_traffic_req *) msg->l2h; + frame = (uint8_t *) tr->data; + msg->l3h = frame; - DEBUGP(DL1C, "TRAFFIC REQ (%s)\n", - osmo_hexdump(msg->l2h, msgb_l2len(msg))); + /* Calculate the frame length */ + frame_len = msgb_l3len(msg); - if (msgb_l2len(msg) != 33) { - LOGP(DL1C, LOGL_ERROR, "Traffic Request has incorrect length " - "(%u != 33)\n", msgb_l2len(msg)); - msgb_free(msg); - return -EINVAL; - } + DEBUGP(DL1C, "TRAFFIC REQ len=%zu (%s)\n", frame_len, + osmo_hexdump(frame, frame_len)); - if ((tr->data[0] >> 4) != 0xd) { + if ((frame[0] >> 4) != 0xd) { LOGP(DL1C, LOGL_ERROR, "Traffic Request has incorrect magic " - "(%u != 0xd)\n", tr->data[0] >> 4); + "(%u != 0xd)\n", frame[0] >> 4); msgb_free(msg); return -EINVAL; } -// printf("TX %s\n", osmo_hexdump(tr->data, 33)); +// printf("TX %s\n", osmo_hexdump(frame, frame_len)); /* prepend uplink info header */ l1i_ul = (struct l1ctl_info_ul *) msgb_push(msg, sizeof(*l1i_ul)); |