-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathNwSaeGwUe.h
235 lines (193 loc) · 7.81 KB
/
NwSaeGwUe.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
/*----------------------------------------------------------------------------*
* *
* n w - e p c *
* L T E / S A E S E R V I N G / P D N G A T E W A Y *
* *
* *
* Copyright (c) 2010-2011 Amit Chawre *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright *
* notice, this list of conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* 3. The name of the author may not be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR *
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. *
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, *
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT *
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF *
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
*----------------------------------------------------------------------------*/
/**
* @file NwSaeGwUe.h
*/
#include <stdio.h>
#include <assert.h>
#include "tree.h"
#include "NwLog.h"
#include "NwTypes.h"
#include "NwGtpv2c.h"
#include "NwGtpv2cMsgParser.h"
#ifndef __NW_SAE_GW_UE__
#define __NW_SAE_GW_UE__
typedef enum
{
NW_SAE_GW_UE_STATE_INIT = 0,
NW_SAE_GW_UE_STATE_SAE_SESSION_CREATED,
NW_SAE_GW_UE_STATE_SGW_SESSION_CREATED,
NW_SAE_GW_UE_STATE_PGW_SESSION_CREATED,
NW_SAE_GW_UE_STATE_PGW_SESSION_ESTABLISHED = NW_SAE_GW_UE_STATE_PGW_SESSION_CREATED,
NW_SAE_GW_UE_STATE_SAE_SESSION_ESTABLISHED,
NW_SAE_GW_UE_STATE_SGW_SESSION_ESTABLISHED,
NW_SAE_GW_UE_STATE_WT_PGW_CREATE_SESSION_RSP,
NW_SAE_GW_UE_STATE_WT_PGW_DELETE_SESSION_RSP,
NW_SAE_GW_UE_STATE_WT_PGW_MODIFY_BEARER_RSP, /* Modify Bearer Sent during X2 based HO with SGW relocation */
NW_SAE_GW_UE_STATE_WT_PGW_MODIFY_BEARER_RSP2, /* Modify Bearer Sent during S1 based HO with SGW relocation */
NW_SAE_GW_UE_STATE_END
} NwUeStateT;
typedef enum
{
NW_SAE_GW_UE_EVENT_NULL = 0,
/* SAEGW SGW S11c Interface Events */
NW_SAE_GW_UE_EVENT_SGW_GTPC_S11_CREATE_SESSION_REQ,
NW_SAE_GW_UE_EVENT_SGW_GTPC_S11_MODIFY_BEARER_REQ,
NW_SAE_GW_UE_EVENT_SGW_GTPC_S11_DELETE_SESSION_REQ,
NW_SAE_GW_UE_EVENT_SGW_GTPC_S11_DELETE_SESSION_RSP,
/* SAEGW SGW S5c Interface Events */
NW_SAE_GW_UE_EVENT_SGW_GTPC_S5_CREATE_SESSION_RSP,
NW_SAE_GW_UE_EVENT_SGW_GTPC_S5_MODIFY_BEARER_RSP,
NW_SAE_GW_UE_EVENT_SGW_GTPC_S5_DELETE_SESSION_REQ,
NW_SAE_GW_UE_EVENT_SGW_GTPC_S5_DELETE_SESSION_RSP,
/* SAEGW PGW S5c Interface Events */
NW_SAE_GW_UE_EVENT_PGW_GTPC_S5_CREATE_SESSION_REQ,
NW_SAE_GW_UE_EVENT_PGW_GTPC_S5_MODIFY_BEARER_REQ,
NW_SAE_GW_UE_EVENT_PGW_GTPC_S5_DELETE_SESSION_REQ,
NW_SAE_GW_UE_EVENT_PGW_GTPC_S5_DELETE_SESSION_RSP,
NW_SAE_GW_UE_EVENT_SESSION_TIMEOUT,
NW_SAE_GW_UE_EVENT_NACK,
NW_SAE_GW_UE_EVENT_END
} NwSaeGwUeEventT;
#define NW_SAE_GW_UE_SESSION_TYPE_SGW (0x01)
#define NW_SAE_GW_UE_SESSION_TYPE_PGW (0x02)
#define NW_SAE_GW_UE_SESSION_TYPE_SAE (NW_SAE_GW_UE_SESSION_TYPE_SGW | NW_SAE_GW_UE_SESSION_TYPE_PGW)
/**
* Fully Qualified Tunnel Endpoint Identifier aka FTEID
*/
typedef struct
{
NwBoolT isValid;
NwBoolT isIpv4;
NwBoolT isIpv6;
NwU8T ifType;
NwU32T teidOrGreKey;
NwU32T ipv4Addr;
NwU8T ipv6Addr[16];
} NwSaeGwFteidT;
typedef struct
{
NwU8T pdnType;
NwU8T ipv4Addr[4];
} NwSaeGwPaaT;
/**
* EPS Bearer
*/
typedef struct
{
NwU8T ebi;
NwU8T cause;
struct {
NwSaeGwFteidT fteidEnodeB;
NwSaeGwFteidT fteidSgw;
} s1u;
struct {
NwSaeGwFteidT fteidPgw;
NwSaeGwFteidT fteidSgw;
} s5s8u;
} NwSaeGwEpsBearerT;
typedef NwPtrT NwDpeBearerHandleT;
typedef struct NwSaeGwUe
{
NwU8T imsi[8];
NwU8T msIsdn[8];
NwU8T mei[8];
NwU8T servingNetwork[3];
NwU8T ratType;
NwU8T selMode;
NwU8T pdnType;
struct {
NwU8T v[256];
NwU16T l;
} apn;
NwU8T apnRes;
NwSaeGwPaaT paa;
NwU32T sessionType;
NwU32T hSgw;
NwU32T hPgw;
NwUeStateT state;
NwGtpv2cStackHandleT hGtpv2cStackSgwS11;
NwGtpv2cStackHandleT hGtpv2cStackSgwS5;
NwGtpv2cStackHandleT hGtpv2cStackPgwS5;
struct {
NwSaeGwFteidT fteidMme;
NwSaeGwFteidT fteidSgw;
NwGtpv2cTunnelHandleT hSgwLocalTunnel;
} s11cTunnel;
struct {
NwSaeGwFteidT fteidPgw;
NwSaeGwFteidT fteidSgw;
NwGtpv2cTunnelHandleT hSgwLocalTunnel;
NwGtpv2cTunnelHandleT hPgwLocalTunnel;
} s5s8cTunnel;
#define NW_SAE_GW_MAX_EPS_BEARERS (16)
struct {
NwBoolT isValid;
NwDpeBearerHandleT hSgwUplink;
NwDpeBearerHandleT hSgwDownlink;
NwDpeBearerHandleT hPgwUplink;
NwDpeBearerHandleT hPgwDownlink;
struct {
NwSaeGwFteidT fteidEnodeB;
NwSaeGwFteidT fteidSgw;
} s1uTunnel;
struct {
NwSaeGwFteidT fteidPgw;
NwSaeGwFteidT fteidSgw;
} s5s8uTunnel;
} epsBearer[NW_SAE_GW_MAX_EPS_BEARERS];
RB_ENTRY (NwSaeGwUe) ueSgwSessionRbtNode; /**< RB Tree Data Structure Node */
RB_ENTRY (NwSaeGwUe) uePgwSessionRbtNode; /**< RB Tree Data Structure Node */
} NwSaeGwUeT;
typedef struct
{
NwSaeGwUeEventT event;
void* arg;
} NwSaeGwUeEventInfoT;
#ifdef __cplusplus
extern "C" {
#endif
NwSaeGwUeT*
nwSaeGwUeNew(NwGtpv2cStackHandleT hGtpv2cStackSgwS11,
NwGtpv2cStackHandleT hGtpv2cStackSgwS5,
NwGtpv2cStackHandleT hGtpv2cStackPgwS5);
NwRcT
nwSaeGwUeDelete(NwSaeGwUeT*);
NwRcT
nwSaeGwDecodePaa(NwSaeGwUeT* thiz, NwGtpv2cMsgHandleT hReqMsg, NwSaeGwPaaT *pPaa);
NwRcT
nwSaeGwUeUnexpectedEvent(NwSaeGwUeT* thiz, NwSaeGwUeEventInfoT* pEv);
#ifdef __cplusplus
}
#endif
#endif