Change in osmo-iuh[master]: WIP: add SABP support to HNBGW

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/.

laforge gerrit-no-reply at lists.osmocom.org
Sun Dec 1 13:20:54 UTC 2019


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-iuh/+/16369 )


Change subject: WIP: add SABP support to HNBGW
......................................................................

WIP: add SABP support to HNBGW

Change-Id: I2d91de2e37770e3635abe8004ac183857d8a6ff2
---
M include/osmocom/iuh/hnbgw.h
M src/Makefile.am
M src/hnbgw.c
A src/hnbgw_sabp.c
4 files changed, 136 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/69/16369/1

diff --git a/include/osmocom/iuh/hnbgw.h b/include/osmocom/iuh/hnbgw.h
index 4848c2f..344d20a 100644
--- a/include/osmocom/iuh/hnbgw.h
+++ b/include/osmocom/iuh/hnbgw.h
@@ -16,6 +16,7 @@
 	DHNBAP,
 	DRUA,
 	DRANAP,
+	DSABP,
 };
 
 enum hnb_ctrl_node {
@@ -96,6 +97,8 @@
 	uint16_t hnbap_stream;
 	/*! SCTP stream ID for RUA */
 	uint16_t rua_stream;
+	/*! SCTP stream ID for SABP */
+	uint16_t sabp_stream;
 
 	/*! True if a HNB-REGISTER-REQ from this HNB has been accepted. Note that
 	 * this entire data structure is freed if the HNB sends HNB-DE-REGISTER-REQ. */
diff --git a/src/Makefile.am b/src/Makefile.am
index b1f8153..24977c2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -85,13 +85,13 @@
 		     rua_msg_factory.c \
 		     hnbgw.c hnbgw_hnbap.c hnbgw_rua.c hnbgw_ranap.c \
 		     hnbgw_vty.c \
-		     context_map.c hnbgw_cn.c
+		     context_map.c hnbgw_cn.c hnbgw_sabp.c
 
 osmo_hnbgw_LDADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) $(OSMOVTY_LIBS) $(OSMOCTRL_LIBS) \
 		   $(ASN1C_LIBS) $(OSMOSIGTRAN_LIBS) \
 		   $(OSMONETIF_LIBS) \
 		   hnbap/libosmo-asn1-hnbap.a rua/libosmo-asn1-rua.a \
-		   libosmo-ranap.la
+		   libosmo-ranap.la libosmo-sabp.la
 
 
 regen: regenerate-from-asn1-source
diff --git a/src/hnbgw.c b/src/hnbgw.c
index 9dc67a2..d8ca123 100644
--- a/src/hnbgw.c
+++ b/src/hnbgw.c
@@ -258,6 +258,9 @@
 		rc = hnbgw_rua_rx(hnb, msg);
 		break;
 	case IUH_PPI_SABP:
+		hnb->sabp_stream = msgb_sctp_stream(msg);
+		rc = hnbgw_sabp_rx(hnb, msg);
+		break;
 	case IUH_PPI_RNA:
 	case IUH_PPI_PUA:
 		LOGP(DMAIN, LOGL_ERROR, "Unimplemented SCTP PPID=%lu received\n",
@@ -354,6 +357,11 @@
 		.color = "",
 		.description = "RAN Application Part",
 	},
+	[DSABP] = {
+		.name = "DSABP", .loglevel = LOGL_DEBUG, .enabled = 1,
+		.color = "",
+		.description = "Service Area Broadcast Protocol",
+	},
 };
 
 static const struct log_info hnbgw_log_info = {
@@ -588,6 +596,7 @@
 	}
 
 	ranap_set_log_area(DRANAP);
+	sabp_set_log_area(DSABP);
 
 	rc = hnbgw_cnlink_init(g_hnb_gw, "127.0.0.1", M3UA_PORT, NULL);
 	if (rc < 0) {
diff --git a/src/hnbgw_sabp.c b/src/hnbgw_sabp.c
new file mode 100644
index 0000000..95177ac
--- /dev/null
+++ b/src/hnbgw_sabp.c
@@ -0,0 +1,122 @@
+/* hnb-gw specific code for SABP (Service Area Broadcast Protocol) */
+
+/* (C) 2019 by Harald Welte <laforge at gnumonks.org>
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <osmocom/core/msgb.h>
+#include <osmocom/core/utils.h>
+#include <osmocom/netif/stream.h>
+
+#include <osmocom/sigtran/sccp_sap.h>
+#include <osmocom/sigtran/sccp_helpers.h>
+
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+
+#include "asn1helpers.h"
+
+#include <osmocom/iuh/hnbgw.h>
+#include <osmocom/iuh/hnbgw_ranap.h>
+#include <osmocom/sabp/sabp_common.h>
+#include <osmocom/sabp/sabp_ies_defs.h>
+
+static int hnbgw_sabp_tx(struct hnb_context *ctx, struct msgb *msg)
+{
+	if (!msg)
+		return -EINVAL;
+
+	msgb_sctp_ppid(msg) = IUH_PPI_SABP;
+	osmo_stream_srv_send(ctx->conn, msg);
+
+	return 0;
+}
+
+static int sabp_rx_initiating_msg(struct msgb *msg, SABP_InitiatingMessage_t *imsg)
+{
+	int rc;
+
+	switch (imsg->procedureCode) {
+	default:
+		LOGP(DSABP, LOGL_NOTICE, "Unknown SABP Procedure %lu\n", imsg->procedureCode);
+		rc = -1;
+	}
+
+	return rc;
+}
+
+static int sabp_rx_successful_outcome_msg(struct msgb *msg, SABP_SuccessfulOutcome_t *in)
+{
+	/* FIXME */
+	LOGP(DSABP, LOGL_NOTICE, "Unexpected SABP Successful Outcome\n");
+	return -1;
+}
+
+static int sabp_rx_unsuccessful_outcome_msg(struct msgb *msg, SABP_UnsuccessfulOutcome_t *in)
+{
+	/* FIXME */
+	LOGP(DSABP, LOGL_NOTICE, "Unexpected SABP Unsucessful Outcome\n");
+	return -1;
+}
+
+
+
+static int _hnbgw_sabp_rx(struct msgb *msg, SABP_SABP_PDU_t *pdu)
+{
+	int rc;
+
+	/* it's a bit odd that we can't dispatch on procedure code, but
+	 * that's not possible */
+	switch (pdu->present) {
+	case SABP_SABP_PDU_PR_initiatingMessage:
+		rc = sabp_rx_initiating_msg(msg, &pdu->choice.initiatingMessage);
+		break;
+	case SABP_SABP_PDU_PR_successfulOutcome:
+		rc = sabp_rx_successful_outcome_msg(msg, &pdu->choice.successfulOutcome);
+		break;
+	case SABP_SABP_PDU_PR_unsuccessfulOutcome:
+		rc = sabp_rx_unsuccessful_outcome_msg(msg, &pdu->choice.unsuccessfulOutcome);
+		break;
+	default:
+		LOGP(DSABP, LOGL_NOTICE, "Unknown SABP presence %u\n", pdu->present);
+		rc = -1;
+	}
+
+	return rc;
+}
+
+int hnbgw_sabp_rx(struct hnb_context *hnb, struct msgb *msg)
+{
+	SABP_SABP_PDU_t _pdu, *pdu = &_pdu;
+	asn_dec_rval_t dec_ret;
+	int rc;
+
+	/* decode and handle to _hnbgw_hnbap_rx() */
+
+	memset(pdu, 0, sizeof(*pdu));
+	dec_ret = aper_decode(NULL, &asn_DEF_SABP_SABP_PDU, (void **) &pdu,
+			      msg->data, msgb_length(msg), 0, 0);
+	if (dec_ret.code != RC_OK) {
+		LOGP(DSABP, LOGL_ERROR, "Error in ASN.1 decode\n");
+		return -1;
+	}
+
+	rc = _hnbgw_sabp_rx(msg, pdu);
+
+	return rc;
+}

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

Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Change-Id: I2d91de2e37770e3635abe8004ac183857d8a6ff2
Gerrit-Change-Number: 16369
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/20191201/c11104d4/attachment.htm>


More information about the gerrit-log mailing list