Change in libosmocore[master]: add BSSMAP coding for Location Services

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

neels gerrit-no-reply at lists.osmocom.org
Thu Oct 1 01:40:20 UTC 2020


neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/20335 )


Change subject: add BSSMAP coding for Location Services
......................................................................

add BSSMAP coding for Location Services

BSSMAP: add A-interface messages between MSC and BSC:
- Perform Location Request
- Perform Location Response
- Perform Location Abort

Change-Id: I4d7302a4853518916b6b425e710c10568eb2ffe5
---
M include/Makefile.am
A include/osmocom/gsm/gsm0808_lcs.h
M src/gsm/gsm0808.c
M src/gsm/libosmogsm.map
4 files changed, 157 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/35/20335/1

diff --git a/include/Makefile.am b/include/Makefile.am
index 91dfd3b..22e14cd 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -96,6 +96,7 @@
                        osmocom/gsm/bssmap_le.h \
                        osmocom/gsm/gad.h \
                        osmocom/gsm/gsm0808.h \
+                       osmocom/gsm/gsm0808_lcs.h \
                        osmocom/gsm/gsm29205.h \
                        osmocom/gsm/gsm0808_utils.h \
                        osmocom/gsm/gsm23003.h \
diff --git a/include/osmocom/gsm/gsm0808_lcs.h b/include/osmocom/gsm/gsm0808_lcs.h
new file mode 100644
index 0000000..58d5763
--- /dev/null
+++ b/include/osmocom/gsm/gsm0808_lcs.h
@@ -0,0 +1,52 @@
+/*! \addtogroup gsm0808
+ *  @{
+ *  \file gsm0808_lcs.h
+ *
+ * Declarations that depend on both gsm0808.h and bssmap_le.h: LCS related message coding.
+ * (This file prevents circular dependency between struct definitions for BSSMAP messages, since BSSMAP references
+ * struct osmo_lcs_cause and struct osmo_bssmap_le_location_type, and BSSMAP-LE references gsm0808_cause.
+ */
+/*
+ * (C) 2020 by sysmocom - s.f.m.c. GmbH <info at sysmocom.de>
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+#pragma once
+
+#include <osmocom/gsm/gsm0808.h>
+#include <osmocom/gsm/bssmap_le.h>
+
+struct gsm0808_perform_location_request {
+	struct osmo_bssmap_le_location_type location_type;
+	struct osmo_mobile_identity imsi;
+
+	bool more_items; /*!< always set this to false */
+};
+struct msgb *gsm0808_create_perform_location_request(const struct gsm0808_perform_location_request *params);
+
+struct gsm0808_perform_location_response {
+	bool location_estimate_present;
+	struct osmo_gad location_estimate;
+
+	struct osmo_lcs_cause_ie lcs_cause;
+};
+struct msgb *gsm0808_create_perform_location_response(const struct gsm0808_perform_location_response *params);
+
+int gsm0808_enc_lcs_cause(struct msgb *msg, const struct osmo_lcs_cause_ie *lcs_cause);
+struct msgb *gsm0808_create_perform_location_abort(const struct osmo_lcs_cause_ie *lcs_cause);
+
+/*! @} */
diff --git a/src/gsm/gsm0808.c b/src/gsm/gsm0808.c
index 5322061..4c027ec 100644
--- a/src/gsm/gsm0808.c
+++ b/src/gsm/gsm0808.c
@@ -26,6 +26,7 @@
 #include <osmocom/core/byteswap.h>
 #include <osmocom/core/endian.h>
 #include <osmocom/gsm/gsm0808.h>
+#include <osmocom/gsm/gsm0808_lcs.h>
 #include <osmocom/gsm/gsm0808_utils.h>
 #include <osmocom/gsm/protocol/gsm_08_08.h>
 #include <osmocom/gsm/gsm48.h>
@@ -1341,6 +1342,106 @@
 	return msg;
 }
 
+struct msgb *gsm0808_create_perform_location_request(const struct gsm0808_perform_location_request *params)
+{
+	struct msgb *msg;
+	uint8_t *out;
+	int rc;
+
+	msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM, "BSSMAP-PERFORM-LOCATION-REQUEST");
+	if (!msg)
+		return NULL;
+
+	/* Message Type, 3.2.2.1 */
+	msgb_v_put(msg, BSS_MAP_MSG_PERFORM_LOCATION_RQST);
+
+	/* Location Type 3.2.2.63 */
+	osmo_bssmap_le_ie_enc_location_type(msg, &params->location_type);
+
+	if (params->imsi.type == GSM_MI_TYPE_IMSI) {
+		/* IMSI 3.2.2.6 */
+		out = msgb_tl_put(msg, GSM0808_IE_IMSI);
+		rc = osmo_mobile_identity_encode_msgb(msg, &params->imsi, false);
+		if (rc < 0) {
+			msgb_free(msg);
+			return NULL;
+		}
+		/* write the MI value length */
+		*out = rc;
+	}
+
+	/* prepend header with final length */
+	msg->l3h = msgb_tv_push(msg, BSSAP_MSG_BSS_MANAGEMENT, msgb_length(msg));
+
+	return msg;
+}
+
+struct msgb *gsm0808_create_perform_location_response(const struct gsm0808_perform_location_response *params)
+{
+	struct msgb *msg;
+
+	msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM, "BSSMAP-PERFORM-LOCATION-RESPONSE");
+	if (!msg)
+		return NULL;
+
+	/* Message Type, 3.2.2.1 */
+	msgb_v_put(msg, BSS_MAP_MSG_PERFORM_LOCATION_RESPONSE);
+
+	if (params->location_estimate_present) {
+		uint8_t *l = msgb_tl_put(msg, GSM0808_IE_LOCATION_ESTIMATE);
+		int rc = osmo_gad_enc(msg, &params->location_estimate);
+		if (rc < 0) {
+			msgb_free(msg);
+			return NULL;
+		}
+		*l = rc;
+	}
+
+	if (params->lcs_cause.present) {
+		uint8_t *l = msgb_tl_put(msg, GSM0808_IE_LCS_CAUSE);
+		int rc = osmo_lcs_cause_enc(msg, &params->lcs_cause);
+		if (rc < 0) {
+			msgb_free(msg);
+			return NULL;
+		}
+		*l = rc;
+	}
+
+	/* prepend header with final length */
+	msg->l3h = msgb_tv_push(msg, BSSAP_MSG_BSS_MANAGEMENT, msgb_length(msg));
+
+	return msg;
+}
+
+int gsm0808_enc_lcs_cause(struct msgb *msg, const struct osmo_lcs_cause_ie *lcs_cause)
+{
+	uint8_t *l = msgb_tl_put(msg, GSM0808_IE_LCS_CAUSE);
+	int rc = osmo_lcs_cause_enc(msg, lcs_cause);
+	if (rc <= 0)
+		return rc;
+	*l = rc;
+	return rc + 2;
+}
+
+struct msgb *gsm0808_create_perform_location_abort(const struct osmo_lcs_cause_ie *lcs_cause)
+{
+	struct msgb *msg;
+
+	msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM, "BSSMAP-PERFORM-LOCATION-ABORT");
+	if (!msg)
+		return NULL;
+
+	/* Message Type, 3.2.2.1 */
+	msgb_v_put(msg, BSS_MAP_MSG_PERFORM_LOCATION_ABORT);
+
+	gsm0808_enc_lcs_cause(msg, lcs_cause);
+
+	/* prepend header with final length */
+	msg->l3h = msgb_tv_push(msg, BSSAP_MSG_BSS_MANAGEMENT, msgb_length(msg));
+
+	return msg;
+}
+
 /* As per 3GPP TS 48.008 version 11.7.0 Release 11 */
 static const struct tlv_definition bss_att_tlvdef = {
 	.def = {
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index 89d81b3..1fd212d 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -255,6 +255,9 @@
 gsm0808_dec_lcls;
 gsm0808_msgb_put_cell_id_u;
 gsm0808_decode_cell_id_u;
+gsm0808_create_perform_location_request;
+gsm0808_create_perform_location_response;
+gsm0808_create_perform_location_abort;
 
 gsm29118_msgb_alloc;
 gsm29118_create_alert_req;

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I4d7302a4853518916b6b425e710c10568eb2ffe5
Gerrit-Change-Number: 20335
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201001/9290db00/attachment.htm>


More information about the gerrit-log mailing list