mirror of https://gerrit.osmocom.org/libosmocore
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
This commit is contained in:
parent
02de87bd5c
commit
5b214e2847
|
@ -96,6 +96,7 @@ nobase_include_HEADERS = \
|
|||
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 \
|
||||
|
|
|
@ -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 lcs_cause and struct bssmap_le_location_type, and BSSMAP-LE references gsm0808_cause.
|
||||
*/
|
||||
/*
|
||||
* (C) 2020 by sysmocom - s.f.m.c. GmbH <info@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 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;
|
||||
union gad_raw location_estimate;
|
||||
|
||||
struct 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 lcs_cause_ie *lcs_cause);
|
||||
struct msgb *gsm0808_create_perform_location_abort(const struct lcs_cause_ie *lcs_cause);
|
||||
|
||||
/*! @} */
|
|
@ -26,9 +26,11 @@
|
|||
#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>
|
||||
#include <osmocom/gsm/gad.h>
|
||||
|
||||
/*! \addtogroup gsm0808
|
||||
* @{
|
||||
|
@ -1341,6 +1343,106 @@ struct msgb *gsm0808_create_dtap(struct msgb *msg_l3, uint8_t link_id)
|
|||
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, ¶ms->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, ¶ms->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_raw_write(msg, ¶ms->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, ¶ms->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 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 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 = {
|
||||
|
|
|
@ -255,6 +255,9 @@ gsm0808_enc_lcls;
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue