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
/*******************************************************************************
Eurecom OpenAirInterface
Copyright(c) 1999 - 2013 Eurecom
This program is free software; you can redistribute it and/or modify it
under the terms and conditions of the GNU General Public License,
version 2, as published by the Free Software Foundation.
This program is distributed in the hope it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
Contact Information
Openair Admin: openair_admin@eurecom.fr
Openair Tech : openair_tech@eurecom.fr
Forums : http://forums.eurecom.fr/openairinterface
Address : EURECOM, Campus SophiaTech, 450 Route des Chappes
06410 Biot FRANCE
*******************************************************************************/
#include <string.h>
#include <stdint.h>
#include <ctype.h>
#include "assertions.h"
#include "intertask_interface.h"
#include "esm_proc.h"
#ifndef NAS_ITTI_MESSAGING_H_
#define NAS_ITTI_MESSAGING_H_
# if ((defined(EPC_BUILD) && defined(NAS_MME)) || (defined(ENABLE_NAS_UE_LOGGING) && defined(UE_BUILD) && defined(NAS_UE)))
int nas_itti_plain_msg(
const char *buffer,
const nas_message_t *msg,
const int lengthP,
const int instance);
int nas_itti_protected_msg(
const char *buffer,
const nas_message_t *msg,
const int lengthP,
const int instance);
# endif
# if defined(EPC_BUILD) && defined(NAS_MME)
#include "conversions.h"
int nas_itti_dl_data_req(
const uint32_t ue_idP,
void *const data_pP,
const uint32_t lengthP);
static inline void nas_itti_pdn_connectivity_req(
int ptiP,
unsigned int ueidP,
const imsi_t *const imsi_pP,
esm_proc_data_t *proc_data_pP,
esm_proc_pdn_request_t request_typeP)
{
MessageDef *message_p = NULL;
AssertFatal(imsi_pP != NULL, "imsi_pP param is NULL");
AssertFatal(proc_data_pP != NULL, "proc_data_pP param is NULL");
message_p = itti_alloc_new_message(TASK_NAS_MME, NAS_PDN_CONNECTIVITY_REQ);
memset(&message_p->ittiMsg.nas_pdn_connectivity_req,
0,
sizeof(nas_pdn_connectivity_req_t));
hexa_to_ascii((uint8_t *)imsi_pP->u.value,
NAS_PDN_CONNECTIVITY_REQ(message_p).imsi,
8);
NAS_PDN_CONNECTIVITY_REQ(message_p).pti = ptiP;
NAS_PDN_CONNECTIVITY_REQ(message_p).ue_id = ueidP;
NAS_PDN_CONNECTIVITY_REQ(message_p).imsi[15] = '\0';
if (isdigit(NAS_PDN_CONNECTIVITY_REQ(message_p).imsi[14])) {
NAS_PDN_CONNECTIVITY_REQ(message_p).imsi_length = 15;
} else {
NAS_PDN_CONNECTIVITY_REQ(message_p).imsi_length = 14;
NAS_PDN_CONNECTIVITY_REQ(message_p).imsi[14] = '\0';
}
DUP_OCTET_STRING(proc_data_pP->apn, NAS_PDN_CONNECTIVITY_REQ(message_p).apn);
DUP_OCTET_STRING(proc_data_pP->pdn_addr, NAS_PDN_CONNECTIVITY_REQ(message_p).pdn_addr);
switch (proc_data_pP->pdn_type) {
case ESM_PDN_TYPE_IPV4:
NAS_PDN_CONNECTIVITY_REQ(message_p).pdn_type = IPv4;
break;
case ESM_PDN_TYPE_IPV6:
NAS_PDN_CONNECTIVITY_REQ(message_p).pdn_type = IPv6;
break;
case ESM_PDN_TYPE_IPV4V6:
NAS_PDN_CONNECTIVITY_REQ(message_p).pdn_type = IPv4_AND_v6;
break;
default:
NAS_PDN_CONNECTIVITY_REQ(message_p).pdn_type = IPv4;
break;
}
// not efficient but be careful about "typedef network_qos_t esm_proc_qos_t;"
NAS_PDN_CONNECTIVITY_REQ(message_p).qos.gbrUL = proc_data_pP->qos.gbrUL;
NAS_PDN_CONNECTIVITY_REQ(message_p).qos.gbrDL = proc_data_pP->qos.gbrDL;
NAS_PDN_CONNECTIVITY_REQ(message_p).qos.mbrUL = proc_data_pP->qos.mbrUL;
NAS_PDN_CONNECTIVITY_REQ(message_p).qos.mbrDL = proc_data_pP->qos.mbrDL;
NAS_PDN_CONNECTIVITY_REQ(message_p).qos.qci = proc_data_pP->qos.qci;
NAS_PDN_CONNECTIVITY_REQ(message_p).proc_data = proc_data_pP;
NAS_PDN_CONNECTIVITY_REQ(message_p).request_type = request_typeP;
itti_send_msg_to_task(TASK_MME_APP, INSTANCE_DEFAULT, message_p);
}
static inline void nas_itti_establish_cnf(
const uint32_t ue_idP,
const nas_error_code_t error_codeP,
void *const data_pP,
const uint32_t lengthP)
{
MessageDef *message_p = NULL;
message_p = itti_alloc_new_message(TASK_NAS_MME, NAS_CONNECTION_ESTABLISHMENT_CNF);
memset(&message_p->ittiMsg.nas_conn_est_cnf,
0,
sizeof(nas_conn_est_cnf_t));
NAS_CONNECTION_ESTABLISHMENT_CNF(message_p).UEid = ue_idP;
NAS_CONNECTION_ESTABLISHMENT_CNF(message_p).errCode = error_codeP;
NAS_CONNECTION_ESTABLISHMENT_CNF(message_p).nasMsg.data = data_pP;
NAS_CONNECTION_ESTABLISHMENT_CNF(message_p).nasMsg.length = lengthP;
itti_send_msg_to_task(TASK_MME_APP, INSTANCE_DEFAULT, message_p);
}
static inline void nas_itti_auth_info_req(
const uint32_t ue_idP,
const imsi_t *const imsi_pP,
uint8_t initial_reqP,
const uint8_t *auts_pP)
{
MessageDef *message_p;
message_p = itti_alloc_new_message(TASK_NAS_MME, NAS_AUTHENTICATION_PARAM_REQ);
memset(&message_p->ittiMsg.nas_auth_param_req,
0,
sizeof(nas_auth_param_req_t));
hexa_to_ascii((uint8_t *)imsi_pP->u.value,
NAS_AUTHENTICATION_PARAM_REQ(message_p).imsi, 8);
NAS_AUTHENTICATION_PARAM_REQ(message_p).imsi[15] = '\0';
if (isdigit(NAS_AUTHENTICATION_PARAM_REQ(message_p).imsi[14])) {
NAS_AUTHENTICATION_PARAM_REQ(message_p).imsi_length = 15;
} else {
NAS_AUTHENTICATION_PARAM_REQ(message_p).imsi_length = 14;
NAS_AUTHENTICATION_PARAM_REQ(message_p).imsi[14] = '\0';
}
NAS_AUTHENTICATION_PARAM_REQ(message_p).initial_req = initial_reqP;
NAS_AUTHENTICATION_PARAM_REQ(message_p).ue_id = ue_idP;
/* Re-synchronisation */
if (auts_pP != NULL) {
NAS_AUTHENTICATION_PARAM_REQ(message_p).re_synchronization = 1;
memcpy(NAS_AUTHENTICATION_PARAM_REQ(message_p).auts, auts_pP, AUTS_LENGTH);
} else {
NAS_AUTHENTICATION_PARAM_REQ(message_p).re_synchronization = 0;
memset(NAS_AUTHENTICATION_PARAM_REQ(message_p).auts, 0, AUTS_LENGTH);
}
itti_send_msg_to_task(TASK_MME_APP, INSTANCE_DEFAULT, message_p);
}
static inline void nas_itti_establish_rej(
const uint32_t ue_idP,
const imsi_t *const imsi_pP
, uint8_t initial_reqP)
{
MessageDef *message_p;
message_p = itti_alloc_new_message(TASK_NAS_MME, NAS_AUTHENTICATION_PARAM_REQ);
memset(&message_p->ittiMsg.nas_auth_param_req,
0,
sizeof(nas_auth_param_req_t));
hexa_to_ascii((uint8_t *)imsi_pP->u.value,
NAS_AUTHENTICATION_PARAM_REQ(message_p).imsi, 8);
NAS_AUTHENTICATION_PARAM_REQ(message_p).imsi[15] = '\0';
if (isdigit(NAS_AUTHENTICATION_PARAM_REQ(message_p).imsi[14])) {
NAS_AUTHENTICATION_PARAM_REQ(message_p).imsi_length = 15;
} else {
NAS_AUTHENTICATION_PARAM_REQ(message_p).imsi_length = 14;
NAS_AUTHENTICATION_PARAM_REQ(message_p).imsi[14] = '\0';
}
NAS_AUTHENTICATION_PARAM_REQ(message_p).initial_req = initial_reqP;
NAS_AUTHENTICATION_PARAM_REQ(message_p).ue_id = ue_idP;
itti_send_msg_to_task(TASK_MME_APP, INSTANCE_DEFAULT, message_p);
}
# endif
# if defined(UE_BUILD) && defined(NAS_UE)
int nas_itti_cell_info_req(const plmn_t plmnID, const Byte_t rat);
int nas_itti_nas_establish_req(as_cause_t cause, as_call_type_t type, as_stmsi_t s_tmsi, plmn_t plmnID, Byte_t *data_pP, UInt32_t lengthP);
int nas_itti_ul_data_req(const uint32_t ue_idP, void *const data_pP, const uint32_t lengthP);
int nas_itti_rab_establish_rsp(const as_stmsi_t s_tmsi, const as_rab_id_t rabID, const nas_error_code_t errCode);
# endif
#endif /* NAS_ITTI_MESSAGING_H_ */