blob: 92896c1f9cabc38046c9e8c155586ac6ba85b333 [file] [log] [blame]
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02001/*! \file gprs_bssgp_util.c
2 * GPRS BSSGP protocol implementation as per 3GPP TS 08.18. */
3/*
4 * (C) 2009-2017 by Harald Welte <laforge@gnumonks.org>
Harald Welteaf086782010-05-11 10:01:17 +02005 *
6 * All Rights Reserved
7 *
Harald Weltee08da972017-11-13 01:00:26 +09008 * SPDX-License-Identifier: GPL-2.0+
9 *
Harald Welteaf086782010-05-11 10:01:17 +020010 * This program is free software; you can redistribute it and/or modify
Harald Welte7fa89c22014-10-26 20:33:09 +010011 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
Harald Welteaf086782010-05-11 10:01:17 +020013 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Harald Welte7fa89c22014-10-26 20:33:09 +010018 * GNU General Public License for more details.
Harald Welteaf086782010-05-11 10:01:17 +020019 *
Harald Welte7fa89c22014-10-26 20:33:09 +010020 * You should have received a copy of the GNU General Public License
Harald Weltee4cbb3f2011-01-01 15:25:50 +010021 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Harald Welteaf086782010-05-11 10:01:17 +020022 *
23 */
24
25#include <errno.h>
26#include <stdint.h>
27
Pablo Neira Ayusoff663232011-03-22 16:47:59 +010028#include <osmocom/core/msgb.h>
Harald Weltebfe62e52017-05-15 12:48:30 +020029#include <osmocom/core/byteswap.h>
Pablo Neira Ayusoff663232011-03-22 16:47:59 +010030#include <osmocom/gsm/tlv.h>
31#include <osmocom/core/talloc.h>
Harald Welte73952e32012-06-16 14:59:56 +080032#include <osmocom/gprs/gprs_bssgp.h>
33#include <osmocom/gprs/gprs_ns.h>
Harald Welteaf086782010-05-11 10:01:17 +020034
Alexander Couzens85a8fd32020-07-18 15:57:07 +020035#include "gprs_bssgp_internal.h"
Harald Welteaf086782010-05-11 10:01:17 +020036
37struct gprs_ns_inst *bssgp_nsi;
38
39/* BSSGP Protocol specific, not implementation specific */
40/* FIXME: This needs to go into libosmocore after finished */
41
42/* Chapter 11.3.9 / Table 11.10: Cause coding */
43static const struct value_string bssgp_cause_strings[] = {
Max4aaa8ab2017-06-29 19:27:24 +020044 { BSSGP_CAUSE_PROC_OVERLOAD, "Processor overload" },
45 { BSSGP_CAUSE_EQUIP_FAIL, "Equipment Failure" },
Pau Espin Pedrol9b90ca82020-01-03 17:45:36 +010046 { BSSGP_CAUSE_TRASIT_NET_FAIL, "Transit network service failure" },
Max4aaa8ab2017-06-29 19:27:24 +020047 { BSSGP_CAUSE_CAPA_GREATER_0KPBS, "Transmission capacity modified" },
48 { BSSGP_CAUSE_UNKNOWN_MS, "Unknown MS" },
49 { BSSGP_CAUSE_UNKNOWN_BVCI, "Unknown BVCI" },
50 { BSSGP_CAUSE_CELL_TRAF_CONG, "Cell traffic congestion" },
51 { BSSGP_CAUSE_SGSN_CONG, "SGSN congestion" },
52 { BSSGP_CAUSE_OML_INTERV, "O&M intervention" },
53 { BSSGP_CAUSE_BVCI_BLOCKED, "BVCI blocked" },
54 { BSSGP_CAUSE_PFC_CREATE_FAIL, "PFC create failure" },
55 { BSSGP_CAUSE_PFC_PREEMPTED, "PFC preempted" },
56 { BSSGP_CAUSE_ABQP_NOT_SUPP, "ABQP no more supported" },
57 { BSSGP_CAUSE_SEM_INCORR_PDU, "Semantically incorrect PDU" },
58 { BSSGP_CAUSE_INV_MAND_INF, "Invalid mandatory information" },
59 { BSSGP_CAUSE_MISSING_MAND_IE, "Missing mandatory IE" },
60 { BSSGP_CAUSE_MISSING_COND_IE, "Missing conditional IE" },
61 { BSSGP_CAUSE_UNEXP_COND_IE, "Unexpected conditional IE" },
62 { BSSGP_CAUSE_COND_IE_ERR, "Conditional IE error" },
63 { BSSGP_CAUSE_PDU_INCOMP_STATE, "PDU incompatible with protocol state" },
64 { BSSGP_CAUSE_PROTO_ERR_UNSPEC, "Protocol error - unspecified" },
65 { BSSGP_CAUSE_PDU_INCOMP_FEAT, "PDU not compatible with feature set" },
66 { BSSGP_CAUSE_REQ_INFO_NOT_AVAIL, "Requested Information not available" },
67 { BSSGP_CAUSE_UNKN_DST , "Unknown Destination address" },
68 { BSSGP_CAUSE_UNKN_RIM_AI, "Unknown RIM Application Identity or RIM application disabled" },
69 { BSSGP_CAUSE_INVAL_CONT_UI, "Invalid Container Unit Information" },
70 { BSSGP_CAUSE_PFC_QUEUE, "PFC queuing" },
71 { BSSGP_CAUSE_PFC_CREATED, "PFC created successfully" },
72 { BSSGP_CAUSE_T12_EXPIRY, "T12 expiry" },
73 { BSSGP_CAUSE_MS_UNDER_PS_HO, "MS under PS Handover treatment" },
74 { BSSGP_CAUSE_UL_QUALITY, "Uplink quality" },
75 { BSSGP_CAUSE_UL_STRENGTH, "Uplink strength" },
76 { BSSGP_CAUSE_DL_QUALITY, "Downlink quality" },
77 { BSSGP_CAUSE_DL_STRENGTH, "Downlink strength" },
78 { BSSGP_CAUSE_DISTANCE, "Distance" },
79 { BSSGP_CAUSE_BETTER_CELL, "Better cell" },
80 { BSSGP_CAUSE_TRAFFIC, "Traffic" },
81 { BSSGP_CAUSE_MS_RADIO_LOSS, "Radio contact lost with MS" },
82 { BSSGP_CAUSE_MS_BACK_OLD_CHAN, "MS back on old channel" },
83 { BSSGP_CAUSE_T13_EXPIRY, "T13 expiry" },
84 { BSSGP_CAUSE_T14_EXPIRY, "T14 expiry" },
85 { BSSGP_CAUSE_NOT_ALL_PFC, "Not all requested PFCs created" },
86 { BSSGP_CAUSE_CS, "CS cause" },
87 { BSSGP_CAUSE_REQ_ALG_NOT_SUPP, "Requested ciphering and/or integrity protection algorithms not supported" },
88 { BSSGP_CAUSE_RELOC_FAIL, "Relocation failure in target system" },
89 { BSSGP_CAUSE_DIR_RETRY , "Directed Retry" },
90 { BSSGP_CAUSE_TIME_CRIT_RELOC , "Time critical relocation" },
91 { BSSGP_CAUSE_PS_HO_TARG_NA , "PS Handover Target not allowed" },
92 { BSSGP_CAUSE_PS_HO_TARG_NOT_SUPP, "PS Handover not Supported in Target BSS or Target System" },
93 { BSSGP_CAUSE_PUESBINE, "Incoming relocation not supported due to PUESBINE feature" },
94 { BSSGP_CAUSE_DTM_HO_NO_CS_RES, "DTM Handover - No CS resource" },
95 { BSSGP_CAUSE_DTM_HO_PS_ALLOC_FAIL, "DTM Handover - PS Allocation failure" },
96 { BSSGP_CAUSE_DTM_HO_T24_EXPIRY, "DTM Handover - T24 expiry" },
97 { BSSGP_CAUSE_DTM_HO_INVAL_CS_IND, "DTM Handover - Invalid CS Indication IE" },
98 { BSSGP_CAUSE_DTM_HO_T23_EXPIRY, "DTM Handover - T23 expiry" },
99 { BSSGP_CAUSE_DTM_HO_MSC_ERR, "DTM Handover - MSC Error" },
100 { BSSGP_CAUSE_INVAL_CSG_CELL, "Invalid CSG cell" },
Harald Welteaf086782010-05-11 10:01:17 +0200101 { 0, NULL },
102};
103
Maxc0d9a6c2016-03-09 12:29:23 +0100104static const struct value_string bssgp_pdu_strings[] = {
105 { BSSGP_PDUT_DL_UNITDATA, "DL-UNITDATA" },
106 { BSSGP_PDUT_UL_UNITDATA, "UL-UNITDATA" },
107 { BSSGP_PDUT_RA_CAPABILITY, "RA-CAPABILITY" },
108 { BSSGP_PDUT_PTM_UNITDATA, "PTM-UNITDATA" },
Harald Welte61e9de82020-12-04 12:54:40 +0100109 { BSSGP_PDUT_DL_MMBS_UNITDATA, "DL-MBMS-UNITDATA" },
110 { BSSGP_PDUT_UL_MMBS_UNITDATA, "UL-MBMS-UNITDATA" },
Maxc0d9a6c2016-03-09 12:29:23 +0100111 { BSSGP_PDUT_PAGING_PS, "PAGING-PS" },
112 { BSSGP_PDUT_PAGING_CS, "PAGING-CS" },
113 { BSSGP_PDUT_RA_CAPA_UDPATE, "RA-CAPABILITY-UPDATE" },
114 { BSSGP_PDUT_RA_CAPA_UPDATE_ACK, "RA-CAPABILITY-UPDATE-ACK" },
115 { BSSGP_PDUT_RADIO_STATUS, "RADIO-STATUS" },
116 { BSSGP_PDUT_SUSPEND, "SUSPEND" },
117 { BSSGP_PDUT_SUSPEND_ACK, "SUSPEND-ACK" },
118 { BSSGP_PDUT_SUSPEND_NACK, "SUSPEND-NACK" },
119 { BSSGP_PDUT_RESUME, "RESUME" },
120 { BSSGP_PDUT_RESUME_ACK, "RESUME-ACK" },
121 { BSSGP_PDUT_RESUME_NACK, "RESUME-NACK" },
Harald Welte61e9de82020-12-04 12:54:40 +0100122 { BSSGP_PDUT_DUMMY_PAGING_PS, "DUMMY-PAGING-PS" },
123 { BSSGP_PDUT_DUMMY_PAGING_PS_RESP, "DUMMY-PAGING-PS-RESP" },
124 { BSSGP_PDUT_MS_REGISTR_ENQ, "MS-REGISTRATION-ENQ" },
125 { BSSGP_PDUT_MS_REGISTR_ENQ_RESP, "MS-REGISTRATION-ENQ-RESP" },
Maxc0d9a6c2016-03-09 12:29:23 +0100126 { BSSGP_PDUT_BVC_BLOCK, "BVC-BLOCK" },
127 { BSSGP_PDUT_BVC_BLOCK_ACK, "BVC-BLOCK-ACK" },
128 { BSSGP_PDUT_BVC_RESET, "BVC-RESET" },
129 { BSSGP_PDUT_BVC_RESET_ACK, "BVC-RESET-ACK" },
130 { BSSGP_PDUT_BVC_UNBLOCK, "BVC-UNBLOCK" },
131 { BSSGP_PDUT_BVC_UNBLOCK_ACK, "BVC-UNBLOCK-ACK" },
132 { BSSGP_PDUT_FLOW_CONTROL_BVC, "FLOW-CONTROL-BVC" },
133 { BSSGP_PDUT_FLOW_CONTROL_BVC_ACK, "FLOW-CONTROL-BVC-ACK" },
134 { BSSGP_PDUT_FLOW_CONTROL_MS, "FLOW-CONTROL-MS" },
135 { BSSGP_PDUT_FLOW_CONTROL_MS_ACK, "FLOW-CONTROL-MS-ACK" },
136 { BSSGP_PDUT_FLUSH_LL, "FLUSH-LL" },
137 { BSSGP_PDUT_FLUSH_LL_ACK, "FLUSH-LL-ACK" },
138 { BSSGP_PDUT_LLC_DISCARD, "LLC DISCARDED" },
Harald Welte61e9de82020-12-04 12:54:40 +0100139 { BSSGP_PDUT_FLOW_CONTROL_PFC, "FLOW-CONTROL-PFC" },
140 { BSSGP_PDUT_FLOW_CONTROL_PFC_ACK, "FLOW-CONTROL-PFC-ACK" },
Maxc0d9a6c2016-03-09 12:29:23 +0100141 { BSSGP_PDUT_SGSN_INVOKE_TRACE, "SGSN-INVOKE-TRACE" },
142 { BSSGP_PDUT_STATUS, "STATUS" },
Harald Welte61e9de82020-12-04 12:54:40 +0100143 { BSSGP_PDUT_OVERLOAD, "OVERLOAD" },
Maxc0d9a6c2016-03-09 12:29:23 +0100144 { BSSGP_PDUT_DOWNLOAD_BSS_PFC, "DOWNLOAD-BSS-PFC" },
145 { BSSGP_PDUT_CREATE_BSS_PFC, "CREATE-BSS-PFC" },
146 { BSSGP_PDUT_CREATE_BSS_PFC_ACK, "CREATE-BSS-PFC-ACK" },
147 { BSSGP_PDUT_CREATE_BSS_PFC_NACK, "CREATE-BSS-PFC-NACK" },
148 { BSSGP_PDUT_MODIFY_BSS_PFC, "MODIFY-BSS-PFC" },
149 { BSSGP_PDUT_MODIFY_BSS_PFC_ACK, "MODIFY-BSS-PFC-ACK" },
150 { BSSGP_PDUT_DELETE_BSS_PFC, "DELETE-BSS-PFC" },
151 { BSSGP_PDUT_DELETE_BSS_PFC_ACK, "DELETE-BSS-PFC-ACK" },
Harald Welte61e9de82020-12-04 12:54:40 +0100152 { BSSGP_PDUT_DELETE_BSS_PFC_REQ, "DELETE-BSS-PFC-REQ" },
153 { BSSGP_PDUT_PS_HO_REQUIRED, "PS-HO-REQUIRED" },
154 { BSSGP_PDUT_PS_HO_REQUIRED_ACK, "PS-HO-REQUIRED-ACK" },
155 { BSSGP_PDUT_PS_HO_REQUIRED_NACK, "PS-HO-REQUIRED-NACK" },
156 { BSSGP_PDUT_PS_HO_REQUEST, "PS-HO-REQUEST" },
157 { BSSGP_PDUT_PS_HO_REQUEST_ACK, "PS-HO-REQUEST-ACK" },
158 { BSSGP_PDUT_PS_HO_REQUEST_NACK, "PS-HO-REQUEST-NACK" },
159 { BSSGP_PDUT_PS_HO_COMPLETE, "PS-HO-COMPLETE" },
160 { BSSGP_PDUT_PS_HO_CANCEL, "PS-HO-CANCEL" },
161 { BSSGP_PDUT_PS_HO_COMPLETE_ACK, "PS-HO-COMPLETE-ACK" },
Philipp Maierb73a3de2020-12-07 20:53:26 +0100162 { BSSGP_PDUT_PERFORM_LOC_REQ, "PERFORM-LOC-REQ" },
163 { BSSGP_PDUT_PERFORM_LOC_RESP, "PERFORM-LOC-RESP" },
164 { BSSGP_PDUT_PERFORM_LOC_ABORT, "PERFORM-LOC-ABORT" },
165 { BSSGP_PDUT_POSITION_COMMAND, "POSITION-COMMAND" },
166 { BSSGP_PDUT_POSITION_RESPONSE, "POSITION-RESPONSE" },
167 { BSSGP_PDUT_RAN_INFO, "RAN-INFO" },
168 { BSSGP_PDUT_RAN_INFO_REQ, "RAN-INFO-REQ" },
169 { BSSGP_PDUT_RAN_INFO_ACK, "RAN-INFO-ACK" },
170 { BSSGP_PDUT_RAN_INFO_ERROR, "RAN-INFO-ERROR" },
171 { BSSGP_PDUT_RAN_INFO_APP_ERROR, "RAN-INFO-APP-ERROR" },
172 { BSSGP_PDUT_MBMS_START_REQ, "MBMS-START-REQ" },
173 { BSSGP_PDUT_MBMS_START_RESP, "MBMS-START-RESP" },
174 { BSSGP_PDUT_MBMS_STOP_REQ, "MBMS-STOP-REQ" },
175 { BSSGP_PDUT_MBMS_STOP_RESP, "MBMS-STOP-RESP" },
176 { BSSGP_PDUT_MBMS_UPDATE_REQ, "MBMS-UPDATE-REQ" },
177 { BSSGP_PDUT_MBMS_UPDATE_RESP, "MBMS-UPDATE-RESP" },
Maxc0d9a6c2016-03-09 12:29:23 +0100178 { 0, NULL },
179};
180
Harald Welte8f825282020-12-04 18:50:11 +0100181static const uint8_t dl_ud_ies[] = { BSSGP_IE_PDU_LIFETIME };
182static const uint8_t ul_ud_ies[] = { BSSGP_IE_CELL_ID };
183static const uint8_t ra_cap_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_MS_RADIO_ACCESS_CAP };
184static const uint8_t dl_mb_ud_ies[] = { BSSGP_IE_PDU_LIFETIME, BSSGP_IE_TMGI, BSSGP_IE_LLC_PDU };
185static const uint8_t ul_mb_ud_ies[] = { BSSGP_IE_PDU_LIFETIME, BSSGP_IE_TMGI, BSSGP_IE_LLC_PDU };
186static const uint8_t pag_ps_ies[] = { BSSGP_IE_IMSI, BSSGP_IE_QOS_PROFILE };
187static const uint8_t pag_cs_ies[] = { BSSGP_IE_IMSI, BSSGP_IE_DRX_PARAMS };
188static const uint8_t ra_cap_upd_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_TAG };
189static const uint8_t ra_cap_upd_ack_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_TAG, BSSGP_IE_RA_CAP_UPD_CAUSE };
190static const uint8_t rad_sts_ies[] = { BSSGP_IE_RADIO_CAUSE };
191static const uint8_t suspend_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_ROUTEING_AREA };
192static const uint8_t suspend_ack_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_ROUTEING_AREA, BSSGP_IE_SUSPEND_REF_NR };
Daniel Willmannfbb78a72021-01-05 15:23:46 +0100193static const uint8_t suspend_nack_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_ROUTEING_AREA };
Harald Welte8f825282020-12-04 18:50:11 +0100194static const uint8_t resume_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_ROUTEING_AREA, BSSGP_IE_SUSPEND_REF_NR };
195static const uint8_t resume_ack_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_ROUTEING_AREA };
196static const uint8_t resume_nack_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_ROUTEING_AREA };
197static const uint8_t d_pag_ps_ies[] = { BSSGP_IE_IMSI };
198static const uint8_t d_pag_ps_resp_ies[] = { BSSGP_IE_IMSI, BSSGP_IE_T_UNTIL_NEXT_PAGING };
199static const uint8_t d_pag_ps_rej_ies[] = { BSSGP_IE_IMSI, BSSGP_IE_T_UNTIL_NEXT_PAGING };
200static const uint8_t ms_reg_enq_ies[] = { BSSGP_IE_IMSI };
201static const uint8_t ms_reg_enq_res_ies[] = { BSSGP_IE_IMSI };
202static const uint8_t flush_ll_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_BVCI };
203static const uint8_t flush_ll_ack_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_FLUSH_ACTION };
204static const uint8_t llc_disc_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_LLC_FRAMES_DISCARDED, BSSGP_IE_BVCI,
205 BSSGP_IE_NUM_OCT_AFF };
206static const uint8_t fc_bvc_ies[] = { BSSGP_IE_TAG, BSSGP_IE_BVC_BUCKET_SIZE, BSSGP_IE_BUCKET_LEAK_RATE,
207 BSSGP_IE_BMAX_DEFAULT_MS, BSSGP_IE_R_DEFAULT_MS };
208static const uint8_t fc_bvc_ack_ies[] = { BSSGP_IE_TAG };
209static const uint8_t fc_ms_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_TAG, BSSGP_IE_MS_BUCKET_SIZE,
210 BSSGP_IE_BUCKET_LEAK_RATE };
211static const uint8_t fc_ms_ack_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_TAG };
212static const uint8_t block_ies[] = { BSSGP_IE_BVCI, BSSGP_IE_CAUSE };
213static const uint8_t block_ack_ies[] = { BSSGP_IE_BVCI };
214static const uint8_t unblock_ies[] = { BSSGP_IE_BVCI };
215static const uint8_t unblock_ack_ies[] = { BSSGP_IE_BVCI };
216static const uint8_t reset_ies[] = { BSSGP_IE_BVCI, BSSGP_IE_CAUSE };
217static const uint8_t reset_ack_ies[] = { BSSGP_IE_BVCI };
218static const uint8_t status_ies[] = { BSSGP_IE_CAUSE };
219static const uint8_t inv_trc_ies[] = { BSSGP_IE_TRACE_TYPE, BSSGP_IE_TRACE_REFERENC };
220static const uint8_t dl_bss_pfc_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_PACKET_FLOW_ID };
221static const uint8_t crt_bss_pfc_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_PACKET_FLOW_ID,
222 BSSGP_IE_PACKET_FLOW_TIMER, BSSGP_IE_AGG_BSS_QOS_PROFILE };
223static const uint8_t crt_bss_pfc_ack_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_PACKET_FLOW_ID,
224 BSSGP_IE_AGG_BSS_QOS_PROFILE };
225static const uint8_t crt_bss_pfc_nack_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_PACKET_FLOW_ID, BSSGP_IE_CAUSE };
226static const uint8_t mod_bss_pfc_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_PACKET_FLOW_ID,
227 BSSGP_IE_AGG_BSS_QOS_PROFILE };
228static const uint8_t mod_bss_pfc_ack_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_PACKET_FLOW_ID,
229 BSSGP_IE_PACKET_FLOW_TIMER, BSSGP_IE_AGG_BSS_QOS_PROFILE };
230static const uint8_t del_bss_pfc_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_PACKET_FLOW_ID };
231static const uint8_t del_bss_pfc_ack_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_PACKET_FLOW_ID };
232static const uint8_t fc_pfc_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_TAG, BSSGP_IE_PFC_FLOW_CTRL_PARAMS };
233static const uint8_t fc_pfc_ack_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_TAG };
234static const uint8_t del_bss_pfc_req_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_PACKET_FLOW_ID, BSSGP_IE_CAUSE };
235static const uint8_t ps_ho_required_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_CAUSE, BSSGP_IE_CELL_ID,
236 BSSGP_IE_ACTIVE_PFC_LIST };
237static const uint8_t ps_ho_required_ack_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_LIST_OF_SETUP_PFC };
238static const uint8_t ps_ho_required_nack_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_CAUSE };
239static const uint8_t ps_ho_request_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_IMSI, BSSGP_IE_CAUSE,
240 BSSGP_IE_CELL_ID, BSSGP_IE_SBSS_TO_TBSS_TR_CONT,
241 BSSGP_IE_PFC_TO_BE_SETUP_LIST };
242static const uint8_t ps_ho_request_ack_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_LIST_OF_SETUP_PFC,
243 BSSGP_IE_TBSS_TO_SBSS_TR_CONT };
244static const uint8_t ps_ho_request_nack_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_CAUSE };
245static const uint8_t ps_ho_compl_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_IMSI };
246static const uint8_t ps_ho_cancel_ies[] = { BSSGP_IE_TLLI, BSSGP_IE_CAUSE, BSSGP_IE_CELL_ID };
247static const uint8_t ps_ho_compl_ack_ies[] = { BSSGP_IE_TLLI };
248static const uint8_t overload_ies[] = { BSSGP_IE_PRIO_CLASS_IND };
249static const uint8_t rinfo_ies[] = { BSSGP_IE_RIM_ROUTING_INFO, BSSGP_IE_RI_RIM_CONTAINER };
250static const uint8_t rinfo_req_ies[] = { BSSGP_IE_RIM_ROUTING_INFO, BSSGP_IE_RI_REQ_RIM_CONTAINER };
251static const uint8_t rinfo_ack_ies[] = { BSSGP_IE_RIM_ROUTING_INFO, BSSGP_IE_RI_ACK_RIM_CONTAINER };
252static const uint8_t rinfo_err_ies[] = { BSSGP_IE_RIM_ROUTING_INFO, BSSGP_IE_RI_ERROR_RIM_COINTAINER };
253static const uint8_t rinfo_aerr_ies[] = { BSSGP_IE_RIM_ROUTING_INFO, BSSGP_IE_RI_APP_ERROR_RIM_CONT };
254
255#define DL BSSGP_PDUF_DL
256#define UL BSSGP_PDUF_UL
257#define SIG BSSGP_PDUF_SIG
258#define PTP BSSGP_PDUF_PTP
259#define PTM BSSGP_PDUF_PTM
260
261const struct osmo_tlv_prot_def osmo_pdef_bssgp = {
262 .name = "BSSGP",
263 .tlv_def = &tvlv_att_def,
264 .msg_def = {
265 [BSSGP_PDUT_DL_UNITDATA] = MSG_DEF("DL-UNITDATA", dl_ud_ies, DL|PTP),
266 [BSSGP_PDUT_UL_UNITDATA] = MSG_DEF("UL-UNITDATA", ul_ud_ies, UL|PTP),
267 [BSSGP_PDUT_RA_CAPABILITY] = MSG_DEF("RA-CAPABILITY", ra_cap_ies, DL|PTP),
268 [BSSGP_PDUT_DL_MMBS_UNITDATA] = MSG_DEF("DL-MBMS-UNITDATA", dl_mb_ud_ies, DL|PTM),
269 [BSSGP_PDUT_UL_MMBS_UNITDATA] = MSG_DEF("UL-MBMS-UNITDATA", ul_mb_ud_ies, UL|PTM),
270 [BSSGP_PDUT_PAGING_PS] = MSG_DEF("PAGING-PS", pag_ps_ies, DL|PTP|SIG),
271 [BSSGP_PDUT_PAGING_CS] = MSG_DEF("PAGING-CS", pag_cs_ies, DL|PTP|SIG),
272 [BSSGP_PDUT_RA_CAPA_UDPATE] = MSG_DEF("RA-CAPABILITY-UPDATE", ra_cap_upd_ies, UL|PTP),
273 [BSSGP_PDUT_RA_CAPA_UPDATE_ACK] = MSG_DEF("RA-CAPABILITY-UPDATE-ACK", ra_cap_upd_ack_ies, DL|PTP),
274 [BSSGP_PDUT_RADIO_STATUS] = MSG_DEF("RADIO-STATUS", rad_sts_ies, UL|PTP),
275 [BSSGP_PDUT_SUSPEND] = MSG_DEF("SUSPEND", suspend_ies, UL|SIG),
276 [BSSGP_PDUT_SUSPEND_ACK] = MSG_DEF("SUSPEND-ACK", suspend_ack_ies, DL|SIG),
Daniel Willmannfbb78a72021-01-05 15:23:46 +0100277 [BSSGP_PDUT_SUSPEND_NACK] = MSG_DEF("SUSPEND-NACK", suspend_nack_ies, DL|SIG),
Harald Welte8f825282020-12-04 18:50:11 +0100278 [BSSGP_PDUT_RESUME] = MSG_DEF("RESUME", resume_ies, UL|SIG),
279 [BSSGP_PDUT_RESUME_ACK] = MSG_DEF("RESUME-ACK", resume_ack_ies, DL|SIG),
280 [BSSGP_PDUT_RESUME_NACK] = MSG_DEF("RESUME-NACK", resume_nack_ies, DL|SIG),
281 [BSSGP_PDUT_DUMMY_PAGING_PS] = MSG_DEF("DUMMY-PAGING-PS", d_pag_ps_ies, DL|SIG|PTP),
282 [BSSGP_PDUT_DUMMY_PAGING_PS_RESP] = MSG_DEF("DUMMY-PAGING-PS-RESP", d_pag_ps_resp_ies, UL|SIG|PTP),
283 [BSSGP_PDUT_PAGING_PS_REJECT] = MSG_DEF("PAGING-PS-REJ", d_pag_ps_rej_ies, UL|SIG|PTP),
284 [BSSGP_PDUT_MS_REGISTR_ENQ] = MSG_DEF("MS-REGISRATION-ENQ", ms_reg_enq_ies, UL|SIG),
285 [BSSGP_PDUT_MS_REGISTR_ENQ_RESP] = MSG_DEF("MS-REGISRATION-ENQ-RESP", ms_reg_enq_res_ies, DL|SIG),
286 [BSSGP_PDUT_FLUSH_LL] = MSG_DEF("FLUSH-LL", flush_ll_ies, DL|SIG),
287 [BSSGP_PDUT_FLUSH_LL_ACK] = MSG_DEF("FLUSH-LL-ACK", flush_ll_ack_ies, UL|SIG),
288 [BSSGP_PDUT_LLC_DISCARD] = MSG_DEF("LLC-DISCARDED", llc_disc_ies, UL|SIG),
289 [BSSGP_PDUT_FLOW_CONTROL_BVC] = MSG_DEF("FC-BVC", fc_bvc_ies, UL|PTP),
290 [BSSGP_PDUT_FLOW_CONTROL_BVC_ACK] = MSG_DEF("FC-BVC-ACK", fc_bvc_ack_ies, DL|PTP),
291 [BSSGP_PDUT_FLOW_CONTROL_MS] = MSG_DEF("FC-MS", fc_ms_ies, UL|PTP),
292 [BSSGP_PDUT_FLOW_CONTROL_MS_ACK] = MSG_DEF("FC-MS-ACK", fc_ms_ack_ies, DL|PTP),
293 [BSSGP_PDUT_BVC_BLOCK] = MSG_DEF("BVC-BLOCK", block_ies, UL|SIG),
294 [BSSGP_PDUT_BVC_BLOCK_ACK] = MSG_DEF("BVC-BLOCK-ACK", block_ack_ies, DL|SIG),
295 [BSSGP_PDUT_BVC_UNBLOCK] = MSG_DEF("BVC-UNBLOCK", unblock_ies, UL|SIG),
296 [BSSGP_PDUT_BVC_UNBLOCK_ACK] = MSG_DEF("BVC-UNBLOCK-ACK", unblock_ack_ies, DL|SIG),
297 [BSSGP_PDUT_BVC_RESET] = MSG_DEF("BVC-RESET", reset_ies, UL|DL|SIG|PTP),
298 [BSSGP_PDUT_BVC_RESET_ACK] = MSG_DEF("BVC-RESET-ACK", reset_ack_ies, UL|DL|SIG|PTP),
299 [BSSGP_PDUT_STATUS] = MSG_DEF("STATUS", status_ies, UL|DL|PTP|SIG|PTM),
300 [BSSGP_PDUT_SGSN_INVOKE_TRACE] = MSG_DEF("SGSN-INVOKE-TRACE", inv_trc_ies, DL|SIG),
301 [BSSGP_PDUT_DOWNLOAD_BSS_PFC] = MSG_DEF("DOWNLOAD-BSS-PFC", dl_bss_pfc_ies, UL|PTP),
302 [BSSGP_PDUT_CREATE_BSS_PFC] = MSG_DEF("CREATE-BSS-PFC", crt_bss_pfc_ies, DL|PTP),
303 [BSSGP_PDUT_CREATE_BSS_PFC_ACK] = MSG_DEF("CREATE-BSS-PFC-ACK", crt_bss_pfc_ack_ies, UL|PTP),
304 [BSSGP_PDUT_CREATE_BSS_PFC_NACK] = MSG_DEF("CREATE-BSS-PFC-NACK", crt_bss_pfc_nack_ies, UL|PTP),
305 [BSSGP_PDUT_MODIFY_BSS_PFC] = MSG_DEF("MODIFY-BSS-PFC", mod_bss_pfc_ies, DL|PTP),
306 [BSSGP_PDUT_MODIFY_BSS_PFC_ACK] = MSG_DEF("MODIFY-BSS-PFC-ACK", mod_bss_pfc_ack_ies, UL|PTP),
307 [BSSGP_PDUT_DELETE_BSS_PFC] = MSG_DEF("DELETE-BSS-PFC", del_bss_pfc_ies, DL|PTP),
308 [BSSGP_PDUT_DELETE_BSS_PFC_ACK] = MSG_DEF("DELETE-BSS-PFC-ACK", del_bss_pfc_ack_ies, UL|PTP),
309 [BSSGP_PDUT_FLOW_CONTROL_PFC] = MSG_DEF("FC-PFC", fc_pfc_ies, UL|PTP),
310 [BSSGP_PDUT_FLOW_CONTROL_PFC_ACK] = MSG_DEF("FC-PFC-ACK", fc_pfc_ack_ies, DL|PTP),
311 [BSSGP_PDUT_DELETE_BSS_PFC_REQ] = MSG_DEF("DELETE-BSS-PFC-REQ", del_bss_pfc_req_ies, UL|PTP),
312 [BSSGP_PDUT_PS_HO_REQUIRED] = MSG_DEF("PS-HO-REQUIRED", ps_ho_required_ies, UL|PTP),
313 [BSSGP_PDUT_PS_HO_REQUIRED_ACK] = MSG_DEF("PS-HO-REQUIRED-ACK", ps_ho_required_ack_ies, DL|PTP),
314 [BSSGP_PDUT_PS_HO_REQUIRED_NACK] = MSG_DEF("PS-HO-REQUIRED-NACK", ps_ho_required_nack_ies, DL|PTP),
315 [BSSGP_PDUT_PS_HO_REQUEST] = MSG_DEF("PS-HO-REQUEST", ps_ho_request_ies, DL|PTP),
316 [BSSGP_PDUT_PS_HO_REQUEST_ACK] = MSG_DEF("PS-HO-REQUEST-ACK", ps_ho_request_ack_ies, UL|PTP),
317 [BSSGP_PDUT_PS_HO_REQUEST_NACK] = MSG_DEF("PS-HO-REQUEST-NACK", ps_ho_request_nack_ies, UL|PTP),
318 [BSSGP_PDUT_PS_HO_COMPLETE] = MSG_DEF("PS-HO-COMPLETE", ps_ho_compl_ies, UL|PTP),
319 [BSSGP_PDUT_PS_HO_CANCEL] = MSG_DEF("PS-HO-CANCEL", ps_ho_cancel_ies, UL|PTP),
320 [BSSGP_PDUT_PS_HO_COMPLETE_ACK] = MSG_DEF("PS-HO-COMPLETE-ACK", ps_ho_compl_ack_ies, DL|PTP),
321 [BSSGP_PDUT_OVERLOAD] = MSG_DEF("OVERLOAD", overload_ies, DL|SIG),
322 /* TODO: Messages on LCS SAP */
323 /* Messages on RIM SAP */
324 [BSSGP_PDUT_RAN_INFO] = MSG_DEF("RAN-INFORMATION", rinfo_ies, DL|UL|SIG),
325 [BSSGP_PDUT_RAN_INFO_REQ] = MSG_DEF("RAN-INFORMATION-REQUEST", rinfo_req_ies, DL|UL|SIG),
326 [BSSGP_PDUT_RAN_INFO_ACK] = MSG_DEF("RAN-INFORMATION-ACK", rinfo_ack_ies, DL|UL|SIG),
327 [BSSGP_PDUT_RAN_INFO_ERROR] = MSG_DEF("RAN-INFORMATION-ERROR", rinfo_err_ies, DL|UL|SIG),
328 [BSSGP_PDUT_RAN_INFO_APP_ERROR] = MSG_DEF("RAN-INFORMATION-APP-ERROR", rinfo_aerr_ies, DL|UL|SIG),
329 /* TODO: Messages on MBMS SAP */
330 },
331 .ie_def = {
332 [BSSGP_IE_ALIGNMENT] = { 0, "Alignment Octets" },
333 [BSSGP_IE_BMAX_DEFAULT_MS] = { 2, "Bmax default MS" },
334 [BSSGP_IE_BSS_AREA_ID] = { 1, "BSS Area Indication" },
335 [BSSGP_IE_BUCKET_LEAK_RATE] = { 2, "Bucket Leak Rate (R)" },
336 [BSSGP_IE_BVC_BUCKET_SIZE] = { 2, "BVC Bucket Size" },
337 [BSSGP_IE_BVCI] = { 2, "BVCI" },
338 [BSSGP_IE_BVC_MEASUREMENT] = {2, "BVC Measurement" },
339 [BSSGP_IE_CAUSE] = { 1, "Cause" },
340 [BSSGP_IE_CELL_ID] = { 8, "Cell Identifier" },
341 [BSSGP_IE_CHAN_NEEDED] = { 1, "Channel Needed" },
342 [BSSGP_IE_DRX_PARAMS] = { 2, "DRX Parameters" },
343 [BSSGP_IE_EMLPP_PRIO] = { 3, "eMLPP Priority" },
344 [BSSGP_IE_FLUSH_ACTION] = { 1, "Flush Action" },
345 [BSSGP_IE_IMSI] = { 1, "Mobile Identity" },
346 [BSSGP_IE_LLC_PDU] = { 0, "LLC-PDU" },
347 [BSSGP_IE_LLC_FRAMES_DISCARDED] = { 1, "LLC Frames Discarded" },
348 [BSSGP_IE_LOCATION_AREA] = { 5, "Location Area" },
349 [BSSGP_IE_LSA_ID_LIST] = { 3, "LSA Identifier List" },
350 [BSSGP_IE_LSA_INFORMATION] = { 5, "LSA Information" },
351 [BSSGP_IE_MOBILE_ID] = { 1, "Mobile Identity" },
352 [BSSGP_IE_MS_BUCKET_SIZE] = { 2, "MS Bucket Size" },
353 [BSSGP_IE_MS_RADIO_ACCESS_CAP] = { 1, "MS Radio Access Capability" },
354 [BSSGP_IE_OMC_ID] = { 1, "OMC Id" },
355 [BSSGP_IE_PDU_IN_ERROR] = { 0, "PDU In Error" },
356 [BSSGP_IE_PDU_LIFETIME] = { 2, "PDU Lifetime" },
357 [BSSGP_IE_PRIORITY] = { 1, "Priority" },
358 [BSSGP_IE_QOS_PROFILE] = { 3, "QoS Profile" },
359 [BSSGP_IE_RADIO_CAUSE] = { 1, "Radio Cause" },
360 [BSSGP_IE_RA_CAP_UPD_CAUSE] = { 1, "RA-Cap-UPD-Cause" },
361 [BSSGP_IE_ROUTEING_AREA] = { 6, "Routeing Area" },
362 [BSSGP_IE_R_DEFAULT_MS] = { 2, "R_default_MS" },
363 [BSSGP_IE_SUSPEND_REF_NR] = { 1, "Suspend Reference Number" },
364 [BSSGP_IE_TAG] = { 1, "Tag" },
365 [BSSGP_IE_TLLI] = { 4, "TLLI" },
366 [BSSGP_IE_TMSI] = { 4, "TMSI" },
367 [BSSGP_IE_TRACE_REFERENC] = { 2, "Trace Reference" },
368 [BSSGP_IE_TRACE_TYPE] = { 1, "Trace Type" },
369 [BSSGP_IE_TRANSACTION_ID] = { 2, "Transaction Id" },
370 [BSSGP_IE_TRIGGER_ID] = { 1, "Trigger Id" },
371 [BSSGP_IE_NUM_OCT_AFF] = { 3, "Number of octets affected" },
372 [BSSGP_IE_PACKET_FLOW_ID] = { 1, "Packet Flow Identifier (PFI)" },
373 [BSSGP_IE_AGG_BSS_QOS_PROFILE] = { 14, "Aggregate BSS QoS Profile" },
374 [BSSGP_IE_PACKET_FLOW_TIMER] = { 1, "GPRS Timer" },
375 [BSSGP_IE_FEATURE_BITMAP] = { 1, "Feature Bitmap" },
376 [BSSGP_IE_BUCKET_FULL_RATIO] = { 1, "Bucket Full Ratio" },
377 [BSSGP_IE_SERVICE_UTRAN_CCO] = { 1, "Service UTRAN COO" },
378 [BSSGP_IE_NSEI] = { 2, "NSEI" },
379 [BSSGP_IE_RRLP_APDU] = { 1, "RLLP APDU" },
380 [BSSGP_IE_LCS_QOS] = { 4, "LCS QoS" },
381 [BSSGP_IE_LCS_CLIENT_TYPE] = { 1, "LCS Client Type" },
382 [BSSGP_IE_REQUESTED_GPS_AST_DATA] = { 4, "Requested GPS Assistance Data" },
383 [BSSGP_IE_LOCATION_TYPE] = { 2, "Location Type" },
384 [BSSGP_IE_LOCATION_ESTIMATE] = { 1, "Location Estimate" },
385 [BSSGP_IE_POSITIONING_DATA] = { 1, "Positioning Data" },
386 [BSSGP_IE_DECIPHERING_KEYS] = { 15, "Deciphering Keys" },
387 [BSSGP_IE_LCS_PRIORITY] = { 1, "LCS Priority" },
388 [BSSGP_IE_LCS_CAUSE] = { 1, "LCS Cause" },
389 [BSSGP_IE_LCS_CAPABILITY] = { 1, "LCS Capability" },
390 [BSSGP_IE_RRLP_FLAGS] = { 1, "RRLP Flags" },
391 [BSSGP_IE_RIM_APP_IDENTITY] = { 1, "RIM Application Identity" },
392 [BSSGP_IE_RIM_SEQ_NR] = { 4, "RIM Sequence Number" },
393 [BSSGP_IE_RIM_REQ_APP_CONTAINER] = { 12, "RIM-REQUEST RIM Container" },
394 [BSSGP_IE_RAN_INFO_APP_CONTAINER] = { 12, "RAN-INFORMATION RIM Container" },
395 [BSSGP_IE_RI_ACK_RIM_CONTAINER] = { 9, "RAN-INFORMATION-ACK RIM Container" },
396 [BSSGP_IE_RI_ERROR_RIM_COINTAINER] = { 9, "RAN-INFOIRMATION-ERROR RIM Container" },
397 [BSSGP_IE_RI_APP_ERROR_RIM_CONT] = { 14, "RAN-INFORMATION-APP-ERROR RIM Container" },
398 [BSSGP_IE_RIM_PDU_INDICATIONS] = { 1, "RIM PDU Indications" },
399 [BSSGP_IE_RIM_PROTOCOL_VERSION] = { 1, "RIM Protocol Version Number" },
400 [BSSGP_IE_PFC_FLOW_CTRL_PARAMS] = { 7, "PFC FLow Control Parameters" },
401 [BSSGP_IE_GLOBAL_CN_ID] = { 5, "Global CN-Id" },
402 [BSSGP_IE_RIM_ROUTING_INFO] = { 1, "RIM Routing Information" },
403 [BSSGP_IE_MBMS_SESSION_ID] = { 0, "MBMS Session Identity" },
404 [BSSGP_IE_MBMS_SESSION_DURATION] = { 0, "MBMS Session Duration" },
405 [BSSGP_IE_MBMS_SA_ID_LIST] = { 3, "MBMS Service Area Identity List" },
406 [BSSGP_IE_MBMS_RESPONSE] = { 1, "MBMS Response" },
407 [BSSGP_IE_MBMS_RA_LIST] = { 9, "MBMS Routing Area List" },
408 [BSSGP_IE_MBMS_SESSION_INFO] = { 1, "MBMS Session Information" },
409 [BSSGP_IE_TMGI] = { 6, "TMGI" },
410 [BSSGP_IE_MBMS_STOP_CAUSE] = { 1, "MBM Stop Cause" },
411 [BSSGP_IE_SBSS_TO_TBSS_TR_CONT] = { 7, "Source BSS to Target BSS Transparent Container" },
412 [BSSGP_IE_TBSS_TO_SBSS_TR_CONT] = { 0, "Target BSS to Source BSS Transparent Container" },
413 [BSSGP_IE_NAS_CONT_FOR_PS_HO] = { 0, "NAS container for PS Handover" },
414 [BSSGP_IE_PFC_TO_BE_SETUP_LIST] = { 9, "PFCs to be set-up list" },
415 [BSSGP_IE_LIST_OF_SETUP_PFC] = { 1, "List of set-up PFCs" },
416 [BSSGP_IE_EXT_FEATURE_BITMAP] = { 1, "Extended Feature Bitmap" },
417 [BSSGP_IE_SRC_TO_TGT_TR_CONT] = { 0, "Source to Target Transparent Container" },
418 [BSSGP_IE_TGT_TO_SRC_TR_CONT] = { 0, "Target to Source Transparent Container" },
419 [BSSGP_IE_NC_ID] = { 8, "RNC Identifier" },
420 [BSSGP_IE_PAGE_MODE] = { 1, "Page Mode" },
421 [BSSGP_IE_CONTAINER_ID] = { 1, "Container ID" },
422 [BSSGP_IE_GLOBAL_TFI] = { 1, "Global TFI" },
423 [BSSGP_IE_IMEI] = { 1, "IMEI" },
424 [BSSGP_IE_TIME_TO_MBMS_DATA_XFR] = { 1, "Time to MBMS Data Transfer" },
425 [BSSGP_IE_MBMS_SESSION_REP_NR] = { 1, "MBMS Session Repetition Number" },
426 [BSSGP_IE_INTER_RAT_HO_INFO] = { 0, "Inter RAT Handover Info" },
427 [BSSGP_IE_PS_HO_COMMAND] = { 0, "PS Handover Command" },
428 [BSSGP_IE_PS_HO_INDICATIONS] = { 1, "PS Handover Indications" },
429 [BSSGP_IE_SI_PSI_CONTAINER] = { 1, "SI/PSI Container" },
430 [BSSGP_IE_ACTIVE_PFC_LIST] = { 2, "Active PFCs List" },
431 [BSSGP_IE_VELOCITY_DATA] = { 0, "Velocity Data" },
432 [BSSGP_IE_DTM_HO_COMMAND] = { 0, "DTM Handover Command" },
433 [BSSGP_IE_CS_INDICATION] = { 1, "CS Indication" },
434 [BSSGP_IE_RQD_GANNS_AST_DATA] = { 0, "Requested GANSS Assistance Data" },
435 [BSSGP_IE_GANSS_LOCATION_TYPE] = { 1, "GANSS Location Type" },
436 [BSSGP_IE_GANSS_POSITIONING_DATA] = { 0, "GANSS Positioning Data" },
437 [BSSGP_IE_FLOW_CTRL_GRANULARITY] = { 1, "Flow Control Granularity" },
438 [BSSGP_IE_ENB_ID] = { 6, "eNB Identifier" },
439 [BSSGP_IE_EUTRAN_IRAT_HO_INFO] = { 0, "E-UTRAN Inter RAT Handover Info" },
440 [BSSGP_IE_SUB_PID4RAT_FREQ_PRIO] = { 1, "Subscriber Profile ID for RAT/Frequency priority" },
441 [BSSGP_IE_REQ4IRAT_HO_INFO] = { 1, "Request for Inter-RAT Handover Info" },
442 [BSSGP_IE_RELIABLE_IRAT_HO_INFO] = { 1, "Reliable Inter-RAT Handover Info" },
443 [BSSGP_IE_SON_TRANSFER_APP_ID] = { 0, "SON Transfer Application Identity" },
444 [BSSGP_IE_CSG_ID] = { 5, "CSG Identifier" },
445 [BSSGP_IE_TAC] = { 3, "Tracking Area Code" },
446 [BSSGP_IE_REDIRECT_ATTEMPT_FLAG] = { 1, "Redirect Attempt Flag" },
447 [BSSGP_IE_REDIRECTION_INDICATION] = { 1, "Redirection Indication" },
448 [BSSGP_IE_REDIRECTION_COMPLETED] = { 1, "Redirection Completed" },
449 [BSSGP_IE_UNCONF_SEND_STATE_VAR] = { 2, "Unconfirmed send state variable" },
450 [BSSGP_IE_IRAT_MEASUREMENT_CONF] = { 10, "IRAT Measurement Configuration" },
451 [BSSGP_IE_SCI] = { 1, "SCI" },
452 [BSSGP_IE_GGSN_PGW_LOCATION] = { 1, "GGSN/P-GW Location" },
453 [BSSGP_IE_SELECTED_PLMN_ID] = { 3, "Selected PLMN ID" },
454 [BSSGP_IE_PRIO_CLASS_IND] = { 1, "Priority Class Indication" },
455 [BSSGP_IE_SOURCE_CELL_ID] = { 6, "Source Cell ID" },
456 [BSSGP_IE_IRAT_MEAS_CFG_E_EARFCN] = { 10, "IRAT Measurement Configuration (extended E-ARFCNs)" },
457 [BSSGP_IE_EDRX_PARAMETERS] = { 1, "eDRX Parameters" },
458 [BSSGP_IE_T_UNTIL_NEXT_PAGING] = { 2, "Time Until Next Paging Occasion" },
459 [BSSGP_IE_COVERAGE_CLASS] = { 1, "Coverage Class" },
460 [BSSGP_IE_PAGING_ATTEMPT_INFO] = { 1, "Paging Attempt Information" },
461 [BSSGP_IE_EXCEPTION_REPORT_FLAG] = { 1, "Exception Report Flag" },
462 [BSSGP_IE_OLD_RA_ID] = { 6, "Old Routing Area Identification" },
463 [BSSGP_IE_ATTACH_IND] = { 1, "Attach Indicator" },
464 [BSSGP_IE_PLMN_ID] = { 3, "PLMN Identity" },
465 [BSSGP_IE_MME_QUERY] = { 1, "MME Query" },
466 [BSSGP_IE_SGSN_GROUP_ID] = { 3, "SGSN Group Identity" },
467 [BSSGP_IE_ADDITIONAL_PTMSI] = { 4, "Additional P-TMSI" },
468 [BSSGP_IE_UE_USAGE_TYPE] = { 1, "UE Usage Type" },
469 [BSSGP_IE_MLAT_TIMER] = { 1, "Multilateration Timer" },
470 [BSSGP_IE_MLAT_TA] = { 2, "Multilateration Timing Advance" },
471 [BSSGP_IE_MS_SYNC_ACCURACY] = { 1, "MS Sync Accuracy" },
472 [BSSGP_IE_BTS_RX_ACCURACY_LVL] = { 1, "BTS Reception Accuracy Level" },
473 [BSSGP_IE_TA_REQ] = { 1, "Timing Advance Request (TAR)" },
474 },
475};
476
477#undef DL
478#undef UL
479#undef SIG
480#undef PTP
481#undef PTM
482
483
Harald Welteaf086782010-05-11 10:01:17 +0200484const char *bssgp_cause_str(enum gprs_bssgp_cause cause)
485{
486 return get_value_string(bssgp_cause_strings, cause);
487}
488
Maxc0d9a6c2016-03-09 12:29:23 +0100489const char *bssgp_pdu_str(enum bssgp_pdu_type pdu)
490{
491 return get_value_string(bssgp_pdu_strings, pdu);
492}
Harald Welteaf086782010-05-11 10:01:17 +0200493
494struct msgb *bssgp_msgb_alloc(void)
495{
Jacob Erlbecka39e2de2014-09-23 13:28:24 +0200496 struct msgb *msg = msgb_alloc_headroom(4096, 128, "BSSGP");
Jacob Erlbecka84db612015-04-09 14:22:22 +0200497
498 /* TODO: Add handling of msg == NULL to this function and to all callers */
499 OSMO_ASSERT(msg != NULL);
500
Jacob Erlbecka39e2de2014-09-23 13:28:24 +0200501 msgb_bssgph(msg) = msg->data;
502 return msg;
Harald Welteaf086782010-05-11 10:01:17 +0200503}
504
Jacob Erlbeckf78ec5c2015-11-17 09:53:23 +0100505struct msgb *bssgp_msgb_copy(const struct msgb *msg, const char *name)
506{
507 struct libgb_msgb_cb *old_cb, *new_cb;
508 struct msgb *new_msg;
509
510 new_msg = msgb_copy(msg, name);
511 if (!new_msg)
512 return NULL;
513
514 /* copy GB specific data */
515 old_cb = LIBGB_MSGB_CB(msg);
516 new_cb = LIBGB_MSGB_CB(new_msg);
517
518 if (old_cb->bssgph)
519 new_cb->bssgph = new_msg->_data + (old_cb->bssgph - msg->_data);
520 if (old_cb->llch)
521 new_cb->llch = new_msg->_data + (old_cb->llch - msg->_data);
522
523 /* bssgp_cell_id is a pointer into the old msgb, so we need to make
524 * it a pointer into the new msgb */
525 if (old_cb->bssgp_cell_id)
526 new_cb->bssgp_cell_id = new_msg->_data +
527 (old_cb->bssgp_cell_id - msg->_data);
528 new_cb->nsei = old_cb->nsei;
529 new_cb->bvci = old_cb->bvci;
530 new_cb->tlli = old_cb->tlli;
531
532 return new_msg;
533}
534
Harald Welteaf086782010-05-11 10:01:17 +0200535/* Transmit a simple response such as BLOCK/UNBLOCK/RESET ACK/NACK */
536int bssgp_tx_simple_bvci(uint8_t pdu_type, uint16_t nsei,
537 uint16_t bvci, uint16_t ns_bvci)
538{
539 struct msgb *msg = bssgp_msgb_alloc();
540 struct bssgp_normal_hdr *bgph =
541 (struct bssgp_normal_hdr *) msgb_put(msg, sizeof(*bgph));
542 uint16_t _bvci;
543
544 msgb_nsei(msg) = nsei;
545 msgb_bvci(msg) = ns_bvci;
546
547 bgph->pdu_type = pdu_type;
Harald Weltebfe62e52017-05-15 12:48:30 +0200548 _bvci = osmo_htons(bvci);
Harald Welteaf086782010-05-11 10:01:17 +0200549 msgb_tvlv_put(msg, BSSGP_IE_BVCI, 2, (uint8_t *) &_bvci);
550
Alexander Couzens85a8fd32020-07-18 15:57:07 +0200551 return bssgp_ns_send(bssgp_ns_send_data, msg);
Harald Welteaf086782010-05-11 10:01:17 +0200552}
553
554/* Chapter 10.4.14: Status */
555int bssgp_tx_status(uint8_t cause, uint16_t *bvci, struct msgb *orig_msg)
556{
557 struct msgb *msg = bssgp_msgb_alloc();
558 struct bssgp_normal_hdr *bgph =
559 (struct bssgp_normal_hdr *) msgb_put(msg, sizeof(*bgph));
560
Jacob Erlbecka7165772014-09-23 13:28:21 +0200561 /* GSM 08.18, 10.4.14.1: The BVCI must be included if (and only if) the
562 cause is either "BVCI blocked" or "BVCI unknown" */
563 if (cause == BSSGP_CAUSE_UNKNOWN_BVCI || cause == BSSGP_CAUSE_BVCI_BLOCKED) {
564 if (bvci == NULL)
Harald Weltefde19ed2020-12-07 21:43:51 +0100565 LOGP(DLBSSGP, LOGL_ERROR, "BSSGP Tx STATUS, cause=%s: "
Jacob Erlbecka7165772014-09-23 13:28:21 +0200566 "missing conditional BVCI\n",
567 bssgp_cause_str(cause));
568 } else {
569 if (bvci != NULL)
Harald Weltefde19ed2020-12-07 21:43:51 +0100570 LOGP(DLBSSGP, LOGL_ERROR, "BSSGP Tx STATUS, cause=%s: "
Jacob Erlbecka7165772014-09-23 13:28:21 +0200571 "unexpected conditional BVCI\n",
572 bssgp_cause_str(cause));
573 }
574
Harald Weltefde19ed2020-12-07 21:43:51 +0100575 LOGP(DLBSSGP, LOGL_NOTICE, "BSSGP BVCI=%u Tx STATUS, cause=%s\n",
Harald Weltecfb545a2010-06-03 21:30:57 +0200576 bvci ? *bvci : 0, bssgp_cause_str(cause));
Harald Welteaf086782010-05-11 10:01:17 +0200577 msgb_nsei(msg) = msgb_nsei(orig_msg);
578 msgb_bvci(msg) = 0;
579
580 bgph->pdu_type = BSSGP_PDUT_STATUS;
581 msgb_tvlv_put(msg, BSSGP_IE_CAUSE, 1, &cause);
582 if (bvci) {
Harald Weltebfe62e52017-05-15 12:48:30 +0200583 uint16_t _bvci = osmo_htons(*bvci);
Harald Welteaf086782010-05-11 10:01:17 +0200584 msgb_tvlv_put(msg, BSSGP_IE_BVCI, 2, (uint8_t *) &_bvci);
585 }
Harald Welted83d1b62011-07-16 13:45:10 +0200586 msgb_tvlv_put(msg, BSSGP_IE_PDU_IN_ERROR,
587 msgb_bssgp_len(orig_msg), msgb_bssgph(orig_msg));
Harald Welteaf086782010-05-11 10:01:17 +0200588
Alexander Couzens85a8fd32020-07-18 15:57:07 +0200589 return bssgp_ns_send(bssgp_ns_send_data, msg);
Harald Welteaf086782010-05-11 10:01:17 +0200590}