libosmogsm  1.0.1
Osmocom GSM library
gsm0808.h
Go to the documentation of this file.
1 
4 /*
5  * (C) 2009,2010 by Holger Hans Peter Freyther <zecke@selfish.org>
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  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  *
23  */
24 #pragma once
25 
26 #include "tlv.h"
29 #include <osmocom/gsm/gsm23003.h>
30 #include <osmocom/core/utils.h>
31 
32 #define BSSMAP_MSG_SIZE 512
33 #define BSSMAP_MSG_HEADROOM 128
34 
35 struct sockaddr_storage;
36 
37 struct msgb;
39 
40 struct msgb *gsm0808_create_layer3(struct msgb *msg_l3, uint16_t nc,
41  uint16_t cc, int lac, uint16_t _ci)
42  OSMO_DEPRECATED("Use gsm0808_create_layer3_2() instead, to not lose leading zeros in the MNC");
43 struct msgb *gsm0808_create_layer3_aoip(const struct msgb *msg_l3, uint16_t nc,
44  uint16_t cc, int lac, uint16_t _ci,
45  const struct gsm0808_speech_codec_list *scl)
46  OSMO_DEPRECATED("Use gsm0808_create_layer3_2() instead, to not lose leading zeros in the MNC");
47 struct msgb *gsm0808_create_layer3_2(const struct msgb *msg_l3, const struct osmo_cell_global_id *cell,
48  const struct gsm0808_speech_codec_list *scl);
49 struct msgb *gsm0808_create_reset(void);
50 struct msgb *gsm0808_create_reset_ack(void);
51 struct msgb *gsm0808_create_clear_command(uint8_t cause);
53 struct msgb *gsm0808_create_cipher(const struct gsm0808_encrypt_info *ei,
54  const uint8_t *cipher_response_mode);
55 struct msgb *gsm0808_create_cipher_complete(struct msgb *layer3, uint8_t alg_id);
57 struct msgb *gsm0808_create_cipher_reject_ext(enum gsm0808_cause_class class, uint8_t ext);
59 struct msgb *gsm0808_create_classmark_update(const uint8_t *cm2, uint8_t cm2_len,
60  const uint8_t *cm3, uint8_t cm3_len);
61 struct msgb *gsm0808_create_sapi_reject(uint8_t link_id);
62 struct msgb *gsm0808_create_ass(const struct gsm0808_channel_type *ct,
63  const uint16_t *cic,
64  const struct sockaddr_storage *ss,
65  const struct gsm0808_speech_codec_list *scl,
66  const uint32_t *ci);
67 struct msgb *gsm0808_create_ass2(const struct gsm0808_channel_type *ct,
68  const uint16_t *cic,
69  const struct sockaddr_storage *ss,
70  const struct gsm0808_speech_codec_list *scl,
71  const uint32_t *ci,
72  const uint8_t *kc, const struct osmo_lcls *lcls);
73 struct msgb *gsm0808_create_ass_compl(uint8_t rr_cause, uint8_t chosen_channel,
74  uint8_t encr_alg_id, uint8_t speech_mode,
75  const struct sockaddr_storage *ss,
76  const struct gsm0808_speech_codec *sc,
77  const struct gsm0808_speech_codec_list
78  *scl);
79 struct msgb *gsm0808_create_ass_compl2(uint8_t rr_cause, uint8_t chosen_channel,
80  uint8_t encr_alg_id, uint8_t speech_mode,
81  const struct sockaddr_storage *ss,
82  const struct gsm0808_speech_codec *sc,
83  const struct gsm0808_speech_codec_list *scl,
84  enum gsm0808_lcls_status lcls_bss_status);
85 struct msgb *gsm0808_create_assignment_completed(uint8_t rr_cause,
86  uint8_t chosen_channel,
87  uint8_t encr_alg_id,
88  uint8_t speech_mode);
89 struct msgb *gsm0808_create_ass_fail(uint8_t cause, const uint8_t *rr_cause,
90  const struct gsm0808_speech_codec_list
91  *scl);
92 struct msgb *gsm0808_create_assignment_failure(uint8_t cause, uint8_t *rr_cause);
93 struct msgb *gsm0808_create_clear_rqst(uint8_t cause);
94 struct msgb *gsm0808_create_paging2(const char *imsi, const uint32_t *tmsi,
95  const struct gsm0808_cell_id_list2 *cil,
96  const uint8_t *chan_needed);
97 struct msgb *gsm0808_create_paging(const char *imsi, const uint32_t *tmsi,
98  const struct gsm0808_cell_id_list *cil,
99  const uint8_t *chan_needed)
100  OSMO_DEPRECATED("use gsm0808_create_paging2 instead");
102  enum gsm0808_lcls_control control);
104 struct msgb *gsm0808_create_lcls_notification(enum gsm0808_lcls_status status, bool break_req);
105 
106 
110  struct {
111  bool prec;
112  bool lcs;
113  bool ue_prob;
114  } extra_information;
115 
117  struct {
118  uint8_t mode;
119  uint8_t field;
120  } current_channel_type_2;
121 
122  /* more items are defined in the spec and may be added later */
123  bool more_items; /*< always set this to false */
124 };
125 
128  uint16_t cause;
130 
133 
136 
138  struct gsm0808_old_bss_to_new_bss_info old_bss_to_new_bss_info;
139 
140  /* more items are defined in the spec and may be added later */
141  bool more_items; /*< always set this to false */
142 };
144 
145 struct msgb *gsm0808_create_handover_request_ack(const uint8_t *l3_info, uint8_t l3_info_len,
146  uint8_t chosen_channel, uint8_t chosen_encr_alg,
147  uint8_t chosen_speech_version);
148 
150 
153  uint8_t rr_cause;
154 
156  struct gsm0808_speech_codec speech_codec_chosen;
157 
158  struct gsm0808_speech_codec_list codec_list_bss_supported; /*< omit when .len == 0 */
159 
162 
164  uint8_t chosen_channel;
165 
167  enum gsm0808_lcls_status lcls_bss_status;
168 
169  /* more items are defined in the spec and may be added later */
170  bool more_items; /*< always set this to false */
171 };
173 
175  uint16_t cause;
176 
178  uint8_t rr_cause;
179 
180  struct gsm0808_speech_codec_list codec_list_bss_supported; /*< omit when .len == 0 */
181 
182  /* more items are defined in the spec and may be added later */
183  bool more_items; /*< always set this to false */
184 };
186 
188  uint16_t cause;
189  struct gsm0808_cell_id cell_id;
190 
192  uint8_t chosen_channel;
193 
196 
199 
201  struct gsm0808_speech_codec speech_codec_chosen;
202 
204  enum gsm0808_lcls_status lcls_bss_status;
205 
206  /* more items are defined in the spec and may be added later */
207  bool more_items; /*< always set this to false */
208 };
210 
211 struct msgb *gsm0808_create_dtap(struct msgb *msg, uint8_t link_id);
212 void gsm0808_prepend_dtap_header(struct msgb *msg, uint8_t link_id);
213 
214 const struct tlv_definition *gsm0808_att_tlvdef(void);
215 
217 #define osmo_bssap_tlv_parse(dec, buf, len) tlv_parse(dec, gsm0808_att_tlvdef(), buf, len, 0, 0)
218 
219 const char *gsm0808_bssmap_name(uint8_t msg_type);
220 const char *gsm0808_bssap_name(uint8_t msg_type);
221 const char *gsm0808_cause_name(enum gsm0808_cause cause);
222 const char *gsm0808_cause_class_name(enum gsm0808_cause_class class);
223 
224 extern const struct value_string gsm0808_lcls_config_names[];
225 extern const struct value_string gsm0808_lcls_control_names[];
226 extern const struct value_string gsm0808_lcls_status_names[];
227 
228 static inline const char *gsm0808_lcls_config_name(enum gsm0808_lcls_config val) {
230 }
231 static inline const char *gsm0808_lcls_control_name(enum gsm0808_lcls_control val) {
233 }
234 static inline const char *gsm0808_lcls_status_name(enum gsm0808_lcls_status val) {
236 }
237 
uint8_t msg_type
Definition: gsm_04_08.h:807
const struct value_string gsm0808_lcls_status_names[]
Definition: gsm0808.c:1450
struct msgb * gsm0808_create_assignment_completed(uint8_t rr_cause, uint8_t chosen_channel, uint8_t encr_alg_id, uint8_t speech_mode)
Create BSSMAP Assignment Completed message.
Definition: gsm0808.c:610
bool prec
Definition: gsm0808.h:111
const char * gsm0808_cause_class_name(enum gsm0808_cause_class class)
Return string name of BSSMAP Cause Class name.
Definition: gsm0808.c:1413
bool speech_version_used_present
Definition: gsm0808.h:134
struct msgb * gsm0808_create_handover_detect()
Create BSSMAP HANDOVER DETECT message, 3GPP TS 48.008 3.2.1.40.
Definition: gsm0808.c:868
bool old_bss_to_new_bss_info_present
Definition: gsm0808.h:137
struct msgb * gsm0808_create_reset_ack(void)
Create BSSMAP RESET ACK message.
Definition: gsm0808.c:152
struct msgb * gsm0808_create_assignment_failure(uint8_t cause, uint8_t *rr_cause)
Create BSSMAP Assignment Failure message.
Definition: gsm0808.c:657
const char * get_value_string(const struct value_string *vs, uint32_t val)
Parsed representation of a Cell Identifier List IE (3GPP TS 48.008 3.2.2.27).
Definition: gsm0808_utils.h:56
struct msgb * gsm0808_create_cipher_reject_ext(enum gsm0808_cause_class class, uint8_t ext)
Create BSSMAP Cipher Mode Reject message.
Definition: gsm0808.c:287
struct msgb * gsm0808_create_lcls_conn_ctrl(enum gsm0808_lcls_config config, enum gsm0808_lcls_control control)
Create BSSMAP LCLS CONNECT CONTROL message (TS 48.008 3.2.1.91).
Definition: gsm0808.c:315
uint8_t field
Definition: gsm0808.h:119
gsm0808_cause_class
Definition: gsm_08_08.h:393
uint16_t cause
Definition: gsm0808.h:128
LCLS-related parameters from 3GPP TS 48.008.
Definition: gsm0808_utils.h:63
struct msgb * gsm0808_create_paging(const char *imsi, const uint32_t *tmsi, const struct gsm0808_cell_id_list *cil, const uint8_t *chan_needed) OSMO_DEPRECATED("use gsm0808_create_paging2 instead")
DEPRECATED: Use gsm0808_create_paging2 instead.
Definition: gsm0808.c:746
struct msgb * gsm0808_create_sapi_reject(uint8_t link_id)
Create BSSMAP SAPI N Reject message.
Definition: gsm0808.c:417
struct msgb * gsm0808_create_cipher_reject(enum gsm0808_cause cause)
Create BSSMAP Cipher Mode Reject message.
Definition: gsm0808.c:267
gsm0808_lcls_control
Definition: gsm_08_08.h:588
gsm0808_lcls_status
Definition: gsm_08_08.h:598
uint8_t rr_cause
Definition: gsm0808.h:178
struct msgb * gsm0808_create_paging2(const char *imsi, const uint32_t *tmsi, const struct gsm0808_cell_id_list2 *cil, const uint8_t *chan_needed)
Create BSSMAP PAGING message.
Definition: gsm0808.c:688
struct msgb * gsm0808_create_reset(void)
Create BSSMAP RESET message.
Definition: gsm0808.c:135
uint16_t cause
Definition: gsm0808.h:188
uint8_t cause
Definition: gsm_04_08.h:807
bool more_items
Definition: gsm0808.h:141
bool more_items
Definition: gsm0808.h:207
struct msgb * gsm0808_create_ass_fail(uint8_t cause, const uint8_t *rr_cause, const struct gsm0808_speech_codec_list *scl)
Create BSSMAP Assignment Failure message.
Definition: gsm0808.c:624
struct msgb * gsm0808_create_handover_required(const struct gsm0808_handover_required *params)
Create BSSMAP HANDOVER REQUIRED message.
Definition: gsm0808.c:801
uint8_t speech_version_chosen
Definition: gsm0808.h:198
uint8_t link_id
Definition: gsm_08_08.h:470
static const char * gsm0808_lcls_control_name(enum gsm0808_lcls_control val)
Definition: gsm0808.h:231
struct msgb * gsm0808_create_lcls_conn_ctrl_ack(enum gsm0808_lcls_status status)
Create BSSMAP LCLS CONNECT CONTROL ACK message (TS 48.008 3.2.1.92).
Definition: gsm0808.c:341
struct msgb * gsm0808_create_classmark_request()
Create BSSMAP Classmark Request message.
Definition: gsm0808.c:377
bool more_items
Definition: gsm0808.h:123
struct msgb * gsm0808_create_classmark_update(const uint8_t *cm2, uint8_t cm2_len, const uint8_t *cm3, uint8_t cm3_len)
Create BSSMAP Classmark Update message.
Definition: gsm0808.c:395
struct msgb * gsm0808_create_dtap(struct msgb *msg, uint8_t link_id)
Create BSSMAP DTAP message.
Definition: gsm0808.c:1015
Definition: gsm_08_08.h:539
Definition: gsm0808.h:151
const char * gsm0808_bssmap_name(uint8_t msg_type)
Return string name of BSSMAP Message Type.
Definition: gsm0808.c:1276
bool chosen_channel_present
Definition: gsm0808.h:163
struct msgb * gsm0808_create_handover_complete(const struct gsm0808_handover_complete *params)
Create BSSMAP HANDOVER COMPLETE message, 3GPP TS 48.008 3.2.1.12.
Definition: gsm0808.c:887
uint8_t rr_cause
Definition: gsm_04_08.h:805
3GPP TS 48.008 §3.2.1.9 HANDOVER REQUIRED
Definition: gsm0808.h:127
struct msgb * gsm0808_create_cipher(const struct gsm0808_encrypt_info *ei, const uint8_t *cipher_response_mode)
Create BSSMAP Cipher Mode Command message.
Definition: gsm0808.c:202
bool speech_version_chosen_present
Definition: gsm0808.h:197
struct msgb to not lose leading zeros in the MNC
Definition: gsm0808.h:42
uint8_t chosen_channel
Definition: gsm0808.h:192
struct msgb * gsm0808_create_layer3_aoip(const struct msgb *msg_l3, uint16_t nc, uint16_t cc, int lac, uint16_t _ci, const struct gsm0808_speech_codec_list *scl) OSMO_DEPRECATED("Use gsm0808_create_layer3_2() instead
Create "Complete L3 Info" for AoIP, legacy implementation.
Definition: gsm0808.c:46
struct msgb * gsm0808_create_ass(const struct gsm0808_channel_type *ct, const uint16_t *cic, const struct sockaddr_storage *ss, const struct gsm0808_speech_codec_list *scl, const uint32_t *ci)
Create BSSMAP Assignment Request message, 3GPP TS 48.008 §3.2.1.1.
Definition: gsm0808.c:513
const struct tlv_definition * gsm0808_att_tlvdef(void)
Definition: gsm0808.c:1170
gsm0808_cause
Definition: gsm_08_08.h:326
bool ue_prob
Definition: gsm0808.h:113
Definition: gsm23003.h:28
const char * gsm0808_bssap_name(uint8_t msg_type)
Return string name of BSSAP Message Type.
Definition: gsm0808.c:1288
static const char * gsm0808_lcls_config_name(enum gsm0808_lcls_config val)
Definition: gsm0808.h:228
uint16_t cause
Definition: gsm0808.h:175
const struct value_string gsm0808_lcls_control_names[]
Definition: gsm0808.c:1440
3GPP TS 48.008 §3.2.2.5.8 Old BSS to New BSS information
Definition: gsm0808.h:108
bool lcls_bss_status_present
Definition: gsm0808.h:166
struct gsm48_classmark2 cm2
Definition: gsm_04_08.h:806
bool chosen_channel_present
Definition: gsm0808.h:191
struct msgb * gsm0808_create_ass_compl(uint8_t rr_cause, uint8_t chosen_channel, uint8_t encr_alg_id, uint8_t speech_mode, const struct sockaddr_storage *ss, const struct gsm0808_speech_codec *sc, const struct gsm0808_speech_codec_list *scl)
Create BSSMAP Assignment Completed message.
Definition: gsm0808.c:594
bool chosen_encr_alg_present
Definition: gsm0808.h:194
uint8_t chosen_encr_alg
Definition: gsm0808.h:161
Definition: gsm0808.h:187
uint8_t speech_version_used
Definition: gsm0808.h:135
struct msgb * gsm0808_create_clear_complete(void)
Create BSSMAP Clear Complete message.
Definition: gsm0808.c:167
Definition: gsm0808.h:174
const struct value_string gsm0808_lcls_config_names[]
Definition: gsm0808.c:1424
struct msgb * gsm0808_create_clear_rqst(uint8_t cause)
Create BSSMAP Clear Request message.
Definition: gsm0808.c:666
bool lcs
Definition: gsm0808.h:112
uint8_t mode
Definition: gsm0808.h:118
bool chosen_encr_alg_present
Definition: gsm0808.h:160
Definition: gsm_08_08.h:546
uint8_t chosen_encr_alg
Definition: gsm0808.h:195
uint8_t chosen_channel
Definition: gsm0808.h:164
bool more_items
Definition: gsm0808.h:183
bool lcls_bss_status_present
Definition: gsm0808.h:203
struct msgb * gsm0808_create_layer3_2(const struct msgb *msg_l3, const struct osmo_cell_global_id *cell, const struct gsm0808_speech_codec_list *scl)
Create "Complete L3 Info" for AoIP.
Definition: gsm0808.c:69
bool rr_cause_present
Definition: gsm0808.h:177
bool speech_codec_chosen_present
Definition: gsm0808.h:200
struct msgb * gsm0808_create_handover_performed(const struct gsm0808_handover_performed *params)
Create BSSMAP HANDOVER PERFORMED message, 3GPP TS 48.008 3.2.1.25.
Definition: gsm0808.c:957
bool more_items
Definition: gsm0808.h:170
struct msgb * gsm0808_create_handover_failure(const struct gsm0808_handover_failure *params)
Create BSSMAP HANDOVER FAILURE message, 3GPP TS 48.008 3.2.1.16.
Definition: gsm0808.c:926
struct msgb * gsm0808_create_layer3(struct msgb *msg_l3, uint16_t nc, uint16_t cc, int lac, uint16_t _ci) OSMO_DEPRECATED("Use gsm0808_create_layer3_2() instead
Create "Complete L3 Info" for A, legacy implementation.
Definition: gsm0808.c:117
struct msgb * gsm0808_create_clear_command(uint8_t cause)
Create BSSMAP Clear Command message.
Definition: gsm0808.c:184
struct msgb * gsm0808_create_ass2(const struct gsm0808_channel_type *ct, const uint16_t *cic, const struct sockaddr_storage *ss, const struct gsm0808_speech_codec_list *scl, const uint32_t *ci, const uint8_t *kc, const struct osmo_lcls *lcls)
Create BSSMAP Assignment Request message, 3GPP TS 48.008 §3.2.1.1.
Definition: gsm0808.c:443
bool extra_information_present
Definition: gsm0808.h:109
struct msgb * gsm0808_create_handover_request_ack(const uint8_t *l3_info, uint8_t l3_info_len, uint8_t chosen_channel, uint8_t chosen_encr_alg, uint8_t chosen_speech_version)
Create BSSMAP HANDOVER REQUEST ACKNOWLEDGE message, 3GPP TS 48.008 3.2.1.10.
Definition: gsm0808.c:838
bool rr_cause_present
Definition: gsm0808.h:152
const char * gsm0808_cause_name(enum gsm0808_cause cause)
Return string name of BSSMAP Cause name.
Definition: gsm0808.c:1419
Definition: gsm_08_08.h:556
uint8_t rr_cause
Definition: gsm0808.h:153
uint8_t current_channel_type_1
Definition: gsm0808.h:132
uint8_t cm2_len
Definition: gsm_04_08.h:805
Definition of All 256 IE / TLV.
Definition: tlv.h:437
bool current_channel_type_2_present
Definition: gsm0808.h:116
struct msgb * gsm0808_create_lcls_notification(enum gsm0808_lcls_status status, bool break_req)
Create BSSMAP LCLS NOTIFICATION message (TS 48.008 3.2.1.93).
Definition: gsm0808.c:359
static const char * gsm0808_lcls_status_name(enum gsm0808_lcls_status val)
Definition: gsm0808.h:234
Parsed representation of Cell Identifier IE (3GPP TS 48.008 3.2.2.17)
Definition: gsm0808_utils.h:50
uint16_t lac
Definition: gsm_04_08.h:806
gsm0808_lcls_config
Definition: gsm_08_08.h:577
bool current_channel_type_1_present
Definition: gsm0808.h:131
_parse instead
Definition: ipa.h:30
void gsm0808_prepend_dtap_header(struct msgb *msg, uint8_t link_id)
Prepend a DTAP header to given Message Buffer.
Definition: gsm0808.c:1003
bool speech_codec_chosen_present
Definition: gsm0808.h:155
struct msgb * gsm0808_create_cipher_complete(struct msgb *layer3, uint8_t alg_id)
Create BSSMAP Cipher Mode Complete message.
Definition: gsm0808.c:239
struct msgb * gsm0808_create_ass_compl2(uint8_t rr_cause, uint8_t chosen_channel, uint8_t encr_alg_id, uint8_t speech_mode, const struct sockaddr_storage *ss, const struct gsm0808_speech_codec *sc, const struct gsm0808_speech_codec_list *scl, enum gsm0808_lcls_status lcls_bss_status)
Create BSSMAP Assignment Completed message as per 3GPP TS 48.008 §3.2.1.2.
Definition: gsm0808.c:532
DEPRECATED: This definition of the cell identifier list is insufficient.
Definition: gsm_08_08.h:570
Definition: gsm_08_08.h:493