libosmogsm  1.1.0
Osmocom GSM library
gsup.h
Go to the documentation of this file.
1 
18 /*
19  * (C) 2014 by sysmocom - s.f.m.c. GmbH, Author: Jacob Erlbeck
20  * (C) 2016 by Harald Welte <laforge@gnumonks.org>
21  * All Rights Reserved
22  *
23  * SPDX-License-Identifier: GPL-2.0+
24  *
25  * This program is free software; you can redistribute it and/or modify
26  * it under the terms of the GNU General Public License as published by
27  * the Free Software Foundation; either version 2 of the License, or
28  * (at your option) any later version.
29  *
30  * This program is distributed in the hope that it will be useful,
31  * but WITHOUT ANY WARRANTY; without even the implied warranty of
32  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33  * GNU General Public License for more details.
34  *
35  * You should have received a copy of the GNU General Public License
36  * along with this program. If not, see <http://www.gnu.org/licenses/>.
37  *
38  */
39 #pragma once
40 
41 #include <stdint.h>
42 #include <osmocom/core/msgb.h>
43 #include <osmocom/gsm/gsup_sms.h>
48 #include <osmocom/crypt/auth.h>
49 
50 #define OSMO_GSUP_PORT 4222
51 
53 #define OSMO_GSUP_MAX_NUM_PDP_INFO 10 /* GSM 09.02 limits this to 50 */
54 
55 #define OSMO_GSUP_MAX_NUM_AUTH_INFO 5
56 
57 #define OSMO_GSUP_MAX_MSISDN_LEN 9
58 #define OSMO_GSUP_MAX_CALLED_PARTY_BCD_LEN 43 /* TS 24.008 10.5.4.7 */
59 
60 #define OSMO_GSUP_PDP_TYPE_SIZE 2
61 
82  /* 3G support */
89 
92 
95 
96  /* SM related IEs (see 3GPP TS 29.002, section 7.6.8) */
104 
107 
108  /* Inter-MSC handover related */
115 
117 };
118 
135 
139 
141 
145 
149 
153 
157 
161 
165 
169 
173 
177 
181 
185 
189 
192 
195 
197 };
198 
199 #define OSMO_GSUP_IS_MSGT_REQUEST(msgt) (((msgt) & 0b00000011) == 0b00)
200 #define OSMO_GSUP_IS_MSGT_ERROR(msgt) (((msgt) & 0b00000011) == 0b01)
201 #define OSMO_GSUP_TO_MSGT_ERROR(msgt) (((msgt) & 0b11111100) | 0b01)
202 
203 extern const struct value_string osmo_gsup_message_type_names[];
204 static inline const char *
207 
209  OSMO_GSUP_CANCEL_TYPE_UPDATE = 1, /* on wire: 0 */
210  OSMO_GSUP_CANCEL_TYPE_WITHDRAW = 2, /* on wire: 1 */
211 };
212 
216 };
217 
219  OSMO_GSUP_IMEI_RESULT_ACK = 1, /* on wire: 0 */
220  OSMO_GSUP_IMEI_RESULT_NACK = 2, /* on wire: 1 */
221 };
222 
223 /* 3GPP 29.002 AccessNetworkProtocolId */
227 };
228 
239 };
240 
241 extern const struct value_string osmo_gsup_session_state_names[];
242 static inline const char *
245 
248  unsigned int context_id;
251  uint16_t pdp_type;
254  const uint8_t *apn_enc;
256  size_t apn_enc_len;
259  const uint8_t *qos_enc;
261  size_t qos_enc_len;
264  const uint8_t *pdp_charg_enc;
267 };
268 
275  /* Keep this as last entry with a value of max(enum osmo_gsup_message_class) + 1.
276  * This value shall serve as the size for an array to aid de-muxing all known GSUP classes. */
278 };
279 
280 extern const struct value_string osmo_gsup_message_class_names[];
281 static inline const char *osmo_gsup_message_class_name(enum osmo_gsup_message_class val)
283 
286  /* AccessNetworkProtocolId as in 3GPP TS 29.002. */
287  enum osmo_gsup_access_network_protocol access_network_proto;
288  const uint8_t *data;
289  size_t data_len;
290 };
291 
294  enum osmo_gsup_message_type message_type;
295  char imsi[OSMO_IMSI_BUF_SIZE];
297  enum osmo_gsup_cancel_type cancel_type;
304  const uint8_t *msisdn_enc;
306  const uint8_t *hlr_enc;
307  size_t hlr_enc_len;
308  const uint8_t *auts;
309  const uint8_t *rand;
310  enum osmo_gsup_cn_domain cn_domain;
311  const uint8_t *pdp_charg_enc;
313 
315  enum osmo_gsup_session_state session_state;
318  uint32_t session_id;
319 
321  uint8_t *ss_info;
322  size_t ss_info_len;
323 
327  const uint8_t *sm_rp_mr;
329  enum osmo_gsup_sms_sm_rp_oda_t sm_rp_da_type;
330  size_t sm_rp_da_len;
331  const uint8_t *sm_rp_da;
333  enum osmo_gsup_sms_sm_rp_oda_t sm_rp_oa_type;
334  size_t sm_rp_oa_len;
335  const uint8_t *sm_rp_oa;
337  const uint8_t *sm_rp_ui;
338  size_t sm_rp_ui_len;
340  const uint8_t *sm_rp_cause;
342  const uint8_t *sm_rp_mms;
344  enum osmo_gsup_sms_sm_alert_rsn_t sm_alert_rsn;
345 
346  const uint8_t *imei_enc;
347  size_t imei_enc_len;
348  enum osmo_gsup_imei_result imei_result;
349 
353  enum osmo_gsup_message_class message_class;
354 
356  const uint8_t *source_name;
361  const uint8_t *destination_name;
364 
366  struct osmo_gsup_an_apdu an_apdu;
367 
368  uint8_t cause_rr;
371  enum gsm0808_cause cause_bssap;
375  enum gsm48_gsm_cause cause_sm;
376 };
377 
378 int osmo_gsup_decode(const uint8_t *data, size_t data_len,
379  struct osmo_gsup_message *gsup_msg);
380 int osmo_gsup_encode(struct msgb *msg, const struct osmo_gsup_message *gsup_msg);
382  OSMO_DEPRECATED("Use OSMO_GSUP_TO_MSGT_ERROR() instead");
383 
AccessNetworkSignalInfo as in 3GPP TS 29.002.
Definition: gsup.h:285
osmo_gsup_cancel_type
Definition: gsup.h:208
Definition: gsup.h:112
const uint8_t * auts
Definition: gsup.h:308
Definition: gsup.h:148
Definition: gsup.h:100
Definition: gsup.h:81
size_t sm_rp_oa_len
Definition: gsup.h:334
Definition: gsup.h:273
Definition: gsup.h:209
Indication of the session end.
Definition: gsup.h:238
Definition: gsup.h:116
#define OSMO_DEPRECATED(text)
Definition: gsup.h:215
const struct value_string osmo_gsup_message_type_names[]
Definition: gsup.c:39
const char * get_value_string(const struct value_string *vs, uint32_t val)
Definition: gsup.h:101
Definition: gsup.h:65
Definition: gsup.h:72
Definition: gsup.h:64
const uint8_t * sm_rp_mms
SM-RP-MMS (More Messages to Send), section 7.6.8.7.
Definition: gsup.h:342
Definition: gsup.h:220
size_t num_pdp_infos
Definition: gsup.h:303
#define OSMO_GSUP_MAX_NUM_AUTH_INFO
Maximum number of auth info inside osmo_gsup_message.
Definition: gsup.h:55
uint16_t pdp_type
Type of PDP context.
Definition: gsup.h:251
Definition: gsup.h:79
const uint8_t * pdp_charg_enc
Definition: gsup.h:311
int freeze_ptmsi
Definition: gsup.h:299
bool cause_rr_set
whether cause_rr is set
Definition: gsup.h:369
Definition: gsup.h:66
Definition: gsup.h:91
const uint8_t * sm_rp_oa
Definition: gsup.h:335
Definition: gsup.h:193
int have_info
Definition: gsup.h:249
int pdp_info_compl
Definition: gsup.h:298
Definition: gsup.h:274
size_t data_len
Definition: gsup.h:289
Definition: gsup.h:73
Definition: gsup.h:86
const uint8_t * msisdn_enc
Definition: gsup.h:304
const uint8_t * source_name
For messages routed via another GSUP entity (via HLR), the IPA name of the entity that sent this mess...
Definition: gsup.h:356
size_t hlr_enc_len
Definition: gsup.h:307
Definition: gsup.h:109
Initiation of a new session.
Definition: gsup.h:234
size_t ss_info_len
Definition: gsup.h:322
uint8_t cause
Definition: gsm_04_08.h:825
const uint8_t * sm_rp_da
Definition: gsup.h:331
osmo_gsup_sms_sm_rp_oda_t
Possible identity types for SM-RP-{OA|DA}.
Definition: gsup_sms.h:16
unsigned int context_id
Definition: gsup.h:248
osmo_gsup_access_network_protocol
Definition: gsup.h:224
osmo_gsup_session_state
TCAP-like session state.
Definition: gsup.h:230
size_t sm_rp_ui_len
Definition: gsup.h:338
osmo_gsup_message_type
GSUP message type Make sure that new messages follow this scheme:
Definition: gsup.h:131
Definition: gsup.h:142
Definition: gsup.h:113
Definition: gsup.h:88
Definition: gsup.h:140
const uint8_t * destination_name
For messages routed via another GSUP entity (via HLR), the IPA name of the entity that should ultimat...
Definition: gsup.h:361
const uint8_t * sm_rp_cause
SM-RP-Cause value (1 oct.) as per GSM TS 04.11, section 8.2.5.4.
Definition: gsup.h:340
static const char * osmo_gsup_message_type_name(enum osmo_gsup_message_type val)
Definition: gsup.h:205
Definition: gsup.h:80
Definition: gsup.h:75
osmo_gsup_iei
Information Element Identifiers for GSUP IEs.
Definition: gsup.h:63
size_t source_name_len
Number of bytes in source_name.
Definition: gsup.h:358
Definition: gsup.h:175
Definition: gsup.h:171
Definition: gsup.h:152
const uint8_t * hlr_enc
Definition: gsup.h:306
Definition: gsup.h:158
Definition: gsup.h:90
uint8_t * ss_info
ASN.1 encoded MAP payload for Supplementary Services.
Definition: gsup.h:321
size_t msisdn_enc_len
Definition: gsup.h:305
Definition: gsup.h:277
Definition: gsup.h:176
Definition: gsup.h:111
static const char * osmo_gsup_message_class_name(enum osmo_gsup_message_class val)
Definition: gsup.h:281
Definition: gsup.h:210
uint8_t data[0]
Definition: gsup.h:71
size_t qos_enc_len
length (in octets) of qos_enc
Definition: gsup.h:261
#define OSMO_IMSI_BUF_SIZE
The char[] buffer size to completely contain an IMSI including the optional checksum digit as well as...
Definition: gsm_23_003.h:10
osmo_gsup_message_class
Definition: gsup.h:269
int osmo_gsup_decode(const uint8_t *data, size_t data_len, struct osmo_gsup_message *gsup_msg)
Decode (parse) a GSUP message.
Definition: gsup.c:296
Definition: gsup.h:74
Definition: gsup.h:70
Definition: gsup.h:272
gsm48_gsm_cause
Definition: gsm_04_08_gprs.h:242
Definition: gsup.h:110
Definition: gsup.h:270
uint32_t session_id
Unique session identifier and origination flag.
Definition: gsup.h:318
Supplementary Services payload.
Definition: gsup.h:94
gsm0808_cause
Definition: gsm_08_08.h:331
Definition: gsup.h:196
Definition: gsup.h:160
#define OSMO_GSUP_MAX_NUM_PDP_INFO
Maximum nubmer of PDP inside osmo_gsup_message.
Definition: gsup.h:53
Definition: gsup.h:78
parsed/decoded PDP context information
Definition: gsup.h:247
Definition: gsup.h:69
size_t pdp_charg_enc_len
Definition: gsup.h:312
gsm48_gmm_cause
Definition: gsm_04_08_gprs.h:206
Definition: gsup.h:67
bool cause_bssap_set
whether cause_bssap is set
Definition: gsup.h:372
const struct value_string osmo_gsup_session_state_names[]
Definition: gsup.c:109
Definition: gsup.h:151
const uint8_t * sm_rp_ui
SM-RP-UI (see 3GPP TS 29.002, 7.6.8.4), SMS TPDU.
Definition: gsup.h:337
Definition: gsup.h:99
static const char * osmo_gsup_session_state_name(enum osmo_gsup_session_state val)
Definition: gsup.h:243
uint8_t cause_rr
0 is a valid cause
Definition: gsup.h:368
Definition: gsup.h:219
Definition: gsup.h:97
Definition: gsup.h:143
Definition: gsup.h:174
parsed/decoded GSUP protocol message
Definition: gsup.h:293
Definition: gsup.h:114
const uint8_t * data
Definition: gsup.h:288
Definition: gsup.h:103
const uint8_t * apn_enc
APN information, still in encoded form.
Definition: gsup.h:254
size_t pdp_charg_enc_len
length (in octets) of pdp_charg_enc
Definition: gsup.h:266
Definition: gsup.h:84
Definition: gsup.h:214
Definition: gsup.h:106
Definition: gsup.h:68
const uint8_t * pdp_charg_enc
PDP Charging Characteristics, still in encoded form.
Definition: gsup.h:264
size_t sm_rp_da_len
Definition: gsup.h:330
const uint8_t * rand
Definition: gsup.h:309
Definition: gsup.h:159
Definition: gsup.h:87
const struct value_string osmo_gsup_message_class_names[]
Definition: gsup.c:862
Definition: gsup.h:83
int osmo_gsup_encode(struct msgb *msg, const struct osmo_gsup_message *gsup_msg)
Encode a GSUP message.
Definition: gsup.c:677
const uint8_t * imei_enc
Definition: gsup.h:346
Definition: gsup.h:147
const uint8_t * qos_enc
QoS information, still in encoded form.
Definition: gsup.h:259
Definition: gsup.h:85
Definition: gsup.h:77
const uint8_t * sm_rp_mr
SM-RP-MR (see 3GPP TS 29.002, 7.6.1.1), Message Reference.
Definition: gsup.h:327
Definition: gsup.h:76
Undefined session state.
Definition: gsup.h:232
Definition: gsup.h:144
size_t imei_enc_len
Definition: gsup.h:347
GSM TS 03.40.
size_t apn_enc_len
length (in octets) of apn_enc
Definition: gsup.h:256
Definition: gsup.h:98
osmo_gsup_imei_result
Definition: gsup.h:218
size_t destination_name_len
Number of bytes in destination_name.
Definition: gsup.h:363
Communication of an existing session.
Definition: gsup.h:236
Definition: auth.h:60
Definition: gsup.h:194
Definition: gsup.h:102
Definition: gsup.h:105
int osmo_gsup_get_err_msg_type(enum osmo_gsup_message_type type_in) OSMO_DEPRECATED("Use OSMO_GSUP_TO_MSGT_ERROR() instead")
return the error message type corresponding to type_in.
Definition: gsup.c:120
SMS (Short Message Service) extensions for Osmocom GSUP.
osmo_gsup_sms_sm_alert_rsn_t
Alert reason values, see 7.6.8.8.
Definition: gsup_sms.h:26
osmo_gsup_cn_domain
Definition: gsup.h:213
size_t num_auth_vectors
Definition: gsup.h:301