neels has submitted this change. (
https://gerrit.osmocom.org/c/osmo-hnbgw/+/32987 )
(
1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: use new osmo_sccp_instance_next_conn_id()
......................................................................
use new osmo_sccp_instance_next_conn_id()
Change-Id: I0fc6e486ce5d68b06d0bc9869292f082ec7a67f0
---
M include/osmocom/hnbgw/hnbgw.h
M src/osmo-hnbgw/context_map.c
M src/osmo-hnbgw/hnbgw_cn.c
3 files changed, 11 insertions(+), 44 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
pespin: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/include/osmocom/hnbgw/hnbgw.h b/include/osmocom/hnbgw/hnbgw.h
index e67a86a..6570bdf 100644
--- a/include/osmocom/hnbgw/hnbgw.h
+++ b/include/osmocom/hnbgw/hnbgw.h
@@ -67,7 +67,6 @@
/* reference to the SCCP User SAP by which we communicate */
struct osmo_sccp_instance *sccp;
struct osmo_sccp_user *sccp_user;
- uint32_t next_conn_id;
/* linked list of hnbgw_context_map */
struct llist_head map_list;
diff --git a/src/osmo-hnbgw/context_map.c b/src/osmo-hnbgw/context_map.c
index f610087..f8d0ecf 100644
--- a/src/osmo-hnbgw/context_map.c
+++ b/src/osmo-hnbgw/context_map.c
@@ -52,47 +52,6 @@
return MAP_S_CONNECTING;
}
-/* is a given SCCP USER SAP Connection ID in use for a given CN link? */
-static int cn_id_in_use(struct hnbgw_cnlink *cn, uint32_t id)
-{
- struct hnbgw_context_map *map;
-
- llist_for_each_entry(map, &cn->map_list, cn_list) {
- if (map->scu_conn_id == id)
- return 1;
- }
- return 0;
-}
-
-/* try to allocate a new SCCP User SAP Connection ID */
-static int alloc_cn_conn_id(struct hnbgw_cnlink *cn, uint32_t *id_out)
-{
- uint32_t i;
- uint32_t id;
-
- /* SUA: RFC3868 sec 3.10.4:
- * The source reference number is a 4 octet long integer.
- * This is allocated by the source SUA instance.
- * M3UA/SCCP: ITU-T Q.713 sec 3.3:
- * The "source local reference" parameter field is a three-octet field
containing a
- * reference number which is generated and used by the local node to identify the
- * connection section after the connection section is set up.
- * The coding "all ones" is reserved for future use.
- * Hence, let's simply use 24 bit ids to fit all link types (excluding 0x00ffffff).
- */
-
- for (i = 0; i < 0x00ffffff; i++) {
- id = cn->next_conn_id++;
- if (cn->next_conn_id == 0x00ffffff)
- cn->next_conn_id = 0;
- if (!cn_id_in_use(cn, id)) {
- *id_out = id;
- return 1;
- }
- }
- return -1;
-}
-
/* Map from a HNB + ContextID to the SCCP-side Connection ID */
struct hnbgw_context_map *
context_map_alloc_by_hnb(struct hnb_context *hnb, uint32_t rua_ctx_id,
@@ -118,7 +77,8 @@
}
}
- if (alloc_cn_conn_id(cn_if_new, &new_scu_conn_id) < 0) {
+ new_scu_conn_id = osmo_sccp_instance_next_conn_id(map->cn_link->sccp);
+ if (new_scu_conn_id < 0) {
LOGHNB(hnb, DMAIN, LOGL_ERROR, "Unable to allocate CN connection ID\n");
return NULL;
}
diff --git a/src/osmo-hnbgw/hnbgw_cn.c b/src/osmo-hnbgw/hnbgw_cn.c
index d9e35af..33ec0f6 100644
--- a/src/osmo-hnbgw/hnbgw_cn.c
+++ b/src/osmo-hnbgw/hnbgw_cn.c
@@ -495,7 +495,6 @@
cnlink = talloc_zero(g_hnbgw, struct hnbgw_cnlink);
INIT_LLIST_HEAD(&cnlink->map_list);
- cnlink->next_conn_id = 1000;
cnlink->sccp_user = osmo_sccp_user_bind_pc(g_hnbgw->sccp.client,
"OsmoHNBGW", sccp_sap_up,
OSMO_SCCP_SSN_RANAP, g_hnbgw->sccp.local_addr.pc);
--
To view, visit
https://gerrit.osmocom.org/c/osmo-hnbgw/+/32987
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: I0fc6e486ce5d68b06d0bc9869292f082ec7a67f0
Gerrit-Change-Number: 32987
Gerrit-PatchSet: 2
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged