libosmogsm  0.9.6.20170825
Osmocom GSM library
gsup.h
Go to the documentation of this file.
1 
3 /*
4  * (C) 2014 by sysmocom s.f.m.c. GmbH, Author: Jacob Erlbeck
5  * (C) 2016 by Harald Welte <laforge@gnumonks.org>
6  * All Rights Reserved
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 #pragma once
23 
24 #include <stdint.h>
25 #include <osmocom/core/msgb.h>
28 #include <osmocom/crypt/auth.h>
29 
30 #define OSMO_GSUP_PORT 4222
31 
33 #define OSMO_GSUP_MAX_NUM_PDP_INFO 10 /* GSM 09.02 limits this to 50 */
34 
35 #define OSMO_GSUP_MAX_NUM_AUTH_INFO 5
36 
37 #define OSMO_GSUP_MAX_MSISDN_LEN 9
38 
39 #define OSMO_GSUP_PDP_TYPE_SIZE 2
40 
60  /* 3G support */
67 };
68 
74 
78 
80 
84 
88 
92 
96 };
97 
98 #define OSMO_GSUP_IS_MSGT_REQUEST(msgt) (((msgt) & 0b00000011) == 0b00)
99 #define OSMO_GSUP_IS_MSGT_ERROR(msgt) (((msgt) & 0b00000011) == 0b01)
100 #define OSMO_GSUP_TO_MSGT_ERROR(msgt) (((msgt) & 0b11111100) | 0b01)
101 
102 extern const struct value_string osmo_gsup_message_type_names[];
103 static inline const char *
106 
108  OSMO_GSUP_CANCEL_TYPE_UPDATE = 1, /* on wire: 0 */
109  OSMO_GSUP_CANCEL_TYPE_WITHDRAW = 2, /* on wire: 1 */
110 };
111 
115 };
116 
119  unsigned int context_id;
122  uint16_t pdp_type;
125  const uint8_t *apn_enc;
127  size_t apn_enc_len;
130  const uint8_t *qos_enc;
132  size_t qos_enc_len;
135  const uint8_t *pdp_charg_enc;
138 };
139 
142  enum osmo_gsup_message_type message_type;
145  enum osmo_gsup_cancel_type cancel_type;
148  struct osmo_auth_vector auth_vectors[OSMO_GSUP_MAX_NUM_AUTH_INFO];
152  const uint8_t *msisdn_enc;
154  const uint8_t *hlr_enc;
155  size_t hlr_enc_len;
156  const uint8_t *auts;
157  const uint8_t *rand;
158  enum osmo_gsup_cn_domain cn_domain;
159  const uint8_t *pdp_charg_enc;
161 };
162 
163 int osmo_gsup_decode(const uint8_t *data, size_t data_len,
164  struct osmo_gsup_message *gsup_msg);
165 void osmo_gsup_encode(struct msgb *msg, const struct osmo_gsup_message *gsup_msg);
Definition: gsup.h:48
const uint8_t * auts
Definition: gsup.h:156
static const char * osmo_gsup_message_type_name(enum osmo_gsup_message_type val)
Definition: gsup.h:104
Definition: gsup.h:58
void osmo_gsup_encode(struct msgb *msg, const struct osmo_gsup_message *gsup_msg)
Encode a GSUP message.
Definition: gsup.c:479
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
size_t num_pdp_infos
Definition: gsup.h:151
Definition: gsup.h:49
uint16_t pdp_type
Type of PDP context.
Definition: gsup.h:122
const uint8_t * pdp_charg_enc
Definition: gsup.h:159
int freeze_ptmsi
Definition: gsup.h:147
Definition: gsup.h:63
Definition: gsup.h:108
int have_info
Definition: gsup.h:120
int pdp_info_compl
Definition: gsup.h:146
#define OSMO_GSUP_MAX_NUM_AUTH_INFO
Maximum number of auth info inside osmo_gsup_message.
Definition: gsup.h:35
const uint8_t * msisdn_enc
Definition: gsup.h:152
size_t hlr_enc_len
Definition: gsup.h:155
osmo_gsup_cn_domain
Definition: gsup.h:112
Definition: gsup.h:62
uint8_t cause
Definition: gsm_04_08.h:86
Definition: gsup.h:81
unsigned int context_id
Definition: gsup.h:119
Definition: gsup.h:43
Definition: gsup.h:82
const uint8_t * hlr_enc
Definition: gsup.h:154
size_t msisdn_enc_len
Definition: gsup.h:153
Definition: gsup.h:50
Definition: gsup.h:79
size_t qos_enc_len
length (in octets) of qos_enc
Definition: gsup.h:132
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:219
Definition: gsup.h:65
Definition: gsup.h:54
Definition: gsup.h:66
Definition: gsup.h:56
Definition: gsup.h:59
Definition: gsup.h:51
parsed/decoded PDP context information
Definition: gsup.h:118
size_t pdp_charg_enc_len
Definition: gsup.h:160
gsm48_gmm_cause
Definition: gsm_04_08_gprs.h:175
Definition: gsup.h:114
Definition: gsup.h:64
Definition: gsup.h:57
Definition: gsup.h:109
Definition: gsup.h:55
Definition: gsup.h:113
parsed/decoded GSUP protocol message
Definition: gsup.h:141
#define OSMO_GSUP_MAX_NUM_PDP_INFO
Maximum nubmer of PDP inside osmo_gsup_message.
Definition: gsup.h:33
const uint8_t * apn_enc
APN information, still in encoded form.
Definition: gsup.h:125
Definition: gsup.h:52
size_t pdp_charg_enc_len
length (in octets) of pdp_charg_enc
Definition: gsup.h:137
Definition: gsup.h:45
const uint8_t * pdp_charg_enc
PDP Charging Characteristics, still in encoded form.
Definition: gsup.h:135
const uint8_t * rand
Definition: gsup.h:157
Definition: gsup.h:44
Definition: gsup.h:83
osmo_gsup_iei
Information Element Identifiers for GSUP IEs.
Definition: gsup.h:42
Definition: gsup.h:47
const uint8_t * qos_enc
QoS information, still in encoded form.
Definition: gsup.h:130
Definition: gsup.h:53
size_t apn_enc_len
length (in octets) of apn_enc
Definition: gsup.h:127
Definition: gsup.h:46
Definition: gsup.h:61
uint8_t data[0]
message payload data
Definition: gsm_03_41.h:101
osmo_gsup_message_type
GSUP message type.
Definition: gsup.h:70
osmo_gsup_cancel_type
Definition: gsup.h:107
size_t num_auth_vectors
Definition: gsup.h:149