blob: 0612a9108edc60f7761d0f071b0bbd22b3d3895c [file] [log] [blame]
Philipp Maier9828d282021-01-06 20:40:23 +01001/*! \file gprs_bssgp.h
2 * GPRS BSSGP RIM protocol implementation as per 3GPP TS 48.018. */
3/*
4 * (C) 2020-2021 by sysmocom - s.f.m.c. GmbH
5 * Author: Philipp Maier <pmaier@sysmocom.de>
6 *
7 * All Rights Reserved
8 *
9 * SPDX-License-Identifier: GPL-2.0+
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 *
24 */
25
26#pragma once
27
28#include <osmocom/gprs/protocol/gsm_08_18.h>
29
30/* 3GPP TS 48.018, table 11.3.63.1.1: RAN-INFORMATION-REQUEST Application Container coding for NACC */
31struct bssgp_ran_inf_req_app_cont_nacc {
32 struct osmo_cell_global_id_ps reprt_cell;
33};
34
35int bssgp_dec_ran_inf_req_app_cont_nacc(struct bssgp_ran_inf_req_app_cont_nacc *cont, const uint8_t *buf, size_t len);
36int bssgp_enc_ran_inf_req_app_cont_nacc(uint8_t *buf, size_t len, const struct bssgp_ran_inf_req_app_cont_nacc *cont);
37
38/* Length of NACC system information, see also: 3GPP TS 48.018 11.3.63.2.1 */
39#define BSSGP_RIM_SI_LEN 21
40#define BSSGP_RIM_PSI_LEN 22
41
42/* 3GPP TS 48.018, table 11.3.63.2.1.a: RAN-INFORMATION Application Container coding for NACC */
43struct bssgp_ran_inf_app_cont_nacc {
44 struct osmo_cell_global_id_ps reprt_cell;
45 bool type_psi;
46 uint8_t num_si;
47
48 /* Pointer to system information messages */
49 const uint8_t *si[127];
50};
51
52int bssgp_dec_ran_inf_app_cont_nacc(struct bssgp_ran_inf_app_cont_nacc *cont, const uint8_t *buf, size_t len);
53int bssgp_enc_ran_inf_app_cont_nacc(uint8_t *buf, size_t len, const struct bssgp_ran_inf_app_cont_nacc *cont);
54
55/* 3GPP TS 48.018, table 11.3.64.1.b, NACC Cause coding */
56enum bssgp_nacc_cause {
57 BSSGP_NACC_CAUSE_UNSPEC,
58 BSSGP_NACC_CAUSE_SYNTAX_ERR,
59 BSSGP_NACC_CAUSE_RPRT_CELL_MISSMTCH,
60 BSSGP_NACC_CAUSE_SIPSI_TYPE_ERR,
61 BSSGP_NACC_CAUSE_SIPSI_LEN_ERR,
62 BSSGP_NACC_CAUSE_SIPSI_SET_ERR,
63};
64
65/* 3GPP TS 48.018, table 11.3.64.1.a, Application Error Container coding for NACC */
66struct bssgp_app_err_cont_nacc {
67 enum bssgp_nacc_cause nacc_cause;
68
69 /* Pointer to errornous application container */
70 const uint8_t *err_app_cont;
71 size_t err_app_cont_len;
72};
73
74int bssgp_dec_app_err_cont_nacc(struct bssgp_app_err_cont_nacc *cont, const uint8_t *buf, size_t len);
75int bssgp_enc_app_err_cont_nacc(uint8_t *buf, size_t len, const struct bssgp_app_err_cont_nacc *cont);
76
77/* 3GPP TS 48.018, table 11.3.61.b: RIM Application Identity coding */
78enum bssgp_ran_inf_app_id {
79 BSSGP_RAN_INF_APP_ID_NACC = 1,
80 BSSGP_RAN_INF_APP_ID_SI3 = 2,
81 BSSGP_RAN_INF_APP_ID_MBMS = 3,
82 BSSGP_RAN_INF_APP_ID_SON = 4,
83 BSSGP_RAN_INF_APP_ID_UTRA_SI = 5,
84};
85
86/* 3GPP TS 48.018, table 11.3.62a.1.b: RAN-INFORMATION-REQUEST RIM Container Contents */
87struct bssgp_ran_inf_req_rim_cont {
88 enum bssgp_ran_inf_app_id app_id;
89 uint32_t seq_num;
90 struct bssgp_rim_pdu_ind pdu_ind;
91 uint8_t prot_ver;
92
93 /* Nested application container */
94 union {
95 struct bssgp_ran_inf_req_app_cont_nacc app_cont_nacc;
96 /* TODO: add containers for Si3, MBMS, SON, UTRA-SI */
97 } u;
98
99 /* Pointer to SON-transfer application identity, only present if app_id is indicating "son-transfer",
100 * see also 3GPP TS 48.018, section 11.3.108 and 3GPP TS 36.413 annex B.1.1 */
101 const uint8_t *son_trans_app_id;
102 size_t son_trans_app_id_len;
103};
104
105int bssgp_dec_ran_inf_req_rim_cont(struct bssgp_ran_inf_req_rim_cont *cont, const uint8_t *buf, size_t len);
106int bssgp_enc_ran_inf_req_rim_cont(uint8_t *buf, size_t len, const struct bssgp_ran_inf_req_rim_cont *cont);
107
108/* 3GPP TS 48.018, table 11.3.62a.2.b: RAN-INFORMATION RIM Container Contents */
109struct bssgp_ran_inf_rim_cont {
110 enum bssgp_ran_inf_app_id app_id;
111 uint32_t seq_num;
112 struct bssgp_rim_pdu_ind pdu_ind;
113 uint8_t prot_ver;
114 bool app_err;
115
116 /* Nested application container */
117 union {
118 struct bssgp_ran_inf_app_cont_nacc app_cont_nacc;
119 struct bssgp_app_err_cont_nacc app_err_cont_nacc;
120 /* TODO: add containers for Si3, MBMS, SON, UTRA-SI */
121 } u;
122
123 /* Pointer to SON-transfer application identity, only present if app_id is indicating "son-transfer",
124 * see also 3GPP TS 48.018, section 11.3.108 and 3GPP TS 36.413 annex B.1.1 */
125 const uint8_t *son_trans_app_id;
126 size_t son_trans_app_id_len;
127};
128
129int bssgp_dec_ran_inf_rim_cont(struct bssgp_ran_inf_rim_cont *cont, const uint8_t *buf, size_t len);
130int bssgp_enc_ran_inf_rim_cont(uint8_t *buf, size_t len, const struct bssgp_ran_inf_rim_cont *cont);
131
132/* 3GPP TS 48.018, table 11.3.62a.3.b: RAN-INFORMATION-ACK RIM Container Contents */
133struct bssgp_ran_inf_ack_rim_cont {
134 enum bssgp_ran_inf_app_id app_id;
135 uint32_t seq_num;
136 uint8_t prot_ver;
137
138 /* Pointer to SON-transfer application identity, only present if app_id is indicating "son-transfer",
139 * see also 3GPP TS 48.018, section 11.3.108 and 3GPP TS 36.413 annex B.1.1 */
140 const uint8_t *son_trans_app_id;
141 size_t son_trans_app_id_len;
142};
143
144int bssgp_dec_ran_inf_ack_rim_cont(struct bssgp_ran_inf_ack_rim_cont *cont, const uint8_t *buf, size_t len);
145int bssgp_enc_ran_inf_ack_rim_cont(uint8_t *buf, size_t len, const struct bssgp_ran_inf_ack_rim_cont *cont);
146
147/* 3GPP TS 48.018, table 11.3.62a.4.b: RAN-INFORMATION-ERROR RIM Container Contents */
148struct bssgp_ran_inf_err_rim_cont {
149 enum bssgp_ran_inf_app_id app_id;
150 uint8_t cause;
151 uint8_t prot_ver;
152
153 /* Pointer to (encoded) errornous PDU,
154 * see also: 3GPP TS 48.018, section 11.3.24 */
155 const uint8_t *err_pdu;
156 size_t err_pdu_len;
157
158 /* Pointer to SON-transfer application identity, only present if app_id is indicating "son-transfer",
159 * see also 3GPP TS 48.018, section 11.3.108 and 3GPP TS 36.413 annex B.1.1 */
160 const uint8_t *son_trans_app_id;
161 size_t son_trans_app_id_len;
162};
163
164int bssgp_dec_ran_inf_err_rim_cont(struct bssgp_ran_inf_err_rim_cont *cont, const uint8_t *buf, size_t len);
165int bssgp_enc_ran_inf_err_rim_cont(uint8_t *buf, size_t len, const struct bssgp_ran_inf_err_rim_cont *cont);
166
167/* 3GPP TS 48.018, table 11.3.62a.5.b: RAN-INFORMATION-APPLICATION-ERROR RIM Container Contents */
168struct bssgp_ran_inf_app_err_rim_cont {
169 enum bssgp_ran_inf_app_id app_id;
170 uint32_t seq_num;
171 struct bssgp_rim_pdu_ind pdu_ind;
172 uint8_t prot_ver;
173
174 /* Nested application container */
175 union {
176 struct bssgp_app_err_cont_nacc app_err_cont_nacc;
177 /* TODO: add containers for Si3, MBMS, SON, UTRA-SI */
178 } u;
179};
180
181int bssgp_dec_ran_inf_app_err_rim_cont(struct bssgp_ran_inf_app_err_rim_cont *cont, const uint8_t *buf, size_t len);
182int bssgp_enc_ran_inf_app_err_rim_cont(uint8_t *buf, size_t len, const struct bssgp_ran_inf_app_err_rim_cont *cont);