Harald Welte | 37b6165 | 2017-10-16 18:46:03 +0200 | [diff] [blame] | 1 | /*! \defgroup gsm0808 GSM 08.08 / 3GPP TS 48.008 A Interface |
| 2 | * @{ |
| 3 | * \file gsm0808.h */ |
Neels Hofmeyr | 17518fe | 2017-06-20 04:35:06 +0200 | [diff] [blame] | 4 | /* |
| 5 | * (C) 2009,2010 by Holger Hans Peter Freyther <zecke@selfish.org> |
Holger Hans Peter Freyther | 280cd51 | 2010-04-15 10:10:39 +0200 | [diff] [blame] | 6 | * (C) 2009,2010 by On-Waves |
| 7 | * All Rights Reserved |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
Holger Hans Peter Freyther | 280cd51 | 2010-04-15 10:10:39 +0200 | [diff] [blame] | 19 | */ |
Sylvain Munaut | 12ba778 | 2014-06-16 10:13:40 +0200 | [diff] [blame] | 20 | #pragma once |
Holger Hans Peter Freyther | 280cd51 | 2010-04-15 10:10:39 +0200 | [diff] [blame] | 21 | |
| 22 | #include "tlv.h" |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 23 | #include <osmocom/gsm/protocol/gsm_08_08.h> |
Neels Hofmeyr | 70aba3f | 2018-03-13 03:40:53 +0100 | [diff] [blame] | 24 | #include <osmocom/gsm/gsm0808_utils.h> |
Neels Hofmeyr | c4fce14 | 2018-02-20 13:47:08 +0100 | [diff] [blame] | 25 | #include <osmocom/gsm/gsm23003.h> |
Neels Hofmeyr | f7e9c51 | 2019-03-06 04:25:38 +0100 | [diff] [blame] | 26 | #include <osmocom/gsm/protocol/gsm_23_003.h> |
Harald Welte | ebd362d | 2018-06-02 14:11:19 +0200 | [diff] [blame] | 27 | #include <osmocom/core/utils.h> |
Neels Hofmeyr | c4fce14 | 2018-02-20 13:47:08 +0100 | [diff] [blame] | 28 | |
Andreas Eversberg | 532b8e9 | 2023-06-09 15:24:59 +0200 | [diff] [blame] | 29 | #include <osmocom/core/socket_compat.h> |
| 30 | |
Neels Hofmeyr | 99273c7 | 2019-02-22 04:48:56 +0100 | [diff] [blame] | 31 | #define BSSMAP_MSG_SIZE 1024 |
| 32 | #define BSSMAP_MSG_HEADROOM 512 |
Max | f69aa9c | 2018-11-29 23:32:06 +0100 | [diff] [blame] | 33 | |
Holger Hans Peter Freyther | 280cd51 | 2010-04-15 10:10:39 +0200 | [diff] [blame] | 34 | struct msgb; |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 35 | struct gsm0808_cell_id_list2; |
Holger Hans Peter Freyther | 280cd51 | 2010-04-15 10:10:39 +0200 | [diff] [blame] | 36 | |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 37 | struct msgb *gsm0808_create_layer3(struct msgb *msg_l3, uint16_t nc, |
Neels Hofmeyr | bd6c8b5 | 2018-03-22 14:05:21 +0100 | [diff] [blame] | 38 | uint16_t cc, int lac, uint16_t _ci) |
| 39 | OSMO_DEPRECATED("Use gsm0808_create_layer3_2() instead, to not lose leading zeros in the MNC"); |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 40 | struct msgb *gsm0808_create_layer3_aoip(const struct msgb *msg_l3, uint16_t nc, |
| 41 | uint16_t cc, int lac, uint16_t _ci, |
Neels Hofmeyr | bd6c8b5 | 2018-03-22 14:05:21 +0100 | [diff] [blame] | 42 | const struct gsm0808_speech_codec_list *scl) |
| 43 | OSMO_DEPRECATED("Use gsm0808_create_layer3_2() instead, to not lose leading zeros in the MNC"); |
Neels Hofmeyr | c4fce14 | 2018-02-20 13:47:08 +0100 | [diff] [blame] | 44 | struct msgb *gsm0808_create_layer3_2(const struct msgb *msg_l3, const struct osmo_cell_global_id *cell, |
| 45 | const struct gsm0808_speech_codec_list *scl); |
Holger Hans Peter Freyther | 280cd51 | 2010-04-15 10:10:39 +0200 | [diff] [blame] | 46 | struct msgb *gsm0808_create_reset(void); |
Harald Welte | a62fe31 | 2013-06-19 15:14:37 +0200 | [diff] [blame] | 47 | struct msgb *gsm0808_create_reset_ack(void); |
Philipp Maier | 1a146c8 | 2018-10-30 09:36:49 +0100 | [diff] [blame] | 48 | struct msgb *gsm0808_create_clear_command(uint8_t cause); |
Philipp Maier | 74c4c4e | 2019-02-04 16:42:28 +0100 | [diff] [blame] | 49 | struct msgb *gsm0808_create_clear_command2(uint8_t cause, bool csfb_ind); |
Holger Hans Peter Freyther | 280cd51 | 2010-04-15 10:10:39 +0200 | [diff] [blame] | 50 | struct msgb *gsm0808_create_clear_complete(void); |
Philipp Maier | b478dd3 | 2017-03-29 15:50:05 +0200 | [diff] [blame] | 51 | struct msgb *gsm0808_create_cipher(const struct gsm0808_encrypt_info *ei, |
| 52 | const uint8_t *cipher_response_mode); |
Neels Hofmeyr | 4a9756c | 2021-06-10 00:48:15 +0200 | [diff] [blame] | 53 | |
| 54 | struct gsm0808_cipher_mode_command { |
| 55 | struct gsm0808_encrypt_info ei; |
| 56 | |
| 57 | /*! 3GPP TS 48.008 3.2.2.34 Cipher Response Mode, optional IE */ |
| 58 | bool cipher_response_mode_present; |
| 59 | /*! 3GPP TS 48.008 3.2.2.34 Cipher Response Mode: |
| 60 | * 0 - IMEISV must not be included by the Mobile Station; |
| 61 | * 1 - IMEISV must be included by the Mobile Station. |
| 62 | */ |
| 63 | uint8_t cipher_response_mode; |
| 64 | |
| 65 | bool kc128_present; |
| 66 | uint8_t kc128[16]; |
| 67 | |
| 68 | /* more items are defined in the spec and may be added later */ |
| 69 | bool more_items; /*< always set this to false */ |
| 70 | }; |
| 71 | struct msgb *gsm0808_create_cipher2(const struct gsm0808_cipher_mode_command *cmc); |
| 72 | |
Holger Hans Peter Freyther | 81716d5 | 2010-04-17 06:16:35 +0200 | [diff] [blame] | 73 | struct msgb *gsm0808_create_cipher_complete(struct msgb *layer3, uint8_t alg_id); |
Max | aa93463 | 2018-11-07 13:16:54 +0100 | [diff] [blame] | 74 | struct msgb *gsm0808_create_cipher_reject(enum gsm0808_cause cause); |
Max | ed651d2 | 2018-11-07 15:25:05 +0100 | [diff] [blame] | 75 | struct msgb *gsm0808_create_cipher_reject_ext(enum gsm0808_cause_class class, uint8_t ext); |
Harald Welte | e61d459 | 2022-11-03 11:05:58 +0100 | [diff] [blame] | 76 | struct msgb *gsm0808_create_classmark_request(void); |
Harald Welte | 07b625d | 2012-01-23 10:02:58 +0100 | [diff] [blame] | 77 | struct msgb *gsm0808_create_classmark_update(const uint8_t *cm2, uint8_t cm2_len, |
| 78 | const uint8_t *cm3, uint8_t cm3_len); |
Vadim Yanitskiy | fa6cd88 | 2020-08-26 18:03:59 +0700 | [diff] [blame] | 79 | struct msgb *gsm0808_create_sapi_reject_cause(uint8_t link_id, uint16_t cause); |
| 80 | struct msgb *gsm0808_create_sapi_reject(uint8_t link_id) |
| 81 | OSMO_DEPRECATED("Use gsm0808_create_sapi_reject_cause() instead"); |
Philipp Maier | c6144a2 | 2017-03-29 17:53:43 +0200 | [diff] [blame] | 82 | struct msgb *gsm0808_create_ass(const struct gsm0808_channel_type *ct, |
| 83 | const uint16_t *cic, |
| 84 | const struct sockaddr_storage *ss, |
| 85 | const struct gsm0808_speech_codec_list *scl, |
| 86 | const uint32_t *ci); |
Max | 5207432 | 2018-11-30 10:44:07 +0100 | [diff] [blame] | 87 | struct msgb *gsm0808_create_ass2(const struct gsm0808_channel_type *ct, |
| 88 | const uint16_t *cic, |
| 89 | const struct sockaddr_storage *ss, |
| 90 | const struct gsm0808_speech_codec_list *scl, |
| 91 | const uint32_t *ci, |
| 92 | const uint8_t *kc, const struct osmo_lcls *lcls); |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 93 | struct msgb *gsm0808_create_ass_compl(uint8_t rr_cause, uint8_t chosen_channel, |
| 94 | uint8_t encr_alg_id, uint8_t speech_mode, |
| 95 | const struct sockaddr_storage *ss, |
| 96 | const struct gsm0808_speech_codec *sc, |
| 97 | const struct gsm0808_speech_codec_list |
| 98 | *scl); |
Max | 414c8f5 | 2019-01-08 14:44:24 +0100 | [diff] [blame] | 99 | struct msgb *gsm0808_create_ass_compl2(uint8_t rr_cause, uint8_t chosen_channel, |
| 100 | uint8_t encr_alg_id, uint8_t speech_mode, |
| 101 | const struct sockaddr_storage *ss, |
| 102 | const struct gsm0808_speech_codec *sc, |
| 103 | const struct gsm0808_speech_codec_list *scl, |
| 104 | enum gsm0808_lcls_status lcls_bss_status); |
Holger Hans Peter Freyther | b60a4b3 | 2010-07-23 18:35:59 +0800 | [diff] [blame] | 105 | struct msgb *gsm0808_create_assignment_completed(uint8_t rr_cause, |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 106 | uint8_t chosen_channel, |
| 107 | uint8_t encr_alg_id, |
Holger Hans Peter Freyther | ba6172a | 2010-04-17 06:21:49 +0200 | [diff] [blame] | 108 | uint8_t speech_mode); |
Philipp Maier | fa896ab | 2017-03-27 16:55:32 +0200 | [diff] [blame] | 109 | struct msgb *gsm0808_create_ass_fail(uint8_t cause, const uint8_t *rr_cause, |
| 110 | const struct gsm0808_speech_codec_list |
| 111 | *scl); |
Holger Hans Peter Freyther | 280cd51 | 2010-04-15 10:10:39 +0200 | [diff] [blame] | 112 | struct msgb *gsm0808_create_assignment_failure(uint8_t cause, uint8_t *rr_cause); |
Holger Hans Peter Freyther | af270a4 | 2010-11-04 12:42:50 +0100 | [diff] [blame] | 113 | struct msgb *gsm0808_create_clear_rqst(uint8_t cause); |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 114 | struct msgb *gsm0808_create_paging2(const char *imsi, const uint32_t *tmsi, |
| 115 | const struct gsm0808_cell_id_list2 *cil, |
| 116 | const uint8_t *chan_needed); |
Philipp Maier | 3d48ec0 | 2017-03-29 17:37:55 +0200 | [diff] [blame] | 117 | struct msgb *gsm0808_create_paging(const char *imsi, const uint32_t *tmsi, |
| 118 | const struct gsm0808_cell_id_list *cil, |
Stefan Sperling | 11a4d9d | 2018-02-15 18:28:04 +0100 | [diff] [blame] | 119 | const uint8_t *chan_needed) |
| 120 | OSMO_DEPRECATED("use gsm0808_create_paging2 instead"); |
Max | 45f89c9 | 2018-12-19 19:35:26 +0100 | [diff] [blame] | 121 | struct msgb *gsm0808_create_lcls_conn_ctrl(enum gsm0808_lcls_config config, |
| 122 | enum gsm0808_lcls_control control); |
Harald Welte | 64e807c | 2018-05-29 21:00:56 +0200 | [diff] [blame] | 123 | struct msgb *gsm0808_create_lcls_conn_ctrl_ack(enum gsm0808_lcls_status status); |
| 124 | struct msgb *gsm0808_create_lcls_notification(enum gsm0808_lcls_status status, bool break_req); |
Harald Welte | 1bd726a | 2020-06-21 22:04:52 +0200 | [diff] [blame] | 125 | struct msgb *gsm0808_create_common_id(const char *imsi, |
| 126 | const struct osmo_plmn_id *selected_plmn_id, |
| 127 | const struct osmo_plmn_id *last_used_eutran_plnm_id); |
Harald Welte | 64e807c | 2018-05-29 21:00:56 +0200 | [diff] [blame] | 128 | |
Holger Hans Peter Freyther | 280cd51 | 2010-04-15 10:10:39 +0200 | [diff] [blame] | 129 | |
Neels Hofmeyr | 70aba3f | 2018-03-13 03:40:53 +0100 | [diff] [blame] | 130 | /*! 3GPP TS 48.008 §3.2.2.5.8 Old BSS to New BSS information */ |
| 131 | struct gsm0808_old_bss_to_new_bss_info { |
| 132 | bool extra_information_present; |
| 133 | struct { |
| 134 | bool prec; |
| 135 | bool lcs; |
| 136 | bool ue_prob; |
| 137 | } extra_information; |
| 138 | |
| 139 | bool current_channel_type_2_present; |
| 140 | struct { |
| 141 | uint8_t mode; |
| 142 | uint8_t field; |
| 143 | } current_channel_type_2; |
| 144 | |
Pau Espin Pedrol | 1b625cb | 2021-04-14 21:27:31 +0200 | [diff] [blame] | 145 | bool last_eutran_plmn_id_present; |
| 146 | struct osmo_plmn_id last_eutran_plmn_id; |
| 147 | |
Neels Hofmeyr | 70aba3f | 2018-03-13 03:40:53 +0100 | [diff] [blame] | 148 | /* more items are defined in the spec and may be added later */ |
Neels Hofmeyr | 60f3153 | 2018-04-16 22:42:09 +0200 | [diff] [blame] | 149 | bool more_items; /*< always set this to false */ |
Neels Hofmeyr | 70aba3f | 2018-03-13 03:40:53 +0100 | [diff] [blame] | 150 | }; |
| 151 | |
| 152 | /*! 3GPP TS 48.008 §3.2.1.9 HANDOVER REQUIRED */ |
| 153 | struct gsm0808_handover_required { |
| 154 | uint16_t cause; |
| 155 | struct gsm0808_cell_id_list2 cil; |
| 156 | |
| 157 | bool current_channel_type_1_present; |
| 158 | uint8_t current_channel_type_1; |
| 159 | |
| 160 | bool speech_version_used_present; |
Neels Hofmeyr | 302aafc | 2019-04-10 19:23:45 +0200 | [diff] [blame] | 161 | enum gsm0808_permitted_speech speech_version_used; |
Neels Hofmeyr | 70aba3f | 2018-03-13 03:40:53 +0100 | [diff] [blame] | 162 | |
| 163 | bool old_bss_to_new_bss_info_present; |
| 164 | struct gsm0808_old_bss_to_new_bss_info old_bss_to_new_bss_info; |
| 165 | |
| 166 | /* more items are defined in the spec and may be added later */ |
Neels Hofmeyr | 60f3153 | 2018-04-16 22:42:09 +0200 | [diff] [blame] | 167 | bool more_items; /*< always set this to false */ |
Neels Hofmeyr | 70aba3f | 2018-03-13 03:40:53 +0100 | [diff] [blame] | 168 | }; |
| 169 | struct msgb *gsm0808_create_handover_required(const struct gsm0808_handover_required *params); |
| 170 | |
Neels Hofmeyr | f7e9c51 | 2019-03-06 04:25:38 +0100 | [diff] [blame] | 171 | /*! 3GPP TS 48.008 §3.2.1.37 HANDOVER REQUIRED REJECT */ |
| 172 | struct gsm0808_handover_required_reject { |
| 173 | uint16_t cause; |
| 174 | |
| 175 | /* more items are defined in the spec and may be added later */ |
| 176 | bool more_items; /*< always set this to false */ |
| 177 | }; |
| 178 | struct msgb *gsm0808_create_handover_required_reject(const struct gsm0808_handover_required_reject *params); |
| 179 | |
| 180 | /*! 3GPP TS 48.008 §3.2.1.8 HANDOVER REQUEST */ |
| 181 | struct gsm0808_handover_request { |
| 182 | struct gsm0808_channel_type channel_type; |
| 183 | struct gsm0808_encrypt_info encryption_information; |
| 184 | struct osmo_gsm48_classmark classmark_information; |
| 185 | struct gsm0808_cell_id cell_identifier_serving; |
| 186 | struct gsm0808_cell_id cell_identifier_target; |
| 187 | enum gsm0808_cause cause; |
| 188 | |
| 189 | bool current_channel_type_1_present; |
| 190 | uint8_t current_channel_type_1; |
| 191 | |
| 192 | enum gsm0808_permitted_speech speech_version_used; |
| 193 | |
| 194 | uint8_t chosen_encryption_algorithm_serving; |
| 195 | |
| 196 | /*! Pass either old_bss_to_new_bss_info or old_bss_to_new_bss_info_raw. */ |
| 197 | bool old_bss_to_new_bss_info_present; |
| 198 | struct gsm0808_old_bss_to_new_bss_info old_bss_to_new_bss_info; |
| 199 | /*! To feed the Old BSS to New BSS Information IE unchanged from the Handover Required message without having to |
| 200 | * decode it. Pass either old_bss_to_new_bss_info or old_bss_to_new_bss_info_raw. Omit the TL part. */ |
| 201 | const uint8_t *old_bss_to_new_bss_info_raw; |
| 202 | uint8_t old_bss_to_new_bss_info_raw_len; |
| 203 | |
| 204 | const char *imsi; |
| 205 | |
| 206 | const struct sockaddr_storage *aoip_transport_layer; |
| 207 | |
| 208 | const struct gsm0808_speech_codec_list *codec_list_msc_preferred; |
| 209 | |
| 210 | bool call_id_present; |
| 211 | uint32_t call_id; |
| 212 | |
| 213 | const uint8_t *global_call_reference; |
| 214 | uint8_t global_call_reference_len; |
| 215 | |
| 216 | /* more items are defined in the spec and may be added later */ |
Neels Hofmeyr | e4378b7 | 2021-06-10 00:54:35 +0200 | [diff] [blame] | 217 | bool more_items; /*!< set this to true iff any fields below are used */ |
| 218 | |
| 219 | bool kc128_present; |
| 220 | uint8_t kc128[16]; |
| 221 | |
| 222 | bool more_items2; /*!< always set this to false */ |
Neels Hofmeyr | f7e9c51 | 2019-03-06 04:25:38 +0100 | [diff] [blame] | 223 | }; |
| 224 | struct msgb *gsm0808_create_handover_request(const struct gsm0808_handover_request *params); |
| 225 | |
Harald Welte | aa98c48 | 2019-05-06 10:31:35 +0200 | [diff] [blame] | 226 | struct msgb *gsm0808_create_handover_request_ack(const uint8_t *l3_info, uint8_t l3_info_len, |
| 227 | uint8_t chosen_channel, uint8_t chosen_encr_alg, |
| 228 | uint8_t chosen_speech_version); |
| 229 | |
Neels Hofmeyr | 73b943e | 2019-03-14 04:10:25 +0100 | [diff] [blame] | 230 | struct gsm0808_handover_request_ack { |
| 231 | const uint8_t *l3_info; |
| 232 | uint8_t l3_info_len; |
| 233 | |
| 234 | bool chosen_channel_present; |
| 235 | uint8_t chosen_channel; |
| 236 | |
| 237 | /*! For A5/N set chosen_encr_alg = N+1, e.g. chosen_encr_alg = 1 means A5/0 (no encryption), 2 means A5/1, 4 |
| 238 | * means A5/3. Set chosen_encr_alg = 0 to omit the Chosen Encryption Algorithm IE. */ |
| 239 | uint8_t chosen_encr_alg; |
| 240 | |
| 241 | /* chosen_speech_version == 0 omits the IE */ |
| 242 | enum gsm0808_permitted_speech chosen_speech_version; |
| 243 | |
| 244 | bool speech_codec_chosen_present; |
| 245 | struct gsm0808_speech_codec speech_codec_chosen; |
| 246 | |
| 247 | const struct sockaddr_storage *aoip_transport_layer; |
| 248 | |
Neels Hofmeyr | a25a6dc | 2022-02-23 14:25:22 +0100 | [diff] [blame] | 249 | bool more_items; /*!< set this to true iff any fields below are used */ |
| 250 | |
| 251 | struct gsm0808_speech_codec_list codec_list_bss_supported; /*< omit when .len == 0 */ |
| 252 | |
Neels Hofmeyr | 73b943e | 2019-03-14 04:10:25 +0100 | [diff] [blame] | 253 | /* more items are defined in the spec and may be added later */ |
Neels Hofmeyr | a25a6dc | 2022-02-23 14:25:22 +0100 | [diff] [blame] | 254 | bool more_items2; /*!< always set this to false */ |
Neels Hofmeyr | 73b943e | 2019-03-14 04:10:25 +0100 | [diff] [blame] | 255 | }; |
| 256 | struct msgb *gsm0808_create_handover_request_ack2(const struct gsm0808_handover_request_ack *params); |
Neels Hofmeyr | b662b36 | 2018-04-16 22:31:15 +0200 | [diff] [blame] | 257 | |
Neels Hofmeyr | f7e9c51 | 2019-03-06 04:25:38 +0100 | [diff] [blame] | 258 | struct gsm0808_handover_command { |
| 259 | const uint8_t *l3_info; |
| 260 | uint8_t l3_info_len; |
| 261 | |
| 262 | struct gsm0808_cell_id cell_identifier; |
| 263 | |
| 264 | const uint8_t *new_bss_to_old_bss_info_raw; |
| 265 | size_t new_bss_to_old_bss_info_raw_len; |
| 266 | |
| 267 | /* more items are defined in the spec and may be added later */ |
| 268 | bool more_items; /*!< always set this to false */ |
| 269 | }; |
| 270 | struct msgb *gsm0808_create_handover_command(const struct gsm0808_handover_command *params); |
| 271 | |
Harald Welte | e61d459 | 2022-11-03 11:05:58 +0100 | [diff] [blame] | 272 | struct msgb *gsm0808_create_handover_detect(void); |
| 273 | struct msgb *gsm0808_create_handover_succeeded(void); |
Neels Hofmeyr | 60f3153 | 2018-04-16 22:42:09 +0200 | [diff] [blame] | 274 | |
| 275 | struct gsm0808_handover_complete { |
| 276 | bool rr_cause_present; |
| 277 | uint8_t rr_cause; |
| 278 | |
| 279 | bool speech_codec_chosen_present; |
| 280 | struct gsm0808_speech_codec speech_codec_chosen; |
| 281 | |
| 282 | struct gsm0808_speech_codec_list codec_list_bss_supported; /*< omit when .len == 0 */ |
| 283 | |
| 284 | bool chosen_encr_alg_present; |
| 285 | uint8_t chosen_encr_alg; |
Pau Espin Pedrol | 4da98cc | 2021-04-14 21:28:01 +0200 | [diff] [blame] | 286 | |
Neels Hofmeyr | 60f3153 | 2018-04-16 22:42:09 +0200 | [diff] [blame] | 287 | bool chosen_channel_present; |
| 288 | uint8_t chosen_channel; |
| 289 | |
| 290 | bool lcls_bss_status_present; |
| 291 | enum gsm0808_lcls_status lcls_bss_status; |
| 292 | |
| 293 | /* more items are defined in the spec and may be added later */ |
| 294 | bool more_items; /*< always set this to false */ |
| 295 | }; |
| 296 | struct msgb *gsm0808_create_handover_complete(const struct gsm0808_handover_complete *params); |
| 297 | |
| 298 | struct gsm0808_handover_failure { |
| 299 | uint16_t cause; |
| 300 | |
| 301 | bool rr_cause_present; |
| 302 | uint8_t rr_cause; |
| 303 | |
| 304 | struct gsm0808_speech_codec_list codec_list_bss_supported; /*< omit when .len == 0 */ |
| 305 | |
| 306 | /* more items are defined in the spec and may be added later */ |
| 307 | bool more_items; /*< always set this to false */ |
| 308 | }; |
| 309 | struct msgb *gsm0808_create_handover_failure(const struct gsm0808_handover_failure *params); |
| 310 | |
Philipp Maier | 225bdf4 | 2018-10-30 14:56:59 +0100 | [diff] [blame] | 311 | struct gsm0808_handover_performed { |
| 312 | uint16_t cause; |
| 313 | struct gsm0808_cell_id cell_id; |
| 314 | |
| 315 | bool chosen_channel_present; |
| 316 | uint8_t chosen_channel; |
| 317 | |
| 318 | bool chosen_encr_alg_present; |
| 319 | uint8_t chosen_encr_alg; |
| 320 | |
| 321 | bool speech_version_chosen_present; |
Neels Hofmeyr | 302aafc | 2019-04-10 19:23:45 +0200 | [diff] [blame] | 322 | enum gsm0808_permitted_speech speech_version_chosen; |
Philipp Maier | 225bdf4 | 2018-10-30 14:56:59 +0100 | [diff] [blame] | 323 | |
| 324 | bool speech_codec_chosen_present; |
| 325 | struct gsm0808_speech_codec speech_codec_chosen; |
| 326 | |
| 327 | bool lcls_bss_status_present; |
| 328 | enum gsm0808_lcls_status lcls_bss_status; |
| 329 | |
| 330 | /* more items are defined in the spec and may be added later */ |
| 331 | bool more_items; /*< always set this to false */ |
| 332 | }; |
| 333 | struct msgb *gsm0808_create_handover_performed(const struct gsm0808_handover_performed *params); |
| 334 | |
Andreas Eversberg | 532b8e9 | 2023-06-09 15:24:59 +0200 | [diff] [blame] | 335 | /*! 3GPP TS 48.008 §3.2.1.50 VGCS/VBS SETUP */ |
| 336 | struct gsm0808_vgcs_vbs_setup { |
| 337 | struct gsm0808_group_callref callref; |
| 338 | |
| 339 | bool priority_present; |
| 340 | struct gsm0808_priority priority; |
| 341 | |
| 342 | bool vgcs_feature_flags_present; |
| 343 | struct gsm0808_vgcs_feature_flags flags; |
| 344 | }; |
| 345 | struct msgb *gsm0808_create_vgcs_vbs_setup(const struct gsm0808_vgcs_vbs_setup *params); |
| 346 | |
| 347 | /*! 3GPP TS 48.008 §3.2.1.51 VGCS/VBS SETUP ACK */ |
| 348 | struct gsm0808_vgcs_vbs_setup_ack { |
| 349 | bool vgcs_feature_flags_present; |
| 350 | struct gsm0808_vgcs_feature_flags flags; |
| 351 | }; |
| 352 | struct msgb *gsm0808_create_vgcs_vbs_setup_ack(const struct gsm0808_vgcs_vbs_setup_ack *params); |
| 353 | |
| 354 | /*! 3GPP TS 48.008 §3.2.1.52 VGCS/VBS SETUP REFUSE */ |
| 355 | struct msgb *gsm0808_create_vgcs_vbs_setup_refuse(enum gsm0808_cause cause); |
| 356 | |
| 357 | /*! 3GPP TS 48.008 §3.2.1.53 VGCS/VBS ASSIGNMENT REQUEST */ |
| 358 | struct gsm0808_vgcs_vbs_assign_req { |
| 359 | struct gsm0808_channel_type channel_type; |
| 360 | enum gsm0808_assignment_requirement ass_req; |
| 361 | struct gsm0808_cell_id cell_identifier; |
| 362 | struct gsm0808_group_callref callref; |
| 363 | |
| 364 | bool priority_present; |
| 365 | struct gsm0808_priority priority; |
| 366 | |
| 367 | bool cic_present; |
| 368 | uint16_t cic; |
| 369 | |
| 370 | bool downlink_dtx_flag_present; |
| 371 | enum gsm0808_downlink_dtx_flag downlink_dtx_flag; |
| 372 | |
| 373 | bool encryption_information_present; |
| 374 | struct gsm0808_encrypt_info encryption_information; |
| 375 | |
| 376 | bool vstk_rand_present; |
| 377 | uint8_t vstk_rand[5]; |
| 378 | |
| 379 | bool vstk_present; |
| 380 | uint8_t vstk[16]; |
| 381 | |
| 382 | bool cils_present; |
| 383 | struct gsm0808_cell_id_list_segment cils; |
| 384 | |
| 385 | bool aoip_transport_layer_present; |
| 386 | struct sockaddr_storage aoip_transport_layer; |
| 387 | |
| 388 | bool call_id_present; |
| 389 | uint32_t call_id; |
| 390 | |
| 391 | bool codec_list_present; |
| 392 | struct gsm0808_speech_codec_list codec_list_msc_preferred; |
| 393 | }; |
| 394 | struct msgb *gsm0808_create_vgcs_vbs_assign_req(const struct gsm0808_vgcs_vbs_assign_req *params); |
| 395 | |
| 396 | /*! 3GPP TS 48.008 §3.2.1.54 VGCS/VBS ASSIGNMENT RESULT */ |
| 397 | struct gsm0808_vgcs_vbs_assign_res { |
| 398 | struct gsm0808_channel_type channel_type; |
| 399 | struct gsm0808_cell_id cell_identifier; |
| 400 | |
| 401 | bool chosen_channel_present; |
| 402 | uint8_t chosen_channel; |
| 403 | |
| 404 | bool cic_present; |
| 405 | uint16_t cic; |
| 406 | |
| 407 | bool circuit_pool_present; |
| 408 | uint8_t circuit_pool; |
| 409 | |
| 410 | bool aoip_transport_layer_present; |
| 411 | struct sockaddr_storage aoip_transport_layer; |
| 412 | |
| 413 | bool codec_present; |
| 414 | struct gsm0808_speech_codec codec_msc_chosen; |
| 415 | |
| 416 | bool call_id_present; |
| 417 | uint32_t call_id; |
| 418 | }; |
| 419 | struct msgb *gsm0808_create_vgcs_vbs_assign_res(const struct gsm0808_vgcs_vbs_assign_res *params); |
| 420 | |
| 421 | /*! 3GPP TS 48.008 §3.2.1.55 VGCS/VBS ASSIGNMENT FAILURE */ |
| 422 | struct gsm0808_vgcs_vbs_assign_fail { |
| 423 | enum gsm0808_cause cause; |
| 424 | |
| 425 | bool circuit_pool_present; |
| 426 | uint8_t circuit_pool; |
| 427 | |
| 428 | bool cpl_present; |
| 429 | struct gsm0808_circuit_pool_list cpl; |
| 430 | |
| 431 | bool codec_list_present; |
| 432 | struct gsm0808_speech_codec_list codec_list_bss_supported; |
| 433 | }; |
| 434 | struct msgb *gsm0808_create_vgcs_vbs_assign_fail(const struct gsm0808_vgcs_vbs_assign_fail *params); |
| 435 | |
| 436 | /*! 3GPP TS 48.008 §3.2.1.57 (VGCS) UPLINK REQUEST */ |
| 437 | struct gsm0808_uplink_request { |
| 438 | bool talker_priority_present; |
| 439 | enum gsm0808_talker_priority talker_priority; |
| 440 | |
| 441 | bool cell_identifier_present; |
| 442 | struct gsm0808_cell_id cell_identifier; |
| 443 | |
| 444 | bool l3_present; |
| 445 | struct gsm0808_layer_3_information l3; |
| 446 | |
| 447 | bool mi_present; |
| 448 | struct osmo_mobile_identity mi; |
| 449 | }; |
| 450 | struct msgb *gsm0808_create_uplink_request(const struct gsm0808_uplink_request *params); |
| 451 | |
| 452 | /*! 3GPP TS 48.008 §3.2.1.58 (VGCS) UPLINK REQUEST ACKNOWLEDGE */ |
| 453 | struct gsm0808_uplink_request_ack { |
| 454 | bool talker_priority_present; |
| 455 | enum gsm0808_talker_priority talker_priority; |
| 456 | |
| 457 | bool emerg_set_ind_present; |
| 458 | |
| 459 | bool talker_identity_present; |
| 460 | struct gsm0808_talker_identity talker_identity; |
| 461 | }; |
| 462 | struct msgb *gsm0808_create_uplink_request_ack(const struct gsm0808_uplink_request_ack *params); |
| 463 | |
| 464 | /*! 3GPP TS 48.008 §3.2.1.59 (VGCS) UPLINK REQUEST CONFIRM */ |
| 465 | struct gsm0808_uplink_request_cnf { |
| 466 | struct gsm0808_cell_id cell_identifier; |
| 467 | |
| 468 | bool talker_identity_present; |
| 469 | struct gsm0808_talker_identity talker_identity; |
| 470 | |
| 471 | /* mandatory! */ |
| 472 | struct gsm0808_layer_3_information l3; |
| 473 | }; |
| 474 | struct msgb *gsm0808_create_uplink_request_cnf(const struct gsm0808_uplink_request_cnf *params); |
| 475 | |
| 476 | /*! 3GPP TS 48.008 §3.2.1.59a (VGCS) UPLINK APPLICATION DATA */ |
| 477 | struct gsm0808_uplink_app_data { |
| 478 | struct gsm0808_cell_id cell_identifier; |
| 479 | struct gsm0808_layer_3_information l3; |
| 480 | bool bt_ind; |
| 481 | }; |
| 482 | struct msgb *gsm0808_create_uplink_app_data(const struct gsm0808_uplink_app_data *params); |
| 483 | |
| 484 | /*! 3GPP TS 48.008 §3.2.1.60 (VGCS) UPLINK RELEASE INDICATION */ |
| 485 | struct gsm0808_uplink_release_ind { |
| 486 | enum gsm0808_cause cause; |
| 487 | |
| 488 | bool talker_priority_present; |
| 489 | enum gsm0808_talker_priority talker_priority; |
| 490 | }; |
| 491 | struct msgb *gsm0808_create_uplink_release_ind(const struct gsm0808_uplink_release_ind *params); |
| 492 | |
| 493 | /*! 3GPP TS 48.008 §3.2.1.61 (VGCS) UPLINK REJECT COMMAND */ |
| 494 | struct gsm0808_uplink_reject_cmd { |
| 495 | enum gsm0808_cause cause; |
| 496 | |
| 497 | bool current_talker_priority_present; |
| 498 | enum gsm0808_talker_priority current_talker_priority; |
| 499 | bool rejected_talker_priority_present; |
| 500 | enum gsm0808_talker_priority rejected_talker_priority; |
| 501 | |
| 502 | bool talker_identity_present; |
| 503 | struct gsm0808_talker_identity talker_identity; |
| 504 | }; |
| 505 | struct msgb *gsm0808_create_uplink_reject_cmd(const struct gsm0808_uplink_reject_cmd *params); |
| 506 | |
| 507 | /*! 3GPP TS 48.008 §3.2.1.62 (VGCS) UPLINK RELEASE COMMAND */ |
| 508 | struct msgb *gsm0808_create_uplink_release_cmd(const enum gsm0808_cause cause); |
| 509 | |
| 510 | /*! 3GPP TS 48.008 §3.2.1.63 (VGCS) UPLINK SEIZED COMMAND */ |
| 511 | struct gsm0808_uplink_seized_cmd { |
| 512 | enum gsm0808_cause cause; |
| 513 | |
| 514 | bool talker_priority_present; |
| 515 | enum gsm0808_talker_priority talker_priority; |
| 516 | |
| 517 | bool emerg_set_ind_present; |
| 518 | |
| 519 | bool talker_identity_present; |
| 520 | struct gsm0808_talker_identity talker_identity; |
| 521 | }; |
| 522 | struct msgb *gsm0808_create_uplink_seized_cmd(const struct gsm0808_uplink_seized_cmd *params); |
| 523 | |
| 524 | /*! 3GPP TS 48.008 §3.2.1.78 VGCS ADDITIONAL INFORMATION */ |
| 525 | struct msgb *gsm0808_create_vgcs_additional_info(const struct gsm0808_talker_identity *ti); |
| 526 | |
| 527 | /*! 3GPP TS 48.008 §3.2.1.79 VGCS/VBS AREA CELL INFO */ |
| 528 | struct gsm0808_vgcs_vbs_area_cell_info { |
| 529 | struct gsm0808_cell_id_list_segment cils; |
| 530 | |
| 531 | bool ass_req_present; |
| 532 | enum gsm0808_assignment_requirement ass_req; |
| 533 | }; |
| 534 | struct msgb *gsm0808_create_vgcs_vbs_area_cell_info(const struct gsm0808_vgcs_vbs_area_cell_info *params); |
| 535 | |
| 536 | /*! 3GPP TS 48.008 §3.2.1.80 VGCS/VBS ASSIGNMENT STATUS */ |
| 537 | struct gsm0808_vgcs_vbs_assign_stat { |
| 538 | /* established cells */ |
| 539 | bool cils_est_present; |
| 540 | struct gsm0808_cell_id_list_segment cils_est; |
| 541 | |
| 542 | /* cells to be established */ |
| 543 | bool cils_tbe_present; |
| 544 | struct gsm0808_cell_id_list_segment cils_tbe; |
| 545 | |
| 546 | /* released cells - no user present */ |
| 547 | bool cils_rel_present; |
| 548 | struct gsm0808_cell_id_list_segment cils_rel; |
| 549 | |
| 550 | /* not established cells - no establishment possible */ |
| 551 | bool cils_ne_present; |
| 552 | struct gsm0808_cell_id_list_segment cils_ne; |
| 553 | |
| 554 | bool cell_status_present; |
| 555 | enum gsm0808_vgcs_vbs_cell_status cell_status; |
| 556 | }; |
| 557 | struct msgb *gsm0808_create_vgcs_vbs_assign_stat(const struct gsm0808_vgcs_vbs_assign_stat *params); |
| 558 | |
| 559 | /*! 3GPP TS 48.008 §3.2.1.81 VGCS SMS */ |
| 560 | struct msgb *gsm0808_create_vgcs_sms(const struct gsm0808_sms_to_vgcs *sms); |
| 561 | |
| 562 | /*! 3GPP TS 48.008 §3.2.1.82 (VGCS/VBS) NOTIFICATION DATA */ |
| 563 | struct gsm0808_notification_data { |
| 564 | struct gsm0808_application_data app_data; |
| 565 | struct gsm0808_data_identity data_ident; |
| 566 | |
| 567 | bool msisdn_present; |
| 568 | char msisdn[MSISDN_MAXLEN + 1]; |
| 569 | }; |
| 570 | struct msgb *gsm0808_create_notification_data(const struct gsm0808_notification_data *parms); |
| 571 | |
Holger Hans Peter Freyther | c25c668 | 2010-11-04 12:26:06 +0100 | [diff] [blame] | 572 | struct msgb *gsm0808_create_dtap(struct msgb *msg, uint8_t link_id); |
Holger Hans Peter Freyther | 9a3dec0 | 2010-05-16 08:15:40 +0800 | [diff] [blame] | 573 | void gsm0808_prepend_dtap_header(struct msgb *msg, uint8_t link_id); |
| 574 | |
Harald Welte | f4d45ab | 2011-07-16 12:13:00 +0200 | [diff] [blame] | 575 | const struct tlv_definition *gsm0808_att_tlvdef(void); |
Pau Espin Pedrol | cde4779 | 2021-04-19 12:24:02 +0200 | [diff] [blame] | 576 | extern const struct tlv_definition gsm0808_old_bss_to_new_bss_info_att_tlvdef; |
Holger Hans Peter Freyther | 280cd51 | 2010-04-15 10:10:39 +0200 | [diff] [blame] | 577 | |
Max | c0d1de3 | 2018-11-07 15:24:11 +0100 | [diff] [blame] | 578 | /*! Parse BSSAP TLV structure using \ref tlv_parse */ |
| 579 | #define osmo_bssap_tlv_parse(dec, buf, len) tlv_parse(dec, gsm0808_att_tlvdef(), buf, len, 0, 0) |
Neels Hofmeyr | d791327 | 2019-04-03 18:07:27 +0200 | [diff] [blame] | 580 | /*! Parse BSSAP TLV structure using \ref tlv_parse2 */ |
| 581 | #define osmo_bssap_tlv_parse2(dec, dec_multiples, buf, len) \ |
| 582 | tlv_parse2(dec, dec_multiples, gsm0808_att_tlvdef(), buf, len, 0, 0) |
Max | c0d1de3 | 2018-11-07 15:24:11 +0100 | [diff] [blame] | 583 | |
Harald Welte | 9b837e6 | 2011-07-11 17:43:19 +0200 | [diff] [blame] | 584 | const char *gsm0808_bssmap_name(uint8_t msg_type); |
| 585 | const char *gsm0808_bssap_name(uint8_t msg_type); |
Max | aa93463 | 2018-11-07 13:16:54 +0100 | [diff] [blame] | 586 | const char *gsm0808_cause_name(enum gsm0808_cause cause); |
| 587 | const char *gsm0808_cause_class_name(enum gsm0808_cause_class class); |
Harald Welte | 37b6165 | 2017-10-16 18:46:03 +0200 | [diff] [blame] | 588 | |
Alexander Chemeris | fdfe25b | 2020-05-12 23:21:56 +0300 | [diff] [blame] | 589 | /*! Parse Cause TLV 3GPP TS 08.08 §3.2.2.5 |
| 590 | * \returns Cause value */ |
| 591 | enum gsm0808_cause gsm0808_get_cause(const struct tlv_parsed *tp); |
| 592 | |
Alexander Chemeris | 22630e6 | 2020-05-13 00:44:04 +0300 | [diff] [blame] | 593 | const char *gsm0808_diagnostics_octet_location_str(uint8_t pointer); |
| 594 | const char *gsm0808_diagnostics_bit_location_str(uint8_t bit_pointer); |
| 595 | |
Harald Welte | ebd362d | 2018-06-02 14:11:19 +0200 | [diff] [blame] | 596 | extern const struct value_string gsm0808_lcls_config_names[]; |
| 597 | extern const struct value_string gsm0808_lcls_control_names[]; |
| 598 | extern const struct value_string gsm0808_lcls_status_names[]; |
| 599 | |
Max | e118ed2 | 2018-12-19 17:05:37 +0100 | [diff] [blame] | 600 | static inline const char *gsm0808_lcls_config_name(enum gsm0808_lcls_config val) { |
Harald Welte | ebd362d | 2018-06-02 14:11:19 +0200 | [diff] [blame] | 601 | return get_value_string(gsm0808_lcls_config_names, val); |
| 602 | } |
Max | e118ed2 | 2018-12-19 17:05:37 +0100 | [diff] [blame] | 603 | static inline const char *gsm0808_lcls_control_name(enum gsm0808_lcls_control val) { |
Harald Welte | ebd362d | 2018-06-02 14:11:19 +0200 | [diff] [blame] | 604 | return get_value_string(gsm0808_lcls_control_names, val); |
| 605 | } |
Max | e118ed2 | 2018-12-19 17:05:37 +0100 | [diff] [blame] | 606 | static inline const char *gsm0808_lcls_status_name(enum gsm0808_lcls_status val) { |
Harald Welte | ebd362d | 2018-06-02 14:11:19 +0200 | [diff] [blame] | 607 | return get_value_string(gsm0808_lcls_status_names, val); |
| 608 | } |
| 609 | |
Harald Welte | 37b6165 | 2017-10-16 18:46:03 +0200 | [diff] [blame] | 610 | /*! @} */ |