Change in libosmocore[master]: gprs_ns2: Introduce gprs_ns2_create_nse2() for SGSN side SNS

laforge gerrit-no-reply at lists.osmocom.org
Tue Mar 23 23:32:20 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/23407 )

Change subject: gprs_ns2: Introduce gprs_ns2_create_nse2() for SGSN side SNS
......................................................................

gprs_ns2: Introduce gprs_ns2_create_nse2() for SGSN side SNS

gprs_ns2_create_nse() doesn't allow the caller to specify if the
BSS or the SGSN role of IP-SNS shall be implemented.  Add
gprs_ns2_create_nse2() to fix that.

Change-Id: I6db8c36f7c69b592d7d0fbcf323804f7e9912be2
Related: OS#3373
---
M include/osmocom/gprs/gprs_ns2.h
M src/gb/gprs_ns2.c
M src/gb/gprs_ns2_internal.h
M src/gb/libosmogb.map
4 files changed, 26 insertions(+), 3 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/gprs/gprs_ns2.h b/include/osmocom/gprs/gprs_ns2.h
index 56a9b4f..be59a67 100644
--- a/include/osmocom/gprs/gprs_ns2.h
+++ b/include/osmocom/gprs/gprs_ns2.h
@@ -158,6 +158,9 @@
 struct gprs_ns2_nse *gprs_ns2_create_nse(struct gprs_ns2_inst *nsi, uint16_t nsei,
 					 enum gprs_ns2_ll linklayer,
 					 enum gprs_ns2_dialect dialect);
+struct gprs_ns2_nse *gprs_ns2_create_nse2(struct gprs_ns2_inst *nsi, uint16_t nsei,
+					 enum gprs_ns2_ll linklayer,
+					 enum gprs_ns2_dialect dialect, bool local_sgsn_role);
 uint16_t gprs_ns2_nse_nsei(struct gprs_ns2_nse *nse);
 void gprs_ns2_free_nse(struct gprs_ns2_nse *nse);
 void gprs_ns2_free_nses(struct gprs_ns2_inst *nsi);
diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c
index 93b7c3a..f2e6435 100644
--- a/src/gb/gprs_ns2.c
+++ b/src/gb/gprs_ns2.c
@@ -776,9 +776,11 @@
 /*! Create a NS Entity within given NS instance.
  *  \param[in] nsi NS instance in which to create NS Entity
  *  \param[in] nsei NS Entity Identifier of to-be-created NSE
+ *  \param[in] ip_sns_role_sgsn Does local side implement SGSN role?
  *  \returns newly-allocated NS-E in successful case; NULL on error */
-struct gprs_ns2_nse *gprs_ns2_create_nse(struct gprs_ns2_inst *nsi, uint16_t nsei,
-					 enum gprs_ns2_ll linklayer, enum gprs_ns2_dialect dialect)
+struct gprs_ns2_nse *gprs_ns2_create_nse2(struct gprs_ns2_inst *nsi, uint16_t nsei,
+					  enum gprs_ns2_ll linklayer, enum gprs_ns2_dialect dialect,
+					  bool ip_sns_role_sgsn)
 {
 	struct gprs_ns2_nse *nse;
 
@@ -792,6 +794,7 @@
 	if (!nse)
 		return NULL;
 	nse->dialect = GPRS_NS2_DIALECT_UNDEF;
+	nse->ip_sns_role_sgsn = ip_sns_role_sgsn;
 
 	if (ns2_nse_set_dialect(nse, dialect) < 0) {
 		talloc_free(nse);
@@ -820,7 +823,10 @@
 	case GPRS_NS2_DIALECT_UNDEF:
 		if (dialect == GPRS_NS2_DIALECT_SNS) {
 			snprintf(sns, sizeof(sns), "NSE%05u-SNS", nse->nsei);
-			nse->bss_sns_fi = ns2_sns_bss_fsm_alloc(nse, sns);
+			if (nse->ip_sns_role_sgsn)
+				nse->bss_sns_fi = ns2_sns_sgsn_fsm_alloc(nse, sns);
+			else
+				nse->bss_sns_fi = ns2_sns_bss_fsm_alloc(nse, sns);
 			if (!nse->bss_sns_fi)
 				return -1;
 		}
@@ -841,6 +847,16 @@
 	return 0;
 }
 
+/*! Create a NS Entity within given NS instance.
+ *  \param[in] nsi NS instance in which to create NS Entity
+ *  \param[in] nsei NS Entity Identifier of to-be-created NSE
+ *  \returns newly-allocated NS-E in successful case; NULL on error */
+struct gprs_ns2_nse *gprs_ns2_create_nse(struct gprs_ns2_inst *nsi, uint16_t nsei,
+					 enum gprs_ns2_ll linklayer, enum gprs_ns2_dialect dialect)
+{
+	return gprs_ns2_create_nse2(nsi, nsei, linklayer, dialect, false);
+}
+
 /*! Return the NSEI
  * \param[in] nse NS Entity
  * \return the nsei.
diff --git a/src/gb/gprs_ns2_internal.h b/src/gb/gprs_ns2_internal.h
index 9b138e5..567e1c5 100644
--- a/src/gb/gprs_ns2_internal.h
+++ b/src/gb/gprs_ns2_internal.h
@@ -182,6 +182,9 @@
 
 	/*! MTU of a NS PDU. This is the lowest MTU of all NSVCs */
 	uint16_t mtu;
+
+	/*! are we implementing the SGSN role? */
+	bool ip_sns_role_sgsn;
 };
 
 /*! Structure representing a single NS-VC */
diff --git a/src/gb/libosmogb.map b/src/gb/libosmogb.map
index 588fabf..fc8ab45 100644
--- a/src/gb/libosmogb.map
+++ b/src/gb/libosmogb.map
@@ -139,6 +139,7 @@
 gprs_ns2_bind_by_name;
 gprs_ns2_cause_strs;
 gprs_ns2_create_nse;
+gprs_ns2_create_nse2;
 gprs_ns2_find_vc_by_sockaddr;
 gprs_ns2_free;
 gprs_ns2_free_bind;

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/23407
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I6db8c36f7c69b592d7d0fbcf323804f7e9912be2
Gerrit-Change-Number: 23407
Gerrit-PatchSet: 5
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210323/54b61241/attachment.htm>


More information about the gerrit-log mailing list