<p>laforge <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/20335">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">add BSSMAP coding for Location Services<br><br>BSSMAP: add A-interface messages between MSC and BSC:<br>- Perform Location Request<br>- Perform Location Response<br>- Perform Location Abort<br><br>Change-Id: I4d7302a4853518916b6b425e710c10568eb2ffe5<br>---<br>M include/Makefile.am<br>A include/osmocom/gsm/gsm0808_lcs.h<br>M src/gsm/gsm0808.c<br>M src/gsm/libosmogsm.map<br>4 files changed, 158 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/Makefile.am b/include/Makefile.am</span><br><span>index 90f448a..44ff378 100644</span><br><span>--- a/include/Makefile.am</span><br><span>+++ b/include/Makefile.am</span><br><span>@@ -96,6 +96,7 @@</span><br><span> osmocom/gsm/bssmap_le.h \</span><br><span> osmocom/gsm/gad.h \</span><br><span> osmocom/gsm/gsm0808.h \</span><br><span style="color: hsl(120, 100%, 40%);">+ osmocom/gsm/gsm0808_lcs.h \</span><br><span> osmocom/gsm/gsm29205.h \</span><br><span> osmocom/gsm/gsm0808_utils.h \</span><br><span> osmocom/gsm/gsm23003.h \</span><br><span>diff --git a/include/osmocom/gsm/gsm0808_lcs.h b/include/osmocom/gsm/gsm0808_lcs.h</span><br><span>new file mode 100644</span><br><span>index 0000000..8fcbe38</span><br><span>--- /dev/null</span><br><span>+++ b/include/osmocom/gsm/gsm0808_lcs.h</span><br><span>@@ -0,0 +1,52 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/*! \addtogroup gsm0808</span><br><span style="color: hsl(120, 100%, 40%);">+ * @{</span><br><span style="color: hsl(120, 100%, 40%);">+ * \file gsm0808_lcs.h</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Declarations that depend on both gsm0808.h and bssmap_le.h: LCS related message coding.</span><br><span style="color: hsl(120, 100%, 40%);">+ * (This file prevents circular dependency between struct definitions for BSSMAP messages, since BSSMAP references</span><br><span style="color: hsl(120, 100%, 40%);">+ * struct lcs_cause and struct bssmap_le_location_type, and BSSMAP-LE references gsm0808_cause.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * (C) 2020 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de></span><br><span style="color: hsl(120, 100%, 40%);">+ * All Rights Reserved</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or modify</span><br><span style="color: hsl(120, 100%, 40%);">+ * it under the terms of the GNU General Public License as published by</span><br><span style="color: hsl(120, 100%, 40%);">+ * the Free Software Foundation; either version 2 of the License, or</span><br><span style="color: hsl(120, 100%, 40%);">+ * (at your option) any later version.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * You should have received a copy of the GNU General Public License along</span><br><span style="color: hsl(120, 100%, 40%);">+ * with this program; if not, write to the Free Software Foundation, Inc.,</span><br><span style="color: hsl(120, 100%, 40%);">+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+#pragma once</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/gsm/gsm0808.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/gsm/bssmap_le.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct gsm0808_perform_location_request {</span><br><span style="color: hsl(120, 100%, 40%);">+ struct bssmap_le_location_type location_type;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct osmo_mobile_identity imsi;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ bool more_items; /*!< always set this to false */</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm0808_create_perform_location_request(const struct gsm0808_perform_location_request *params);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct gsm0808_perform_location_response {</span><br><span style="color: hsl(120, 100%, 40%);">+ bool location_estimate_present;</span><br><span style="color: hsl(120, 100%, 40%);">+ union gad_raw location_estimate;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ struct lcs_cause_ie lcs_cause;</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm0808_create_perform_location_response(const struct gsm0808_perform_location_response *params);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int gsm0808_enc_lcs_cause(struct msgb *msg, const struct lcs_cause_ie *lcs_cause);</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm0808_create_perform_location_abort(const struct lcs_cause_ie *lcs_cause);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*! @} */</span><br><span>diff --git a/src/gsm/gsm0808.c b/src/gsm/gsm0808.c</span><br><span>index 5322061..971d962 100644</span><br><span>--- a/src/gsm/gsm0808.c</span><br><span>+++ b/src/gsm/gsm0808.c</span><br><span>@@ -26,9 +26,11 @@</span><br><span> #include <osmocom/core/byteswap.h></span><br><span> #include <osmocom/core/endian.h></span><br><span> #include <osmocom/gsm/gsm0808.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/gsm/gsm0808_lcs.h></span><br><span> #include <osmocom/gsm/gsm0808_utils.h></span><br><span> #include <osmocom/gsm/protocol/gsm_08_08.h></span><br><span> #include <osmocom/gsm/gsm48.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/gsm/gad.h></span><br><span> </span><br><span> /*! \addtogroup gsm0808</span><br><span> * @{</span><br><span>@@ -1341,6 +1343,106 @@</span><br><span> return msg;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm0808_create_perform_location_request(const struct gsm0808_perform_location_request *params)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ struct msgb *msg;</span><br><span style="color: hsl(120, 100%, 40%);">+ uint8_t *out;</span><br><span style="color: hsl(120, 100%, 40%);">+ int rc;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM, "BSSMAP-PERFORM-LOCATION-REQUEST");</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!msg)</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Message Type, 3.2.2.1 */</span><br><span style="color: hsl(120, 100%, 40%);">+ msgb_v_put(msg, BSS_MAP_MSG_PERFORM_LOCATION_RQST);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Location Type 3.2.2.63 */</span><br><span style="color: hsl(120, 100%, 40%);">+ osmo_bssmap_le_ie_enc_location_type(msg, ¶ms->location_type);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (params->imsi.type == GSM_MI_TYPE_IMSI) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* IMSI 3.2.2.6 */</span><br><span style="color: hsl(120, 100%, 40%);">+ out = msgb_tl_put(msg, GSM0808_IE_IMSI);</span><br><span style="color: hsl(120, 100%, 40%);">+ rc = osmo_mobile_identity_encode_msgb(msg, ¶ms->imsi, false);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (rc < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ msgb_free(msg);</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ /* write the MI value length */</span><br><span style="color: hsl(120, 100%, 40%);">+ *out = rc;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* prepend header with final length */</span><br><span style="color: hsl(120, 100%, 40%);">+ msg->l3h = msgb_tv_push(msg, BSSAP_MSG_BSS_MANAGEMENT, msgb_length(msg));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return msg;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm0808_create_perform_location_response(const struct gsm0808_perform_location_response *params)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ struct msgb *msg;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM, "BSSMAP-PERFORM-LOCATION-RESPONSE");</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!msg)</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Message Type, 3.2.2.1 */</span><br><span style="color: hsl(120, 100%, 40%);">+ msgb_v_put(msg, BSS_MAP_MSG_PERFORM_LOCATION_RESPONSE);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (params->location_estimate_present) {</span><br><span style="color: hsl(120, 100%, 40%);">+ uint8_t *l = msgb_tl_put(msg, GSM0808_IE_LOCATION_ESTIMATE);</span><br><span style="color: hsl(120, 100%, 40%);">+ int rc = osmo_gad_raw_write(msg, ¶ms->location_estimate);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (rc < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ msgb_free(msg);</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ *l = rc;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (params->lcs_cause.present) {</span><br><span style="color: hsl(120, 100%, 40%);">+ uint8_t *l = msgb_tl_put(msg, GSM0808_IE_LCS_CAUSE);</span><br><span style="color: hsl(120, 100%, 40%);">+ int rc = osmo_lcs_cause_enc(msg, ¶ms->lcs_cause);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (rc < 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+ msgb_free(msg);</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ *l = rc;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* prepend header with final length */</span><br><span style="color: hsl(120, 100%, 40%);">+ msg->l3h = msgb_tv_push(msg, BSSAP_MSG_BSS_MANAGEMENT, msgb_length(msg));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return msg;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int gsm0808_enc_lcs_cause(struct msgb *msg, const struct lcs_cause_ie *lcs_cause)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ uint8_t *l = msgb_tl_put(msg, GSM0808_IE_LCS_CAUSE);</span><br><span style="color: hsl(120, 100%, 40%);">+ int rc = osmo_lcs_cause_enc(msg, lcs_cause);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (rc <= 0)</span><br><span style="color: hsl(120, 100%, 40%);">+ return rc;</span><br><span style="color: hsl(120, 100%, 40%);">+ *l = rc;</span><br><span style="color: hsl(120, 100%, 40%);">+ return rc + 2;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct msgb *gsm0808_create_perform_location_abort(const struct lcs_cause_ie *lcs_cause)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ struct msgb *msg;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ msg = msgb_alloc_headroom(BSSMAP_MSG_SIZE, BSSMAP_MSG_HEADROOM, "BSSMAP-PERFORM-LOCATION-ABORT");</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!msg)</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Message Type, 3.2.2.1 */</span><br><span style="color: hsl(120, 100%, 40%);">+ msgb_v_put(msg, BSS_MAP_MSG_PERFORM_LOCATION_ABORT);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ gsm0808_enc_lcs_cause(msg, lcs_cause);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* prepend header with final length */</span><br><span style="color: hsl(120, 100%, 40%);">+ msg->l3h = msgb_tv_push(msg, BSSAP_MSG_BSS_MANAGEMENT, msgb_length(msg));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return msg;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* As per 3GPP TS 48.008 version 11.7.0 Release 11 */</span><br><span> static const struct tlv_definition bss_att_tlvdef = {</span><br><span> .def = {</span><br><span>diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map</span><br><span>index 89d81b3..1fd212d 100644</span><br><span>--- a/src/gsm/libosmogsm.map</span><br><span>+++ b/src/gsm/libosmogsm.map</span><br><span>@@ -255,6 +255,9 @@</span><br><span> gsm0808_dec_lcls;</span><br><span> gsm0808_msgb_put_cell_id_u;</span><br><span> gsm0808_decode_cell_id_u;</span><br><span style="color: hsl(120, 100%, 40%);">+gsm0808_create_perform_location_request;</span><br><span style="color: hsl(120, 100%, 40%);">+gsm0808_create_perform_location_response;</span><br><span style="color: hsl(120, 100%, 40%);">+gsm0808_create_perform_location_abort;</span><br><span> </span><br><span> gsm29118_msgb_alloc;</span><br><span> gsm29118_create_alert_req;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/20335">change 20335</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/libosmocore/+/20335"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I4d7302a4853518916b6b425e710c10568eb2ffe5 </div>
<div style="display:none"> Gerrit-Change-Number: 20335 </div>
<div style="display:none"> Gerrit-PatchSet: 6 </div>
<div style="display:none"> Gerrit-Owner: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-Reviewer: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>