From bfc270ca190c0e8e1f1fd63bf96798c55c6be3b3 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 13 Jun 2020 19:50:04 +0200 Subject: WIP: 3GPP TS 29.018 definitions for Gs interface Change-Id: I4730f15142276fbdf5678c99d24b19cc9a9a76b1 --- include/Makefile.am | 1 + include/osmocom/gsm/protocol/gsm_29_018.h | 134 ++++++++++++++++++++++++++++++ src/gsm/Makefile.am | 3 +- src/gsm/gsm29018.c | 90 ++++++++++++++++++++ 4 files changed, 227 insertions(+), 1 deletion(-) create mode 100644 include/osmocom/gsm/protocol/gsm_29_018.h create mode 100644 src/gsm/gsm29018.c diff --git a/include/Makefile.am b/include/Makefile.am index 456b8ef0..a632ca7f 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -128,6 +128,7 @@ nobase_include_HEADERS = \ osmocom/gsm/protocol/gsm_23_003.h \ osmocom/gsm/protocol/gsm_23_041.h \ osmocom/gsm/protocol/gsm_29_118.h \ + osmocom/gsm/protocol/gsm_29_018.h \ osmocom/gsm/protocol/gsm_44_318.h \ osmocom/gsm/protocol/gsm_48_049.h \ osmocom/gsm/protocol/ipaccess.h \ diff --git a/include/osmocom/gsm/protocol/gsm_29_018.h b/include/osmocom/gsm/protocol/gsm_29_018.h new file mode 100644 index 00000000..e52faffe --- /dev/null +++ b/include/osmocom/gsm/protocol/gsm_29_018.h @@ -0,0 +1,134 @@ +#pragma once + +/* Definitions for the BSSAP+ protocol of the Gs interface as per 3GPP TS 29.018 V15.0.0 */ + +#include + +/* TS 29.018 Section 18.2 */ +enum bssapp_msg_type { + BSSAPP_PAGING_REQ = 0x01, + BSSAPP_PAGING_REJ = 0x02, + BSSAPP_DL_TUNNEL_REQ = 0x07, + BSSAPP_UL_TUNNEL_REQ = 0x08, + BSSAPP_LOC_UPD_REQ = 0x09, + BSSAPP_LOC_UPD_ACC = 0x0a, + BSSAPP_LOC_UPD_REJ = 0x0b, + BSSAPP_TMSI_REALL_CMPL = 0x0c, + BSSAPP_ALERT_REQ = 0x0d, + BSSAPP_ALERT_ACK = 0x0e, + BSSAPP_ALERT_REJ = 0x0f, + BSSAPP_MS_ACTIVITY_IND = 0x10, + BSSAPP_GPRS_DETACH_IND = 0x11, + BSSAPP_GPRS_DETACH_ACK = 0x12, + BSSAPP_IMSI_DETACH_IND = 0x13, + BSSAPP_IMSI_DETACH_ACK = 0x14, + BSSAPP_RESET_IND = 0x15, + BSSAPP_RESET_ACK = 0x16, + BSSAPP_MS_INFO_REQ = 0x17, + BSSAPP_MS_INFO_RESP = 0x18, + BSSAPP_MM_INFO_REQ = 0x1a, + BSSAPP_MOBILE_STATUS = 0x1d, + BSSAPP_MS_UNREACHABLE = 0x1f, +}; +extern const struct value_string bssapp_msg_type_names[]; +static inline const char *bssapp_msg_type_name(enum bssapp_msg_type msgt) { + return get_value_string(bssapp_msg_type_names, msgt); +} + + +/* TS 29.018 Section 18.3 */ +enum bssapp_iei { + BSSAPP_IEI_IMSI = 0x01, + BSSAPP_IEI_VLR_NUMBER = 0x02, + BSSAPP_IEI_TMSI = 0x03, + BSSAPP_IEI_LAI = 0x04, + BSSAPP_IEI_CHAN_NEEDED = 0x05, + BSSAPP_IEI_eMLPP_PRIORITY = 0x06, + BSSAPP_IEI_TMSI_STATUS = 0x07, + BSSAPP_IEI_Gs_CAUSE = 0x08, + BSSAPP_IEI_SGSN_NUMBER = 0x09, + BSSAPP_IEI_GPRS_LU_TYPE = 0x0a, + BSSAPP_IEI_GLOBAL_CN_ID = 0x0b, + BSSAPP_IEI_MS_CLASSMARK_1 = 0x0d, + BSSAPP_IEI_MOBILE_ID = 0x0e, + BSSAPP_IEI_REJECT_CAUSE = 0x0f, + BSSAPP_IEI_IMSI_DET_FROM_GPRS_TYPE = 0x10, + BSSAPP_IEI_IMSI_DET_FROM_NON_GPRS_TYPE = 0x11, + BSSAPP_IEI_INFORMATION_REQUESTED = 0x12, + BSSAPP_IEI_PTMSI = 0x13, + BSSAPP_IEI_IMEI = 0x14, + BSSAPP_IEI_IMEISV = 0x15, + BSSAPP_IEI_MM_INFORMATION = 0x17, + BSSAPP_IEI_CGI = 0x18, + BSSAPP_IEI_LOC_INFO_AGE = 0x19, + BSSAPP_IEI_MS_STATE = 0x1a, + BSSAPP_IEI_ERRONEOUS_MSG = 0x1b, + BSSAPP_IEI_DL_TUN_PAYLOAD_CTRL_INFO = 0x1c, + BSSAPP_IEI_UL_TUN_PAYLOAD_CTRL_INFO = 0x1d, + BSSAPP_IEI_SAI = 0x1e, + BSSAPP_IEI_TMSI_BASED_NRI_CONTAINER = 0x1f, +}; +extern const struct value_string bssapp_iei_names[]; +static inline const char *bssapp_iei_name(enum bssapp_iei iei) { + return get_value_string(bssapp_iei_names, iei); +} + + +/* TS 29.018 Section 18.4.6 */ +enum bssapp_gprs_lu_type { + BSSAPP_LU_T_IMSI_ATTACH = 0x01, + BSSAPP_LU_T_NORMAL = 0x02, +}; + +/* TS 29.018 Section 18.4.7 */ +enum bssapp_gs_cause { + BSSAPP_GSC_IMSI_DET_FOR_GPRS = 0x01, + BSSAPP_GSC_IMSI_DET_FOR_GPRS_AND_NON = 0x02, + BSSAPP_GSC_IMSI_UNKNOWN = 0x03, + BSSAPP_GSC_IMSI_DET_FOR_NON_GPRS = 0x04, + BSSAPP_GSC_IMSI_IMPL_DET_FOR_NON_GPRS = 0x05, + BSSAPP_GSC_MS_UNREACHABLE = 0x06, + BSSAPP_GSC_MSG_INCOMP_PROT_STATE = 0x07, + BSSAPP_GSC_MISSING_MAND_IE = 0x08, + BSSAPP_GSC_INVAL_MAND_IE = 0x09, + BSSAPP_GSC_COND_IE_ERR = 0x0a, + BSSAPP_GSC_SEM_INCORR_MSG = 0x0b, + BSSAPP_GSC_MSG_UNKNOWN = 0x0c, + BSSAPP_GSC_ADDR_ERROR = 0x0d, + BSSAPP_GSC_TOM_NOT_SUPPORTED = 0x0e, + BSSAPP_GSC_CIPH_REQ_CANT_ACCOMM = 0x0f, +}; + +/* TS 29.018 Section 18.4.12 */ +enum bssapp_imsi_det_non_gprs_type { + BSSAPP_IDNGT_EXPL_MO_IMSI_DET_NON_GPRS = 0x01, + BSSAPP_IDNGT_COMB_EXPL_MO_IMSI_DET_GPRS_AND_NON = 0x02, + BSSAPP_IDNGT_IMPL_MT_IMSI_DET_GPRS_AND_NON = 0x03, +}; + + +/* TS 29.018 Section 18.4.13 */ +enum bssapp_info_req { + BSSAPP_INFO_PTMSI = 0x01, + BSSAPP_INFO_IMEI = 0x02, + BSSAPP_INFO_IMEISV = 0x03, + BSSAPP_INFO_PTMSI_AND_IMEI = 0x04, + BSSAPP_INFO_PTMSI_AND_IMEISV = 0x05, + BSSAPP_INFO_IMEI_AND_IMEISV = 0x06, + BSSAPP_INFO_PTMSI_IMEI_AND_IMEISV = 0x07, + BSSAPP_INFO_MOBILE_LOC_INFO = 0x08, + BSSAPP_INFO_TMSI = 0x09, +}; + +/* TS 29.018 Mobile station state */ +enum bssapp_ms_state { + BSSAPP_MS_ST_IDLE_OR_PMM_DETACHED = 0x00, + BSSAPP_MS_ST_STANDBY_OR_PMM_IDLE_NO_PDP = 0x01, + BSSAPP_MS_ST_STANDBY_OR_PMM_IDLE_PDP = 0x02, + BSSAPP_MS_ST_SUSPENDED_NO_PDP = 0x03, + BSSAPP_MS_ST_SUSPENDED_PDP = 0x04, + BSSAPP_MS_ST_READY_OR_PMM_CONN_NO_PDP = 0x05, + BSSAPP_MS_ST_READY_OR_PMM_CONN_PDP = 0x06, + BSSAPP_MS_ST_IMSI_UNKNOWN = 0x07, + BSSAPP_MS_ST_INFO_REQ_NOTSUPP = 0x08, +}; diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am index eeb11648..c8b9389d 100644 --- a/src/gsm/Makefile.am +++ b/src/gsm/Makefile.am @@ -32,7 +32,8 @@ libgsmint_la_SOURCES = a5.c rxlev_stat.c tlv_parser.c comp128.c comp128v23.c \ milenage/milenage.c gan.c ipa.c gsm0341.c apn.c \ gsup.c gsup_sms.c gprs_gea.c gsm0503_conv.c oap.c gsm0808_utils.c \ gsm23003.c mncc.c bts_features.c oap_client.c \ - gsm29118.c gsm48_rest_octets.c cbsp.c gsm48049.c i460_mux.c + gsm29118.c gsm48_rest_octets.c cbsp.c gsm48049.c i460_mux.c \ + gsm29018.c libgsmint_la_LDFLAGS = -no-undefined libgsmint_la_LIBADD = $(top_builddir)/src/libosmocore.la diff --git a/src/gsm/gsm29018.c b/src/gsm/gsm29018.c new file mode 100644 index 00000000..78669343 --- /dev/null +++ b/src/gsm/gsm29018.c @@ -0,0 +1,90 @@ +/* (C) 2020 by Harald Welte + * All Rights Reserved + * + * SPDX-License-Identifier: GPL-2.0+ + * + * 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. + */ + +#include +#include + +#include + +const struct value_string bssapp_msg_type_names[] = { + { BSSAPP_PAGING_REQ, "PAGING-REQUEST" }, + { BSSAPP_PAGING_REJ, "PAGING-REJECT" }, + { BSSAPP_DL_TUNNEL_REQ, "DOWNLINK-TUNNEL-REQUEST" }, + { BSSAPP_UL_TUNNEL_REQ, "UPLINK-TUNNEL-REQUEST" }, + { BSSAPP_LOC_UPD_REQ, "LOCATION-UPDATE-REQUEST" }, + { BSSAPP_LOC_UPD_ACC, "LOCATION-UPDATE-ACCEPT" }, + { BSSAPP_LOC_UPD_REJ, "LOCATION-UPDATE-REJECT" }, + { BSSAPP_TMSI_REALL_CMPL, "TMSI-REALLOCATION-COMPLETE" }, + { BSSAPP_ALERT_REQ, "ALERT-REQUEST" }, + { BSSAPP_ALERT_ACK, "ALART-ACK" }, + { BSSAPP_ALERT_REJ, "ALERT-REJECT" }, + { BSSAPP_MS_ACTIVITY_IND, "MS-ACTIVITY-INDICATION" }, + { BSSAPP_GPRS_DETACH_IND, "GPRS-DETACH-INDICATION" }, + { BSSAPP_GPRS_DETACH_ACK, "GPRS-DETACH-ACK" }, + { BSSAPP_IMSI_DETACH_IND, "IMSI-DETACH-INDICATION" }, + { BSSAPP_IMSI_DETACH_ACK, "IMSI-DETACH-ACK" }, + { BSSAPP_RESET_IND, "RESET-INDICATION" }, + { BSSAPP_RESET_ACK, "RESET-ACK" }, + { BSSAPP_MS_INFO_REQ, "MS-INFO-REQUEST" }, + { BSSAPP_MS_INFO_RESP, "MS-INFO-RESPONSE" }, + { BSSAPP_MM_INFO_REQ, "MM-INFO-REQUEST" }, + { BSSAPP_MOBILE_STATUS, "MOBILE-STATUS" }, + { BSSAPP_MS_UNREACHABLE, "MS-UNREACHABLE" }, + { 0, NULL } +}; + +extern const struct value_string bssapp_iei_names[] = { + { 0, FIXME } +}; + + +const struct tlv_definition bssapp_ie_tlvdef = { + .def = { + [BSSAPP_IEI_IMSI] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_VLR_NUMBER] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_TMSI] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_LAI] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_CHAN_NEEDED] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_eMLPP_PRIORITY] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_TMSI_STATUS] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_Gs_CAUSE] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_SGSN_NUMBER] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_GPRS_LU_TYPE] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_GLOBAL_CN_ID] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_MS_CLASSMARK_1] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_MOBILE_ID] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_REJECT_CAUSE] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_IMSI_DET_FROM_GPRS_TYPE] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_IMSI_DET_FROM_NON_GPRS_TYPE]= { TLV_TYPE_TLV }, + [BSSAPP_IEI_INFORMATION_REQUESTED] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_PTMSI] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_IMEI] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_IMEISV] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_MM_INFORMATION] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_CGI] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_LOC_INFO_AGE] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_MS_STATE] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_ERRONEOUS_MSG] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_DL_TUN_PAYLOAD_CTRL_INFO] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_UL_TUN_PAYLOAD_CTRL_INFO] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_SAI] = { TLV_TYPE_TLV }, + [BSSAPP_IEI_TMSI_BASED_NRI_CONTAINER] = { TLV_TYPE_TLV }, + }, +}; -- cgit v1.2.3