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/.
Harald Welte gerrit-no-reply at lists.osmocom.orgHarald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/13567 )
Change subject: ggsn: Remove magic numbers from pco_contains_proto()
......................................................................
ggsn: Remove magic numbers from pco_contains_proto()
Let's remove some magic numbers and use a data structure to describe
the PCO element header.
Change-Id: I9871ffced677320aa82438332bfdb951ab129f04
---
M ggsn/ggsn.c
1 file changed, 11 insertions(+), 6 deletions(-)
Approvals:
Jenkins Builder: Verified
Pau Espin Pedrol: Looks good to me, approved
diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c
index 423f0c0..65e15c3 100644
--- a/ggsn/ggsn.c
+++ b/ggsn/ggsn.c
@@ -462,18 +462,23 @@
PCO_P_REL_DATA_SVC = 0x0018,
};
+struct pco_element {
+ uint16_t protocol_id; /* network byte order */
+ uint8_t length; /* length of data below */
+ uint8_t data[0];
+} __attribute__((packed));
+
/* determine if PCO contains given protocol */
static uint8_t *pco_contains_proto(struct ul255_t *pco, size_t offset, uint16_t prot, size_t prot_minlen)
{
- uint8_t *cur = pco->v + 1 + offset;
+ uint8_t *cur = pco->v + 1 /*length*/ + offset;
/* iterate over PCO and check if protocol contained */
- while (cur + 3 <= pco->v + pco->l) {
- uint16_t cur_prot = osmo_load16be(cur);
- uint8_t cur_len = cur[2];
- if (cur_prot == prot && cur_len >= prot_minlen)
+ while (cur + sizeof(struct pco_element) <= pco->v + pco->l) {
+ const struct pco_element *elem = (const struct pco_element *)cur;
+ if (ntohs(elem->protocol_id) == prot && elem->length >= prot_minlen)
return cur;
- cur += cur_len + 3;
+ cur += elem->length + sizeof(struct pco_element);
}
return NULL;
}
--
To view, visit https://gerrit.osmocom.org/13567
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I9871ffced677320aa82438332bfdb951ab129f04
Gerrit-Change-Number: 13567
Gerrit-PatchSet: 2
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190425/9a9ae6d9/attachment.htm>