-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathue.h
263 lines (213 loc) · 6.23 KB
/
ue.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
/* SPDX-License-Identifier: Apache-2.0
* Copyright(c) 2017 Intel Corporation
*/
#ifndef UE_H
#define UE_H
/**
* @file
*
* Contains all data structures required by 3GPP TS 23.401 Tables 5.7.3-1 and
* 5.7.4-1 (that are nessecary for current implementaiton) to describe the
* Connections, state, bearers, etc as well as functions to manage and/or
* obtain value for their fields.
*
*/
#include <stdint.h>
#include <arpa/inet.h>
#include <rte_malloc.h>
#include <rte_lcore.h>
#include <rte_jhash.h>
#include <rte_hash.h>
#include "gtpv2c_ie.h"
#include "packet_filters.h"
#include "interface.h"
#define SDF_FILTER_TABLE "sdf_filter_table"
#define ADC_TABLE "adc_rule_table"
#define PCC_TABLE "pcc_table"
#define SESSION_TABLE "session_table"
#define METER_PROFILE_SDF_TABLE "meter_profile_sdf_table"
#define METER_PROFILE_APN_TABLE "meter_profile_apn_table"
#define SDF_FILTER_TABLE_SIZE (1024)
#define ADC_TABLE_SIZE (1024)
#define PCC_TABLE_SIZE (1025)
#define METER_PROFILE_SDF_TABLE_SIZE (2048)
#define DPN_ID (12345)
#define MAX_BEARERS (11)
#define MAX_FILTERS_PER_UE (16)
#define GET_UE_IP(ue_index) \
(((ip_pool_ip.s_addr | (~ip_pool_mask.s_addr)) \
- htonl(ue_index)) - 0x01000000)
struct eps_bearer_t;
struct pdn_connection_t;
typedef struct apn_t {
char *apn_name_label;
size_t apn_name_length;
uint8_t apn_idx;
} apn;
typedef struct ue_context_t {
uint64_t imsi;
uint8_t unathenticated_imsi;
uint64_t mei;
uint64_t msisdn;
ambr_ie mn_ambr;
uint32_t s11_sgw_gtpc_teid;
struct in_addr s11_sgw_gtpc_ipv4;
uint32_t s11_mme_gtpc_teid;
struct in_addr s11_mme_gtpc_ipv4;
uint16_t bearer_bitmap;
uint16_t teid_bitmap;
uint8_t num_pdns;
struct pdn_connection_t *pdns[MAX_BEARERS];
struct eps_bearer_t *eps_bearers[MAX_BEARERS]; /* index by ebi - 5 */
/* temporary bearer to be used during resource bearer cmd -
* create/deletee bearer req - rsp */
struct eps_bearer_t *ded_bearer;
} ue_context;
typedef struct pdn_connection_t {
apn *apn_in_use;
ambr_ie apn_ambr;
uint32_t apn_restriction;
ambr_ie session_ambr;
ambr_ie session_gbr;
struct in_addr ipv4;
struct in6_addr ipv6;
uint32_t s5s8_sgw_gtpc_teid;
struct in_addr s5s8_sgw_gtpc_ipv4;
uint32_t s5s8_pgw_gtpc_teid;
struct in_addr s5s8_pgw_gtpc_ipv4;
pdn_type_ie pdn_type;
/* See 3GPP TS 32.298 5.1.2.2.7 for Charging Characteristics fields*/
charging_characteristics_ie charging_characteristics;
uint8_t default_bearer_id;
struct eps_bearer_t *eps_bearers[MAX_BEARERS]; /* index by ebi - 5 */
struct eps_bearer_t *packet_filter_map[MAX_FILTERS_PER_UE];
} pdn_connection;
typedef struct eps_bearer_t {
uint8_t eps_bearer_id;
bearer_qos_ie qos;
uint32_t charging_id;
struct in_addr s1u_sgw_gtpu_ipv4;
uint32_t s1u_sgw_gtpu_teid;
struct in_addr s5s8_sgw_gtpu_ipv4;
uint32_t s5s8_sgw_gtpu_teid;
struct in_addr s5s8_pgw_gtpu_ipv4;
uint32_t s5s8_pgw_gtpu_teid;
struct in_addr s1u_enb_gtpu_ipv4;
uint32_t s1u_enb_gtpu_teid;
struct in_addr s11u_mme_gtpu_ipv4;
uint32_t s11u_mme_gtpu_teid;
struct pdn_connection_t *pdn;
int packet_filter_map[MAX_FILTERS_PER_UE];
uint8_t num_packet_filters;
} eps_bearer;
extern struct rte_hash *ue_context_by_imsi_hash;
extern struct rte_hash *ue_context_by_fteid_hash;
extern apn apn_list[MAX_NB_DPN];
/**
* sets the s1u_sgw gtpu teid given the bearer
* @param bearer
* bearer whose tied is to be set
* @param context
* ue context of bearer, whose teid is to be set
*/
void
set_s1u_sgw_gtpu_teid(eps_bearer *bearer, ue_context *context);
/**
* sets the s5s8_sgw gtpu teid given the bearer
* @param bearer
* bearer whose tied is to be set
* @param context
* ue context of bearer, whose teid is to be set
*/
void
set_s5s8_sgw_gtpu_teid(eps_bearer *bearer, ue_context *context);
/**
* sets the s5s8_pgw gtpc teid given the pdn_connection
* @param pdn
* pdn_connection whose s5s8 tied is to be set
*/
void
set_s5s8_pgw_gtpc_teid(pdn_connection *pdn);
/**
* Initializes UE hash table
*/
void
create_ue_hash(void);
/** creates an UE Context (if needed), and pdn connection with a default bearer
* given the UE IMSI, and EBI
* @param imsi
* value of information element of the imsi
* @param imsi_len
* length of information element of the imsi
* @param ebi
* Eps Bearer Identifier of default bearer
* @param context
* UE context to be created
* @return
* \- 0 if successful
* \- > 0 if error occurs during packet filter parsing corresponds to
* 3gpp specified cause error value
* \- < 0 for all other errors
*/
int
create_ue_context(uint8_t *imsi_val, uint16_t imsi_len,
uint8_t ebi, ue_context **context);
/**
* assigns the ip pool variable from parsed c-string
* @param ip_str
* ip address c-string from command line
*/
void
set_ip_pool_ip(const char *ip_str);
/**
* assigns the ip pool mask variable from parsed c-string
* @param ip_str
* ip address c-string from command line
*
*/
void
set_ip_pool_mask(const char *ip_str);
/**
* This function takes the c-string argstr describing a apn by url, for example
* label1.label2.label3 and populates the apn structure according 3gpp 23.003
* clause 9.1
* @param an_apn
* apn to be initialized
* @param argstr
* c-string containing the apn label
*/
void
set_apn_name(apn *an_apn, char *argstr);
/**
* returns the apn strucutre of the apn referenced by create session message
* @param apn_label
* apn_label within a create session message
* @param apn_length
* the length as recorded by the apn information element
* @return
* the apn label configured for the CP
*/
apn *
get_apn(char *apn_label, uint16_t apn_length);
/**
* Simple ip-pool
* @param ipv4
* ip address to be used for a new UE connection
* @return
* \- 0 if successful
* \- > 0 if error occurs during packet filter parsing corresponds to
* 3gpp specified cause error value
*/
uint32_t
acquire_ip(struct in_addr *ipv4);
/* debug */
/** print (with a column header) either context by the context and/or
* iterating over hash
* @param h
* pointer to rte_hash containing ue hash table
* @param context
* denotes if some context is to be indicated by '*' character
*/
void
print_ue_context_by(struct rte_hash *h, ue_context *context);
#endif /* UE_H */