lynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/37794?usp=email )
Change subject: gb: add bssgp_parse_cell_id2/bssgp_create_cell_id2 ......................................................................
gb: add bssgp_parse_cell_id2/bssgp_create_cell_id2
Add bssgp_cell_id functions which use the new struct osmo_routing_area_id.
Related: OS#6536 Change-Id: I6cdae75a32547968add2421a07d287a0a42bdbc0 --- M TODO-RELEASE M include/osmocom/gprs/gprs_bssgp.h M src/gb/gprs_bssgp.c 3 files changed, 37 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/94/37794/1
diff --git a/TODO-RELEASE b/TODO-RELEASE index 0ed7189..904d9e0 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -7,3 +7,4 @@ # If any interfaces have been added since the last public release: c:r:a + 1. # If any interfaces have been removed or changed since the last public release: c:r:0. #library what description / commit summary line +gb ADD add bssgp_parse_cell_id2/bssgp_create_cell_id2 diff --git a/include/osmocom/gprs/gprs_bssgp.h b/include/osmocom/gprs/gprs_bssgp.h index 6c04332..391f8c6 100644 --- a/include/osmocom/gprs/gprs_bssgp.h +++ b/include/osmocom/gprs/gprs_bssgp.h @@ -182,6 +182,12 @@ int bssgp_create_cell_id(uint8_t *buf, const struct gprs_ra_id *raid, uint16_t cid);
+uint16_t bssgp_parse_cell_id2(struct osmo_routing_area_id *raid, uint16_t *cid, + const uint8_t *buf, size_t buf_len); +int bssgp_create_cell_id2(uint8_t *buf, size_t buf_len, + const struct osmo_routing_area_id *raid, + uint16_t cid); + /* Wrapper around TLV parser to parse BSSGP IEs */ static inline int bssgp_tlv_parse(struct tlv_parsed *tp, const uint8_t *buf, int len) { diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c index 7abef80..e11299d 100644 --- a/src/gb/gprs_bssgp.c +++ b/src/gb/gprs_bssgp.c @@ -354,6 +354,20 @@ return osmo_load16be(buf+6); }
+int bssgp_parse_cell_id2(struct osmo_routing_area_id *raid, uint16_t *cellid, + const uint8_t *buf, size_t buf_len) +{ + if (buf_len < 8) + return -EINVAL; + + /* 6 octets RAC */ + osmo_routing_area_id_decode(raid, buf, buf_len); + /* 2 octets CID */ + *cellid = osmo_load16be(buf+6); + + return 0; +} + int bssgp_create_cell_id(uint8_t *buf, const struct gprs_ra_id *raid, uint16_t cid) { @@ -365,6 +379,22 @@ return 8; }
+int bssgp_create_cell_id2(uint8_t *buf, size_t buf_len, + const struct osmo_routing_area_id *raid, + uint16_t cid) +{ + if (buf_len < 8) + return -ENOMEM; + + /* 6 octets RAC */ + osmo_routing_area_id_encode_buf(buf, buf_len, raid); + + /* 2 octets CID */ + osmo_store16be(cid, buf+6); + + return 8; +} + /* Chapter 8.4 BVC-Reset Procedure */ static int bssgp_rx_bvc_reset(struct msgb *msg, struct tlv_parsed *tp, uint16_t ns_bvci)