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

laforge gerrit-no-reply at lists.osmocom.org
Fri Mar 19 12:38:54 UTC 2021


laforge has uploaded this change for review. ( 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(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/07/23407/1

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..5b91ab8 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] local_sgsn_role 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 local_sgsn_role)
 {
 	struct gprs_ns2_nse *nse;
 
@@ -792,6 +794,7 @@
 	if (!nse)
 		return NULL;
 	nse->dialect = GPRS_NS2_DIALECT_UNDEF;
+	nse->sgsn_role = local_sgsn_role;
 
 	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->sgsn_role)
+				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..f0dd9bf 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 sgsn_role;
 };
 
 /*! 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: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210319/47c74cff/attachment.htm>


More information about the gerrit-log mailing list