libosmogsm  1.0.1
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>
46 #include <osmocom/crypt/auth.h>
47 
48 #define OSMO_GSUP_PORT 4222
49 
51 #define OSMO_GSUP_MAX_NUM_PDP_INFO 10 /* GSM 09.02 limits this to 50 */
52 
53 #define OSMO_GSUP_MAX_NUM_AUTH_INFO 5
54 
55 #define OSMO_GSUP_MAX_MSISDN_LEN 9
56 #define OSMO_GSUP_MAX_CALLED_PARTY_BCD_LEN 43 /* TS 24.008 10.5.4.7 */
57 
58 #define OSMO_GSUP_PDP_TYPE_SIZE 2
59 
79  /* 3G support */
86 
89 
92 
93  /* SM related IEs (see 3GPP TS 29.002, section 7.6.8) */
101 
104 
106 };
107 
113 
117 
119 
123 
127 
131 
135 
139 
143 
147 
151 
155 };
156 
157 #define OSMO_GSUP_IS_MSGT_REQUEST(msgt) (((msgt) & 0b00000011) == 0b00)
158 #define OSMO_GSUP_IS_MSGT_ERROR(msgt) (((msgt) & 0b00000011) == 0b01)
159 #define OSMO_GSUP_TO_MSGT_ERROR(msgt) (((msgt) & 0b11111100) | 0b01)
160 
161 extern const struct value_string osmo_gsup_message_type_names[];
162 static inline const char *
165 
167  OSMO_GSUP_CANCEL_TYPE_UPDATE = 1, /* on wire: 0 */
168  OSMO_GSUP_CANCEL_TYPE_WITHDRAW = 2, /* on wire: 1 */
169 };
170 
174 };
175 
177  OSMO_GSUP_IMEI_RESULT_ACK = 1, /* on wire: 0 */
178  OSMO_GSUP_IMEI_RESULT_NACK = 2, /* on wire: 1 */
179 };
180 
191 };
192 
193 extern const struct value_string osmo_gsup_session_state_names[];
194 static inline const char *
197 
200  unsigned int context_id;
203  uint16_t pdp_type;
206  const uint8_t *apn_enc;
208  size_t apn_enc_len;
211  const uint8_t *qos_enc;
213  size_t qos_enc_len;
216  const uint8_t *pdp_charg_enc;
219 };
220 
223  enum osmo_gsup_message_type message_type;
226  enum osmo_gsup_cancel_type cancel_type;
233  const uint8_t *msisdn_enc;
235  const uint8_t *hlr_enc;
236  size_t hlr_enc_len;
237  const uint8_t *auts;
238  const uint8_t *rand;
239  enum osmo_gsup_cn_domain cn_domain;
240  const uint8_t *pdp_charg_enc;
242 
244  enum osmo_gsup_session_state session_state;
247  uint32_t session_id;
248 
250  uint8_t *ss_info;
251  size_t ss_info_len;
252 
256  const uint8_t *sm_rp_mr;
258  enum osmo_gsup_sms_sm_rp_oda_t sm_rp_da_type;
259  size_t sm_rp_da_len;
260  const uint8_t *sm_rp_da;
262  enum osmo_gsup_sms_sm_rp_oda_t sm_rp_oa_type;
263  size_t sm_rp_oa_len;
264  const uint8_t *sm_rp_oa;
266  const uint8_t *sm_rp_ui;
267  size_t sm_rp_ui_len;
269  const uint8_t *sm_rp_cause;
271  const uint8_t *sm_rp_mms;
273  enum osmo_gsup_sms_sm_alert_rsn_t sm_alert_rsn;
274 
275  const uint8_t *imei_enc;
276  size_t imei_enc_len;
277  enum osmo_gsup_imei_result imei_result;
278 };
279 
280 int osmo_gsup_decode(const uint8_t *data, size_t data_len,
281  struct osmo_gsup_message *gsup_msg);
282 int osmo_gsup_encode(struct msgb *msg, const struct osmo_gsup_message *gsup_msg);
284 
osmo_gsup_cancel_type
Definition: gsup.h:166
const uint8_t * auts
Definition: gsup.h:237
Definition: gsup.h:126
Definition: gsup.h:97
Definition: gsup.h:78
size_t sm_rp_oa_len
Definition: gsup.h:263
Definition: gsup.h:167
Indication of the session end.
Definition: gsup.h:190
Definition: gsup.h:105
Definition: gsup.h:173
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)
#define GSM23003_IMSI_MAX_DIGITS
Definition: gsm_23_003.h:6
Definition: gsup.h:98
Definition: gsup.h:63
Definition: gsup.h:70
Definition: gsup.h:62
const uint8_t * sm_rp_mms
SM-RP-MMS (More Messages to Send), section 7.6.8.7.
Definition: gsup.h:271
Definition: gsup.h:178
size_t num_pdp_infos
Definition: gsup.h:232
#define OSMO_GSUP_MAX_NUM_AUTH_INFO
Maximum number of auth info inside osmo_gsup_message.
Definition: gsup.h:53
uint16_t pdp_type
Type of PDP context.
Definition: gsup.h:203
Definition: gsup.h:76
const uint8_t * pdp_charg_enc
Definition: gsup.h:240
int freeze_ptmsi
Definition: gsup.h:228
Definition: gsup.h:64
Definition: gsup.h:88
const uint8_t * sm_rp_oa
Definition: gsup.h:264
int have_info
Definition: gsup.h:201
int pdp_info_compl
Definition: gsup.h:227
Definition: gsup.h:83
const uint8_t * msisdn_enc
Definition: gsup.h:233
size_t hlr_enc_len
Definition: gsup.h:236
Initiation of a new session.
Definition: gsup.h:186
size_t ss_info_len
Definition: gsup.h:251
uint8_t cause
Definition: gsm_04_08.h:807
const uint8_t * sm_rp_da
Definition: gsup.h:260
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:200
osmo_gsup_session_state
TCAP-like session state.
Definition: gsup.h:182
size_t sm_rp_ui_len
Definition: gsup.h:267
osmo_gsup_message_type
GSUP message type.
Definition: gsup.h:109
Definition: gsup.h:120
Definition: gsup.h:85
Definition: gsup.h:118
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:269
static const char * osmo_gsup_message_type_name(enum osmo_gsup_message_type val)
Definition: gsup.h:163
Definition: gsup.h:77
Definition: gsup.h:72
osmo_gsup_iei
Information Element Identifiers for GSUP IEs.
Definition: gsup.h:61
Definition: gsup.h:153
Definition: gsup.h:149
Definition: gsup.h:130
const uint8_t * hlr_enc
Definition: gsup.h:235
Definition: gsup.h:136
Definition: gsup.h:87
uint8_t * ss_info
ASN.1 encoded MAP payload for Supplementary Services.
Definition: gsup.h:250
size_t msisdn_enc_len
Definition: gsup.h:234
Definition: gsup.h:154
Definition: gsup.h:168
Definition: gsup.h:69
size_t qos_enc_len
length (in octets) of qos_enc
Definition: gsup.h:213
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:281
Definition: gsup.h:71
Definition: gsup.h:68
uint32_t session_id
Unique session identifier and origination flag.
Definition: gsup.h:247
Supplementary Services payload.
Definition: gsup.h:91
Definition: gsup.h:138
#define OSMO_GSUP_MAX_NUM_PDP_INFO
Maximum nubmer of PDP inside osmo_gsup_message.
Definition: gsup.h:51
Definition: gsup.h:75
parsed/decoded PDP context information
Definition: gsup.h:199
Definition: gsup.h:67
size_t pdp_charg_enc_len
Definition: gsup.h:241
gsm48_gmm_cause
Definition: gsm_04_08_gprs.h:206
Definition: gsup.h:65
const struct value_string osmo_gsup_session_state_names[]
Definition: gsup.c:89
Definition: gsup.h:129
const uint8_t * sm_rp_ui
SM-RP-UI (see 3GPP TS 29.002, 7.6.8.4), SMS TPDU.
Definition: gsup.h:266
Definition: gsup.h:96
static const char * osmo_gsup_session_state_name(enum osmo_gsup_session_state val)
Definition: gsup.h:195
Definition: gsup.h:177
Definition: gsup.h:94
Definition: gsup.h:121
Definition: gsup.h:152
parsed/decoded GSUP protocol message
Definition: gsup.h:222
Definition: gsup.h:100
const uint8_t * apn_enc
APN information, still in encoded form.
Definition: gsup.h:206
size_t pdp_charg_enc_len
length (in octets) of pdp_charg_enc
Definition: gsup.h:218
Definition: gsup.h:81
Definition: gsup.h:172
Definition: gsup.h:103
Definition: gsup.h:66
const uint8_t * pdp_charg_enc
PDP Charging Characteristics, still in encoded form.
Definition: gsup.h:216
size_t sm_rp_da_len
Definition: gsup.h:259
const uint8_t * rand
Definition: gsup.h:238
Definition: gsup.h:137
Definition: gsup.h:84
Definition: gsup.h:80
int osmo_gsup_encode(struct msgb *msg, const struct osmo_gsup_message *gsup_msg)
Encode a GSUP message.
Definition: gsup.c:597
const uint8_t * imei_enc
Definition: gsup.h:275
Definition: gsup.h:125
const uint8_t * qos_enc
QoS information, still in encoded form.
Definition: gsup.h:211
Definition: gsup.h:82
Definition: gsup.h:74
const uint8_t * sm_rp_mr
SM-RP-MR (see 3GPP TS 29.002, 7.6.1.1), Message Reference.
Definition: gsup.h:256
Definition: gsup.h:73
Undefined session state.
Definition: gsup.h:184
Definition: gsup.h:122
size_t imei_enc_len
Definition: gsup.h:276
size_t apn_enc_len
length (in octets) of apn_enc
Definition: gsup.h:208
Definition: gsup.h:95
osmo_gsup_imei_result
Definition: gsup.h:176
Communication of an existing session.
Definition: gsup.h:188
Definition: auth.h:60
Definition: gsup.h:99
Definition: gsup.h:102
uint8_t data[0]
message payload data
Definition: gsm_03_41.h:89
int osmo_gsup_get_err_msg_type(enum osmo_gsup_message_type type_in)
return the error message type corresponding to type_in
Definition: gsup.c:100
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:171
size_t num_auth_vectors
Definition: gsup.h:230