Coverage Report

Created: 2023-09-25 07:12

/src/open5gs/lib/nas/eps/decoder.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * The MIT License
3
 *
4
 * Copyright (C) 2019-2023 by Sukchan Lee <acetcom@gmail.com>
5
 *
6
 * This file is part of Open5GS.
7
 *
8
 * Permission is hereby granted, free of charge, to any person obtaining
9
 * a copy of this software and associated documentation files (the
10
 * "Software"), to deal in the Software without restriction, including
11
 * without limitation the rights to use, copy, modify, merge, publish,
12
 * distribute, sublicense, and/or sell copies of the Software, and to
13
 * permit persons to whom the Software is furnished to do so, subject to
14
 * the following conditions:
15
 *
16
 * The above copyright notice and this permission notice shall be
17
 * included in all copies or substantial portions of the Software.
18
 *
19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
 */
27
28
/*******************************************************************************
29
 * This file had been created by nas-message.py script v0.1.0
30
 * Please do not modify this file but regenerate it via script.
31
 * Created on: 2023-03-02 22:57:51.860294 by acetcom
32
 * from 24301-h90.docx
33
 ******************************************************************************/
34
35
#include "ogs-nas-eps.h"
36
37
int ogs_nas_eps_decode_attach_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
38
int ogs_nas_eps_decode_attach_accept(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
39
int ogs_nas_eps_decode_attach_complete(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
40
int ogs_nas_eps_decode_attach_reject(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
41
int ogs_nas_eps_decode_detach_request_from_ue(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
42
int ogs_nas_eps_decode_detach_request_to_ue(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
43
int ogs_nas_eps_decode_tracking_area_update_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
44
int ogs_nas_eps_decode_tracking_area_update_accept(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
45
int ogs_nas_eps_decode_tracking_area_update_reject(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
46
int ogs_nas_eps_decode_extended_service_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
47
int ogs_nas_eps_decode_service_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
48
int ogs_nas_eps_decode_service_reject(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
49
int ogs_nas_eps_decode_guti_reallocation_command(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
50
int ogs_nas_eps_decode_authentication_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
51
int ogs_nas_eps_decode_authentication_response(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
52
int ogs_nas_eps_decode_identity_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
53
int ogs_nas_eps_decode_identity_response(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
54
int ogs_nas_eps_decode_authentication_failure(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
55
int ogs_nas_eps_decode_security_mode_command(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
56
int ogs_nas_eps_decode_security_mode_complete(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
57
int ogs_nas_eps_decode_security_mode_reject(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
58
int ogs_nas_eps_decode_emm_status(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
59
int ogs_nas_eps_decode_emm_information(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
60
int ogs_nas_eps_decode_downlink_nas_transport(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
61
int ogs_nas_eps_decode_uplink_nas_transport(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
62
int ogs_nas_eps_decode_cs_service_notification(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
63
int ogs_nas_eps_decode_uplink_generic_nas_transport(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
64
int ogs_nas_eps_decode_downlink_generic_nas_transport(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
65
int ogs_nas_eps_decode_activate_default_eps_bearer_context_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
66
int ogs_nas_eps_decode_activate_default_eps_bearer_context_accept(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
67
int ogs_nas_eps_decode_activate_default_eps_bearer_context_reject(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
68
int ogs_nas_eps_decode_activate_dedicated_eps_bearer_context_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
69
int ogs_nas_eps_decode_activate_dedicated_eps_bearer_context_accept(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
70
int ogs_nas_eps_decode_activate_dedicated_eps_bearer_context_reject(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
71
int ogs_nas_eps_decode_modify_eps_bearer_context_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
72
int ogs_nas_eps_decode_modify_eps_bearer_context_accept(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
73
int ogs_nas_eps_decode_modify_eps_bearer_context_reject(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
74
int ogs_nas_eps_decode_deactivate_eps_bearer_context_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
75
int ogs_nas_eps_decode_deactivate_eps_bearer_context_accept(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
76
int ogs_nas_eps_decode_pdn_connectivity_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
77
int ogs_nas_eps_decode_pdn_connectivity_reject(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
78
int ogs_nas_eps_decode_pdn_disconnect_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
79
int ogs_nas_eps_decode_pdn_disconnect_reject(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
80
int ogs_nas_eps_decode_bearer_resource_allocation_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
81
int ogs_nas_eps_decode_bearer_resource_allocation_reject(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
82
int ogs_nas_eps_decode_bearer_resource_modification_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
83
int ogs_nas_eps_decode_bearer_resource_modification_reject(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
84
int ogs_nas_eps_decode_esm_information_response(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
85
int ogs_nas_eps_decode_esm_status(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf);
86
int ogs_nas_eps_decode_attach_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
87
346
{
88
346
    ogs_nas_eps_attach_request_t *attach_request = &message->emm.attach_request;
89
346
    int decoded = 0;
90
346
    int size = 0;
91
92
346
    ogs_trace("[NAS] Decode ATTACH_REQUEST\n");
93
94
346
    size = ogs_nas_eps_decode_eps_attach_type(&attach_request->eps_attach_type, pkbuf);
95
346
    if (size < 0) {
96
0
        ogs_error("ogs_nas_eps_decode_eps_attach_type() failed");
97
0
        return size;
98
0
    }
99
100
346
    decoded += size;
101
102
346
    size = ogs_nas_eps_decode_eps_mobile_identity(&attach_request->eps_mobile_identity, pkbuf);
103
346
    if (size < 0) {
104
2
        ogs_error("ogs_nas_eps_decode_eps_mobile_identity() failed");
105
2
        return size;
106
2
    }
107
108
344
    decoded += size;
109
110
344
    size = ogs_nas_eps_decode_ue_network_capability(&attach_request->ue_network_capability, pkbuf);
111
344
    if (size < 0) {
112
16
        ogs_error("ogs_nas_eps_decode_ue_network_capability() failed");
113
16
        return size;
114
16
    }
115
116
328
    decoded += size;
117
118
328
    size = ogs_nas_eps_decode_esm_message_container(&attach_request->esm_message_container, pkbuf);
119
328
    if (size < 0) {
120
8
        ogs_error("ogs_nas_eps_decode_esm_message_container() failed");
121
8
        return size;
122
8
    }
123
124
320
    decoded += size;
125
126
14.0k
    while (pkbuf->len > 0) {
127
13.7k
        uint8_t *buffer = pkbuf->data;
128
13.7k
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
129
130
13.7k
        size = sizeof(uint8_t);
131
13.7k
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
132
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
133
0
           return OGS_ERROR;
134
0
        }
135
13.7k
        decoded += size;
136
137
13.7k
        switch (type) {
138
267
        case OGS_NAS_EPS_ATTACH_REQUEST_OLD_P_TMSI_SIGNATURE_TYPE:
139
267
            size = ogs_nas_eps_decode_p_tmsi_signature(&attach_request->old_p_tmsi_signature, pkbuf);
140
267
            if (size < 0) {
141
1
               ogs_error("ogs_nas_eps_decode_p_tmsi_signature() failed");
142
1
               return size;
143
1
            }
144
145
266
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_OLD_P_TMSI_SIGNATURE_PRESENT;
146
266
            decoded += size;
147
266
            break;
148
197
        case OGS_NAS_EPS_ATTACH_REQUEST_ADDITIONAL_GUTI_TYPE:
149
197
            size = ogs_nas_eps_decode_eps_mobile_identity(&attach_request->additional_guti, pkbuf);
150
197
            if (size < 0) {
151
1
               ogs_error("ogs_nas_eps_decode_eps_mobile_identity() failed");
152
1
               return size;
153
1
            }
154
155
196
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_ADDITIONAL_GUTI_PRESENT;
156
196
            decoded += size;
157
196
            break;
158
202
        case OGS_NAS_EPS_ATTACH_REQUEST_LAST_VISITED_REGISTERED_TAI_TYPE:
159
202
            size = ogs_nas_eps_decode_tracking_area_identity(&attach_request->last_visited_registered_tai, pkbuf);
160
202
            if (size < 0) {
161
1
               ogs_error("ogs_nas_eps_decode_tracking_area_identity() failed");
162
1
               return size;
163
1
            }
164
165
201
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_LAST_VISITED_REGISTERED_TAI_PRESENT;
166
201
            decoded += size;
167
201
            break;
168
208
        case OGS_NAS_EPS_ATTACH_REQUEST_DRX_PARAMETER_TYPE:
169
208
            size = ogs_nas_eps_decode_drx_parameter(&attach_request->drx_parameter, pkbuf);
170
208
            if (size < 0) {
171
1
               ogs_error("ogs_nas_eps_decode_drx_parameter() failed");
172
1
               return size;
173
1
            }
174
175
207
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_DRX_PARAMETER_PRESENT;
176
207
            decoded += size;
177
207
            break;
178
204
        case OGS_NAS_EPS_ATTACH_REQUEST_MS_NETWORK_CAPABILITY_TYPE:
179
204
            size = ogs_nas_eps_decode_ms_network_capability(&attach_request->ms_network_capability, pkbuf);
180
204
            if (size < 0) {
181
2
               ogs_error("ogs_nas_eps_decode_ms_network_capability() failed");
182
2
               return size;
183
2
            }
184
185
202
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_MS_NETWORK_CAPABILITY_PRESENT;
186
202
            decoded += size;
187
202
            break;
188
305
        case OGS_NAS_EPS_ATTACH_REQUEST_OLD_LOCATION_AREA_IDENTIFICATION_TYPE:
189
305
            size = ogs_nas_eps_decode_location_area_identification(&attach_request->old_location_area_identification, pkbuf);
190
305
            if (size < 0) {
191
1
               ogs_error("ogs_nas_eps_decode_location_area_identification() failed");
192
1
               return size;
193
1
            }
194
195
304
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_OLD_LOCATION_AREA_IDENTIFICATION_PRESENT;
196
304
            decoded += size;
197
304
            break;
198
372
        case OGS_NAS_EPS_ATTACH_REQUEST_TMSI_STATUS_TYPE:
199
372
            decoded--;
200
372
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
201
372
            size = ogs_nas_eps_decode_tmsi_status(&attach_request->tmsi_status, pkbuf);
202
372
            if (size < 0) {
203
0
               ogs_error("ogs_nas_eps_decode_tmsi_status() failed");
204
0
               return size;
205
0
            }
206
207
372
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_TMSI_STATUS_PRESENT;
208
372
            decoded += size;
209
372
            break;
210
207
        case OGS_NAS_EPS_ATTACH_REQUEST_MOBILE_STATION_CLASSMARK_2_TYPE:
211
207
            size = ogs_nas_eps_decode_mobile_station_classmark_2(&attach_request->mobile_station_classmark_2, pkbuf);
212
207
            if (size < 0) {
213
1
               ogs_error("ogs_nas_eps_decode_mobile_station_classmark_2() failed");
214
1
               return size;
215
1
            }
216
217
206
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_MOBILE_STATION_CLASSMARK_2_PRESENT;
218
206
            decoded += size;
219
206
            break;
220
218
        case OGS_NAS_EPS_ATTACH_REQUEST_MOBILE_STATION_CLASSMARK_3_TYPE:
221
218
            size = ogs_nas_eps_decode_mobile_station_classmark_3(&attach_request->mobile_station_classmark_3, pkbuf);
222
218
            if (size < 0) {
223
2
               ogs_error("ogs_nas_eps_decode_mobile_station_classmark_3() failed");
224
2
               return size;
225
2
            }
226
227
216
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_MOBILE_STATION_CLASSMARK_3_PRESENT;
228
216
            decoded += size;
229
216
            break;
230
207
        case OGS_NAS_EPS_ATTACH_REQUEST_SUPPORTED_CODECS_TYPE:
231
207
            size = ogs_nas_eps_decode_supported_codec_list(&attach_request->supported_codecs, pkbuf);
232
207
            if (size < 0) {
233
2
               ogs_error("ogs_nas_eps_decode_supported_codec_list() failed");
234
2
               return size;
235
2
            }
236
237
205
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_SUPPORTED_CODECS_PRESENT;
238
205
            decoded += size;
239
205
            break;
240
2.05k
        case OGS_NAS_EPS_ATTACH_REQUEST_ADDITIONAL_UPDATE_TYPE_TYPE:
241
2.05k
            decoded--;
242
2.05k
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
243
2.05k
            size = ogs_nas_eps_decode_additional_update_type(&attach_request->additional_update_type, pkbuf);
244
2.05k
            if (size < 0) {
245
0
               ogs_error("ogs_nas_eps_decode_additional_update_type() failed");
246
0
               return size;
247
0
            }
248
249
2.05k
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_ADDITIONAL_UPDATE_TYPE_PRESENT;
250
2.05k
            decoded += size;
251
2.05k
            break;
252
208
        case OGS_NAS_EPS_ATTACH_REQUEST_VOICE_DOMAIN_PREFERENCE_AND_UE_USAGE_SETTING_TYPE:
253
208
            size = ogs_nas_eps_decode_voice_domain_preference_and_ue_usage_setting(&attach_request->voice_domain_preference_and_ue_usage_setting, pkbuf);
254
208
            if (size < 0) {
255
1
               ogs_error("ogs_nas_eps_decode_voice_domain_preference_and_ue_usage_setting() failed");
256
1
               return size;
257
1
            }
258
259
207
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_VOICE_DOMAIN_PREFERENCE_AND_UE_USAGE_SETTING_PRESENT;
260
207
            decoded += size;
261
207
            break;
262
738
        case OGS_NAS_EPS_ATTACH_REQUEST_DEVICE_PROPERTIES_TYPE:
263
738
            decoded--;
264
738
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
265
738
            size = ogs_nas_eps_decode_device_properties(&attach_request->device_properties, pkbuf);
266
738
            if (size < 0) {
267
0
               ogs_error("ogs_nas_eps_decode_device_properties() failed");
268
0
               return size;
269
0
            }
270
271
738
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_DEVICE_PROPERTIES_PRESENT;
272
738
            decoded += size;
273
738
            break;
274
331
        case OGS_NAS_EPS_ATTACH_REQUEST_OLD_GUTI_TYPE_TYPE:
275
331
            decoded--;
276
331
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
277
331
            size = ogs_nas_eps_decode_guti_type(&attach_request->old_guti_type, pkbuf);
278
331
            if (size < 0) {
279
0
               ogs_error("ogs_nas_eps_decode_guti_type() failed");
280
0
               return size;
281
0
            }
282
283
331
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_OLD_GUTI_TYPE_PRESENT;
284
331
            decoded += size;
285
331
            break;
286
976
        case OGS_NAS_EPS_ATTACH_REQUEST_MS_NETWORK_FEATURE_SUPPORT_TYPE:
287
976
            decoded--;
288
976
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
289
976
            size = ogs_nas_eps_decode_ms_network_feature_support(&attach_request->ms_network_feature_support, pkbuf);
290
976
            if (size < 0) {
291
0
               ogs_error("ogs_nas_eps_decode_ms_network_feature_support() failed");
292
0
               return size;
293
0
            }
294
295
976
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_MS_NETWORK_FEATURE_SUPPORT_PRESENT;
296
976
            decoded += size;
297
976
            break;
298
203
        case OGS_NAS_EPS_ATTACH_REQUEST_TMSI_BASED_NRI_CONTAINER_TYPE:
299
203
            size = ogs_nas_eps_decode_network_resource_identifier_container(&attach_request->tmsi_based_nri_container, pkbuf);
300
203
            if (size < 0) {
301
1
               ogs_error("ogs_nas_eps_decode_network_resource_identifier_container() failed");
302
1
               return size;
303
1
            }
304
305
202
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_TMSI_BASED_NRI_CONTAINER_PRESENT;
306
202
            decoded += size;
307
202
            break;
308
199
        case OGS_NAS_EPS_ATTACH_REQUEST_T3324_VALUE_TYPE:
309
199
            size = ogs_nas_eps_decode_gprs_timer_2(&attach_request->t3324_value, pkbuf);
310
199
            if (size < 0) {
311
2
               ogs_error("ogs_nas_eps_decode_gprs_timer_2() failed");
312
2
               return size;
313
2
            }
314
315
197
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_T3324_VALUE_PRESENT;
316
197
            decoded += size;
317
197
            break;
318
229
        case OGS_NAS_EPS_ATTACH_REQUEST_T3412_EXTENDED_VALUE_TYPE:
319
229
            size = ogs_nas_eps_decode_gprs_timer_3(&attach_request->t3412_extended_value, pkbuf);
320
229
            if (size < 0) {
321
1
               ogs_error("ogs_nas_eps_decode_gprs_timer_3() failed");
322
1
               return size;
323
1
            }
324
325
228
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_T3412_EXTENDED_VALUE_PRESENT;
326
228
            decoded += size;
327
228
            break;
328
209
        case OGS_NAS_EPS_ATTACH_REQUEST_EXTENDED_DRX_PARAMETERS_TYPE:
329
209
            size = ogs_nas_eps_decode_extended_drx_parameters(&attach_request->extended_drx_parameters, pkbuf);
330
209
            if (size < 0) {
331
1
               ogs_error("ogs_nas_eps_decode_extended_drx_parameters() failed");
332
1
               return size;
333
1
            }
334
335
208
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_EXTENDED_DRX_PARAMETERS_PRESENT;
336
208
            decoded += size;
337
208
            break;
338
205
        case OGS_NAS_EPS_ATTACH_REQUEST_UE_ADDITIONAL_SECURITY_CAPABILITY_TYPE:
339
205
            size = ogs_nas_eps_decode_ue_additional_security_capability(&attach_request->ue_additional_security_capability, pkbuf);
340
205
            if (size < 0) {
341
1
               ogs_error("ogs_nas_eps_decode_ue_additional_security_capability() failed");
342
1
               return size;
343
1
            }
344
345
204
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_UE_ADDITIONAL_SECURITY_CAPABILITY_PRESENT;
346
204
            decoded += size;
347
204
            break;
348
199
        case OGS_NAS_EPS_ATTACH_REQUEST_UE_STATUS_TYPE:
349
199
            size = ogs_nas_eps_decode_ue_status(&attach_request->ue_status, pkbuf);
350
199
            if (size < 0) {
351
2
               ogs_error("ogs_nas_eps_decode_ue_status() failed");
352
2
               return size;
353
2
            }
354
355
197
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_UE_STATUS_PRESENT;
356
197
            decoded += size;
357
197
            break;
358
235
        case OGS_NAS_EPS_ATTACH_REQUEST_ADDITIONAL_INFORMATION_REQUESTED_TYPE:
359
235
            size = ogs_nas_eps_decode_additional_information_requested(&attach_request->additional_information_requested, pkbuf);
360
235
            if (size < 0) {
361
2
               ogs_error("ogs_nas_eps_decode_additional_information_requested() failed");
362
2
               return size;
363
2
            }
364
365
233
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_ADDITIONAL_INFORMATION_REQUESTED_PRESENT;
366
233
            decoded += size;
367
233
            break;
368
211
        case OGS_NAS_EPS_ATTACH_REQUEST_N1_UE_NETWORK_CAPABILITY_TYPE:
369
211
            size = ogs_nas_eps_decode_n1_ue_network_capability(&attach_request->n1_ue_network_capability, pkbuf);
370
211
            if (size < 0) {
371
2
               ogs_error("ogs_nas_eps_decode_n1_ue_network_capability() failed");
372
2
               return size;
373
2
            }
374
375
209
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_N1_UE_NETWORK_CAPABILITY_PRESENT;
376
209
            decoded += size;
377
209
            break;
378
198
        case OGS_NAS_EPS_ATTACH_REQUEST_UE_RADIO_CAPABILITY_ID_AVAILABILITY_TYPE:
379
198
            size = ogs_nas_eps_decode_ue_radio_capability_id_availability(&attach_request->ue_radio_capability_id_availability, pkbuf);
380
198
            if (size < 0) {
381
1
               ogs_error("ogs_nas_eps_decode_ue_radio_capability_id_availability() failed");
382
1
               return size;
383
1
            }
384
385
197
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_UE_RADIO_CAPABILITY_ID_AVAILABILITY_PRESENT;
386
197
            decoded += size;
387
197
            break;
388
215
        case OGS_NAS_EPS_ATTACH_REQUEST_REQUESTED_WUS_ASSISTANCE_INFORMATION_TYPE:
389
215
            size = ogs_nas_eps_decode_wus_assistance_information(&attach_request->requested_wus_assistance_information, pkbuf);
390
215
            if (size < 0) {
391
2
               ogs_error("ogs_nas_eps_decode_wus_assistance_information() failed");
392
2
               return size;
393
2
            }
394
395
213
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_REQUESTED_WUS_ASSISTANCE_INFORMATION_PRESENT;
396
213
            decoded += size;
397
213
            break;
398
205
        case OGS_NAS_EPS_ATTACH_REQUEST_DRX_PARAMETER_IN_NB_S1_MODE_TYPE:
399
205
            size = ogs_nas_eps_decode_nb_s1_drx_parameter(&attach_request->drx_parameter_in_nb_s1_mode, pkbuf);
400
205
            if (size < 0) {
401
1
               ogs_error("ogs_nas_eps_decode_nb_s1_drx_parameter() failed");
402
1
               return size;
403
1
            }
404
405
204
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_DRX_PARAMETER_IN_NB_S1_MODE_PRESENT;
406
204
            decoded += size;
407
204
            break;
408
290
        case OGS_NAS_EPS_ATTACH_REQUEST_REQUESTED_IMSI_OFFSET_TYPE:
409
290
            size = ogs_nas_eps_decode_imsi_offset(&attach_request->requested_imsi_offset, pkbuf);
410
290
            if (size < 0) {
411
1
               ogs_error("ogs_nas_eps_decode_imsi_offset() failed");
412
1
               return size;
413
1
            }
414
415
289
            attach_request->presencemask |= OGS_NAS_EPS_ATTACH_REQUEST_REQUESTED_IMSI_OFFSET_PRESENT;
416
289
            decoded += size;
417
289
            break;
418
4.50k
        default:
419
4.50k
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
420
4.50k
            break;
421
13.7k
        }
422
13.7k
    }
423
424
290
    return decoded;
425
320
}
426
427
int ogs_nas_eps_decode_attach_accept(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
428
373
{
429
373
    ogs_nas_eps_attach_accept_t *attach_accept = &message->emm.attach_accept;
430
373
    int decoded = 0;
431
373
    int size = 0;
432
433
373
    ogs_trace("[NAS] Decode ATTACH_ACCEPT\n");
434
435
373
    size = ogs_nas_eps_decode_eps_attach_result(&attach_accept->eps_attach_result, pkbuf);
436
373
    if (size < 0) {
437
0
        ogs_error("ogs_nas_eps_decode_eps_attach_result() failed");
438
0
        return size;
439
0
    }
440
441
373
    decoded += size;
442
443
373
    size = ogs_nas_eps_decode_gprs_timer(&attach_accept->t3412_value, pkbuf);
444
373
    if (size < 0) {
445
0
        ogs_error("ogs_nas_eps_decode_gprs_timer() failed");
446
0
        return size;
447
0
    }
448
449
373
    decoded += size;
450
451
373
    size = ogs_nas_eps_decode_tracking_area_identity_list(&attach_accept->tai_list, pkbuf);
452
373
    if (size < 0) {
453
4
        ogs_error("ogs_nas_eps_decode_tracking_area_identity_list() failed");
454
4
        return size;
455
4
    }
456
457
369
    decoded += size;
458
459
369
    size = ogs_nas_eps_decode_esm_message_container(&attach_accept->esm_message_container, pkbuf);
460
369
    if (size < 0) {
461
10
        ogs_error("ogs_nas_eps_decode_esm_message_container() failed");
462
10
        return size;
463
10
    }
464
465
359
    decoded += size;
466
467
14.1k
    while (pkbuf->len > 0) {
468
13.8k
        uint8_t *buffer = pkbuf->data;
469
13.8k
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
470
471
13.8k
        size = sizeof(uint8_t);
472
13.8k
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
473
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
474
0
           return OGS_ERROR;
475
0
        }
476
13.8k
        decoded += size;
477
478
13.8k
        switch (type) {
479
225
        case OGS_NAS_EPS_ATTACH_ACCEPT_GUTI_TYPE:
480
225
            size = ogs_nas_eps_decode_eps_mobile_identity(&attach_accept->guti, pkbuf);
481
225
            if (size < 0) {
482
2
               ogs_error("ogs_nas_eps_decode_eps_mobile_identity() failed");
483
2
               return size;
484
2
            }
485
486
223
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_GUTI_PRESENT;
487
223
            decoded += size;
488
223
            break;
489
203
        case OGS_NAS_EPS_ATTACH_ACCEPT_LOCATION_AREA_IDENTIFICATION_TYPE:
490
203
            size = ogs_nas_eps_decode_location_area_identification(&attach_accept->location_area_identification, pkbuf);
491
203
            if (size < 0) {
492
1
               ogs_error("ogs_nas_eps_decode_location_area_identification() failed");
493
1
               return size;
494
1
            }
495
496
202
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_LOCATION_AREA_IDENTIFICATION_PRESENT;
497
202
            decoded += size;
498
202
            break;
499
209
        case OGS_NAS_EPS_ATTACH_ACCEPT_MS_IDENTITY_TYPE:
500
209
            size = ogs_nas_eps_decode_mobile_identity(&attach_accept->ms_identity, pkbuf);
501
209
            if (size < 0) {
502
2
               ogs_error("ogs_nas_eps_decode_mobile_identity() failed");
503
2
               return size;
504
2
            }
505
506
207
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_MS_IDENTITY_PRESENT;
507
207
            decoded += size;
508
207
            break;
509
216
        case OGS_NAS_EPS_ATTACH_ACCEPT_EMM_CAUSE_TYPE:
510
216
            size = ogs_nas_eps_decode_emm_cause(&attach_accept->emm_cause, pkbuf);
511
216
            if (size < 0) {
512
1
               ogs_error("ogs_nas_eps_decode_emm_cause() failed");
513
1
               return size;
514
1
            }
515
516
215
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_EMM_CAUSE_PRESENT;
517
215
            decoded += size;
518
215
            break;
519
285
        case OGS_NAS_EPS_ATTACH_ACCEPT_T3402_VALUE_TYPE:
520
285
            size = ogs_nas_eps_decode_gprs_timer(&attach_accept->t3402_value, pkbuf);
521
285
            if (size < 0) {
522
1
               ogs_error("ogs_nas_eps_decode_gprs_timer() failed");
523
1
               return size;
524
1
            }
525
526
284
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_T3402_VALUE_PRESENT;
527
284
            decoded += size;
528
284
            break;
529
227
        case OGS_NAS_EPS_ATTACH_ACCEPT_T3423_VALUE_TYPE:
530
227
            size = ogs_nas_eps_decode_gprs_timer(&attach_accept->t3423_value, pkbuf);
531
227
            if (size < 0) {
532
1
               ogs_error("ogs_nas_eps_decode_gprs_timer() failed");
533
1
               return size;
534
1
            }
535
536
226
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_T3423_VALUE_PRESENT;
537
226
            decoded += size;
538
226
            break;
539
195
        case OGS_NAS_EPS_ATTACH_ACCEPT_EQUIVALENT_PLMNS_TYPE:
540
195
            size = ogs_nas_eps_decode_plmn_list(&attach_accept->equivalent_plmns, pkbuf);
541
195
            if (size < 0) {
542
1
               ogs_error("ogs_nas_eps_decode_plmn_list() failed");
543
1
               return size;
544
1
            }
545
546
194
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_EQUIVALENT_PLMNS_PRESENT;
547
194
            decoded += size;
548
194
            break;
549
201
        case OGS_NAS_EPS_ATTACH_ACCEPT_EMERGENCY_NUMBER_LIST_TYPE:
550
201
            size = ogs_nas_eps_decode_emergency_number_list(&attach_accept->emergency_number_list, pkbuf);
551
201
            if (size < 0) {
552
1
               ogs_error("ogs_nas_eps_decode_emergency_number_list() failed");
553
1
               return size;
554
1
            }
555
556
200
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_EMERGENCY_NUMBER_LIST_PRESENT;
557
200
            decoded += size;
558
200
            break;
559
249
        case OGS_NAS_EPS_ATTACH_ACCEPT_EPS_NETWORK_FEATURE_SUPPORT_TYPE:
560
249
            size = ogs_nas_eps_decode_eps_network_feature_support(&attach_accept->eps_network_feature_support, pkbuf);
561
249
            if (size < 0) {
562
1
               ogs_error("ogs_nas_eps_decode_eps_network_feature_support() failed");
563
1
               return size;
564
1
            }
565
566
248
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_EPS_NETWORK_FEATURE_SUPPORT_PRESENT;
567
248
            decoded += size;
568
248
            break;
569
1.66k
        case OGS_NAS_EPS_ATTACH_ACCEPT_ADDITIONAL_UPDATE_RESULT_TYPE:
570
1.66k
            decoded--;
571
1.66k
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
572
1.66k
            size = ogs_nas_eps_decode_additional_update_result(&attach_accept->additional_update_result, pkbuf);
573
1.66k
            if (size < 0) {
574
0
               ogs_error("ogs_nas_eps_decode_additional_update_result() failed");
575
0
               return size;
576
0
            }
577
578
1.66k
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_ADDITIONAL_UPDATE_RESULT_PRESENT;
579
1.66k
            decoded += size;
580
1.66k
            break;
581
209
        case OGS_NAS_EPS_ATTACH_ACCEPT_T3412_EXTENDED_VALUE_TYPE:
582
209
            size = ogs_nas_eps_decode_gprs_timer_3(&attach_accept->t3412_extended_value, pkbuf);
583
209
            if (size < 0) {
584
1
               ogs_error("ogs_nas_eps_decode_gprs_timer_3() failed");
585
1
               return size;
586
1
            }
587
588
208
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_T3412_EXTENDED_VALUE_PRESENT;
589
208
            decoded += size;
590
208
            break;
591
243
        case OGS_NAS_EPS_ATTACH_ACCEPT_T3324_VALUE_TYPE:
592
243
            size = ogs_nas_eps_decode_gprs_timer_2(&attach_accept->t3324_value, pkbuf);
593
243
            if (size < 0) {
594
1
               ogs_error("ogs_nas_eps_decode_gprs_timer_2() failed");
595
1
               return size;
596
1
            }
597
598
242
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_T3324_VALUE_PRESENT;
599
242
            decoded += size;
600
242
            break;
601
196
        case OGS_NAS_EPS_ATTACH_ACCEPT_EXTENDED_DRX_PARAMETERS_TYPE:
602
196
            size = ogs_nas_eps_decode_extended_drx_parameters(&attach_accept->extended_drx_parameters, pkbuf);
603
196
            if (size < 0) {
604
1
               ogs_error("ogs_nas_eps_decode_extended_drx_parameters() failed");
605
1
               return size;
606
1
            }
607
608
195
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_EXTENDED_DRX_PARAMETERS_PRESENT;
609
195
            decoded += size;
610
195
            break;
611
196
        case OGS_NAS_EPS_ATTACH_ACCEPT_DCN_ID_TYPE:
612
196
            size = ogs_nas_eps_decode_dcn_id(&attach_accept->dcn_id, pkbuf);
613
196
            if (size < 0) {
614
1
               ogs_error("ogs_nas_eps_decode_dcn_id() failed");
615
1
               return size;
616
1
            }
617
618
195
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_DCN_ID_PRESENT;
619
195
            decoded += size;
620
195
            break;
621
361
        case OGS_NAS_EPS_ATTACH_ACCEPT_SMS_SERVICES_STATUS_TYPE:
622
361
            decoded--;
623
361
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
624
361
            size = ogs_nas_eps_decode_sms_services_status(&attach_accept->sms_services_status, pkbuf);
625
361
            if (size < 0) {
626
0
               ogs_error("ogs_nas_eps_decode_sms_services_status() failed");
627
0
               return size;
628
0
            }
629
630
361
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_SMS_SERVICES_STATUS_PRESENT;
631
361
            decoded += size;
632
361
            break;
633
468
        case OGS_NAS_EPS_ATTACH_ACCEPT_NON__NW_PROVIDED_POLICIES_TYPE:
634
468
            decoded--;
635
468
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
636
468
            size = ogs_nas_eps_decode_non__nw_provided_policies(&attach_accept->non__nw_provided_policies, pkbuf);
637
468
            if (size < 0) {
638
0
               ogs_error("ogs_nas_eps_decode_non__nw_provided_policies() failed");
639
0
               return size;
640
0
            }
641
642
468
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_NON__NW_PROVIDED_POLICIES_PRESENT;
643
468
            decoded += size;
644
468
            break;
645
206
        case OGS_NAS_EPS_ATTACH_ACCEPT_T3448_VALUE_TYPE:
646
206
            size = ogs_nas_eps_decode_gprs_timer_2(&attach_accept->t3448_value, pkbuf);
647
206
            if (size < 0) {
648
2
               ogs_error("ogs_nas_eps_decode_gprs_timer_2() failed");
649
2
               return size;
650
2
            }
651
652
204
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_T3448_VALUE_PRESENT;
653
204
            decoded += size;
654
204
            break;
655
366
        case OGS_NAS_EPS_ATTACH_ACCEPT_NETWORK_POLICY_TYPE:
656
366
            decoded--;
657
366
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
658
366
            size = ogs_nas_eps_decode_network_policy(&attach_accept->network_policy, pkbuf);
659
366
            if (size < 0) {
660
0
               ogs_error("ogs_nas_eps_decode_network_policy() failed");
661
0
               return size;
662
0
            }
663
664
366
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_NETWORK_POLICY_PRESENT;
665
366
            decoded += size;
666
366
            break;
667
252
        case OGS_NAS_EPS_ATTACH_ACCEPT_T3447_VALUE_TYPE:
668
252
            size = ogs_nas_eps_decode_gprs_timer_3(&attach_accept->t3447_value, pkbuf);
669
252
            if (size < 0) {
670
1
               ogs_error("ogs_nas_eps_decode_gprs_timer_3() failed");
671
1
               return size;
672
1
            }
673
674
251
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_T3447_VALUE_PRESENT;
675
251
            decoded += size;
676
251
            break;
677
204
        case OGS_NAS_EPS_ATTACH_ACCEPT_EXTENDED_EMERGENCY_NUMBER_LIST_TYPE:
678
204
            size = ogs_nas_eps_decode_extended_emergency_number_list(&attach_accept->extended_emergency_number_list, pkbuf);
679
204
            if (size < 0) {
680
1
               ogs_error("ogs_nas_eps_decode_extended_emergency_number_list() failed");
681
1
               return size;
682
1
            }
683
684
203
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_EXTENDED_EMERGENCY_NUMBER_LIST_PRESENT;
685
203
            decoded += size;
686
203
            break;
687
227
        case OGS_NAS_EPS_ATTACH_ACCEPT_CIPHERING_KEY_DATA_TYPE:
688
227
            size = ogs_nas_eps_decode_ciphering_key_data(&attach_accept->ciphering_key_data, pkbuf);
689
227
            if (size < 0) {
690
1
               ogs_error("ogs_nas_eps_decode_ciphering_key_data() failed");
691
1
               return size;
692
1
            }
693
694
226
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_CIPHERING_KEY_DATA_PRESENT;
695
226
            decoded += size;
696
226
            break;
697
218
        case OGS_NAS_EPS_ATTACH_ACCEPT_UE_RADIO_CAPABILITY_ID_TYPE:
698
218
            size = ogs_nas_eps_decode_ue_radio_capability_id(&attach_accept->ue_radio_capability_id, pkbuf);
699
218
            if (size < 0) {
700
1
               ogs_error("ogs_nas_eps_decode_ue_radio_capability_id() failed");
701
1
               return size;
702
1
            }
703
704
217
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_UE_RADIO_CAPABILITY_ID_PRESENT;
705
217
            decoded += size;
706
217
            break;
707
920
        case OGS_NAS_EPS_ATTACH_ACCEPT_UE_RADIO_CAPABILITY_ID_DELETION_INDICATION_TYPE:
708
920
            decoded--;
709
920
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
710
920
            size = ogs_nas_eps_decode_ue_radio_capability_id_deletion_indication(&attach_accept->ue_radio_capability_id_deletion_indication, pkbuf);
711
920
            if (size < 0) {
712
0
               ogs_error("ogs_nas_eps_decode_ue_radio_capability_id_deletion_indication() failed");
713
0
               return size;
714
0
            }
715
716
920
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_UE_RADIO_CAPABILITY_ID_DELETION_INDICATION_PRESENT;
717
920
            decoded += size;
718
920
            break;
719
232
        case OGS_NAS_EPS_ATTACH_ACCEPT_NEGOTIATED_WUS_ASSISTANCE_INFORMATION_TYPE:
720
232
            size = ogs_nas_eps_decode_wus_assistance_information(&attach_accept->negotiated_wus_assistance_information, pkbuf);
721
232
            if (size < 0) {
722
1
               ogs_error("ogs_nas_eps_decode_wus_assistance_information() failed");
723
1
               return size;
724
1
            }
725
726
231
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_NEGOTIATED_WUS_ASSISTANCE_INFORMATION_PRESENT;
727
231
            decoded += size;
728
231
            break;
729
203
        case OGS_NAS_EPS_ATTACH_ACCEPT_NEGOTIATED_DRX_PARAMETER_IN_NB_S1_MODE_TYPE:
730
203
            size = ogs_nas_eps_decode_nb_s1_drx_parameter(&attach_accept->negotiated_drx_parameter_in_nb_s1_mode, pkbuf);
731
203
            if (size < 0) {
732
1
               ogs_error("ogs_nas_eps_decode_nb_s1_drx_parameter() failed");
733
1
               return size;
734
1
            }
735
736
202
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_NEGOTIATED_DRX_PARAMETER_IN_NB_S1_MODE_PRESENT;
737
202
            decoded += size;
738
202
            break;
739
208
        case OGS_NAS_EPS_ATTACH_ACCEPT_NEGOTIATED_IMSI_OFFSET_TYPE:
740
208
            size = ogs_nas_eps_decode_imsi_offset(&attach_accept->negotiated_imsi_offset, pkbuf);
741
208
            if (size < 0) {
742
2
               ogs_error("ogs_nas_eps_decode_imsi_offset() failed");
743
2
               return size;
744
2
            }
745
746
206
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_NEGOTIATED_IMSI_OFFSET_PRESENT;
747
206
            decoded += size;
748
206
            break;
749
292
        case OGS_NAS_EPS_ATTACH_ACCEPT_FORBIDDEN_TAI_FOR_THE_LIST_OF_FORBIDDEN_TRACKING_AREAS_FOR_ROAMING_TYPE:
750
292
            size = ogs_nas_eps_decode_tracking_area_identity_list(&attach_accept->forbidden_tai_for_the_list_of_forbidden_tracking_areas_for_roaming, pkbuf);
751
292
            if (size < 0) {
752
1
               ogs_error("ogs_nas_eps_decode_tracking_area_identity_list() failed");
753
1
               return size;
754
1
            }
755
756
291
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_FORBIDDEN_TAI_FOR_THE_LIST_OF_FORBIDDEN_TRACKING_AREAS_FOR_ROAMING_PRESENT;
757
291
            decoded += size;
758
291
            break;
759
216
        case OGS_NAS_EPS_ATTACH_ACCEPT_FORBIDDEN_TAI_FOR_THE_LIST_OF_FORBIDDEN_TRACKING_AREAS_FORREGIONAL_PROVISION_OF_SERVICE_TYPE:
760
216
            size = ogs_nas_eps_decode_tracking_area_identity_list(&attach_accept->forbidden_tai_for_the_list_of_forbidden_tracking_areas_forregional_provision_of_service, pkbuf);
761
216
            if (size < 0) {
762
1
               ogs_error("ogs_nas_eps_decode_tracking_area_identity_list() failed");
763
1
               return size;
764
1
            }
765
766
215
            attach_accept->presencemask |= OGS_NAS_EPS_ATTACH_ACCEPT_FORBIDDEN_TAI_FOR_THE_LIST_OF_FORBIDDEN_TRACKING_AREAS_FORREGIONAL_PROVISION_OF_SERVICE_PRESENT;
767
215
            decoded += size;
768
215
            break;
769
4.94k
        default:
770
4.94k
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
771
4.94k
            break;
772
13.8k
        }
773
13.8k
    }
774
775
332
    return decoded;
776
359
}
777
778
int ogs_nas_eps_decode_attach_complete(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
779
34
{
780
34
    ogs_nas_eps_attach_complete_t *attach_complete = &message->emm.attach_complete;
781
34
    int decoded = 0;
782
34
    int size = 0;
783
784
34
    ogs_trace("[NAS] Decode ATTACH_COMPLETE\n");
785
786
34
    size = ogs_nas_eps_decode_esm_message_container(&attach_complete->esm_message_container, pkbuf);
787
34
    if (size < 0) {
788
13
        ogs_error("ogs_nas_eps_decode_esm_message_container() failed");
789
13
        return size;
790
13
    }
791
792
21
    decoded += size;
793
794
21
    return decoded;
795
34
}
796
797
int ogs_nas_eps_decode_attach_reject(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
798
130
{
799
130
    ogs_nas_eps_attach_reject_t *attach_reject = &message->emm.attach_reject;
800
130
    int decoded = 0;
801
130
    int size = 0;
802
803
130
    ogs_trace("[NAS] Decode ATTACH_REJECT\n");
804
805
130
    size = ogs_nas_eps_decode_emm_cause(&attach_reject->emm_cause, pkbuf);
806
130
    if (size < 0) {
807
0
        ogs_error("ogs_nas_eps_decode_emm_cause() failed");
808
0
        return size;
809
0
    }
810
811
130
    decoded += size;
812
813
5.66k
    while (pkbuf->len > 0) {
814
5.56k
        uint8_t *buffer = pkbuf->data;
815
5.56k
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
816
817
5.56k
        size = sizeof(uint8_t);
818
5.56k
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
819
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
820
0
           return OGS_ERROR;
821
0
        }
822
5.56k
        decoded += size;
823
824
5.56k
        switch (type) {
825
241
        case OGS_NAS_EPS_ATTACH_REJECT_ESM_MESSAGE_CONTAINER_TYPE:
826
241
            size = ogs_nas_eps_decode_esm_message_container(&attach_reject->esm_message_container, pkbuf);
827
241
            if (size < 0) {
828
7
               ogs_error("ogs_nas_eps_decode_esm_message_container() failed");
829
7
               return size;
830
7
            }
831
832
234
            attach_reject->presencemask |= OGS_NAS_EPS_ATTACH_REJECT_ESM_MESSAGE_CONTAINER_PRESENT;
833
234
            decoded += size;
834
234
            break;
835
239
        case OGS_NAS_EPS_ATTACH_REJECT_T3346_VALUE_TYPE:
836
239
            size = ogs_nas_eps_decode_gprs_timer_2(&attach_reject->t3346_value, pkbuf);
837
239
            if (size < 0) {
838
3
               ogs_error("ogs_nas_eps_decode_gprs_timer_2() failed");
839
3
               return size;
840
3
            }
841
842
236
            attach_reject->presencemask |= OGS_NAS_EPS_ATTACH_REJECT_T3346_VALUE_PRESENT;
843
236
            decoded += size;
844
236
            break;
845
197
        case OGS_NAS_EPS_ATTACH_REJECT_T3402_VALUE_TYPE:
846
197
            size = ogs_nas_eps_decode_gprs_timer_2(&attach_reject->t3402_value, pkbuf);
847
197
            if (size < 0) {
848
2
               ogs_error("ogs_nas_eps_decode_gprs_timer_2() failed");
849
2
               return size;
850
2
            }
851
852
195
            attach_reject->presencemask |= OGS_NAS_EPS_ATTACH_REJECT_T3402_VALUE_PRESENT;
853
195
            decoded += size;
854
195
            break;
855
892
        case OGS_NAS_EPS_ATTACH_REJECT_EXTENDED_EMM_CAUSE_TYPE:
856
892
            decoded--;
857
892
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
858
892
            size = ogs_nas_eps_decode_extended_emm_cause(&attach_reject->extended_emm_cause, pkbuf);
859
892
            if (size < 0) {
860
0
               ogs_error("ogs_nas_eps_decode_extended_emm_cause() failed");
861
0
               return size;
862
0
            }
863
864
892
            attach_reject->presencemask |= OGS_NAS_EPS_ATTACH_REJECT_EXTENDED_EMM_CAUSE_PRESENT;
865
892
            decoded += size;
866
892
            break;
867
372
        case OGS_NAS_EPS_ATTACH_REJECT_LOWER_BOUND_TIMER_VALUE_TYPE:
868
372
            size = ogs_nas_eps_decode_gprs_timer_3(&attach_reject->lower_bound_timer_value, pkbuf);
869
372
            if (size < 0) {
870
8
               ogs_error("ogs_nas_eps_decode_gprs_timer_3() failed");
871
8
               return size;
872
8
            }
873
874
364
            attach_reject->presencemask |= OGS_NAS_EPS_ATTACH_REJECT_LOWER_BOUND_TIMER_VALUE_PRESENT;
875
364
            decoded += size;
876
364
            break;
877
200
        case OGS_NAS_EPS_ATTACH_REJECT_FORBIDDEN_TAI_FOR_THE_LIST_OF_FORBIDDEN_TRACKING_AREAS_FOR_ROAMING_TYPE:
878
200
            size = ogs_nas_eps_decode_tracking_area_identity_list(&attach_reject->forbidden_tai_for_the_list_of_forbidden_tracking_areas_for_roaming, pkbuf);
879
200
            if (size < 0) {
880
2
               ogs_error("ogs_nas_eps_decode_tracking_area_identity_list() failed");
881
2
               return size;
882
2
            }
883
884
198
            attach_reject->presencemask |= OGS_NAS_EPS_ATTACH_REJECT_FORBIDDEN_TAI_FOR_THE_LIST_OF_FORBIDDEN_TRACKING_AREAS_FOR_ROAMING_PRESENT;
885
198
            decoded += size;
886
198
            break;
887
423
        case OGS_NAS_EPS_ATTACH_REJECT_FORBIDDEN_TAI_FOR_THE_LIST_OF_FORBIDDEN_TRACKING_AREAS_FORREGIONAL_PROVISION_OF_SERVICE_TYPE:
888
423
            size = ogs_nas_eps_decode_tracking_area_identity_list(&attach_reject->forbidden_tai_for_the_list_of_forbidden_tracking_areas_forregional_provision_of_service, pkbuf);
889
423
            if (size < 0) {
890
2
               ogs_error("ogs_nas_eps_decode_tracking_area_identity_list() failed");
891
2
               return size;
892
2
            }
893
894
421
            attach_reject->presencemask |= OGS_NAS_EPS_ATTACH_REJECT_FORBIDDEN_TAI_FOR_THE_LIST_OF_FORBIDDEN_TRACKING_AREAS_FORREGIONAL_PROVISION_OF_SERVICE_PRESENT;
895
421
            decoded += size;
896
421
            break;
897
2.99k
        default:
898
2.99k
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
899
2.99k
            break;
900
5.56k
        }
901
5.56k
    }
902
903
106
    return decoded;
904
130
}
905
906
int ogs_nas_eps_decode_detach_request_from_ue(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
907
9
{
908
9
    ogs_nas_eps_detach_request_from_ue_t *detach_request_from_ue = &message->emm.detach_request_from_ue;
909
9
    int decoded = 0;
910
9
    int size = 0;
911
912
9
    ogs_trace("[NAS] Decode DETACH_REQUEST\n");
913
914
9
    size = ogs_nas_eps_decode_detach_type(&detach_request_from_ue->detach_type, pkbuf);
915
9
    if (size < 0) {
916
0
        ogs_error("ogs_nas_eps_decode_detach_type() failed");
917
0
        return size;
918
0
    }
919
920
9
    decoded += size;
921
922
9
    size = ogs_nas_eps_decode_eps_mobile_identity(&detach_request_from_ue->eps_mobile_identity, pkbuf);
923
9
    if (size < 0) {
924
3
        ogs_error("ogs_nas_eps_decode_eps_mobile_identity() failed");
925
3
        return size;
926
3
    }
927
928
6
    decoded += size;
929
930
6
    return decoded;
931
9
}
932
933
int ogs_nas_eps_decode_detach_request_to_ue(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
934
0
{
935
0
    ogs_nas_eps_detach_request_to_ue_t *detach_request_to_ue = &message->emm.detach_request_to_ue;
936
0
    int decoded = 0;
937
0
    int size = 0;
938
939
0
    ogs_trace("[NAS] Decode DETACH_REQUEST\n");
940
941
0
    size = ogs_nas_eps_decode_detach_type(&detach_request_to_ue->detach_type, pkbuf);
942
0
    if (size < 0) {
943
0
        ogs_error("ogs_nas_eps_decode_detach_type() failed");
944
0
        return size;
945
0
    }
946
947
0
    decoded += size;
948
949
0
    while (pkbuf->len > 0) {
950
0
        uint8_t *buffer = pkbuf->data;
951
0
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
952
953
0
        size = sizeof(uint8_t);
954
0
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
955
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
956
0
           return OGS_ERROR;
957
0
        }
958
0
        decoded += size;
959
960
0
        switch (type) {
961
0
        case OGS_NAS_EPS_DETACH_REQUEST_EMM_CAUSE_TYPE:
962
0
            size = ogs_nas_eps_decode_emm_cause(&detach_request_to_ue->emm_cause, pkbuf);
963
0
            if (size < 0) {
964
0
               ogs_error("ogs_nas_eps_decode_emm_cause() failed");
965
0
               return size;
966
0
            }
967
968
0
            detach_request_to_ue->presencemask |= OGS_NAS_EPS_DETACH_REQUEST_EMM_CAUSE_PRESENT;
969
0
            decoded += size;
970
0
            break;
971
0
        case OGS_NAS_EPS_DETACH_REQUEST_LOWER_BOUND_TIMER_VALUE_TYPE:
972
0
            size = ogs_nas_eps_decode_gprs_timer_3(&detach_request_to_ue->lower_bound_timer_value, pkbuf);
973
0
            if (size < 0) {
974
0
               ogs_error("ogs_nas_eps_decode_gprs_timer_3() failed");
975
0
               return size;
976
0
            }
977
978
0
            detach_request_to_ue->presencemask |= OGS_NAS_EPS_DETACH_REQUEST_LOWER_BOUND_TIMER_VALUE_PRESENT;
979
0
            decoded += size;
980
0
            break;
981
0
        case OGS_NAS_EPS_DETACH_REQUEST_FORBIDDEN_TAI_FOR_THE_LIST_OF_FORBIDDEN_TRACKING_AREAS_FOR_ROAMING_TYPE:
982
0
            size = ogs_nas_eps_decode_tracking_area_identity_list(&detach_request_to_ue->forbidden_tai_for_the_list_of_forbidden_tracking_areas_for_roaming, pkbuf);
983
0
            if (size < 0) {
984
0
               ogs_error("ogs_nas_eps_decode_tracking_area_identity_list() failed");
985
0
               return size;
986
0
            }
987
988
0
            detach_request_to_ue->presencemask |= OGS_NAS_EPS_DETACH_REQUEST_FORBIDDEN_TAI_FOR_THE_LIST_OF_FORBIDDEN_TRACKING_AREAS_FOR_ROAMING_PRESENT;
989
0
            decoded += size;
990
0
            break;
991
0
        case OGS_NAS_EPS_DETACH_REQUEST_FORBIDDEN_TAI_FOR_THE_LIST_OF_FORBIDDEN_TRACKING_AREAS_FORREGIONAL_PROVISION_OF_SERVICE_TYPE:
992
0
            size = ogs_nas_eps_decode_tracking_area_identity_list(&detach_request_to_ue->forbidden_tai_for_the_list_of_forbidden_tracking_areas_forregional_provision_of_service, pkbuf);
993
0
            if (size < 0) {
994
0
               ogs_error("ogs_nas_eps_decode_tracking_area_identity_list() failed");
995
0
               return size;
996
0
            }
997
998
0
            detach_request_to_ue->presencemask |= OGS_NAS_EPS_DETACH_REQUEST_FORBIDDEN_TAI_FOR_THE_LIST_OF_FORBIDDEN_TRACKING_AREAS_FORREGIONAL_PROVISION_OF_SERVICE_PRESENT;
999
0
            decoded += size;
1000
0
            break;
1001
0
        default:
1002
0
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
1003
0
            break;
1004
0
        }
1005
0
    }
1006
1007
0
    return decoded;
1008
0
}
1009
1010
int ogs_nas_eps_decode_tracking_area_update_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
1011
699
{
1012
699
    ogs_nas_eps_tracking_area_update_request_t *tracking_area_update_request = &message->emm.tracking_area_update_request;
1013
699
    int decoded = 0;
1014
699
    int size = 0;
1015
1016
699
    ogs_trace("[NAS] Decode TRACKING_AREA_UPDATE_REQUEST\n");
1017
1018
699
    size = ogs_nas_eps_decode_eps_update_type(&tracking_area_update_request->eps_update_type, pkbuf);
1019
699
    if (size < 0) {
1020
0
        ogs_error("ogs_nas_eps_decode_eps_update_type() failed");
1021
0
        return size;
1022
0
    }
1023
1024
699
    decoded += size;
1025
1026
699
    size = ogs_nas_eps_decode_eps_mobile_identity(&tracking_area_update_request->old_guti, pkbuf);
1027
699
    if (size < 0) {
1028
1
        ogs_error("ogs_nas_eps_decode_eps_mobile_identity() failed");
1029
1
        return size;
1030
1
    }
1031
1032
698
    decoded += size;
1033
1034
31.9k
    while (pkbuf->len > 0) {
1035
31.4k
        uint8_t *buffer = pkbuf->data;
1036
31.4k
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
1037
1038
31.4k
        size = sizeof(uint8_t);
1039
31.4k
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
1040
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
1041
0
           return OGS_ERROR;
1042
0
        }
1043
31.4k
        decoded += size;
1044
1045
31.4k
        switch (type) {
1046
1.02k
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_NON_CURRENT_NATIVE_NAS_KEY_SET_IDENTIFIER_TYPE:
1047
1.02k
            decoded--;
1048
1.02k
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
1049
1.02k
            size = ogs_nas_eps_decode_key_set_identifier(&tracking_area_update_request->non_current_native_nas_key_set_identifier, pkbuf);
1050
1.02k
            if (size < 0) {
1051
0
               ogs_error("ogs_nas_eps_decode_key_set_identifier() failed");
1052
0
               return size;
1053
0
            }
1054
1055
1.02k
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_NON_CURRENT_NATIVE_NAS_KEY_SET_IDENTIFIER_PRESENT;
1056
1.02k
            decoded += size;
1057
1.02k
            break;
1058
1.33k
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_GPRS_CIPHERING_KEY_SEQUENCE_NUMBER_TYPE:
1059
1.33k
            decoded--;
1060
1.33k
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
1061
1.33k
            size = ogs_nas_eps_decode_ciphering_key_sequence_number(&tracking_area_update_request->gprs_ciphering_key_sequence_number, pkbuf);
1062
1.33k
            if (size < 0) {
1063
0
               ogs_error("ogs_nas_eps_decode_ciphering_key_sequence_number() failed");
1064
0
               return size;
1065
0
            }
1066
1067
1.33k
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_GPRS_CIPHERING_KEY_SEQUENCE_NUMBER_PRESENT;
1068
1.33k
            decoded += size;
1069
1.33k
            break;
1070
504
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_OLD_P_TMSI_SIGNATURE_TYPE:
1071
504
            size = ogs_nas_eps_decode_p_tmsi_signature(&tracking_area_update_request->old_p_tmsi_signature, pkbuf);
1072
504
            if (size < 0) {
1073
14
               ogs_error("ogs_nas_eps_decode_p_tmsi_signature() failed");
1074
14
               return size;
1075
14
            }
1076
1077
490
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_OLD_P_TMSI_SIGNATURE_PRESENT;
1078
490
            decoded += size;
1079
490
            break;
1080
416
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_ADDITIONAL_GUTI_TYPE:
1081
416
            size = ogs_nas_eps_decode_eps_mobile_identity(&tracking_area_update_request->additional_guti, pkbuf);
1082
416
            if (size < 0) {
1083
6
               ogs_error("ogs_nas_eps_decode_eps_mobile_identity() failed");
1084
6
               return size;
1085
6
            }
1086
1087
410
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_ADDITIONAL_GUTI_PRESENT;
1088
410
            decoded += size;
1089
410
            break;
1090
565
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_NONCEUE_TYPE:
1091
565
            size = ogs_nas_eps_decode_nonce(&tracking_area_update_request->nonceue, pkbuf);
1092
565
            if (size < 0) {
1093
10
               ogs_error("ogs_nas_eps_decode_nonce() failed");
1094
10
               return size;
1095
10
            }
1096
1097
555
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_NONCEUE_PRESENT;
1098
555
            decoded += size;
1099
555
            break;
1100
354
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_UE_NETWORK_CAPABILITY_TYPE:
1101
354
            size = ogs_nas_eps_decode_ue_network_capability(&tracking_area_update_request->ue_network_capability, pkbuf);
1102
354
            if (size < 0) {
1103
8
               ogs_error("ogs_nas_eps_decode_ue_network_capability() failed");
1104
8
               return size;
1105
8
            }
1106
1107
346
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_UE_NETWORK_CAPABILITY_PRESENT;
1108
346
            decoded += size;
1109
346
            break;
1110
452
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_LAST_VISITED_REGISTERED_TAI_TYPE:
1111
452
            size = ogs_nas_eps_decode_tracking_area_identity(&tracking_area_update_request->last_visited_registered_tai, pkbuf);
1112
452
            if (size < 0) {
1113
9
               ogs_error("ogs_nas_eps_decode_tracking_area_identity() failed");
1114
9
               return size;
1115
9
            }
1116
1117
443
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_LAST_VISITED_REGISTERED_TAI_PRESENT;
1118
443
            decoded += size;
1119
443
            break;
1120
612
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_DRX_PARAMETER_TYPE:
1121
612
            size = ogs_nas_eps_decode_drx_parameter(&tracking_area_update_request->drx_parameter, pkbuf);
1122
612
            if (size < 0) {
1123
11
               ogs_error("ogs_nas_eps_decode_drx_parameter() failed");
1124
11
               return size;
1125
11
            }
1126
1127
601
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_DRX_PARAMETER_PRESENT;
1128
601
            decoded += size;
1129
601
            break;
1130
1.84k
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_UE_RADIO_CAPABILITY_INFORMATION_UPDATE_NEEDED_TYPE:
1131
1.84k
            decoded--;
1132
1.84k
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
1133
1.84k
            size = ogs_nas_eps_decode_ue_radio_capability_information_update_needed(&tracking_area_update_request->ue_radio_capability_information_update_needed, pkbuf);
1134
1.84k
            if (size < 0) {
1135
0
               ogs_error("ogs_nas_eps_decode_ue_radio_capability_information_update_needed() failed");
1136
0
               return size;
1137
0
            }
1138
1139
1.84k
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_UE_RADIO_CAPABILITY_INFORMATION_UPDATE_NEEDED_PRESENT;
1140
1.84k
            decoded += size;
1141
1.84k
            break;
1142
197
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_EPS_BEARER_CONTEXT_STATUS_TYPE:
1143
197
            size = ogs_nas_eps_decode_eps_bearer_context_status(&tracking_area_update_request->eps_bearer_context_status, pkbuf);
1144
197
            if (size < 0) {
1145
1
               ogs_error("ogs_nas_eps_decode_eps_bearer_context_status() failed");
1146
1
               return size;
1147
1
            }
1148
1149
196
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_EPS_BEARER_CONTEXT_STATUS_PRESENT;
1150
196
            decoded += size;
1151
196
            break;
1152
265
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_MS_NETWORK_CAPABILITY_TYPE:
1153
265
            size = ogs_nas_eps_decode_ms_network_capability(&tracking_area_update_request->ms_network_capability, pkbuf);
1154
265
            if (size < 0) {
1155
14
               ogs_error("ogs_nas_eps_decode_ms_network_capability() failed");
1156
14
               return size;
1157
14
            }
1158
1159
251
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_MS_NETWORK_CAPABILITY_PRESENT;
1160
251
            decoded += size;
1161
251
            break;
1162
260
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_OLD_LOCATION_AREA_IDENTIFICATION_TYPE:
1163
260
            size = ogs_nas_eps_decode_location_area_identification(&tracking_area_update_request->old_location_area_identification, pkbuf);
1164
260
            if (size < 0) {
1165
1
               ogs_error("ogs_nas_eps_decode_location_area_identification() failed");
1166
1
               return size;
1167
1
            }
1168
1169
259
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_OLD_LOCATION_AREA_IDENTIFICATION_PRESENT;
1170
259
            decoded += size;
1171
259
            break;
1172
1.01k
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_TMSI_STATUS_TYPE:
1173
1.01k
            decoded--;
1174
1.01k
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
1175
1.01k
            size = ogs_nas_eps_decode_tmsi_status(&tracking_area_update_request->tmsi_status, pkbuf);
1176
1.01k
            if (size < 0) {
1177
0
               ogs_error("ogs_nas_eps_decode_tmsi_status() failed");
1178
0
               return size;
1179
0
            }
1180
1181
1.01k
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_TMSI_STATUS_PRESENT;
1182
1.01k
            decoded += size;
1183
1.01k
            break;
1184
321
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_MOBILE_STATION_CLASSMARK_2_TYPE:
1185
321
            size = ogs_nas_eps_decode_mobile_station_classmark_2(&tracking_area_update_request->mobile_station_classmark_2, pkbuf);
1186
321
            if (size < 0) {
1187
22
               ogs_error("ogs_nas_eps_decode_mobile_station_classmark_2() failed");
1188
22
               return size;
1189
22
            }
1190
1191
299
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_MOBILE_STATION_CLASSMARK_2_PRESENT;
1192
299
            decoded += size;
1193
299
            break;
1194
440
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_MOBILE_STATION_CLASSMARK_3_TYPE:
1195
440
            size = ogs_nas_eps_decode_mobile_station_classmark_3(&tracking_area_update_request->mobile_station_classmark_3, pkbuf);
1196
440
            if (size < 0) {
1197
9
               ogs_error("ogs_nas_eps_decode_mobile_station_classmark_3() failed");
1198
9
               return size;
1199
9
            }
1200
1201
431
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_MOBILE_STATION_CLASSMARK_3_PRESENT;
1202
431
            decoded += size;
1203
431
            break;
1204
558
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_SUPPORTED_CODECS_TYPE:
1205
558
            size = ogs_nas_eps_decode_supported_codec_list(&tracking_area_update_request->supported_codecs, pkbuf);
1206
558
            if (size < 0) {
1207
22
               ogs_error("ogs_nas_eps_decode_supported_codec_list() failed");
1208
22
               return size;
1209
22
            }
1210
1211
536
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_SUPPORTED_CODECS_PRESENT;
1212
536
            decoded += size;
1213
536
            break;
1214
3.77k
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_ADDITIONAL_UPDATE_TYPE_TYPE:
1215
3.77k
            decoded--;
1216
3.77k
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
1217
3.77k
            size = ogs_nas_eps_decode_additional_update_type(&tracking_area_update_request->additional_update_type, pkbuf);
1218
3.77k
            if (size < 0) {
1219
0
               ogs_error("ogs_nas_eps_decode_additional_update_type() failed");
1220
0
               return size;
1221
0
            }
1222
1223
3.77k
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_ADDITIONAL_UPDATE_TYPE_PRESENT;
1224
3.77k
            decoded += size;
1225
3.77k
            break;
1226
287
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_VOICE_DOMAIN_PREFERENCE_AND_UE_USAGE_SETTING_TYPE:
1227
287
            size = ogs_nas_eps_decode_voice_domain_preference_and_ue_usage_setting(&tracking_area_update_request->voice_domain_preference_and_ue_usage_setting, pkbuf);
1228
287
            if (size < 0) {
1229
13
               ogs_error("ogs_nas_eps_decode_voice_domain_preference_and_ue_usage_setting() failed");
1230
13
               return size;
1231
13
            }
1232
1233
274
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_VOICE_DOMAIN_PREFERENCE_AND_UE_USAGE_SETTING_PRESENT;
1234
274
            decoded += size;
1235
274
            break;
1236
812
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_OLD_GUTI_TYPE_TYPE:
1237
812
            decoded--;
1238
812
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
1239
812
            size = ogs_nas_eps_decode_guti_type(&tracking_area_update_request->old_guti_type, pkbuf);
1240
812
            if (size < 0) {
1241
0
               ogs_error("ogs_nas_eps_decode_guti_type() failed");
1242
0
               return size;
1243
0
            }
1244
1245
812
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_OLD_GUTI_TYPE_PRESENT;
1246
812
            decoded += size;
1247
812
            break;
1248
559
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_DEVICE_PROPERTIES_TYPE:
1249
559
            decoded--;
1250
559
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
1251
559
            size = ogs_nas_eps_decode_device_properties(&tracking_area_update_request->device_properties, pkbuf);
1252
559
            if (size < 0) {
1253
0
               ogs_error("ogs_nas_eps_decode_device_properties() failed");
1254
0
               return size;
1255
0
            }
1256
1257
559
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_DEVICE_PROPERTIES_PRESENT;
1258
559
            decoded += size;
1259
559
            break;
1260
1.36k
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_MS_NETWORK_FEATURE_SUPPORT_TYPE:
1261
1.36k
            decoded--;
1262
1.36k
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
1263
1.36k
            size = ogs_nas_eps_decode_ms_network_feature_support(&tracking_area_update_request->ms_network_feature_support, pkbuf);
1264
1.36k
            if (size < 0) {
1265
0
               ogs_error("ogs_nas_eps_decode_ms_network_feature_support() failed");
1266
0
               return size;
1267
0
            }
1268
1269
1.36k
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_MS_NETWORK_FEATURE_SUPPORT_PRESENT;
1270
1.36k
            decoded += size;
1271
1.36k
            break;
1272
271
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_TMSI_BASED_NRI_CONTAINER_TYPE:
1273
271
            size = ogs_nas_eps_decode_network_resource_identifier_container(&tracking_area_update_request->tmsi_based_nri_container, pkbuf);
1274
271
            if (size < 0) {
1275
9
               ogs_error("ogs_nas_eps_decode_network_resource_identifier_container() failed");
1276
9
               return size;
1277
9
            }
1278
1279
262
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_TMSI_BASED_NRI_CONTAINER_PRESENT;
1280
262
            decoded += size;
1281
262
            break;
1282
209
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_T3324_VALUE_TYPE:
1283
209
            size = ogs_nas_eps_decode_gprs_timer_2(&tracking_area_update_request->t3324_value, pkbuf);
1284
209
            if (size < 0) {
1285
1
               ogs_error("ogs_nas_eps_decode_gprs_timer_2() failed");
1286
1
               return size;
1287
1
            }
1288
1289
208
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_T3324_VALUE_PRESENT;
1290
208
            decoded += size;
1291
208
            break;
1292
208
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_T3412_EXTENDED_VALUE_TYPE:
1293
208
            size = ogs_nas_eps_decode_gprs_timer_3(&tracking_area_update_request->t3412_extended_value, pkbuf);
1294
208
            if (size < 0) {
1295
1
               ogs_error("ogs_nas_eps_decode_gprs_timer_3() failed");
1296
1
               return size;
1297
1
            }
1298
1299
207
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_T3412_EXTENDED_VALUE_PRESENT;
1300
207
            decoded += size;
1301
207
            break;
1302
213
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_EXTENDED_DRX_PARAMETERS_TYPE:
1303
213
            size = ogs_nas_eps_decode_extended_drx_parameters(&tracking_area_update_request->extended_drx_parameters, pkbuf);
1304
213
            if (size < 0) {
1305
2
               ogs_error("ogs_nas_eps_decode_extended_drx_parameters() failed");
1306
2
               return size;
1307
2
            }
1308
1309
211
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_EXTENDED_DRX_PARAMETERS_PRESENT;
1310
211
            decoded += size;
1311
211
            break;
1312
444
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_UE_ADDITIONAL_SECURITY_CAPABILITY_TYPE:
1313
444
            size = ogs_nas_eps_decode_ue_additional_security_capability(&tracking_area_update_request->ue_additional_security_capability, pkbuf);
1314
444
            if (size < 0) {
1315
29
               ogs_error("ogs_nas_eps_decode_ue_additional_security_capability() failed");
1316
29
               return size;
1317
29
            }
1318
1319
415
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_UE_ADDITIONAL_SECURITY_CAPABILITY_PRESENT;
1320
415
            decoded += size;
1321
415
            break;
1322
433
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_UE_STATUS_TYPE:
1323
433
            size = ogs_nas_eps_decode_ue_status(&tracking_area_update_request->ue_status, pkbuf);
1324
433
            if (size < 0) {
1325
9
               ogs_error("ogs_nas_eps_decode_ue_status() failed");
1326
9
               return size;
1327
9
            }
1328
1329
424
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_UE_STATUS_PRESENT;
1330
424
            decoded += size;
1331
424
            break;
1332
530
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_ADDITIONAL_INFORMATION_REQUESTED_TYPE:
1333
530
            size = ogs_nas_eps_decode_additional_information_requested(&tracking_area_update_request->additional_information_requested, pkbuf);
1334
530
            if (size < 0) {
1335
11
               ogs_error("ogs_nas_eps_decode_additional_information_requested() failed");
1336
11
               return size;
1337
11
            }
1338
1339
519
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_ADDITIONAL_INFORMATION_REQUESTED_PRESENT;
1340
519
            decoded += size;
1341
519
            break;
1342
371
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_N1_UE_NETWORK_CAPABILITY_TYPE:
1343
371
            size = ogs_nas_eps_decode_n1_ue_network_capability(&tracking_area_update_request->n1_ue_network_capability, pkbuf);
1344
371
            if (size < 0) {
1345
9
               ogs_error("ogs_nas_eps_decode_n1_ue_network_capability() failed");
1346
9
               return size;
1347
9
            }
1348
1349
362
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_N1_UE_NETWORK_CAPABILITY_PRESENT;
1350
362
            decoded += size;
1351
362
            break;
1352
310
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_UE_RADIO_CAPABILITY_ID_AVAILABILITY_TYPE:
1353
310
            size = ogs_nas_eps_decode_ue_radio_capability_id_availability(&tracking_area_update_request->ue_radio_capability_id_availability, pkbuf);
1354
310
            if (size < 0) {
1355
25
               ogs_error("ogs_nas_eps_decode_ue_radio_capability_id_availability() failed");
1356
25
               return size;
1357
25
            }
1358
1359
285
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_UE_RADIO_CAPABILITY_ID_AVAILABILITY_PRESENT;
1360
285
            decoded += size;
1361
285
            break;
1362
383
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_REQUESTED_WUS_ASSISTANCE_INFORMATION_TYPE:
1363
383
            size = ogs_nas_eps_decode_wus_assistance_information(&tracking_area_update_request->requested_wus_assistance_information, pkbuf);
1364
383
            if (size < 0) {
1365
2
               ogs_error("ogs_nas_eps_decode_wus_assistance_information() failed");
1366
2
               return size;
1367
2
            }
1368
1369
381
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_REQUESTED_WUS_ASSISTANCE_INFORMATION_PRESENT;
1370
381
            decoded += size;
1371
381
            break;
1372
221
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_DRX_PARAMETER_IN_NB_S1_MODE_TYPE:
1373
221
            size = ogs_nas_eps_decode_nb_s1_drx_parameter(&tracking_area_update_request->drx_parameter_in_nb_s1_mode, pkbuf);
1374
221
            if (size < 0) {
1375
2
               ogs_error("ogs_nas_eps_decode_nb_s1_drx_parameter() failed");
1376
2
               return size;
1377
2
            }
1378
1379
219
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_DRX_PARAMETER_IN_NB_S1_MODE_PRESENT;
1380
219
            decoded += size;
1381
219
            break;
1382
248
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_REQUESTED_IMSI_OFFSET_TYPE:
1383
248
            size = ogs_nas_eps_decode_imsi_offset(&tracking_area_update_request->requested_imsi_offset, pkbuf);
1384
248
            if (size < 0) {
1385
4
               ogs_error("ogs_nas_eps_decode_imsi_offset() failed");
1386
4
               return size;
1387
4
            }
1388
1389
244
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_REQUESTED_IMSI_OFFSET_PRESENT;
1390
244
            decoded += size;
1391
244
            break;
1392
267
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_UE_REQUEST_TYPE_TYPE:
1393
267
            size = ogs_nas_eps_decode_ue_request_type(&tracking_area_update_request->ue_request_type, pkbuf);
1394
267
            if (size < 0) {
1395
20
               ogs_error("ogs_nas_eps_decode_ue_request_type() failed");
1396
20
               return size;
1397
20
            }
1398
1399
247
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_UE_REQUEST_TYPE_PRESENT;
1400
247
            decoded += size;
1401
247
            break;
1402
408
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_PAGING_RESTRICTION_TYPE:
1403
408
            size = ogs_nas_eps_decode_paging_restriction(&tracking_area_update_request->paging_restriction, pkbuf);
1404
408
            if (size < 0) {
1405
9
               ogs_error("ogs_nas_eps_decode_paging_restriction() failed");
1406
9
               return size;
1407
9
            }
1408
1409
399
            tracking_area_update_request->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REQUEST_PAGING_RESTRICTION_PRESENT;
1410
399
            decoded += size;
1411
399
            break;
1412
10.0k
        default:
1413
10.0k
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
1414
10.0k
            break;
1415
31.4k
        }
1416
31.4k
    }
1417
1418
425
    return decoded;
1419
698
}
1420
1421
int ogs_nas_eps_decode_tracking_area_update_accept(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
1422
774
{
1423
774
    ogs_nas_eps_tracking_area_update_accept_t *tracking_area_update_accept = &message->emm.tracking_area_update_accept;
1424
774
    int decoded = 0;
1425
774
    int size = 0;
1426
1427
774
    ogs_trace("[NAS] Decode TRACKING_AREA_UPDATE_ACCEPT\n");
1428
1429
774
    size = ogs_nas_eps_decode_eps_update_result(&tracking_area_update_accept->eps_update_result, pkbuf);
1430
774
    if (size < 0) {
1431
0
        ogs_error("ogs_nas_eps_decode_eps_update_result() failed");
1432
0
        return size;
1433
0
    }
1434
1435
774
    decoded += size;
1436
1437
23.6k
    while (pkbuf->len > 0) {
1438
23.2k
        uint8_t *buffer = pkbuf->data;
1439
23.2k
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
1440
1441
23.2k
        size = sizeof(uint8_t);
1442
23.2k
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
1443
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
1444
0
           return OGS_ERROR;
1445
0
        }
1446
23.2k
        decoded += size;
1447
1448
23.2k
        switch (type) {
1449
245
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_T3412_VALUE_TYPE:
1450
245
            size = ogs_nas_eps_decode_gprs_timer(&tracking_area_update_accept->t3412_value, pkbuf);
1451
245
            if (size < 0) {
1452
6
               ogs_error("ogs_nas_eps_decode_gprs_timer() failed");
1453
6
               return size;
1454
6
            }
1455
1456
239
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_T3412_VALUE_PRESENT;
1457
239
            decoded += size;
1458
239
            break;
1459
400
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_GUTI_TYPE:
1460
400
            size = ogs_nas_eps_decode_eps_mobile_identity(&tracking_area_update_accept->guti, pkbuf);
1461
400
            if (size < 0) {
1462
1
               ogs_error("ogs_nas_eps_decode_eps_mobile_identity() failed");
1463
1
               return size;
1464
1
            }
1465
1466
399
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_GUTI_PRESENT;
1467
399
            decoded += size;
1468
399
            break;
1469
214
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_TAI_LIST_TYPE:
1470
214
            size = ogs_nas_eps_decode_tracking_area_identity_list(&tracking_area_update_accept->tai_list, pkbuf);
1471
214
            if (size < 0) {
1472
4
               ogs_error("ogs_nas_eps_decode_tracking_area_identity_list() failed");
1473
4
               return size;
1474
4
            }
1475
1476
210
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_TAI_LIST_PRESENT;
1477
210
            decoded += size;
1478
210
            break;
1479
324
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_EPS_BEARER_CONTEXT_STATUS_TYPE:
1480
324
            size = ogs_nas_eps_decode_eps_bearer_context_status(&tracking_area_update_accept->eps_bearer_context_status, pkbuf);
1481
324
            if (size < 0) {
1482
24
               ogs_error("ogs_nas_eps_decode_eps_bearer_context_status() failed");
1483
24
               return size;
1484
24
            }
1485
1486
300
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_EPS_BEARER_CONTEXT_STATUS_PRESENT;
1487
300
            decoded += size;
1488
300
            break;
1489
553
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_LOCATION_AREA_IDENTIFICATION_TYPE:
1490
553
            size = ogs_nas_eps_decode_location_area_identification(&tracking_area_update_accept->location_area_identification, pkbuf);
1491
553
            if (size < 0) {
1492
15
               ogs_error("ogs_nas_eps_decode_location_area_identification() failed");
1493
15
               return size;
1494
15
            }
1495
1496
538
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_LOCATION_AREA_IDENTIFICATION_PRESENT;
1497
538
            decoded += size;
1498
538
            break;
1499
217
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_MS_IDENTITY_TYPE:
1500
217
            size = ogs_nas_eps_decode_mobile_identity(&tracking_area_update_accept->ms_identity, pkbuf);
1501
217
            if (size < 0) {
1502
7
               ogs_error("ogs_nas_eps_decode_mobile_identity() failed");
1503
7
               return size;
1504
7
            }
1505
1506
210
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_MS_IDENTITY_PRESENT;
1507
210
            decoded += size;
1508
210
            break;
1509
402
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_EMM_CAUSE_TYPE:
1510
402
            size = ogs_nas_eps_decode_emm_cause(&tracking_area_update_accept->emm_cause, pkbuf);
1511
402
            if (size < 0) {
1512
9
               ogs_error("ogs_nas_eps_decode_emm_cause() failed");
1513
9
               return size;
1514
9
            }
1515
1516
393
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_EMM_CAUSE_PRESENT;
1517
393
            decoded += size;
1518
393
            break;
1519
499
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_T3402_VALUE_TYPE:
1520
499
            size = ogs_nas_eps_decode_gprs_timer(&tracking_area_update_accept->t3402_value, pkbuf);
1521
499
            if (size < 0) {
1522
4
               ogs_error("ogs_nas_eps_decode_gprs_timer() failed");
1523
4
               return size;
1524
4
            }
1525
1526
495
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_T3402_VALUE_PRESENT;
1527
495
            decoded += size;
1528
495
            break;
1529
291
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_T3423_VALUE_TYPE:
1530
291
            size = ogs_nas_eps_decode_gprs_timer(&tracking_area_update_accept->t3423_value, pkbuf);
1531
291
            if (size < 0) {
1532
2
               ogs_error("ogs_nas_eps_decode_gprs_timer() failed");
1533
2
               return size;
1534
2
            }
1535
1536
289
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_T3423_VALUE_PRESENT;
1537
289
            decoded += size;
1538
289
            break;
1539
375
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_EQUIVALENT_PLMNS_TYPE:
1540
375
            size = ogs_nas_eps_decode_plmn_list(&tracking_area_update_accept->equivalent_plmns, pkbuf);
1541
375
            if (size < 0) {
1542
20
               ogs_error("ogs_nas_eps_decode_plmn_list() failed");
1543
20
               return size;
1544
20
            }
1545
1546
355
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_EQUIVALENT_PLMNS_PRESENT;
1547
355
            decoded += size;
1548
355
            break;
1549
272
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_EMERGENCY_NUMBER_LIST_TYPE:
1550
272
            size = ogs_nas_eps_decode_emergency_number_list(&tracking_area_update_accept->emergency_number_list, pkbuf);
1551
272
            if (size < 0) {
1552
30
               ogs_error("ogs_nas_eps_decode_emergency_number_list() failed");
1553
30
               return size;
1554
30
            }
1555
1556
242
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_EMERGENCY_NUMBER_LIST_PRESENT;
1557
242
            decoded += size;
1558
242
            break;
1559
238
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_EPS_NETWORK_FEATURE_SUPPORT_TYPE:
1560
238
            size = ogs_nas_eps_decode_eps_network_feature_support(&tracking_area_update_accept->eps_network_feature_support, pkbuf);
1561
238
            if (size < 0) {
1562
8
               ogs_error("ogs_nas_eps_decode_eps_network_feature_support() failed");
1563
8
               return size;
1564
8
            }
1565
1566
230
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_EPS_NETWORK_FEATURE_SUPPORT_PRESENT;
1567
230
            decoded += size;
1568
230
            break;
1569
2.69k
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_ADDITIONAL_UPDATE_RESULT_TYPE:
1570
2.69k
            decoded--;
1571
2.69k
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
1572
2.69k
            size = ogs_nas_eps_decode_additional_update_result(&tracking_area_update_accept->additional_update_result, pkbuf);
1573
2.69k
            if (size < 0) {
1574
0
               ogs_error("ogs_nas_eps_decode_additional_update_result() failed");
1575
0
               return size;
1576
0
            }
1577
1578
2.69k
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_ADDITIONAL_UPDATE_RESULT_PRESENT;
1579
2.69k
            decoded += size;
1580
2.69k
            break;
1581
227
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_T3412_EXTENDED_VALUE_TYPE:
1582
227
            size = ogs_nas_eps_decode_gprs_timer_3(&tracking_area_update_accept->t3412_extended_value, pkbuf);
1583
227
            if (size < 0) {
1584
8
               ogs_error("ogs_nas_eps_decode_gprs_timer_3() failed");
1585
8
               return size;
1586
8
            }
1587
1588
219
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_T3412_EXTENDED_VALUE_PRESENT;
1589
219
            decoded += size;
1590
219
            break;
1591
225
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_T3324_VALUE_TYPE:
1592
225
            size = ogs_nas_eps_decode_gprs_timer_2(&tracking_area_update_accept->t3324_value, pkbuf);
1593
225
            if (size < 0) {
1594
5
               ogs_error("ogs_nas_eps_decode_gprs_timer_2() failed");
1595
5
               return size;
1596
5
            }
1597
1598
220
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_T3324_VALUE_PRESENT;
1599
220
            decoded += size;
1600
220
            break;
1601
275
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_EXTENDED_DRX_PARAMETERS_TYPE:
1602
275
            size = ogs_nas_eps_decode_extended_drx_parameters(&tracking_area_update_accept->extended_drx_parameters, pkbuf);
1603
275
            if (size < 0) {
1604
18
               ogs_error("ogs_nas_eps_decode_extended_drx_parameters() failed");
1605
18
               return size;
1606
18
            }
1607
1608
257
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_EXTENDED_DRX_PARAMETERS_PRESENT;
1609
257
            decoded += size;
1610
257
            break;
1611
529
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_HEADER_COMPRESSION_CONFIGURATION_STATUS_TYPE:
1612
529
            size = ogs_nas_eps_decode_header_compression_configuration_status(&tracking_area_update_accept->header_compression_configuration_status, pkbuf);
1613
529
            if (size < 0) {
1614
27
               ogs_error("ogs_nas_eps_decode_header_compression_configuration_status() failed");
1615
27
               return size;
1616
27
            }
1617
1618
502
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_HEADER_COMPRESSION_CONFIGURATION_STATUS_PRESENT;
1619
502
            decoded += size;
1620
502
            break;
1621
406
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_DCN_ID_TYPE:
1622
406
            size = ogs_nas_eps_decode_dcn_id(&tracking_area_update_accept->dcn_id, pkbuf);
1623
406
            if (size < 0) {
1624
15
               ogs_error("ogs_nas_eps_decode_dcn_id() failed");
1625
15
               return size;
1626
15
            }
1627
1628
391
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_DCN_ID_PRESENT;
1629
391
            decoded += size;
1630
391
            break;
1631
872
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_SMS_SERVICES_STATUS_TYPE:
1632
872
            decoded--;
1633
872
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
1634
872
            size = ogs_nas_eps_decode_sms_services_status(&tracking_area_update_accept->sms_services_status, pkbuf);
1635
872
            if (size < 0) {
1636
0
               ogs_error("ogs_nas_eps_decode_sms_services_status() failed");
1637
0
               return size;
1638
0
            }
1639
1640
872
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_SMS_SERVICES_STATUS_PRESENT;
1641
872
            decoded += size;
1642
872
            break;
1643
1.26k
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_NON__NW_POLICIES_TYPE:
1644
1.26k
            decoded--;
1645
1.26k
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
1646
1.26k
            size = ogs_nas_eps_decode_non__nw_provided_policies(&tracking_area_update_accept->non__nw_policies, pkbuf);
1647
1.26k
            if (size < 0) {
1648
0
               ogs_error("ogs_nas_eps_decode_non__nw_provided_policies() failed");
1649
0
               return size;
1650
0
            }
1651
1652
1.26k
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_NON__NW_POLICIES_PRESENT;
1653
1.26k
            decoded += size;
1654
1.26k
            break;
1655
229
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_T3448_VALUE_TYPE:
1656
229
            size = ogs_nas_eps_decode_gprs_timer_2(&tracking_area_update_accept->t3448_value, pkbuf);
1657
229
            if (size < 0) {
1658
7
               ogs_error("ogs_nas_eps_decode_gprs_timer_2() failed");
1659
7
               return size;
1660
7
            }
1661
1662
222
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_T3448_VALUE_PRESENT;
1663
222
            decoded += size;
1664
222
            break;
1665
1.14k
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_NETWORK_POLICY_TYPE:
1666
1.14k
            decoded--;
1667
1.14k
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
1668
1.14k
            size = ogs_nas_eps_decode_network_policy(&tracking_area_update_accept->network_policy, pkbuf);
1669
1.14k
            if (size < 0) {
1670
0
               ogs_error("ogs_nas_eps_decode_network_policy() failed");
1671
0
               return size;
1672
0
            }
1673
1674
1.14k
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_NETWORK_POLICY_PRESENT;
1675
1.14k
            decoded += size;
1676
1.14k
            break;
1677
265
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_T3447_VALUE_TYPE:
1678
265
            size = ogs_nas_eps_decode_gprs_timer_3(&tracking_area_update_accept->t3447_value, pkbuf);
1679
265
            if (size < 0) {
1680
6
               ogs_error("ogs_nas_eps_decode_gprs_timer_3() failed");
1681
6
               return size;
1682
6
            }
1683
1684
259
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_T3447_VALUE_PRESENT;
1685
259
            decoded += size;
1686
259
            break;
1687
335
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_EXTENDED_EMERGENCY_NUMBER_LIST_TYPE:
1688
335
            size = ogs_nas_eps_decode_extended_emergency_number_list(&tracking_area_update_accept->extended_emergency_number_list, pkbuf);
1689
335
            if (size < 0) {
1690
26
               ogs_error("ogs_nas_eps_decode_extended_emergency_number_list() failed");
1691
26
               return size;
1692
26
            }
1693
1694
309
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_EXTENDED_EMERGENCY_NUMBER_LIST_PRESENT;
1695
309
            decoded += size;
1696
309
            break;
1697
311
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_CIPHERING_KEY_DATA_TYPE:
1698
311
            size = ogs_nas_eps_decode_ciphering_key_data(&tracking_area_update_accept->ciphering_key_data, pkbuf);
1699
311
            if (size < 0) {
1700
26
               ogs_error("ogs_nas_eps_decode_ciphering_key_data() failed");
1701
26
               return size;
1702
26
            }
1703
1704
285
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_CIPHERING_KEY_DATA_PRESENT;
1705
285
            decoded += size;
1706
285
            break;
1707
396
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_UE_RADIO_CAPABILITY_ID_TYPE:
1708
396
            size = ogs_nas_eps_decode_ue_radio_capability_id(&tracking_area_update_accept->ue_radio_capability_id, pkbuf);
1709
396
            if (size < 0) {
1710
3
               ogs_error("ogs_nas_eps_decode_ue_radio_capability_id() failed");
1711
3
               return size;
1712
3
            }
1713
1714
393
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_UE_RADIO_CAPABILITY_ID_PRESENT;
1715
393
            decoded += size;
1716
393
            break;
1717
834
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_UE_RADIO_CAPABILITY_ID_DELETION_INDICATION_TYPE:
1718
834
            decoded--;
1719
834
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
1720
834
            size = ogs_nas_eps_decode_ue_radio_capability_id_deletion_indication(&tracking_area_update_accept->ue_radio_capability_id_deletion_indication, pkbuf);
1721
834
            if (size < 0) {
1722
0
               ogs_error("ogs_nas_eps_decode_ue_radio_capability_id_deletion_indication() failed");
1723
0
               return size;
1724
0
            }
1725
1726
834
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_UE_RADIO_CAPABILITY_ID_DELETION_INDICATION_PRESENT;
1727
834
            decoded += size;
1728
834
            break;
1729
290
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_NEGOTIATED_WUS_ASSISTANCE_INFORMATION_TYPE:
1730
290
            size = ogs_nas_eps_decode_wus_assistance_information(&tracking_area_update_accept->negotiated_wus_assistance_information, pkbuf);
1731
290
            if (size < 0) {
1732
13
               ogs_error("ogs_nas_eps_decode_wus_assistance_information() failed");
1733
13
               return size;
1734
13
            }
1735
1736
277
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_NEGOTIATED_WUS_ASSISTANCE_INFORMATION_PRESENT;
1737
277
            decoded += size;
1738
277
            break;
1739
279
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_NEGOTIATED_DRX_PARAMETER_IN_NB_S1_MODE_TYPE:
1740
279
            size = ogs_nas_eps_decode_nb_s1_drx_parameter(&tracking_area_update_accept->negotiated_drx_parameter_in_nb_s1_mode, pkbuf);
1741
279
            if (size < 0) {
1742
16
               ogs_error("ogs_nas_eps_decode_nb_s1_drx_parameter() failed");
1743
16
               return size;
1744
16
            }
1745
1746
263
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_NEGOTIATED_DRX_PARAMETER_IN_NB_S1_MODE_PRESENT;
1747
263
            decoded += size;
1748
263
            break;
1749
410
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_NEGOTIATED_IMSI_OFFSET_TYPE:
1750
410
            size = ogs_nas_eps_decode_imsi_offset(&tracking_area_update_accept->negotiated_imsi_offset, pkbuf);
1751
410
            if (size < 0) {
1752
23
               ogs_error("ogs_nas_eps_decode_imsi_offset() failed");
1753
23
               return size;
1754
23
            }
1755
1756
387
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_NEGOTIATED_IMSI_OFFSET_PRESENT;
1757
387
            decoded += size;
1758
387
            break;
1759
301
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_EPS_ADDITIONAL_REQUEST_RESULT_TYPE:
1760
301
            size = ogs_nas_eps_decode_eps_additional_request_result(&tracking_area_update_accept->eps_additional_request_result, pkbuf);
1761
301
            if (size < 0) {
1762
23
               ogs_error("ogs_nas_eps_decode_eps_additional_request_result() failed");
1763
23
               return size;
1764
23
            }
1765
1766
278
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_EPS_ADDITIONAL_REQUEST_RESULT_PRESENT;
1767
278
            decoded += size;
1768
278
            break;
1769
359
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_FORBIDDEN_TAI_FOR_THE_LIST_OF_FORBIDDEN_TRACKING_AREAS_FOR_ROAMING_TYPE:
1770
359
            size = ogs_nas_eps_decode_tracking_area_identity_list(&tracking_area_update_accept->forbidden_tai_for_the_list_of_forbidden_tracking_areas_for_roaming, pkbuf);
1771
359
            if (size < 0) {
1772
3
               ogs_error("ogs_nas_eps_decode_tracking_area_identity_list() failed");
1773
3
               return size;
1774
3
            }
1775
1776
356
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_FORBIDDEN_TAI_FOR_THE_LIST_OF_FORBIDDEN_TRACKING_AREAS_FOR_ROAMING_PRESENT;
1777
356
            decoded += size;
1778
356
            break;
1779
243
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_FORBIDDEN_TAI_FOR_THE_LIST_OF_FORBIDDEN_TRACKING_AREAS_FORREGIONAL_PROVISION_OF_SERVICE_TYPE:
1780
243
            size = ogs_nas_eps_decode_tracking_area_identity_list(&tracking_area_update_accept->forbidden_tai_for_the_list_of_forbidden_tracking_areas_forregional_provision_of_service, pkbuf);
1781
243
            if (size < 0) {
1782
2
               ogs_error("ogs_nas_eps_decode_tracking_area_identity_list() failed");
1783
2
               return size;
1784
2
            }
1785
1786
241
            tracking_area_update_accept->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_ACCEPT_FORBIDDEN_TAI_FOR_THE_LIST_OF_FORBIDDEN_TRACKING_AREAS_FORREGIONAL_PROVISION_OF_SERVICE_PRESENT;
1787
241
            decoded += size;
1788
241
            break;
1789
7.29k
        default:
1790
7.29k
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
1791
7.29k
            break;
1792
23.2k
        }
1793
23.2k
    }
1794
1795
423
    return decoded;
1796
774
}
1797
1798
int ogs_nas_eps_decode_tracking_area_update_reject(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
1799
82
{
1800
82
    ogs_nas_eps_tracking_area_update_reject_t *tracking_area_update_reject = &message->emm.tracking_area_update_reject;
1801
82
    int decoded = 0;
1802
82
    int size = 0;
1803
1804
82
    ogs_trace("[NAS] Decode TRACKING_AREA_UPDATE_REJECT\n");
1805
1806
82
    size = ogs_nas_eps_decode_emm_cause(&tracking_area_update_reject->emm_cause, pkbuf);
1807
82
    if (size < 0) {
1808
0
        ogs_error("ogs_nas_eps_decode_emm_cause() failed");
1809
0
        return size;
1810
0
    }
1811
1812
82
    decoded += size;
1813
1814
4.18k
    while (pkbuf->len > 0) {
1815
4.11k
        uint8_t *buffer = pkbuf->data;
1816
4.11k
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
1817
1818
4.11k
        size = sizeof(uint8_t);
1819
4.11k
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
1820
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
1821
0
           return OGS_ERROR;
1822
0
        }
1823
4.11k
        decoded += size;
1824
1825
4.11k
        switch (type) {
1826
195
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REJECT_T3346_VALUE_TYPE:
1827
195
            size = ogs_nas_eps_decode_gprs_timer_2(&tracking_area_update_reject->t3346_value, pkbuf);
1828
195
            if (size < 0) {
1829
1
               ogs_error("ogs_nas_eps_decode_gprs_timer_2() failed");
1830
1
               return size;
1831
1
            }
1832
1833
194
            tracking_area_update_reject->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REJECT_T3346_VALUE_PRESENT;
1834
194
            decoded += size;
1835
194
            break;
1836
565
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REJECT_EXTENDED_EMM_CAUSE_TYPE:
1837
565
            decoded--;
1838
565
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
1839
565
            size = ogs_nas_eps_decode_extended_emm_cause(&tracking_area_update_reject->extended_emm_cause, pkbuf);
1840
565
            if (size < 0) {
1841
0
               ogs_error("ogs_nas_eps_decode_extended_emm_cause() failed");
1842
0
               return size;
1843
0
            }
1844
1845
565
            tracking_area_update_reject->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REJECT_EXTENDED_EMM_CAUSE_PRESENT;
1846
565
            decoded += size;
1847
565
            break;
1848
217
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REJECT_LOWER_BOUND_TIMER_VALUE_TYPE:
1849
217
            size = ogs_nas_eps_decode_gprs_timer_3(&tracking_area_update_reject->lower_bound_timer_value, pkbuf);
1850
217
            if (size < 0) {
1851
2
               ogs_error("ogs_nas_eps_decode_gprs_timer_3() failed");
1852
2
               return size;
1853
2
            }
1854
1855
215
            tracking_area_update_reject->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REJECT_LOWER_BOUND_TIMER_VALUE_PRESENT;
1856
215
            decoded += size;
1857
215
            break;
1858
238
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REJECT_FORBIDDEN_TAI_FOR_THE_LIST_OF_FORBIDDEN_TRACKING_AREAS_FOR_ROAMING_TYPE:
1859
238
            size = ogs_nas_eps_decode_tracking_area_identity_list(&tracking_area_update_reject->forbidden_tai_for_the_list_of_forbidden_tracking_areas_for_roaming, pkbuf);
1860
238
            if (size < 0) {
1861
2
               ogs_error("ogs_nas_eps_decode_tracking_area_identity_list() failed");
1862
2
               return size;
1863
2
            }
1864
1865
236
            tracking_area_update_reject->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REJECT_FORBIDDEN_TAI_FOR_THE_LIST_OF_FORBIDDEN_TRACKING_AREAS_FOR_ROAMING_PRESENT;
1866
236
            decoded += size;
1867
236
            break;
1868
223
        case OGS_NAS_EPS_TRACKING_AREA_UPDATE_REJECT_FORBIDDEN_TAI_FOR_THE_LIST_OF_FORBIDDEN_TRACKING_AREAS_FORREGIONAL_PROVISION_OF_SERVICE_TYPE:
1869
223
            size = ogs_nas_eps_decode_tracking_area_identity_list(&tracking_area_update_reject->forbidden_tai_for_the_list_of_forbidden_tracking_areas_forregional_provision_of_service, pkbuf);
1870
223
            if (size < 0) {
1871
3
               ogs_error("ogs_nas_eps_decode_tracking_area_identity_list() failed");
1872
3
               return size;
1873
3
            }
1874
1875
220
            tracking_area_update_reject->presencemask |= OGS_NAS_EPS_TRACKING_AREA_UPDATE_REJECT_FORBIDDEN_TAI_FOR_THE_LIST_OF_FORBIDDEN_TRACKING_AREAS_FORREGIONAL_PROVISION_OF_SERVICE_PRESENT;
1876
220
            decoded += size;
1877
220
            break;
1878
2.67k
        default:
1879
2.67k
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
1880
2.67k
            break;
1881
4.11k
        }
1882
4.11k
    }
1883
1884
74
    return decoded;
1885
82
}
1886
1887
int ogs_nas_eps_decode_extended_service_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
1888
112
{
1889
112
    ogs_nas_eps_extended_service_request_t *extended_service_request = &message->emm.extended_service_request;
1890
112
    int decoded = 0;
1891
112
    int size = 0;
1892
1893
112
    ogs_trace("[NAS] Decode EXTENDED_SERVICE_REQUEST\n");
1894
1895
112
    size = ogs_nas_eps_decode_service_type(&extended_service_request->service_type, pkbuf);
1896
112
    if (size < 0) {
1897
0
        ogs_error("ogs_nas_eps_decode_service_type() failed");
1898
0
        return size;
1899
0
    }
1900
1901
112
    decoded += size;
1902
1903
112
    size = ogs_nas_eps_decode_mobile_identity(&extended_service_request->m_tmsi, pkbuf);
1904
112
    if (size < 0) {
1905
6
        ogs_error("ogs_nas_eps_decode_mobile_identity() failed");
1906
6
        return size;
1907
6
    }
1908
1909
106
    decoded += size;
1910
1911
7.30k
    while (pkbuf->len > 0) {
1912
7.20k
        uint8_t *buffer = pkbuf->data;
1913
7.20k
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
1914
1915
7.20k
        size = sizeof(uint8_t);
1916
7.20k
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
1917
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
1918
0
           return OGS_ERROR;
1919
0
        }
1920
7.20k
        decoded += size;
1921
1922
7.20k
        switch (type) {
1923
608
        case OGS_NAS_EPS_EXTENDED_SERVICE_REQUEST_CSFB_RESPONSE_TYPE:
1924
608
            decoded--;
1925
608
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
1926
608
            size = ogs_nas_eps_decode_csfb_response(&extended_service_request->csfb_response, pkbuf);
1927
608
            if (size < 0) {
1928
0
               ogs_error("ogs_nas_eps_decode_csfb_response() failed");
1929
0
               return size;
1930
0
            }
1931
1932
608
            extended_service_request->presencemask |= OGS_NAS_EPS_EXTENDED_SERVICE_REQUEST_CSFB_RESPONSE_PRESENT;
1933
608
            decoded += size;
1934
608
            break;
1935
211
        case OGS_NAS_EPS_EXTENDED_SERVICE_REQUEST_EPS_BEARER_CONTEXT_STATUS_TYPE:
1936
211
            size = ogs_nas_eps_decode_eps_bearer_context_status(&extended_service_request->eps_bearer_context_status, pkbuf);
1937
211
            if (size < 0) {
1938
2
               ogs_error("ogs_nas_eps_decode_eps_bearer_context_status() failed");
1939
2
               return size;
1940
2
            }
1941
1942
209
            extended_service_request->presencemask |= OGS_NAS_EPS_EXTENDED_SERVICE_REQUEST_EPS_BEARER_CONTEXT_STATUS_PRESENT;
1943
209
            decoded += size;
1944
209
            break;
1945
645
        case OGS_NAS_EPS_EXTENDED_SERVICE_REQUEST_DEVICE_PROPERTIES_TYPE:
1946
645
            decoded--;
1947
645
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
1948
645
            size = ogs_nas_eps_decode_device_properties(&extended_service_request->device_properties, pkbuf);
1949
645
            if (size < 0) {
1950
0
               ogs_error("ogs_nas_eps_decode_device_properties() failed");
1951
0
               return size;
1952
0
            }
1953
1954
645
            extended_service_request->presencemask |= OGS_NAS_EPS_EXTENDED_SERVICE_REQUEST_DEVICE_PROPERTIES_PRESENT;
1955
645
            decoded += size;
1956
645
            break;
1957
277
        case OGS_NAS_EPS_EXTENDED_SERVICE_REQUEST_UE_REQUEST_TYPE_TYPE:
1958
277
            size = ogs_nas_eps_decode_ue_request_type(&extended_service_request->ue_request_type, pkbuf);
1959
277
            if (size < 0) {
1960
7
               ogs_error("ogs_nas_eps_decode_ue_request_type() failed");
1961
7
               return size;
1962
7
            }
1963
1964
270
            extended_service_request->presencemask |= OGS_NAS_EPS_EXTENDED_SERVICE_REQUEST_UE_REQUEST_TYPE_PRESENT;
1965
270
            decoded += size;
1966
270
            break;
1967
209
        case OGS_NAS_EPS_EXTENDED_SERVICE_REQUEST_PAGING_RESTRICTION_TYPE:
1968
209
            size = ogs_nas_eps_decode_paging_restriction(&extended_service_request->paging_restriction, pkbuf);
1969
209
            if (size < 0) {
1970
4
               ogs_error("ogs_nas_eps_decode_paging_restriction() failed");
1971
4
               return size;
1972
4
            }
1973
1974
205
            extended_service_request->presencemask |= OGS_NAS_EPS_EXTENDED_SERVICE_REQUEST_PAGING_RESTRICTION_PRESENT;
1975
205
            decoded += size;
1976
205
            break;
1977
5.25k
        default:
1978
5.25k
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
1979
5.25k
            break;
1980
7.20k
        }
1981
7.20k
    }
1982
1983
93
    return decoded;
1984
106
}
1985
1986
int ogs_nas_eps_decode_service_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
1987
18
{
1988
18
    ogs_nas_eps_service_request_t *service_request = &message->emm.service_request;
1989
18
    int decoded = 0;
1990
18
    int size = 0;
1991
1992
18
    ogs_trace("[NAS] Decode SERVICE_REQUEST\n");
1993
1994
18
    size = ogs_nas_eps_decode_ksi_and_sequence_number(&service_request->ksi_and_sequence_number, pkbuf);
1995
18
    if (size < 0) {
1996
0
        ogs_error("ogs_nas_eps_decode_ksi_and_sequence_number() failed");
1997
0
        return size;
1998
0
    }
1999
2000
18
    decoded += size;
2001
2002
18
    size = ogs_nas_eps_decode_short_mac(&service_request->message_authentication_code, pkbuf);
2003
18
    if (size < 0) {
2004
0
        ogs_error("ogs_nas_eps_decode_short_mac() failed");
2005
0
        return size;
2006
0
    }
2007
2008
18
    decoded += size;
2009
2010
18
    return decoded;
2011
18
}
2012
2013
int ogs_nas_eps_decode_service_reject(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
2014
109
{
2015
109
    ogs_nas_eps_service_reject_t *service_reject = &message->emm.service_reject;
2016
109
    int decoded = 0;
2017
109
    int size = 0;
2018
2019
109
    ogs_trace("[NAS] Decode SERVICE_REJECT\n");
2020
2021
109
    size = ogs_nas_eps_decode_emm_cause(&service_reject->emm_cause, pkbuf);
2022
109
    if (size < 0) {
2023
0
        ogs_error("ogs_nas_eps_decode_emm_cause() failed");
2024
0
        return size;
2025
0
    }
2026
2027
109
    decoded += size;
2028
2029
3.71k
    while (pkbuf->len > 0) {
2030
3.63k
        uint8_t *buffer = pkbuf->data;
2031
3.63k
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
2032
2033
3.63k
        size = sizeof(uint8_t);
2034
3.63k
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
2035
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
2036
0
           return OGS_ERROR;
2037
0
        }
2038
3.63k
        decoded += size;
2039
2040
3.63k
        switch (type) {
2041
206
        case OGS_NAS_EPS_SERVICE_REJECT_T3442_VALUE_TYPE:
2042
206
            size = ogs_nas_eps_decode_gprs_timer(&service_reject->t3442_value, pkbuf);
2043
206
            if (size < 0) {
2044
2
               ogs_error("ogs_nas_eps_decode_gprs_timer() failed");
2045
2
               return size;
2046
2
            }
2047
2048
204
            service_reject->presencemask |= OGS_NAS_EPS_SERVICE_REJECT_T3442_VALUE_PRESENT;
2049
204
            decoded += size;
2050
204
            break;
2051
229
        case OGS_NAS_EPS_SERVICE_REJECT_T3346_VALUE_TYPE:
2052
229
            size = ogs_nas_eps_decode_gprs_timer_2(&service_reject->t3346_value, pkbuf);
2053
229
            if (size < 0) {
2054
5
               ogs_error("ogs_nas_eps_decode_gprs_timer_2() failed");
2055
5
               return size;
2056
5
            }
2057
2058
224
            service_reject->presencemask |= OGS_NAS_EPS_SERVICE_REJECT_T3346_VALUE_PRESENT;
2059
224
            decoded += size;
2060
224
            break;
2061
198
        case OGS_NAS_EPS_SERVICE_REJECT_T3448_VALUE_TYPE:
2062
198
            size = ogs_nas_eps_decode_gprs_timer_2(&service_reject->t3448_value, pkbuf);
2063
198
            if (size < 0) {
2064
2
               ogs_error("ogs_nas_eps_decode_gprs_timer_2() failed");
2065
2
               return size;
2066
2
            }
2067
2068
196
            service_reject->presencemask |= OGS_NAS_EPS_SERVICE_REJECT_T3448_VALUE_PRESENT;
2069
196
            decoded += size;
2070
196
            break;
2071
216
        case OGS_NAS_EPS_SERVICE_REJECT_LOWER_BOUND_TIMER_VALUE_TYPE:
2072
216
            size = ogs_nas_eps_decode_gprs_timer_3(&service_reject->lower_bound_timer_value, pkbuf);
2073
216
            if (size < 0) {
2074
5
               ogs_error("ogs_nas_eps_decode_gprs_timer_3() failed");
2075
5
               return size;
2076
5
            }
2077
2078
211
            service_reject->presencemask |= OGS_NAS_EPS_SERVICE_REJECT_LOWER_BOUND_TIMER_VALUE_PRESENT;
2079
211
            decoded += size;
2080
211
            break;
2081
330
        case OGS_NAS_EPS_SERVICE_REJECT_FORBIDDEN_TAI_FOR_THE_LIST_OF_FORBIDDEN_TRACKING_AREAS_FOR_ROAMING_TYPE:
2082
330
            size = ogs_nas_eps_decode_tracking_area_identity_list(&service_reject->forbidden_tai_for_the_list_of_forbidden_tracking_areas_for_roaming, pkbuf);
2083
330
            if (size < 0) {
2084
3
               ogs_error("ogs_nas_eps_decode_tracking_area_identity_list() failed");
2085
3
               return size;
2086
3
            }
2087
2088
327
            service_reject->presencemask |= OGS_NAS_EPS_SERVICE_REJECT_FORBIDDEN_TAI_FOR_THE_LIST_OF_FORBIDDEN_TRACKING_AREAS_FOR_ROAMING_PRESENT;
2089
327
            decoded += size;
2090
327
            break;
2091
269
        case OGS_NAS_EPS_SERVICE_REJECT_FORBIDDEN_TAI_FOR_THE_LIST_OF_FORBIDDEN_TRACKING_AREAS_FORREGIONAL_PROVISION_OF_SERVICE_TYPE:
2092
269
            size = ogs_nas_eps_decode_tracking_area_identity_list(&service_reject->forbidden_tai_for_the_list_of_forbidden_tracking_areas_forregional_provision_of_service, pkbuf);
2093
269
            if (size < 0) {
2094
6
               ogs_error("ogs_nas_eps_decode_tracking_area_identity_list() failed");
2095
6
               return size;
2096
6
            }
2097
2098
263
            service_reject->presencemask |= OGS_NAS_EPS_SERVICE_REJECT_FORBIDDEN_TAI_FOR_THE_LIST_OF_FORBIDDEN_TRACKING_AREAS_FORREGIONAL_PROVISION_OF_SERVICE_PRESENT;
2099
263
            decoded += size;
2100
263
            break;
2101
2.18k
        default:
2102
2.18k
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
2103
2.18k
            break;
2104
3.63k
        }
2105
3.63k
    }
2106
2107
86
    return decoded;
2108
109
}
2109
2110
int ogs_nas_eps_decode_guti_reallocation_command(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
2111
90
{
2112
90
    ogs_nas_eps_guti_reallocation_command_t *guti_reallocation_command = &message->emm.guti_reallocation_command;
2113
90
    int decoded = 0;
2114
90
    int size = 0;
2115
2116
90
    ogs_trace("[NAS] Decode GUTI_REALLOCATION_COMMAND\n");
2117
2118
90
    size = ogs_nas_eps_decode_eps_mobile_identity(&guti_reallocation_command->guti, pkbuf);
2119
90
    if (size < 0) {
2120
9
        ogs_error("ogs_nas_eps_decode_eps_mobile_identity() failed");
2121
9
        return size;
2122
9
    }
2123
2124
81
    decoded += size;
2125
2126
2.94k
    while (pkbuf->len > 0) {
2127
2.87k
        uint8_t *buffer = pkbuf->data;
2128
2.87k
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
2129
2130
2.87k
        size = sizeof(uint8_t);
2131
2.87k
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
2132
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
2133
0
           return OGS_ERROR;
2134
0
        }
2135
2.87k
        decoded += size;
2136
2137
2.87k
        switch (type) {
2138
229
        case OGS_NAS_EPS_GUTI_REALLOCATION_COMMAND_TAI_LIST_TYPE:
2139
229
            size = ogs_nas_eps_decode_tracking_area_identity_list(&guti_reallocation_command->tai_list, pkbuf);
2140
229
            if (size < 0) {
2141
2
               ogs_error("ogs_nas_eps_decode_tracking_area_identity_list() failed");
2142
2
               return size;
2143
2
            }
2144
2145
227
            guti_reallocation_command->presencemask |= OGS_NAS_EPS_GUTI_REALLOCATION_COMMAND_TAI_LIST_PRESENT;
2146
227
            decoded += size;
2147
227
            break;
2148
215
        case OGS_NAS_EPS_GUTI_REALLOCATION_COMMAND_DCN_ID_TYPE:
2149
215
            size = ogs_nas_eps_decode_dcn_id(&guti_reallocation_command->dcn_id, pkbuf);
2150
215
            if (size < 0) {
2151
7
               ogs_error("ogs_nas_eps_decode_dcn_id() failed");
2152
7
               return size;
2153
7
            }
2154
2155
208
            guti_reallocation_command->presencemask |= OGS_NAS_EPS_GUTI_REALLOCATION_COMMAND_DCN_ID_PRESENT;
2156
208
            decoded += size;
2157
208
            break;
2158
205
        case OGS_NAS_EPS_GUTI_REALLOCATION_COMMAND_UE_RADIO_CAPABILITY_ID_TYPE:
2159
205
            size = ogs_nas_eps_decode_ue_radio_capability_id(&guti_reallocation_command->ue_radio_capability_id, pkbuf);
2160
205
            if (size < 0) {
2161
4
               ogs_error("ogs_nas_eps_decode_ue_radio_capability_id() failed");
2162
4
               return size;
2163
4
            }
2164
2165
201
            guti_reallocation_command->presencemask |= OGS_NAS_EPS_GUTI_REALLOCATION_COMMAND_UE_RADIO_CAPABILITY_ID_PRESENT;
2166
201
            decoded += size;
2167
201
            break;
2168
258
        case OGS_NAS_EPS_GUTI_REALLOCATION_COMMAND_UE_RADIO_CAPABILITY_ID_DELETION_INDICATION_TYPE:
2169
258
            decoded--;
2170
258
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
2171
258
            size = ogs_nas_eps_decode_ue_radio_capability_id_deletion_indication(&guti_reallocation_command->ue_radio_capability_id_deletion_indication, pkbuf);
2172
258
            if (size < 0) {
2173
0
               ogs_error("ogs_nas_eps_decode_ue_radio_capability_id_deletion_indication() failed");
2174
0
               return size;
2175
0
            }
2176
2177
258
            guti_reallocation_command->presencemask |= OGS_NAS_EPS_GUTI_REALLOCATION_COMMAND_UE_RADIO_CAPABILITY_ID_DELETION_INDICATION_PRESENT;
2178
258
            decoded += size;
2179
258
            break;
2180
1.97k
        default:
2181
1.97k
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
2182
1.97k
            break;
2183
2.87k
        }
2184
2.87k
    }
2185
2186
68
    return decoded;
2187
81
}
2188
2189
int ogs_nas_eps_decode_authentication_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
2190
38
{
2191
38
    ogs_nas_eps_authentication_request_t *authentication_request = &message->emm.authentication_request;
2192
38
    int decoded = 0;
2193
38
    int size = 0;
2194
2195
38
    ogs_trace("[NAS] Decode AUTHENTICATION_REQUEST\n");
2196
2197
38
    size = ogs_nas_eps_decode_key_set_identifier(&authentication_request->nas_key_set_identifierasme, pkbuf);
2198
38
    if (size < 0) {
2199
0
        ogs_error("ogs_nas_eps_decode_key_set_identifier() failed");
2200
0
        return size;
2201
0
    }
2202
2203
38
    decoded += size;
2204
2205
38
    size = ogs_nas_eps_decode_authentication_parameter_rand(&authentication_request->authentication_parameter_rand, pkbuf);
2206
38
    if (size < 0) {
2207
6
        ogs_error("ogs_nas_eps_decode_authentication_parameter_rand() failed");
2208
6
        return size;
2209
6
    }
2210
2211
32
    decoded += size;
2212
2213
32
    size = ogs_nas_eps_decode_authentication_parameter_autn(&authentication_request->authentication_parameter_autn, pkbuf);
2214
32
    if (size < 0) {
2215
15
        ogs_error("ogs_nas_eps_decode_authentication_parameter_autn() failed");
2216
15
        return size;
2217
15
    }
2218
2219
17
    decoded += size;
2220
2221
17
    return decoded;
2222
32
}
2223
2224
int ogs_nas_eps_decode_authentication_response(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
2225
32
{
2226
32
    ogs_nas_eps_authentication_response_t *authentication_response = &message->emm.authentication_response;
2227
32
    int decoded = 0;
2228
32
    int size = 0;
2229
2230
32
    ogs_trace("[NAS] Decode AUTHENTICATION_RESPONSE\n");
2231
2232
32
    size = ogs_nas_eps_decode_authentication_response_parameter(&authentication_response->authentication_response_parameter, pkbuf);
2233
32
    if (size < 0) {
2234
12
        ogs_error("ogs_nas_eps_decode_authentication_response_parameter() failed");
2235
12
        return size;
2236
12
    }
2237
2238
20
    decoded += size;
2239
2240
20
    return decoded;
2241
32
}
2242
2243
int ogs_nas_eps_decode_identity_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
2244
10
{
2245
10
    ogs_nas_eps_identity_request_t *identity_request = &message->emm.identity_request;
2246
10
    int decoded = 0;
2247
10
    int size = 0;
2248
2249
10
    ogs_trace("[NAS] Decode IDENTITY_REQUEST\n");
2250
2251
10
    size = ogs_nas_eps_decode_identity_type_2(&identity_request->identity_type, pkbuf);
2252
10
    if (size < 0) {
2253
0
        ogs_error("ogs_nas_eps_decode_identity_type_2() failed");
2254
0
        return size;
2255
0
    }
2256
2257
10
    decoded += size;
2258
2259
10
    return decoded;
2260
10
}
2261
2262
int ogs_nas_eps_decode_identity_response(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
2263
22
{
2264
22
    ogs_nas_eps_identity_response_t *identity_response = &message->emm.identity_response;
2265
22
    int decoded = 0;
2266
22
    int size = 0;
2267
2268
22
    ogs_trace("[NAS] Decode IDENTITY_RESPONSE\n");
2269
2270
22
    size = ogs_nas_eps_decode_mobile_identity(&identity_response->mobile_identity, pkbuf);
2271
22
    if (size < 0) {
2272
8
        ogs_error("ogs_nas_eps_decode_mobile_identity() failed");
2273
8
        return size;
2274
8
    }
2275
2276
14
    decoded += size;
2277
2278
14
    return decoded;
2279
22
}
2280
2281
int ogs_nas_eps_decode_authentication_failure(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
2282
52
{
2283
52
    ogs_nas_eps_authentication_failure_t *authentication_failure = &message->emm.authentication_failure;
2284
52
    int decoded = 0;
2285
52
    int size = 0;
2286
2287
52
    ogs_trace("[NAS] Decode AUTHENTICATION_FAILURE\n");
2288
2289
52
    size = ogs_nas_eps_decode_emm_cause(&authentication_failure->emm_cause, pkbuf);
2290
52
    if (size < 0) {
2291
0
        ogs_error("ogs_nas_eps_decode_emm_cause() failed");
2292
0
        return size;
2293
0
    }
2294
2295
52
    decoded += size;
2296
2297
1.68k
    while (pkbuf->len > 0) {
2298
1.64k
        uint8_t *buffer = pkbuf->data;
2299
1.64k
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
2300
2301
1.64k
        size = sizeof(uint8_t);
2302
1.64k
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
2303
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
2304
0
           return OGS_ERROR;
2305
0
        }
2306
1.64k
        decoded += size;
2307
2308
1.64k
        switch (type) {
2309
237
        case OGS_NAS_EPS_AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_TYPE:
2310
237
            size = ogs_nas_eps_decode_authentication_failure_parameter(&authentication_failure->authentication_failure_parameter, pkbuf);
2311
237
            if (size < 0) {
2312
8
               ogs_error("ogs_nas_eps_decode_authentication_failure_parameter() failed");
2313
8
               return size;
2314
8
            }
2315
2316
229
            authentication_failure->presencemask |= OGS_NAS_EPS_AUTHENTICATION_FAILURE_AUTHENTICATION_FAILURE_PARAMETER_PRESENT;
2317
229
            decoded += size;
2318
229
            break;
2319
1.40k
        default:
2320
1.40k
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
2321
1.40k
            break;
2322
1.64k
        }
2323
1.64k
    }
2324
2325
44
    return decoded;
2326
52
}
2327
2328
int ogs_nas_eps_decode_security_mode_command(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
2329
175
{
2330
175
    ogs_nas_eps_security_mode_command_t *security_mode_command = &message->emm.security_mode_command;
2331
175
    int decoded = 0;
2332
175
    int size = 0;
2333
2334
175
    ogs_trace("[NAS] Decode SECURITY_MODE_COMMAND\n");
2335
2336
175
    size = ogs_nas_eps_decode_security_algorithms(&security_mode_command->selected_nas_security_algorithms, pkbuf);
2337
175
    if (size < 0) {
2338
0
        ogs_error("ogs_nas_eps_decode_security_algorithms() failed");
2339
0
        return size;
2340
0
    }
2341
2342
175
    decoded += size;
2343
2344
175
    size = ogs_nas_eps_decode_key_set_identifier(&security_mode_command->nas_key_set_identifier, pkbuf);
2345
175
    if (size < 0) {
2346
0
        ogs_error("ogs_nas_eps_decode_key_set_identifier() failed");
2347
0
        return size;
2348
0
    }
2349
2350
175
    decoded += size;
2351
2352
175
    size = ogs_nas_eps_decode_ue_security_capability(&security_mode_command->replayed_ue_security_capabilities, pkbuf);
2353
175
    if (size < 0) {
2354
15
        ogs_error("ogs_nas_eps_decode_ue_security_capability() failed");
2355
15
        return size;
2356
15
    }
2357
2358
160
    decoded += size;
2359
2360
7.18k
    while (pkbuf->len > 0) {
2361
7.08k
        uint8_t *buffer = pkbuf->data;
2362
7.08k
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
2363
2364
7.08k
        size = sizeof(uint8_t);
2365
7.08k
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
2366
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
2367
0
           return OGS_ERROR;
2368
0
        }
2369
7.08k
        decoded += size;
2370
2371
7.08k
        switch (type) {
2372
1.21k
        case OGS_NAS_EPS_SECURITY_MODE_COMMAND_IMEISV_REQUEST_TYPE:
2373
1.21k
            decoded--;
2374
1.21k
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
2375
1.21k
            size = ogs_nas_eps_decode_imeisv_request(&security_mode_command->imeisv_request, pkbuf);
2376
1.21k
            if (size < 0) {
2377
0
               ogs_error("ogs_nas_eps_decode_imeisv_request() failed");
2378
0
               return size;
2379
0
            }
2380
2381
1.21k
            security_mode_command->presencemask |= OGS_NAS_EPS_SECURITY_MODE_COMMAND_IMEISV_REQUEST_PRESENT;
2382
1.21k
            decoded += size;
2383
1.21k
            break;
2384
196
        case OGS_NAS_EPS_SECURITY_MODE_COMMAND_REPLAYED_NONCEUE_TYPE:
2385
196
            size = ogs_nas_eps_decode_nonce(&security_mode_command->replayed_nonceue, pkbuf);
2386
196
            if (size < 0) {
2387
1
               ogs_error("ogs_nas_eps_decode_nonce() failed");
2388
1
               return size;
2389
1
            }
2390
2391
195
            security_mode_command->presencemask |= OGS_NAS_EPS_SECURITY_MODE_COMMAND_REPLAYED_NONCEUE_PRESENT;
2392
195
            decoded += size;
2393
195
            break;
2394
206
        case OGS_NAS_EPS_SECURITY_MODE_COMMAND_NONCEMME_TYPE:
2395
206
            size = ogs_nas_eps_decode_nonce(&security_mode_command->noncemme, pkbuf);
2396
206
            if (size < 0) {
2397
1
               ogs_error("ogs_nas_eps_decode_nonce() failed");
2398
1
               return size;
2399
1
            }
2400
2401
205
            security_mode_command->presencemask |= OGS_NAS_EPS_SECURITY_MODE_COMMAND_NONCEMME_PRESENT;
2402
205
            decoded += size;
2403
205
            break;
2404
566
        case OGS_NAS_EPS_SECURITY_MODE_COMMAND_HASHMME_TYPE:
2405
566
            size = ogs_nas_eps_decode_hashmme(&security_mode_command->hashmme, pkbuf);
2406
566
            if (size < 0) {
2407
25
               ogs_error("ogs_nas_eps_decode_hashmme() failed");
2408
25
               return size;
2409
25
            }
2410
2411
541
            security_mode_command->presencemask |= OGS_NAS_EPS_SECURITY_MODE_COMMAND_HASHMME_PRESENT;
2412
541
            decoded += size;
2413
541
            break;
2414
196
        case OGS_NAS_EPS_SECURITY_MODE_COMMAND_REPLAYED_UE_ADDITIONAL_SECURITY_CAPABILITY_TYPE:
2415
196
            size = ogs_nas_eps_decode_ue_additional_security_capability(&security_mode_command->replayed_ue_additional_security_capability, pkbuf);
2416
196
            if (size < 0) {
2417
2
               ogs_error("ogs_nas_eps_decode_ue_additional_security_capability() failed");
2418
2
               return size;
2419
2
            }
2420
2421
194
            security_mode_command->presencemask |= OGS_NAS_EPS_SECURITY_MODE_COMMAND_REPLAYED_UE_ADDITIONAL_SECURITY_CAPABILITY_PRESENT;
2422
194
            decoded += size;
2423
194
            break;
2424
295
        case OGS_NAS_EPS_SECURITY_MODE_COMMAND_UE_RADIO_CAPABILITY_ID_REQUEST_TYPE:
2425
295
            size = ogs_nas_eps_decode_ue_radio_capability_id_request(&security_mode_command->ue_radio_capability_id_request, pkbuf);
2426
295
            if (size < 0) {
2427
29
               ogs_error("ogs_nas_eps_decode_ue_radio_capability_id_request() failed");
2428
29
               return size;
2429
29
            }
2430
2431
266
            security_mode_command->presencemask |= OGS_NAS_EPS_SECURITY_MODE_COMMAND_UE_RADIO_CAPABILITY_ID_REQUEST_PRESENT;
2432
266
            decoded += size;
2433
266
            break;
2434
4.41k
        default:
2435
4.41k
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
2436
4.41k
            break;
2437
7.08k
        }
2438
7.08k
    }
2439
2440
102
    return decoded;
2441
160
}
2442
2443
int ogs_nas_eps_decode_security_mode_complete(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
2444
121
{
2445
121
    ogs_nas_eps_security_mode_complete_t *security_mode_complete = &message->emm.security_mode_complete;
2446
121
    int decoded = 0;
2447
121
    int size = 0;
2448
2449
121
    ogs_trace("[NAS] Decode SECURITY_MODE_COMPLETE\n");
2450
2451
3.74k
    while (pkbuf->len > 0) {
2452
3.67k
        uint8_t *buffer = pkbuf->data;
2453
3.67k
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
2454
2455
3.67k
        size = sizeof(uint8_t);
2456
3.67k
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
2457
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
2458
0
           return OGS_ERROR;
2459
0
        }
2460
3.67k
        decoded += size;
2461
2462
3.67k
        switch (type) {
2463
346
        case OGS_NAS_EPS_SECURITY_MODE_COMPLETE_IMEISV_TYPE:
2464
346
            size = ogs_nas_eps_decode_mobile_identity(&security_mode_complete->imeisv, pkbuf);
2465
346
            if (size < 0) {
2466
10
               ogs_error("ogs_nas_eps_decode_mobile_identity() failed");
2467
10
               return size;
2468
10
            }
2469
2470
336
            security_mode_complete->presencemask |= OGS_NAS_EPS_SECURITY_MODE_COMPLETE_IMEISV_PRESENT;
2471
336
            decoded += size;
2472
336
            break;
2473
480
        case OGS_NAS_EPS_SECURITY_MODE_COMPLETE_REPLAYED_NAS_MESSAGE_CONTAINER_TYPE:
2474
480
            size = ogs_nas_eps_decode_replayed_nas_message_container(&security_mode_complete->replayed_nas_message_container, pkbuf);
2475
480
            if (size < 0) {
2476
23
               ogs_error("ogs_nas_eps_decode_replayed_nas_message_container() failed");
2477
23
               return size;
2478
23
            }
2479
2480
457
            security_mode_complete->presencemask |= OGS_NAS_EPS_SECURITY_MODE_COMPLETE_REPLAYED_NAS_MESSAGE_CONTAINER_PRESENT;
2481
457
            decoded += size;
2482
457
            break;
2483
328
        case OGS_NAS_EPS_SECURITY_MODE_COMPLETE_UE_RADIO_CAPABILITY_ID_TYPE:
2484
328
            size = ogs_nas_eps_decode_ue_radio_capability_id(&security_mode_complete->ue_radio_capability_id, pkbuf);
2485
328
            if (size < 0) {
2486
14
               ogs_error("ogs_nas_eps_decode_ue_radio_capability_id() failed");
2487
14
               return size;
2488
14
            }
2489
2490
314
            security_mode_complete->presencemask |= OGS_NAS_EPS_SECURITY_MODE_COMPLETE_UE_RADIO_CAPABILITY_ID_PRESENT;
2491
314
            decoded += size;
2492
314
            break;
2493
2.51k
        default:
2494
2.51k
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
2495
2.51k
            break;
2496
3.67k
        }
2497
3.67k
    }
2498
2499
74
    return decoded;
2500
121
}
2501
2502
int ogs_nas_eps_decode_security_mode_reject(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
2503
1
{
2504
1
    ogs_nas_eps_security_mode_reject_t *security_mode_reject = &message->emm.security_mode_reject;
2505
1
    int decoded = 0;
2506
1
    int size = 0;
2507
2508
1
    ogs_trace("[NAS] Decode SECURITY_MODE_REJECT\n");
2509
2510
1
    size = ogs_nas_eps_decode_emm_cause(&security_mode_reject->emm_cause, pkbuf);
2511
1
    if (size < 0) {
2512
0
        ogs_error("ogs_nas_eps_decode_emm_cause() failed");
2513
0
        return size;
2514
0
    }
2515
2516
1
    decoded += size;
2517
2518
1
    return decoded;
2519
1
}
2520
2521
int ogs_nas_eps_decode_emm_status(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
2522
1
{
2523
1
    ogs_nas_eps_emm_status_t *emm_status = &message->emm.emm_status;
2524
1
    int decoded = 0;
2525
1
    int size = 0;
2526
2527
1
    ogs_trace("[NAS] Decode EMM_STATUS\n");
2528
2529
1
    size = ogs_nas_eps_decode_emm_cause(&emm_status->emm_cause, pkbuf);
2530
1
    if (size < 0) {
2531
0
        ogs_error("ogs_nas_eps_decode_emm_cause() failed");
2532
0
        return size;
2533
0
    }
2534
2535
1
    decoded += size;
2536
2537
1
    return decoded;
2538
1
}
2539
2540
int ogs_nas_eps_decode_emm_information(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
2541
150
{
2542
150
    ogs_nas_eps_emm_information_t *emm_information = &message->emm.emm_information;
2543
150
    int decoded = 0;
2544
150
    int size = 0;
2545
2546
150
    ogs_trace("[NAS] Decode EMM_INFORMATION\n");
2547
2548
6.30k
    while (pkbuf->len > 0) {
2549
6.21k
        uint8_t *buffer = pkbuf->data;
2550
6.21k
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
2551
2552
6.21k
        size = sizeof(uint8_t);
2553
6.21k
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
2554
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
2555
0
           return OGS_ERROR;
2556
0
        }
2557
6.21k
        decoded += size;
2558
2559
6.21k
        switch (type) {
2560
505
        case OGS_NAS_EPS_EMM_INFORMATION_FULL_NAME_FOR_NETWORK_TYPE:
2561
505
            size = ogs_nas_eps_decode_network_name(&emm_information->full_name_for_network, pkbuf);
2562
505
            if (size < 0) {
2563
10
               ogs_error("ogs_nas_eps_decode_network_name() failed");
2564
10
               return size;
2565
10
            }
2566
2567
495
            emm_information->presencemask |= OGS_NAS_EPS_EMM_INFORMATION_FULL_NAME_FOR_NETWORK_PRESENT;
2568
495
            decoded += size;
2569
495
            break;
2570
233
        case OGS_NAS_EPS_EMM_INFORMATION_SHORT_NAME_FOR_NETWORK_TYPE:
2571
233
            size = ogs_nas_eps_decode_network_name(&emm_information->short_name_for_network, pkbuf);
2572
233
            if (size < 0) {
2573
11
               ogs_error("ogs_nas_eps_decode_network_name() failed");
2574
11
               return size;
2575
11
            }
2576
2577
222
            emm_information->presencemask |= OGS_NAS_EPS_EMM_INFORMATION_SHORT_NAME_FOR_NETWORK_PRESENT;
2578
222
            decoded += size;
2579
222
            break;
2580
418
        case OGS_NAS_EPS_EMM_INFORMATION_LOCAL_TIME_ZONE_TYPE:
2581
418
            size = ogs_nas_eps_decode_time_zone(&emm_information->local_time_zone, pkbuf);
2582
418
            if (size < 0) {
2583
8
               ogs_error("ogs_nas_eps_decode_time_zone() failed");
2584
8
               return size;
2585
8
            }
2586
2587
410
            emm_information->presencemask |= OGS_NAS_EPS_EMM_INFORMATION_LOCAL_TIME_ZONE_PRESENT;
2588
410
            decoded += size;
2589
410
            break;
2590
217
        case OGS_NAS_EPS_EMM_INFORMATION_UNIVERSAL_TIME_AND_LOCAL_TIME_ZONE_TYPE:
2591
217
            size = ogs_nas_eps_decode_time_zone_and_time(&emm_information->universal_time_and_local_time_zone, pkbuf);
2592
217
            if (size < 0) {
2593
9
               ogs_error("ogs_nas_eps_decode_time_zone_and_time() failed");
2594
9
               return size;
2595
9
            }
2596
2597
208
            emm_information->presencemask |= OGS_NAS_EPS_EMM_INFORMATION_UNIVERSAL_TIME_AND_LOCAL_TIME_ZONE_PRESENT;
2598
208
            decoded += size;
2599
208
            break;
2600
436
        case OGS_NAS_EPS_EMM_INFORMATION_NETWORK_DAYLIGHT_SAVING_TIME_TYPE:
2601
436
            size = ogs_nas_eps_decode_daylight_saving_time(&emm_information->network_daylight_saving_time, pkbuf);
2602
436
            if (size < 0) {
2603
24
               ogs_error("ogs_nas_eps_decode_daylight_saving_time() failed");
2604
24
               return size;
2605
24
            }
2606
2607
412
            emm_information->presencemask |= OGS_NAS_EPS_EMM_INFORMATION_NETWORK_DAYLIGHT_SAVING_TIME_PRESENT;
2608
412
            decoded += size;
2609
412
            break;
2610
4.40k
        default:
2611
4.40k
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
2612
4.40k
            break;
2613
6.21k
        }
2614
6.21k
    }
2615
2616
88
    return decoded;
2617
150
}
2618
2619
int ogs_nas_eps_decode_downlink_nas_transport(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
2620
19
{
2621
19
    ogs_nas_eps_downlink_nas_transport_t *downlink_nas_transport = &message->emm.downlink_nas_transport;
2622
19
    int decoded = 0;
2623
19
    int size = 0;
2624
2625
19
    ogs_trace("[NAS] Decode DOWNLINK_NAS_TRANSPORT\n");
2626
2627
19
    size = ogs_nas_eps_decode_eps_message_container(&downlink_nas_transport->nas_message_container, pkbuf);
2628
19
    if (size < 0) {
2629
3
        ogs_error("ogs_nas_eps_decode_eps_message_container() failed");
2630
3
        return size;
2631
3
    }
2632
2633
16
    decoded += size;
2634
2635
16
    return decoded;
2636
19
}
2637
2638
int ogs_nas_eps_decode_uplink_nas_transport(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
2639
27
{
2640
27
    ogs_nas_eps_uplink_nas_transport_t *uplink_nas_transport = &message->emm.uplink_nas_transport;
2641
27
    int decoded = 0;
2642
27
    int size = 0;
2643
2644
27
    ogs_trace("[NAS] Decode UPLINK_NAS_TRANSPORT\n");
2645
2646
27
    size = ogs_nas_eps_decode_eps_message_container(&uplink_nas_transport->nas_message_container, pkbuf);
2647
27
    if (size < 0) {
2648
6
        ogs_error("ogs_nas_eps_decode_eps_message_container() failed");
2649
6
        return size;
2650
6
    }
2651
2652
21
    decoded += size;
2653
2654
21
    return decoded;
2655
27
}
2656
2657
int ogs_nas_eps_decode_cs_service_notification(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
2658
124
{
2659
124
    ogs_nas_eps_cs_service_notification_t *cs_service_notification = &message->emm.cs_service_notification;
2660
124
    int decoded = 0;
2661
124
    int size = 0;
2662
2663
124
    ogs_trace("[NAS] Decode CS_SERVICE_NOTIFICATION\n");
2664
2665
124
    size = ogs_nas_eps_decode_paging_identity(&cs_service_notification->paging_identity, pkbuf);
2666
124
    if (size < 0) {
2667
0
        ogs_error("ogs_nas_eps_decode_paging_identity() failed");
2668
0
        return size;
2669
0
    }
2670
2671
124
    decoded += size;
2672
2673
4.53k
    while (pkbuf->len > 0) {
2674
4.47k
        uint8_t *buffer = pkbuf->data;
2675
4.47k
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
2676
2677
4.47k
        size = sizeof(uint8_t);
2678
4.47k
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
2679
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
2680
0
           return OGS_ERROR;
2681
0
        }
2682
4.47k
        decoded += size;
2683
2684
4.47k
        switch (type) {
2685
326
        case OGS_NAS_EPS_CS_SERVICE_NOTIFICATION_CLI_TYPE:
2686
326
            size = ogs_nas_eps_decode_cli(&cs_service_notification->cli, pkbuf);
2687
326
            if (size < 0) {
2688
27
               ogs_error("ogs_nas_eps_decode_cli() failed");
2689
27
               return size;
2690
27
            }
2691
2692
299
            cs_service_notification->presencemask |= OGS_NAS_EPS_CS_SERVICE_NOTIFICATION_CLI_PRESENT;
2693
299
            decoded += size;
2694
299
            break;
2695
396
        case OGS_NAS_EPS_CS_SERVICE_NOTIFICATION_SS_CODE_TYPE:
2696
396
            size = ogs_nas_eps_decode_ss_code(&cs_service_notification->ss_code, pkbuf);
2697
396
            if (size < 0) {
2698
9
               ogs_error("ogs_nas_eps_decode_ss_code() failed");
2699
9
               return size;
2700
9
            }
2701
2702
387
            cs_service_notification->presencemask |= OGS_NAS_EPS_CS_SERVICE_NOTIFICATION_SS_CODE_PRESENT;
2703
387
            decoded += size;
2704
387
            break;
2705
392
        case OGS_NAS_EPS_CS_SERVICE_NOTIFICATION_LCS_INDICATOR_TYPE:
2706
392
            size = ogs_nas_eps_decode_lcs_indicator(&cs_service_notification->lcs_indicator, pkbuf);
2707
392
            if (size < 0) {
2708
10
               ogs_error("ogs_nas_eps_decode_lcs_indicator() failed");
2709
10
               return size;
2710
10
            }
2711
2712
382
            cs_service_notification->presencemask |= OGS_NAS_EPS_CS_SERVICE_NOTIFICATION_LCS_INDICATOR_PRESENT;
2713
382
            decoded += size;
2714
382
            break;
2715
482
        case OGS_NAS_EPS_CS_SERVICE_NOTIFICATION_LCS_CLIENT_IDENTITY_TYPE:
2716
482
            size = ogs_nas_eps_decode_lcs_client_identity(&cs_service_notification->lcs_client_identity, pkbuf);
2717
482
            if (size < 0) {
2718
14
               ogs_error("ogs_nas_eps_decode_lcs_client_identity() failed");
2719
14
               return size;
2720
14
            }
2721
2722
468
            cs_service_notification->presencemask |= OGS_NAS_EPS_CS_SERVICE_NOTIFICATION_LCS_CLIENT_IDENTITY_PRESENT;
2723
468
            decoded += size;
2724
468
            break;
2725
2.87k
        default:
2726
2.87k
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
2727
2.87k
            break;
2728
4.47k
        }
2729
4.47k
    }
2730
2731
64
    return decoded;
2732
124
}
2733
2734
int ogs_nas_eps_decode_uplink_generic_nas_transport(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
2735
71
{
2736
71
    ogs_nas_eps_uplink_generic_nas_transport_t *uplink_generic_nas_transport = &message->emm.uplink_generic_nas_transport;
2737
71
    int decoded = 0;
2738
71
    int size = 0;
2739
2740
71
    ogs_trace("[NAS] Decode UPLINK_GENERIC_NAS_TRANSPORT\n");
2741
2742
71
    size = ogs_nas_eps_decode_generic_message_container_type(&uplink_generic_nas_transport->generic_message_container_type, pkbuf);
2743
71
    if (size < 0) {
2744
0
        ogs_error("ogs_nas_eps_decode_generic_message_container_type() failed");
2745
0
        return size;
2746
0
    }
2747
2748
71
    decoded += size;
2749
2750
71
    size = ogs_nas_eps_decode_generic_message_container(&uplink_generic_nas_transport->generic_message_container, pkbuf);
2751
71
    if (size < 0) {
2752
8
        ogs_error("ogs_nas_eps_decode_generic_message_container() failed");
2753
8
        return size;
2754
8
    }
2755
2756
63
    decoded += size;
2757
2758
1.22k
    while (pkbuf->len > 0) {
2759
1.16k
        uint8_t *buffer = pkbuf->data;
2760
1.16k
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
2761
2762
1.16k
        size = sizeof(uint8_t);
2763
1.16k
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
2764
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
2765
0
           return OGS_ERROR;
2766
0
        }
2767
1.16k
        decoded += size;
2768
2769
1.16k
        switch (type) {
2770
205
        case OGS_NAS_EPS_UPLINK_GENERIC_NAS_TRANSPORT_ADDITIONAL_INFORMATION_TYPE:
2771
205
            size = ogs_nas_eps_decode_additional_information(&uplink_generic_nas_transport->additional_information, pkbuf);
2772
205
            if (size < 0) {
2773
3
               ogs_error("ogs_nas_eps_decode_additional_information() failed");
2774
3
               return size;
2775
3
            }
2776
2777
202
            uplink_generic_nas_transport->presencemask |= OGS_NAS_EPS_UPLINK_GENERIC_NAS_TRANSPORT_ADDITIONAL_INFORMATION_PRESENT;
2778
202
            decoded += size;
2779
202
            break;
2780
956
        default:
2781
956
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
2782
956
            break;
2783
1.16k
        }
2784
1.16k
    }
2785
2786
60
    return decoded;
2787
63
}
2788
2789
int ogs_nas_eps_decode_downlink_generic_nas_transport(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
2790
79
{
2791
79
    ogs_nas_eps_downlink_generic_nas_transport_t *downlink_generic_nas_transport = &message->emm.downlink_generic_nas_transport;
2792
79
    int decoded = 0;
2793
79
    int size = 0;
2794
2795
79
    ogs_trace("[NAS] Decode DOWNLINK_GENERIC_NAS_TRANSPORT\n");
2796
2797
79
    size = ogs_nas_eps_decode_generic_message_container_type(&downlink_generic_nas_transport->generic_message_container_type, pkbuf);
2798
79
    if (size < 0) {
2799
0
        ogs_error("ogs_nas_eps_decode_generic_message_container_type() failed");
2800
0
        return size;
2801
0
    }
2802
2803
79
    decoded += size;
2804
2805
79
    size = ogs_nas_eps_decode_generic_message_container(&downlink_generic_nas_transport->generic_message_container, pkbuf);
2806
79
    if (size < 0) {
2807
8
        ogs_error("ogs_nas_eps_decode_generic_message_container() failed");
2808
8
        return size;
2809
8
    }
2810
2811
71
    decoded += size;
2812
2813
3.50k
    while (pkbuf->len > 0) {
2814
3.44k
        uint8_t *buffer = pkbuf->data;
2815
3.44k
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
2816
2817
3.44k
        size = sizeof(uint8_t);
2818
3.44k
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
2819
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
2820
0
           return OGS_ERROR;
2821
0
        }
2822
3.44k
        decoded += size;
2823
2824
3.44k
        switch (type) {
2825
299
        case OGS_NAS_EPS_DOWNLINK_GENERIC_NAS_TRANSPORT_ADDITIONAL_INFORMATION_TYPE:
2826
299
            size = ogs_nas_eps_decode_additional_information(&downlink_generic_nas_transport->additional_information, pkbuf);
2827
299
            if (size < 0) {
2828
7
               ogs_error("ogs_nas_eps_decode_additional_information() failed");
2829
7
               return size;
2830
7
            }
2831
2832
292
            downlink_generic_nas_transport->presencemask |= OGS_NAS_EPS_DOWNLINK_GENERIC_NAS_TRANSPORT_ADDITIONAL_INFORMATION_PRESENT;
2833
292
            decoded += size;
2834
292
            break;
2835
3.14k
        default:
2836
3.14k
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
2837
3.14k
            break;
2838
3.44k
        }
2839
3.44k
    }
2840
2841
64
    return decoded;
2842
71
}
2843
2844
int ogs_nas_eps_decode_activate_default_eps_bearer_context_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
2845
0
{
2846
0
    ogs_nas_eps_activate_default_eps_bearer_context_request_t *activate_default_eps_bearer_context_request = &message->esm.activate_default_eps_bearer_context_request;
2847
0
    int decoded = 0;
2848
0
    int size = 0;
2849
2850
0
    ogs_trace("[NAS] Decode ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST\n");
2851
2852
0
    size = ogs_nas_eps_decode_eps_quality_of_service(&activate_default_eps_bearer_context_request->eps_qos, pkbuf);
2853
0
    if (size < 0) {
2854
0
        ogs_error("ogs_nas_eps_decode_eps_quality_of_service() failed");
2855
0
        return size;
2856
0
    }
2857
2858
0
    decoded += size;
2859
2860
0
    size = ogs_nas_eps_decode_access_point_name(&activate_default_eps_bearer_context_request->access_point_name, pkbuf);
2861
0
    if (size < 0) {
2862
0
        ogs_error("ogs_nas_eps_decode_access_point_name() failed");
2863
0
        return size;
2864
0
    }
2865
2866
0
    decoded += size;
2867
2868
0
    size = ogs_nas_eps_decode_pdn_address(&activate_default_eps_bearer_context_request->pdn_address, pkbuf);
2869
0
    if (size < 0) {
2870
0
        ogs_error("ogs_nas_eps_decode_pdn_address() failed");
2871
0
        return size;
2872
0
    }
2873
2874
0
    decoded += size;
2875
2876
0
    while (pkbuf->len > 0) {
2877
0
        uint8_t *buffer = pkbuf->data;
2878
0
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
2879
2880
0
        size = sizeof(uint8_t);
2881
0
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
2882
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
2883
0
           return OGS_ERROR;
2884
0
        }
2885
0
        decoded += size;
2886
2887
0
        switch (type) {
2888
0
        case OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_TRANSACTION_IDENTIFIER_TYPE:
2889
0
            size = ogs_nas_eps_decode_transaction_identifier(&activate_default_eps_bearer_context_request->transaction_identifier, pkbuf);
2890
0
            if (size < 0) {
2891
0
               ogs_error("ogs_nas_eps_decode_transaction_identifier() failed");
2892
0
               return size;
2893
0
            }
2894
2895
0
            activate_default_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_TRANSACTION_IDENTIFIER_PRESENT;
2896
0
            decoded += size;
2897
0
            break;
2898
0
        case OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_QOS_TYPE:
2899
0
            size = ogs_nas_eps_decode_quality_of_service(&activate_default_eps_bearer_context_request->negotiated_qos, pkbuf);
2900
0
            if (size < 0) {
2901
0
               ogs_error("ogs_nas_eps_decode_quality_of_service() failed");
2902
0
               return size;
2903
0
            }
2904
2905
0
            activate_default_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_QOS_PRESENT;
2906
0
            decoded += size;
2907
0
            break;
2908
0
        case OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_LLC_SAPI_TYPE:
2909
0
            size = ogs_nas_eps_decode_llc_service_access_point_identifier(&activate_default_eps_bearer_context_request->negotiated_llc_sapi, pkbuf);
2910
0
            if (size < 0) {
2911
0
               ogs_error("ogs_nas_eps_decode_llc_service_access_point_identifier() failed");
2912
0
               return size;
2913
0
            }
2914
2915
0
            activate_default_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_LLC_SAPI_PRESENT;
2916
0
            decoded += size;
2917
0
            break;
2918
0
        case OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_RADIO_PRIORITY_TYPE:
2919
0
            decoded--;
2920
0
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
2921
0
            size = ogs_nas_eps_decode_radio_priority(&activate_default_eps_bearer_context_request->radio_priority, pkbuf);
2922
0
            if (size < 0) {
2923
0
               ogs_error("ogs_nas_eps_decode_radio_priority() failed");
2924
0
               return size;
2925
0
            }
2926
2927
0
            activate_default_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_RADIO_PRIORITY_PRESENT;
2928
0
            decoded += size;
2929
0
            break;
2930
0
        case OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_PACKET_FLOW_IDENTIFIER_TYPE:
2931
0
            size = ogs_nas_eps_decode_packet_flow_identifier(&activate_default_eps_bearer_context_request->packet_flow_identifier, pkbuf);
2932
0
            if (size < 0) {
2933
0
               ogs_error("ogs_nas_eps_decode_packet_flow_identifier() failed");
2934
0
               return size;
2935
0
            }
2936
2937
0
            activate_default_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_PACKET_FLOW_IDENTIFIER_PRESENT;
2938
0
            decoded += size;
2939
0
            break;
2940
0
        case OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_APN_AMBR_TYPE:
2941
0
            size = ogs_nas_eps_decode_apn_aggregate_maximum_bit_rate(&activate_default_eps_bearer_context_request->apn_ambr, pkbuf);
2942
0
            if (size < 0) {
2943
0
               ogs_error("ogs_nas_eps_decode_apn_aggregate_maximum_bit_rate() failed");
2944
0
               return size;
2945
0
            }
2946
2947
0
            activate_default_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_APN_AMBR_PRESENT;
2948
0
            decoded += size;
2949
0
            break;
2950
0
        case OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_ESM_CAUSE_TYPE:
2951
0
            size = ogs_nas_eps_decode_esm_cause(&activate_default_eps_bearer_context_request->esm_cause, pkbuf);
2952
0
            if (size < 0) {
2953
0
               ogs_error("ogs_nas_eps_decode_esm_cause() failed");
2954
0
               return size;
2955
0
            }
2956
2957
0
            activate_default_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_ESM_CAUSE_PRESENT;
2958
0
            decoded += size;
2959
0
            break;
2960
0
        case OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
2961
0
            size = ogs_nas_eps_decode_protocol_configuration_options(&activate_default_eps_bearer_context_request->protocol_configuration_options, pkbuf);
2962
0
            if (size < 0) {
2963
0
               ogs_error("ogs_nas_eps_decode_protocol_configuration_options() failed");
2964
0
               return size;
2965
0
            }
2966
2967
0
            activate_default_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
2968
0
            decoded += size;
2969
0
            break;
2970
0
        case OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_CONNECTIVITY_TYPE_TYPE:
2971
0
            decoded--;
2972
0
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
2973
0
            size = ogs_nas_eps_decode_connectivity_type(&activate_default_eps_bearer_context_request->connectivity_type, pkbuf);
2974
0
            if (size < 0) {
2975
0
               ogs_error("ogs_nas_eps_decode_connectivity_type() failed");
2976
0
               return size;
2977
0
            }
2978
2979
0
            activate_default_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_CONNECTIVITY_TYPE_PRESENT;
2980
0
            decoded += size;
2981
0
            break;
2982
0
        case OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_WLAN_OFFLOAD_INDICATION_TYPE:
2983
0
            decoded--;
2984
0
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
2985
0
            size = ogs_nas_eps_decode_wlan_offload_acceptability(&activate_default_eps_bearer_context_request->wlan_offload_indication, pkbuf);
2986
0
            if (size < 0) {
2987
0
               ogs_error("ogs_nas_eps_decode_wlan_offload_acceptability() failed");
2988
0
               return size;
2989
0
            }
2990
2991
0
            activate_default_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_WLAN_OFFLOAD_INDICATION_PRESENT;
2992
0
            decoded += size;
2993
0
            break;
2994
0
        case OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_NBIFOM_CONTAINER_TYPE:
2995
0
            size = ogs_nas_eps_decode_nbifom_container(&activate_default_eps_bearer_context_request->nbifom_container, pkbuf);
2996
0
            if (size < 0) {
2997
0
               ogs_error("ogs_nas_eps_decode_nbifom_container() failed");
2998
0
               return size;
2999
0
            }
3000
3001
0
            activate_default_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_NBIFOM_CONTAINER_PRESENT;
3002
0
            decoded += size;
3003
0
            break;
3004
0
        case OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_HEADER_COMPRESSION_CONFIGURATION_TYPE:
3005
0
            size = ogs_nas_eps_decode_header_compression_configuration(&activate_default_eps_bearer_context_request->header_compression_configuration, pkbuf);
3006
0
            if (size < 0) {
3007
0
               ogs_error("ogs_nas_eps_decode_header_compression_configuration() failed");
3008
0
               return size;
3009
0
            }
3010
3011
0
            activate_default_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_HEADER_COMPRESSION_CONFIGURATION_PRESENT;
3012
0
            decoded += size;
3013
0
            break;
3014
0
        case OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_CONTROL_PLANE_ONLY_INDICATION_TYPE:
3015
0
            decoded--;
3016
0
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
3017
0
            size = ogs_nas_eps_decode_control_plane_only_indication(&activate_default_eps_bearer_context_request->control_plane_only_indication, pkbuf);
3018
0
            if (size < 0) {
3019
0
               ogs_error("ogs_nas_eps_decode_control_plane_only_indication() failed");
3020
0
               return size;
3021
0
            }
3022
3023
0
            activate_default_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_CONTROL_PLANE_ONLY_INDICATION_PRESENT;
3024
0
            decoded += size;
3025
0
            break;
3026
0
        case OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
3027
0
            size = ogs_nas_eps_decode_extended_protocol_configuration_options(&activate_default_eps_bearer_context_request->extended_protocol_configuration_options, pkbuf);
3028
0
            if (size < 0) {
3029
0
               ogs_error("ogs_nas_eps_decode_extended_protocol_configuration_options() failed");
3030
0
               return size;
3031
0
            }
3032
3033
0
            activate_default_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
3034
0
            decoded += size;
3035
0
            break;
3036
0
        case OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_SERVING_PLMN_RATE_CONTROL_TYPE:
3037
0
            size = ogs_nas_eps_decode_serving_plmn_rate_control(&activate_default_eps_bearer_context_request->serving_plmn_rate_control, pkbuf);
3038
0
            if (size < 0) {
3039
0
               ogs_error("ogs_nas_eps_decode_serving_plmn_rate_control() failed");
3040
0
               return size;
3041
0
            }
3042
3043
0
            activate_default_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_SERVING_PLMN_RATE_CONTROL_PRESENT;
3044
0
            decoded += size;
3045
0
            break;
3046
0
        case OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_EXTENDED_APN_AMBR_TYPE:
3047
0
            size = ogs_nas_eps_decode_extended_apn_aggregate_maximum_bit_rate(&activate_default_eps_bearer_context_request->extended_apn_ambr, pkbuf);
3048
0
            if (size < 0) {
3049
0
               ogs_error("ogs_nas_eps_decode_extended_apn_aggregate_maximum_bit_rate() failed");
3050
0
               return size;
3051
0
            }
3052
3053
0
            activate_default_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REQUEST_EXTENDED_APN_AMBR_PRESENT;
3054
0
            decoded += size;
3055
0
            break;
3056
0
        default:
3057
0
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
3058
0
            break;
3059
0
        }
3060
0
    }
3061
3062
0
    return decoded;
3063
0
}
3064
3065
int ogs_nas_eps_decode_activate_default_eps_bearer_context_accept(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
3066
0
{
3067
0
    ogs_nas_eps_activate_default_eps_bearer_context_accept_t *activate_default_eps_bearer_context_accept = &message->esm.activate_default_eps_bearer_context_accept;
3068
0
    int decoded = 0;
3069
0
    int size = 0;
3070
3071
0
    ogs_trace("[NAS] Decode ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT\n");
3072
3073
0
    while (pkbuf->len > 0) {
3074
0
        uint8_t *buffer = pkbuf->data;
3075
0
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
3076
3077
0
        size = sizeof(uint8_t);
3078
0
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
3079
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
3080
0
           return OGS_ERROR;
3081
0
        }
3082
0
        decoded += size;
3083
3084
0
        switch (type) {
3085
0
        case OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
3086
0
            size = ogs_nas_eps_decode_protocol_configuration_options(&activate_default_eps_bearer_context_accept->protocol_configuration_options, pkbuf);
3087
0
            if (size < 0) {
3088
0
               ogs_error("ogs_nas_eps_decode_protocol_configuration_options() failed");
3089
0
               return size;
3090
0
            }
3091
3092
0
            activate_default_eps_bearer_context_accept->presencemask |= OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
3093
0
            decoded += size;
3094
0
            break;
3095
0
        case OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
3096
0
            size = ogs_nas_eps_decode_extended_protocol_configuration_options(&activate_default_eps_bearer_context_accept->extended_protocol_configuration_options, pkbuf);
3097
0
            if (size < 0) {
3098
0
               ogs_error("ogs_nas_eps_decode_extended_protocol_configuration_options() failed");
3099
0
               return size;
3100
0
            }
3101
3102
0
            activate_default_eps_bearer_context_accept->presencemask |= OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_ACCEPT_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
3103
0
            decoded += size;
3104
0
            break;
3105
0
        default:
3106
0
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
3107
0
            break;
3108
0
        }
3109
0
    }
3110
3111
0
    return decoded;
3112
0
}
3113
3114
int ogs_nas_eps_decode_activate_default_eps_bearer_context_reject(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
3115
0
{
3116
0
    ogs_nas_eps_activate_default_eps_bearer_context_reject_t *activate_default_eps_bearer_context_reject = &message->esm.activate_default_eps_bearer_context_reject;
3117
0
    int decoded = 0;
3118
0
    int size = 0;
3119
3120
0
    ogs_trace("[NAS] Decode ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT\n");
3121
3122
0
    size = ogs_nas_eps_decode_esm_cause(&activate_default_eps_bearer_context_reject->esm_cause, pkbuf);
3123
0
    if (size < 0) {
3124
0
        ogs_error("ogs_nas_eps_decode_esm_cause() failed");
3125
0
        return size;
3126
0
    }
3127
3128
0
    decoded += size;
3129
3130
0
    while (pkbuf->len > 0) {
3131
0
        uint8_t *buffer = pkbuf->data;
3132
0
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
3133
3134
0
        size = sizeof(uint8_t);
3135
0
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
3136
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
3137
0
           return OGS_ERROR;
3138
0
        }
3139
0
        decoded += size;
3140
3141
0
        switch (type) {
3142
0
        case OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
3143
0
            size = ogs_nas_eps_decode_protocol_configuration_options(&activate_default_eps_bearer_context_reject->protocol_configuration_options, pkbuf);
3144
0
            if (size < 0) {
3145
0
               ogs_error("ogs_nas_eps_decode_protocol_configuration_options() failed");
3146
0
               return size;
3147
0
            }
3148
3149
0
            activate_default_eps_bearer_context_reject->presencemask |= OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
3150
0
            decoded += size;
3151
0
            break;
3152
0
        case OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
3153
0
            size = ogs_nas_eps_decode_extended_protocol_configuration_options(&activate_default_eps_bearer_context_reject->extended_protocol_configuration_options, pkbuf);
3154
0
            if (size < 0) {
3155
0
               ogs_error("ogs_nas_eps_decode_extended_protocol_configuration_options() failed");
3156
0
               return size;
3157
0
            }
3158
3159
0
            activate_default_eps_bearer_context_reject->presencemask |= OGS_NAS_EPS_ACTIVATE_DEFAULT_EPS_BEARER_CONTEXT_REJECT_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
3160
0
            decoded += size;
3161
0
            break;
3162
0
        default:
3163
0
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
3164
0
            break;
3165
0
        }
3166
0
    }
3167
3168
0
    return decoded;
3169
0
}
3170
3171
int ogs_nas_eps_decode_activate_dedicated_eps_bearer_context_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
3172
0
{
3173
0
    ogs_nas_eps_activate_dedicated_eps_bearer_context_request_t *activate_dedicated_eps_bearer_context_request = &message->esm.activate_dedicated_eps_bearer_context_request;
3174
0
    int decoded = 0;
3175
0
    int size = 0;
3176
3177
0
    ogs_trace("[NAS] Decode ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST\n");
3178
3179
0
    size = ogs_nas_eps_decode_linked_eps_bearer_identity(&activate_dedicated_eps_bearer_context_request->linked_eps_bearer_identity, pkbuf);
3180
0
    if (size < 0) {
3181
0
        ogs_error("ogs_nas_eps_decode_linked_eps_bearer_identity() failed");
3182
0
        return size;
3183
0
    }
3184
3185
0
    decoded += size;
3186
3187
0
    size = ogs_nas_eps_decode_eps_quality_of_service(&activate_dedicated_eps_bearer_context_request->eps_qos, pkbuf);
3188
0
    if (size < 0) {
3189
0
        ogs_error("ogs_nas_eps_decode_eps_quality_of_service() failed");
3190
0
        return size;
3191
0
    }
3192
3193
0
    decoded += size;
3194
3195
0
    size = ogs_nas_eps_decode_traffic_flow_template(&activate_dedicated_eps_bearer_context_request->tft, pkbuf);
3196
0
    if (size < 0) {
3197
0
        ogs_error("ogs_nas_eps_decode_traffic_flow_template() failed");
3198
0
        return size;
3199
0
    }
3200
3201
0
    decoded += size;
3202
3203
0
    while (pkbuf->len > 0) {
3204
0
        uint8_t *buffer = pkbuf->data;
3205
0
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
3206
3207
0
        size = sizeof(uint8_t);
3208
0
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
3209
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
3210
0
           return OGS_ERROR;
3211
0
        }
3212
0
        decoded += size;
3213
3214
0
        switch (type) {
3215
0
        case OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_TRANSACTION_IDENTIFIER_TYPE:
3216
0
            size = ogs_nas_eps_decode_transaction_identifier(&activate_dedicated_eps_bearer_context_request->transaction_identifier, pkbuf);
3217
0
            if (size < 0) {
3218
0
               ogs_error("ogs_nas_eps_decode_transaction_identifier() failed");
3219
0
               return size;
3220
0
            }
3221
3222
0
            activate_dedicated_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_TRANSACTION_IDENTIFIER_PRESENT;
3223
0
            decoded += size;
3224
0
            break;
3225
0
        case OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_QOS_TYPE:
3226
0
            size = ogs_nas_eps_decode_quality_of_service(&activate_dedicated_eps_bearer_context_request->negotiated_qos, pkbuf);
3227
0
            if (size < 0) {
3228
0
               ogs_error("ogs_nas_eps_decode_quality_of_service() failed");
3229
0
               return size;
3230
0
            }
3231
3232
0
            activate_dedicated_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_QOS_PRESENT;
3233
0
            decoded += size;
3234
0
            break;
3235
0
        case OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_LLC_SAPI_TYPE:
3236
0
            size = ogs_nas_eps_decode_llc_service_access_point_identifier(&activate_dedicated_eps_bearer_context_request->negotiated_llc_sapi, pkbuf);
3237
0
            if (size < 0) {
3238
0
               ogs_error("ogs_nas_eps_decode_llc_service_access_point_identifier() failed");
3239
0
               return size;
3240
0
            }
3241
3242
0
            activate_dedicated_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_LLC_SAPI_PRESENT;
3243
0
            decoded += size;
3244
0
            break;
3245
0
        case OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_RADIO_PRIORITY_TYPE:
3246
0
            decoded--;
3247
0
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
3248
0
            size = ogs_nas_eps_decode_radio_priority(&activate_dedicated_eps_bearer_context_request->radio_priority, pkbuf);
3249
0
            if (size < 0) {
3250
0
               ogs_error("ogs_nas_eps_decode_radio_priority() failed");
3251
0
               return size;
3252
0
            }
3253
3254
0
            activate_dedicated_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_RADIO_PRIORITY_PRESENT;
3255
0
            decoded += size;
3256
0
            break;
3257
0
        case OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_PACKET_FLOW_IDENTIFIER_TYPE:
3258
0
            size = ogs_nas_eps_decode_packet_flow_identifier(&activate_dedicated_eps_bearer_context_request->packet_flow_identifier, pkbuf);
3259
0
            if (size < 0) {
3260
0
               ogs_error("ogs_nas_eps_decode_packet_flow_identifier() failed");
3261
0
               return size;
3262
0
            }
3263
3264
0
            activate_dedicated_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_PACKET_FLOW_IDENTIFIER_PRESENT;
3265
0
            decoded += size;
3266
0
            break;
3267
0
        case OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
3268
0
            size = ogs_nas_eps_decode_protocol_configuration_options(&activate_dedicated_eps_bearer_context_request->protocol_configuration_options, pkbuf);
3269
0
            if (size < 0) {
3270
0
               ogs_error("ogs_nas_eps_decode_protocol_configuration_options() failed");
3271
0
               return size;
3272
0
            }
3273
3274
0
            activate_dedicated_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
3275
0
            decoded += size;
3276
0
            break;
3277
0
        case OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_WLAN_OFFLOAD_INDICATION_TYPE:
3278
0
            decoded--;
3279
0
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
3280
0
            size = ogs_nas_eps_decode_wlan_offload_acceptability(&activate_dedicated_eps_bearer_context_request->wlan_offload_indication, pkbuf);
3281
0
            if (size < 0) {
3282
0
               ogs_error("ogs_nas_eps_decode_wlan_offload_acceptability() failed");
3283
0
               return size;
3284
0
            }
3285
3286
0
            activate_dedicated_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_WLAN_OFFLOAD_INDICATION_PRESENT;
3287
0
            decoded += size;
3288
0
            break;
3289
0
        case OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_NBIFOM_CONTAINER_TYPE:
3290
0
            size = ogs_nas_eps_decode_nbifom_container(&activate_dedicated_eps_bearer_context_request->nbifom_container, pkbuf);
3291
0
            if (size < 0) {
3292
0
               ogs_error("ogs_nas_eps_decode_nbifom_container() failed");
3293
0
               return size;
3294
0
            }
3295
3296
0
            activate_dedicated_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_NBIFOM_CONTAINER_PRESENT;
3297
0
            decoded += size;
3298
0
            break;
3299
0
        case OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
3300
0
            size = ogs_nas_eps_decode_extended_protocol_configuration_options(&activate_dedicated_eps_bearer_context_request->extended_protocol_configuration_options, pkbuf);
3301
0
            if (size < 0) {
3302
0
               ogs_error("ogs_nas_eps_decode_extended_protocol_configuration_options() failed");
3303
0
               return size;
3304
0
            }
3305
3306
0
            activate_dedicated_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
3307
0
            decoded += size;
3308
0
            break;
3309
0
        case OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_EXTENDED_EPS_QOS_TYPE:
3310
0
            size = ogs_nas_eps_decode_extended_quality_of_service(&activate_dedicated_eps_bearer_context_request->extended_eps_qos, pkbuf);
3311
0
            if (size < 0) {
3312
0
               ogs_error("ogs_nas_eps_decode_extended_quality_of_service() failed");
3313
0
               return size;
3314
0
            }
3315
3316
0
            activate_dedicated_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REQUEST_EXTENDED_EPS_QOS_PRESENT;
3317
0
            decoded += size;
3318
0
            break;
3319
0
        default:
3320
0
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
3321
0
            break;
3322
0
        }
3323
0
    }
3324
3325
0
    return decoded;
3326
0
}
3327
3328
int ogs_nas_eps_decode_activate_dedicated_eps_bearer_context_accept(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
3329
0
{
3330
0
    ogs_nas_eps_activate_dedicated_eps_bearer_context_accept_t *activate_dedicated_eps_bearer_context_accept = &message->esm.activate_dedicated_eps_bearer_context_accept;
3331
0
    int decoded = 0;
3332
0
    int size = 0;
3333
3334
0
    ogs_trace("[NAS] Decode ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT\n");
3335
3336
0
    while (pkbuf->len > 0) {
3337
0
        uint8_t *buffer = pkbuf->data;
3338
0
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
3339
3340
0
        size = sizeof(uint8_t);
3341
0
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
3342
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
3343
0
           return OGS_ERROR;
3344
0
        }
3345
0
        decoded += size;
3346
3347
0
        switch (type) {
3348
0
        case OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
3349
0
            size = ogs_nas_eps_decode_protocol_configuration_options(&activate_dedicated_eps_bearer_context_accept->protocol_configuration_options, pkbuf);
3350
0
            if (size < 0) {
3351
0
               ogs_error("ogs_nas_eps_decode_protocol_configuration_options() failed");
3352
0
               return size;
3353
0
            }
3354
3355
0
            activate_dedicated_eps_bearer_context_accept->presencemask |= OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
3356
0
            decoded += size;
3357
0
            break;
3358
0
        case OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT_NBIFOM_CONTAINER_TYPE:
3359
0
            size = ogs_nas_eps_decode_nbifom_container(&activate_dedicated_eps_bearer_context_accept->nbifom_container, pkbuf);
3360
0
            if (size < 0) {
3361
0
               ogs_error("ogs_nas_eps_decode_nbifom_container() failed");
3362
0
               return size;
3363
0
            }
3364
3365
0
            activate_dedicated_eps_bearer_context_accept->presencemask |= OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT_NBIFOM_CONTAINER_PRESENT;
3366
0
            decoded += size;
3367
0
            break;
3368
0
        case OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
3369
0
            size = ogs_nas_eps_decode_extended_protocol_configuration_options(&activate_dedicated_eps_bearer_context_accept->extended_protocol_configuration_options, pkbuf);
3370
0
            if (size < 0) {
3371
0
               ogs_error("ogs_nas_eps_decode_extended_protocol_configuration_options() failed");
3372
0
               return size;
3373
0
            }
3374
3375
0
            activate_dedicated_eps_bearer_context_accept->presencemask |= OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_ACCEPT_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
3376
0
            decoded += size;
3377
0
            break;
3378
0
        default:
3379
0
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
3380
0
            break;
3381
0
        }
3382
0
    }
3383
3384
0
    return decoded;
3385
0
}
3386
3387
int ogs_nas_eps_decode_activate_dedicated_eps_bearer_context_reject(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
3388
0
{
3389
0
    ogs_nas_eps_activate_dedicated_eps_bearer_context_reject_t *activate_dedicated_eps_bearer_context_reject = &message->esm.activate_dedicated_eps_bearer_context_reject;
3390
0
    int decoded = 0;
3391
0
    int size = 0;
3392
3393
0
    ogs_trace("[NAS] Decode ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT\n");
3394
3395
0
    size = ogs_nas_eps_decode_esm_cause(&activate_dedicated_eps_bearer_context_reject->esm_cause, pkbuf);
3396
0
    if (size < 0) {
3397
0
        ogs_error("ogs_nas_eps_decode_esm_cause() failed");
3398
0
        return size;
3399
0
    }
3400
3401
0
    decoded += size;
3402
3403
0
    while (pkbuf->len > 0) {
3404
0
        uint8_t *buffer = pkbuf->data;
3405
0
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
3406
3407
0
        size = sizeof(uint8_t);
3408
0
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
3409
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
3410
0
           return OGS_ERROR;
3411
0
        }
3412
0
        decoded += size;
3413
3414
0
        switch (type) {
3415
0
        case OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
3416
0
            size = ogs_nas_eps_decode_protocol_configuration_options(&activate_dedicated_eps_bearer_context_reject->protocol_configuration_options, pkbuf);
3417
0
            if (size < 0) {
3418
0
               ogs_error("ogs_nas_eps_decode_protocol_configuration_options() failed");
3419
0
               return size;
3420
0
            }
3421
3422
0
            activate_dedicated_eps_bearer_context_reject->presencemask |= OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
3423
0
            decoded += size;
3424
0
            break;
3425
0
        case OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT_NBIFOM_CONTAINER_TYPE:
3426
0
            size = ogs_nas_eps_decode_nbifom_container(&activate_dedicated_eps_bearer_context_reject->nbifom_container, pkbuf);
3427
0
            if (size < 0) {
3428
0
               ogs_error("ogs_nas_eps_decode_nbifom_container() failed");
3429
0
               return size;
3430
0
            }
3431
3432
0
            activate_dedicated_eps_bearer_context_reject->presencemask |= OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT_NBIFOM_CONTAINER_PRESENT;
3433
0
            decoded += size;
3434
0
            break;
3435
0
        case OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
3436
0
            size = ogs_nas_eps_decode_extended_protocol_configuration_options(&activate_dedicated_eps_bearer_context_reject->extended_protocol_configuration_options, pkbuf);
3437
0
            if (size < 0) {
3438
0
               ogs_error("ogs_nas_eps_decode_extended_protocol_configuration_options() failed");
3439
0
               return size;
3440
0
            }
3441
3442
0
            activate_dedicated_eps_bearer_context_reject->presencemask |= OGS_NAS_EPS_ACTIVATE_DEDICATED_EPS_BEARER_CONTEXT_REJECT_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
3443
0
            decoded += size;
3444
0
            break;
3445
0
        default:
3446
0
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
3447
0
            break;
3448
0
        }
3449
0
    }
3450
3451
0
    return decoded;
3452
0
}
3453
3454
int ogs_nas_eps_decode_modify_eps_bearer_context_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
3455
0
{
3456
0
    ogs_nas_eps_modify_eps_bearer_context_request_t *modify_eps_bearer_context_request = &message->esm.modify_eps_bearer_context_request;
3457
0
    int decoded = 0;
3458
0
    int size = 0;
3459
3460
0
    ogs_trace("[NAS] Decode MODIFY_EPS_BEARER_CONTEXT_REQUEST\n");
3461
3462
0
    while (pkbuf->len > 0) {
3463
0
        uint8_t *buffer = pkbuf->data;
3464
0
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
3465
3466
0
        size = sizeof(uint8_t);
3467
0
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
3468
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
3469
0
           return OGS_ERROR;
3470
0
        }
3471
0
        decoded += size;
3472
3473
0
        switch (type) {
3474
0
        case OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_NEW_EPS_QOS_TYPE:
3475
0
            size = ogs_nas_eps_decode_eps_quality_of_service(&modify_eps_bearer_context_request->new_eps_qos, pkbuf);
3476
0
            if (size < 0) {
3477
0
               ogs_error("ogs_nas_eps_decode_eps_quality_of_service() failed");
3478
0
               return size;
3479
0
            }
3480
3481
0
            modify_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_NEW_EPS_QOS_PRESENT;
3482
0
            decoded += size;
3483
0
            break;
3484
0
        case OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_TFT_TYPE:
3485
0
            size = ogs_nas_eps_decode_traffic_flow_template(&modify_eps_bearer_context_request->tft, pkbuf);
3486
0
            if (size < 0) {
3487
0
               ogs_error("ogs_nas_eps_decode_traffic_flow_template() failed");
3488
0
               return size;
3489
0
            }
3490
3491
0
            modify_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_TFT_PRESENT;
3492
0
            decoded += size;
3493
0
            break;
3494
0
        case OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_NEW_QOS_TYPE:
3495
0
            size = ogs_nas_eps_decode_quality_of_service(&modify_eps_bearer_context_request->new_qos, pkbuf);
3496
0
            if (size < 0) {
3497
0
               ogs_error("ogs_nas_eps_decode_quality_of_service() failed");
3498
0
               return size;
3499
0
            }
3500
3501
0
            modify_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_NEW_QOS_PRESENT;
3502
0
            decoded += size;
3503
0
            break;
3504
0
        case OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_LLC_SAPI_TYPE:
3505
0
            size = ogs_nas_eps_decode_llc_service_access_point_identifier(&modify_eps_bearer_context_request->negotiated_llc_sapi, pkbuf);
3506
0
            if (size < 0) {
3507
0
               ogs_error("ogs_nas_eps_decode_llc_service_access_point_identifier() failed");
3508
0
               return size;
3509
0
            }
3510
3511
0
            modify_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_NEGOTIATED_LLC_SAPI_PRESENT;
3512
0
            decoded += size;
3513
0
            break;
3514
0
        case OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_RADIO_PRIORITY_TYPE:
3515
0
            decoded--;
3516
0
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
3517
0
            size = ogs_nas_eps_decode_radio_priority(&modify_eps_bearer_context_request->radio_priority, pkbuf);
3518
0
            if (size < 0) {
3519
0
               ogs_error("ogs_nas_eps_decode_radio_priority() failed");
3520
0
               return size;
3521
0
            }
3522
3523
0
            modify_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_RADIO_PRIORITY_PRESENT;
3524
0
            decoded += size;
3525
0
            break;
3526
0
        case OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_PACKET_FLOW_IDENTIFIER_TYPE:
3527
0
            size = ogs_nas_eps_decode_packet_flow_identifier(&modify_eps_bearer_context_request->packet_flow_identifier, pkbuf);
3528
0
            if (size < 0) {
3529
0
               ogs_error("ogs_nas_eps_decode_packet_flow_identifier() failed");
3530
0
               return size;
3531
0
            }
3532
3533
0
            modify_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_PACKET_FLOW_IDENTIFIER_PRESENT;
3534
0
            decoded += size;
3535
0
            break;
3536
0
        case OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_APN_AMBR_TYPE:
3537
0
            size = ogs_nas_eps_decode_apn_aggregate_maximum_bit_rate(&modify_eps_bearer_context_request->apn_ambr, pkbuf);
3538
0
            if (size < 0) {
3539
0
               ogs_error("ogs_nas_eps_decode_apn_aggregate_maximum_bit_rate() failed");
3540
0
               return size;
3541
0
            }
3542
3543
0
            modify_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_APN_AMBR_PRESENT;
3544
0
            decoded += size;
3545
0
            break;
3546
0
        case OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
3547
0
            size = ogs_nas_eps_decode_protocol_configuration_options(&modify_eps_bearer_context_request->protocol_configuration_options, pkbuf);
3548
0
            if (size < 0) {
3549
0
               ogs_error("ogs_nas_eps_decode_protocol_configuration_options() failed");
3550
0
               return size;
3551
0
            }
3552
3553
0
            modify_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
3554
0
            decoded += size;
3555
0
            break;
3556
0
        case OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_WLAN_OFFLOAD_INDICATION_TYPE:
3557
0
            decoded--;
3558
0
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
3559
0
            size = ogs_nas_eps_decode_wlan_offload_acceptability(&modify_eps_bearer_context_request->wlan_offload_indication, pkbuf);
3560
0
            if (size < 0) {
3561
0
               ogs_error("ogs_nas_eps_decode_wlan_offload_acceptability() failed");
3562
0
               return size;
3563
0
            }
3564
3565
0
            modify_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_WLAN_OFFLOAD_INDICATION_PRESENT;
3566
0
            decoded += size;
3567
0
            break;
3568
0
        case OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_NBIFOM_CONTAINER_TYPE:
3569
0
            size = ogs_nas_eps_decode_nbifom_container(&modify_eps_bearer_context_request->nbifom_container, pkbuf);
3570
0
            if (size < 0) {
3571
0
               ogs_error("ogs_nas_eps_decode_nbifom_container() failed");
3572
0
               return size;
3573
0
            }
3574
3575
0
            modify_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_NBIFOM_CONTAINER_PRESENT;
3576
0
            decoded += size;
3577
0
            break;
3578
0
        case OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_HEADER_COMPRESSION_CONFIGURATION_TYPE:
3579
0
            size = ogs_nas_eps_decode_header_compression_configuration(&modify_eps_bearer_context_request->header_compression_configuration, pkbuf);
3580
0
            if (size < 0) {
3581
0
               ogs_error("ogs_nas_eps_decode_header_compression_configuration() failed");
3582
0
               return size;
3583
0
            }
3584
3585
0
            modify_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_HEADER_COMPRESSION_CONFIGURATION_PRESENT;
3586
0
            decoded += size;
3587
0
            break;
3588
0
        case OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
3589
0
            size = ogs_nas_eps_decode_extended_protocol_configuration_options(&modify_eps_bearer_context_request->extended_protocol_configuration_options, pkbuf);
3590
0
            if (size < 0) {
3591
0
               ogs_error("ogs_nas_eps_decode_extended_protocol_configuration_options() failed");
3592
0
               return size;
3593
0
            }
3594
3595
0
            modify_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
3596
0
            decoded += size;
3597
0
            break;
3598
0
        case OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_EXTENDED_APN_AMBR_TYPE:
3599
0
            size = ogs_nas_eps_decode_extended_apn_aggregate_maximum_bit_rate(&modify_eps_bearer_context_request->extended_apn_ambr, pkbuf);
3600
0
            if (size < 0) {
3601
0
               ogs_error("ogs_nas_eps_decode_extended_apn_aggregate_maximum_bit_rate() failed");
3602
0
               return size;
3603
0
            }
3604
3605
0
            modify_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_EXTENDED_APN_AMBR_PRESENT;
3606
0
            decoded += size;
3607
0
            break;
3608
0
        case OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_EXTENDED_EPS_QOS_TYPE:
3609
0
            size = ogs_nas_eps_decode_extended_quality_of_service(&modify_eps_bearer_context_request->extended_eps_qos, pkbuf);
3610
0
            if (size < 0) {
3611
0
               ogs_error("ogs_nas_eps_decode_extended_quality_of_service() failed");
3612
0
               return size;
3613
0
            }
3614
3615
0
            modify_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REQUEST_EXTENDED_EPS_QOS_PRESENT;
3616
0
            decoded += size;
3617
0
            break;
3618
0
        default:
3619
0
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
3620
0
            break;
3621
0
        }
3622
0
    }
3623
3624
0
    return decoded;
3625
0
}
3626
3627
int ogs_nas_eps_decode_modify_eps_bearer_context_accept(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
3628
0
{
3629
0
    ogs_nas_eps_modify_eps_bearer_context_accept_t *modify_eps_bearer_context_accept = &message->esm.modify_eps_bearer_context_accept;
3630
0
    int decoded = 0;
3631
0
    int size = 0;
3632
3633
0
    ogs_trace("[NAS] Decode MODIFY_EPS_BEARER_CONTEXT_ACCEPT\n");
3634
3635
0
    while (pkbuf->len > 0) {
3636
0
        uint8_t *buffer = pkbuf->data;
3637
0
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
3638
3639
0
        size = sizeof(uint8_t);
3640
0
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
3641
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
3642
0
           return OGS_ERROR;
3643
0
        }
3644
0
        decoded += size;
3645
3646
0
        switch (type) {
3647
0
        case OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
3648
0
            size = ogs_nas_eps_decode_protocol_configuration_options(&modify_eps_bearer_context_accept->protocol_configuration_options, pkbuf);
3649
0
            if (size < 0) {
3650
0
               ogs_error("ogs_nas_eps_decode_protocol_configuration_options() failed");
3651
0
               return size;
3652
0
            }
3653
3654
0
            modify_eps_bearer_context_accept->presencemask |= OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
3655
0
            decoded += size;
3656
0
            break;
3657
0
        case OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_ACCEPT_NBIFOM_CONTAINER_TYPE:
3658
0
            size = ogs_nas_eps_decode_nbifom_container(&modify_eps_bearer_context_accept->nbifom_container, pkbuf);
3659
0
            if (size < 0) {
3660
0
               ogs_error("ogs_nas_eps_decode_nbifom_container() failed");
3661
0
               return size;
3662
0
            }
3663
3664
0
            modify_eps_bearer_context_accept->presencemask |= OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_ACCEPT_NBIFOM_CONTAINER_PRESENT;
3665
0
            decoded += size;
3666
0
            break;
3667
0
        case OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_ACCEPT_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
3668
0
            size = ogs_nas_eps_decode_extended_protocol_configuration_options(&modify_eps_bearer_context_accept->extended_protocol_configuration_options, pkbuf);
3669
0
            if (size < 0) {
3670
0
               ogs_error("ogs_nas_eps_decode_extended_protocol_configuration_options() failed");
3671
0
               return size;
3672
0
            }
3673
3674
0
            modify_eps_bearer_context_accept->presencemask |= OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_ACCEPT_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
3675
0
            decoded += size;
3676
0
            break;
3677
0
        default:
3678
0
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
3679
0
            break;
3680
0
        }
3681
0
    }
3682
3683
0
    return decoded;
3684
0
}
3685
3686
int ogs_nas_eps_decode_modify_eps_bearer_context_reject(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
3687
0
{
3688
0
    ogs_nas_eps_modify_eps_bearer_context_reject_t *modify_eps_bearer_context_reject = &message->esm.modify_eps_bearer_context_reject;
3689
0
    int decoded = 0;
3690
0
    int size = 0;
3691
3692
0
    ogs_trace("[NAS] Decode MODIFY_EPS_BEARER_CONTEXT_REJECT\n");
3693
3694
0
    size = ogs_nas_eps_decode_esm_cause(&modify_eps_bearer_context_reject->esm_cause, pkbuf);
3695
0
    if (size < 0) {
3696
0
        ogs_error("ogs_nas_eps_decode_esm_cause() failed");
3697
0
        return size;
3698
0
    }
3699
3700
0
    decoded += size;
3701
3702
0
    while (pkbuf->len > 0) {
3703
0
        uint8_t *buffer = pkbuf->data;
3704
0
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
3705
3706
0
        size = sizeof(uint8_t);
3707
0
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
3708
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
3709
0
           return OGS_ERROR;
3710
0
        }
3711
0
        decoded += size;
3712
3713
0
        switch (type) {
3714
0
        case OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
3715
0
            size = ogs_nas_eps_decode_protocol_configuration_options(&modify_eps_bearer_context_reject->protocol_configuration_options, pkbuf);
3716
0
            if (size < 0) {
3717
0
               ogs_error("ogs_nas_eps_decode_protocol_configuration_options() failed");
3718
0
               return size;
3719
0
            }
3720
3721
0
            modify_eps_bearer_context_reject->presencemask |= OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
3722
0
            decoded += size;
3723
0
            break;
3724
0
        case OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REJECT_NBIFOM_CONTAINER_TYPE:
3725
0
            size = ogs_nas_eps_decode_nbifom_container(&modify_eps_bearer_context_reject->nbifom_container, pkbuf);
3726
0
            if (size < 0) {
3727
0
               ogs_error("ogs_nas_eps_decode_nbifom_container() failed");
3728
0
               return size;
3729
0
            }
3730
3731
0
            modify_eps_bearer_context_reject->presencemask |= OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REJECT_NBIFOM_CONTAINER_PRESENT;
3732
0
            decoded += size;
3733
0
            break;
3734
0
        case OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REJECT_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
3735
0
            size = ogs_nas_eps_decode_extended_protocol_configuration_options(&modify_eps_bearer_context_reject->extended_protocol_configuration_options, pkbuf);
3736
0
            if (size < 0) {
3737
0
               ogs_error("ogs_nas_eps_decode_extended_protocol_configuration_options() failed");
3738
0
               return size;
3739
0
            }
3740
3741
0
            modify_eps_bearer_context_reject->presencemask |= OGS_NAS_EPS_MODIFY_EPS_BEARER_CONTEXT_REJECT_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
3742
0
            decoded += size;
3743
0
            break;
3744
0
        default:
3745
0
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
3746
0
            break;
3747
0
        }
3748
0
    }
3749
3750
0
    return decoded;
3751
0
}
3752
3753
int ogs_nas_eps_decode_deactivate_eps_bearer_context_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
3754
0
{
3755
0
    ogs_nas_eps_deactivate_eps_bearer_context_request_t *deactivate_eps_bearer_context_request = &message->esm.deactivate_eps_bearer_context_request;
3756
0
    int decoded = 0;
3757
0
    int size = 0;
3758
3759
0
    ogs_trace("[NAS] Decode DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST\n");
3760
3761
0
    size = ogs_nas_eps_decode_esm_cause(&deactivate_eps_bearer_context_request->esm_cause, pkbuf);
3762
0
    if (size < 0) {
3763
0
        ogs_error("ogs_nas_eps_decode_esm_cause() failed");
3764
0
        return size;
3765
0
    }
3766
3767
0
    decoded += size;
3768
3769
0
    while (pkbuf->len > 0) {
3770
0
        uint8_t *buffer = pkbuf->data;
3771
0
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
3772
3773
0
        size = sizeof(uint8_t);
3774
0
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
3775
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
3776
0
           return OGS_ERROR;
3777
0
        }
3778
0
        decoded += size;
3779
3780
0
        switch (type) {
3781
0
        case OGS_NAS_EPS_DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
3782
0
            size = ogs_nas_eps_decode_protocol_configuration_options(&deactivate_eps_bearer_context_request->protocol_configuration_options, pkbuf);
3783
0
            if (size < 0) {
3784
0
               ogs_error("ogs_nas_eps_decode_protocol_configuration_options() failed");
3785
0
               return size;
3786
0
            }
3787
3788
0
            deactivate_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
3789
0
            decoded += size;
3790
0
            break;
3791
0
        case OGS_NAS_EPS_DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST_T3396_VALUE_TYPE:
3792
0
            size = ogs_nas_eps_decode_gprs_timer_3(&deactivate_eps_bearer_context_request->t3396_value, pkbuf);
3793
0
            if (size < 0) {
3794
0
               ogs_error("ogs_nas_eps_decode_gprs_timer_3() failed");
3795
0
               return size;
3796
0
            }
3797
3798
0
            deactivate_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST_T3396_VALUE_PRESENT;
3799
0
            decoded += size;
3800
0
            break;
3801
0
        case OGS_NAS_EPS_DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST_WLAN_OFFLOAD_INDICATION_TYPE:
3802
0
            decoded--;
3803
0
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
3804
0
            size = ogs_nas_eps_decode_wlan_offload_acceptability(&deactivate_eps_bearer_context_request->wlan_offload_indication, pkbuf);
3805
0
            if (size < 0) {
3806
0
               ogs_error("ogs_nas_eps_decode_wlan_offload_acceptability() failed");
3807
0
               return size;
3808
0
            }
3809
3810
0
            deactivate_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST_WLAN_OFFLOAD_INDICATION_PRESENT;
3811
0
            decoded += size;
3812
0
            break;
3813
0
        case OGS_NAS_EPS_DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST_NBIFOM_CONTAINER_TYPE:
3814
0
            size = ogs_nas_eps_decode_nbifom_container(&deactivate_eps_bearer_context_request->nbifom_container, pkbuf);
3815
0
            if (size < 0) {
3816
0
               ogs_error("ogs_nas_eps_decode_nbifom_container() failed");
3817
0
               return size;
3818
0
            }
3819
3820
0
            deactivate_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST_NBIFOM_CONTAINER_PRESENT;
3821
0
            decoded += size;
3822
0
            break;
3823
0
        case OGS_NAS_EPS_DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
3824
0
            size = ogs_nas_eps_decode_extended_protocol_configuration_options(&deactivate_eps_bearer_context_request->extended_protocol_configuration_options, pkbuf);
3825
0
            if (size < 0) {
3826
0
               ogs_error("ogs_nas_eps_decode_extended_protocol_configuration_options() failed");
3827
0
               return size;
3828
0
            }
3829
3830
0
            deactivate_eps_bearer_context_request->presencemask |= OGS_NAS_EPS_DEACTIVATE_EPS_BEARER_CONTEXT_REQUEST_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
3831
0
            decoded += size;
3832
0
            break;
3833
0
        default:
3834
0
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
3835
0
            break;
3836
0
        }
3837
0
    }
3838
3839
0
    return decoded;
3840
0
}
3841
3842
int ogs_nas_eps_decode_deactivate_eps_bearer_context_accept(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
3843
0
{
3844
0
    ogs_nas_eps_deactivate_eps_bearer_context_accept_t *deactivate_eps_bearer_context_accept = &message->esm.deactivate_eps_bearer_context_accept;
3845
0
    int decoded = 0;
3846
0
    int size = 0;
3847
3848
0
    ogs_trace("[NAS] Decode DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT\n");
3849
3850
0
    while (pkbuf->len > 0) {
3851
0
        uint8_t *buffer = pkbuf->data;
3852
0
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
3853
3854
0
        size = sizeof(uint8_t);
3855
0
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
3856
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
3857
0
           return OGS_ERROR;
3858
0
        }
3859
0
        decoded += size;
3860
3861
0
        switch (type) {
3862
0
        case OGS_NAS_EPS_DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
3863
0
            size = ogs_nas_eps_decode_protocol_configuration_options(&deactivate_eps_bearer_context_accept->protocol_configuration_options, pkbuf);
3864
0
            if (size < 0) {
3865
0
               ogs_error("ogs_nas_eps_decode_protocol_configuration_options() failed");
3866
0
               return size;
3867
0
            }
3868
3869
0
            deactivate_eps_bearer_context_accept->presencemask |= OGS_NAS_EPS_DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
3870
0
            decoded += size;
3871
0
            break;
3872
0
        case OGS_NAS_EPS_DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
3873
0
            size = ogs_nas_eps_decode_extended_protocol_configuration_options(&deactivate_eps_bearer_context_accept->extended_protocol_configuration_options, pkbuf);
3874
0
            if (size < 0) {
3875
0
               ogs_error("ogs_nas_eps_decode_extended_protocol_configuration_options() failed");
3876
0
               return size;
3877
0
            }
3878
3879
0
            deactivate_eps_bearer_context_accept->presencemask |= OGS_NAS_EPS_DEACTIVATE_EPS_BEARER_CONTEXT_ACCEPT_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
3880
0
            decoded += size;
3881
0
            break;
3882
0
        default:
3883
0
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
3884
0
            break;
3885
0
        }
3886
0
    }
3887
3888
0
    return decoded;
3889
0
}
3890
3891
int ogs_nas_eps_decode_pdn_connectivity_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
3892
0
{
3893
0
    ogs_nas_eps_pdn_connectivity_request_t *pdn_connectivity_request = &message->esm.pdn_connectivity_request;
3894
0
    int decoded = 0;
3895
0
    int size = 0;
3896
3897
0
    ogs_trace("[NAS] Decode PDN_CONNECTIVITY_REQUEST\n");
3898
3899
0
    size = ogs_nas_eps_decode_request_type(&pdn_connectivity_request->request_type, pkbuf);
3900
0
    if (size < 0) {
3901
0
        ogs_error("ogs_nas_eps_decode_request_type() failed");
3902
0
        return size;
3903
0
    }
3904
3905
0
    decoded += size;
3906
3907
0
    while (pkbuf->len > 0) {
3908
0
        uint8_t *buffer = pkbuf->data;
3909
0
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
3910
3911
0
        size = sizeof(uint8_t);
3912
0
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
3913
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
3914
0
           return OGS_ERROR;
3915
0
        }
3916
0
        decoded += size;
3917
3918
0
        switch (type) {
3919
0
        case OGS_NAS_EPS_PDN_CONNECTIVITY_REQUEST_ESM_INFORMATION_TRANSFER_FLAG_TYPE:
3920
0
            decoded--;
3921
0
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
3922
0
            size = ogs_nas_eps_decode_esm_information_transfer_flag(&pdn_connectivity_request->esm_information_transfer_flag, pkbuf);
3923
0
            if (size < 0) {
3924
0
               ogs_error("ogs_nas_eps_decode_esm_information_transfer_flag() failed");
3925
0
               return size;
3926
0
            }
3927
3928
0
            pdn_connectivity_request->presencemask |= OGS_NAS_EPS_PDN_CONNECTIVITY_REQUEST_ESM_INFORMATION_TRANSFER_FLAG_PRESENT;
3929
0
            decoded += size;
3930
0
            break;
3931
0
        case OGS_NAS_EPS_PDN_CONNECTIVITY_REQUEST_ACCESS_POINT_NAME_TYPE:
3932
0
            size = ogs_nas_eps_decode_access_point_name(&pdn_connectivity_request->access_point_name, pkbuf);
3933
0
            if (size < 0) {
3934
0
               ogs_error("ogs_nas_eps_decode_access_point_name() failed");
3935
0
               return size;
3936
0
            }
3937
3938
0
            pdn_connectivity_request->presencemask |= OGS_NAS_EPS_PDN_CONNECTIVITY_REQUEST_ACCESS_POINT_NAME_PRESENT;
3939
0
            decoded += size;
3940
0
            break;
3941
0
        case OGS_NAS_EPS_PDN_CONNECTIVITY_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
3942
0
            size = ogs_nas_eps_decode_protocol_configuration_options(&pdn_connectivity_request->protocol_configuration_options, pkbuf);
3943
0
            if (size < 0) {
3944
0
               ogs_error("ogs_nas_eps_decode_protocol_configuration_options() failed");
3945
0
               return size;
3946
0
            }
3947
3948
0
            pdn_connectivity_request->presencemask |= OGS_NAS_EPS_PDN_CONNECTIVITY_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
3949
0
            decoded += size;
3950
0
            break;
3951
0
        case OGS_NAS_EPS_PDN_CONNECTIVITY_REQUEST_DEVICE_PROPERTIES_TYPE:
3952
0
            decoded--;
3953
0
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
3954
0
            size = ogs_nas_eps_decode_device_properties(&pdn_connectivity_request->device_properties, pkbuf);
3955
0
            if (size < 0) {
3956
0
               ogs_error("ogs_nas_eps_decode_device_properties() failed");
3957
0
               return size;
3958
0
            }
3959
3960
0
            pdn_connectivity_request->presencemask |= OGS_NAS_EPS_PDN_CONNECTIVITY_REQUEST_DEVICE_PROPERTIES_PRESENT;
3961
0
            decoded += size;
3962
0
            break;
3963
0
        case OGS_NAS_EPS_PDN_CONNECTIVITY_REQUEST_NBIFOM_CONTAINER_TYPE:
3964
0
            size = ogs_nas_eps_decode_nbifom_container(&pdn_connectivity_request->nbifom_container, pkbuf);
3965
0
            if (size < 0) {
3966
0
               ogs_error("ogs_nas_eps_decode_nbifom_container() failed");
3967
0
               return size;
3968
0
            }
3969
3970
0
            pdn_connectivity_request->presencemask |= OGS_NAS_EPS_PDN_CONNECTIVITY_REQUEST_NBIFOM_CONTAINER_PRESENT;
3971
0
            decoded += size;
3972
0
            break;
3973
0
        case OGS_NAS_EPS_PDN_CONNECTIVITY_REQUEST_HEADER_COMPRESSION_CONFIGURATION_TYPE:
3974
0
            size = ogs_nas_eps_decode_header_compression_configuration(&pdn_connectivity_request->header_compression_configuration, pkbuf);
3975
0
            if (size < 0) {
3976
0
               ogs_error("ogs_nas_eps_decode_header_compression_configuration() failed");
3977
0
               return size;
3978
0
            }
3979
3980
0
            pdn_connectivity_request->presencemask |= OGS_NAS_EPS_PDN_CONNECTIVITY_REQUEST_HEADER_COMPRESSION_CONFIGURATION_PRESENT;
3981
0
            decoded += size;
3982
0
            break;
3983
0
        case OGS_NAS_EPS_PDN_CONNECTIVITY_REQUEST_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
3984
0
            size = ogs_nas_eps_decode_extended_protocol_configuration_options(&pdn_connectivity_request->extended_protocol_configuration_options, pkbuf);
3985
0
            if (size < 0) {
3986
0
               ogs_error("ogs_nas_eps_decode_extended_protocol_configuration_options() failed");
3987
0
               return size;
3988
0
            }
3989
3990
0
            pdn_connectivity_request->presencemask |= OGS_NAS_EPS_PDN_CONNECTIVITY_REQUEST_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
3991
0
            decoded += size;
3992
0
            break;
3993
0
        default:
3994
0
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
3995
0
            break;
3996
0
        }
3997
0
    }
3998
3999
0
    return decoded;
4000
0
}
4001
4002
int ogs_nas_eps_decode_pdn_connectivity_reject(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
4003
0
{
4004
0
    ogs_nas_eps_pdn_connectivity_reject_t *pdn_connectivity_reject = &message->esm.pdn_connectivity_reject;
4005
0
    int decoded = 0;
4006
0
    int size = 0;
4007
4008
0
    ogs_trace("[NAS] Decode PDN_CONNECTIVITY_REJECT\n");
4009
4010
0
    size = ogs_nas_eps_decode_esm_cause(&pdn_connectivity_reject->esm_cause, pkbuf);
4011
0
    if (size < 0) {
4012
0
        ogs_error("ogs_nas_eps_decode_esm_cause() failed");
4013
0
        return size;
4014
0
    }
4015
4016
0
    decoded += size;
4017
4018
0
    while (pkbuf->len > 0) {
4019
0
        uint8_t *buffer = pkbuf->data;
4020
0
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
4021
4022
0
        size = sizeof(uint8_t);
4023
0
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
4024
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
4025
0
           return OGS_ERROR;
4026
0
        }
4027
0
        decoded += size;
4028
4029
0
        switch (type) {
4030
0
        case OGS_NAS_EPS_PDN_CONNECTIVITY_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
4031
0
            size = ogs_nas_eps_decode_protocol_configuration_options(&pdn_connectivity_reject->protocol_configuration_options, pkbuf);
4032
0
            if (size < 0) {
4033
0
               ogs_error("ogs_nas_eps_decode_protocol_configuration_options() failed");
4034
0
               return size;
4035
0
            }
4036
4037
0
            pdn_connectivity_reject->presencemask |= OGS_NAS_EPS_PDN_CONNECTIVITY_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
4038
0
            decoded += size;
4039
0
            break;
4040
0
        case OGS_NAS_EPS_PDN_CONNECTIVITY_REJECT_BACK_OFF_TIMER_VALUE_TYPE:
4041
0
            size = ogs_nas_eps_decode_gprs_timer_3(&pdn_connectivity_reject->back_off_timer_value, pkbuf);
4042
0
            if (size < 0) {
4043
0
               ogs_error("ogs_nas_eps_decode_gprs_timer_3() failed");
4044
0
               return size;
4045
0
            }
4046
4047
0
            pdn_connectivity_reject->presencemask |= OGS_NAS_EPS_PDN_CONNECTIVITY_REJECT_BACK_OFF_TIMER_VALUE_PRESENT;
4048
0
            decoded += size;
4049
0
            break;
4050
0
        case OGS_NAS_EPS_PDN_CONNECTIVITY_REJECT_RE_ATTEMPT_INDICATOR_TYPE:
4051
0
            size = ogs_nas_eps_decode_re_attempt_indicator(&pdn_connectivity_reject->re_attempt_indicator, pkbuf);
4052
0
            if (size < 0) {
4053
0
               ogs_error("ogs_nas_eps_decode_re_attempt_indicator() failed");
4054
0
               return size;
4055
0
            }
4056
4057
0
            pdn_connectivity_reject->presencemask |= OGS_NAS_EPS_PDN_CONNECTIVITY_REJECT_RE_ATTEMPT_INDICATOR_PRESENT;
4058
0
            decoded += size;
4059
0
            break;
4060
0
        case OGS_NAS_EPS_PDN_CONNECTIVITY_REJECT_NBIFOM_CONTAINER_TYPE:
4061
0
            size = ogs_nas_eps_decode_nbifom_container(&pdn_connectivity_reject->nbifom_container, pkbuf);
4062
0
            if (size < 0) {
4063
0
               ogs_error("ogs_nas_eps_decode_nbifom_container() failed");
4064
0
               return size;
4065
0
            }
4066
4067
0
            pdn_connectivity_reject->presencemask |= OGS_NAS_EPS_PDN_CONNECTIVITY_REJECT_NBIFOM_CONTAINER_PRESENT;
4068
0
            decoded += size;
4069
0
            break;
4070
0
        case OGS_NAS_EPS_PDN_CONNECTIVITY_REJECT_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
4071
0
            size = ogs_nas_eps_decode_extended_protocol_configuration_options(&pdn_connectivity_reject->extended_protocol_configuration_options, pkbuf);
4072
0
            if (size < 0) {
4073
0
               ogs_error("ogs_nas_eps_decode_extended_protocol_configuration_options() failed");
4074
0
               return size;
4075
0
            }
4076
4077
0
            pdn_connectivity_reject->presencemask |= OGS_NAS_EPS_PDN_CONNECTIVITY_REJECT_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
4078
0
            decoded += size;
4079
0
            break;
4080
0
        default:
4081
0
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
4082
0
            break;
4083
0
        }
4084
0
    }
4085
4086
0
    return decoded;
4087
0
}
4088
4089
int ogs_nas_eps_decode_pdn_disconnect_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
4090
0
{
4091
0
    ogs_nas_eps_pdn_disconnect_request_t *pdn_disconnect_request = &message->esm.pdn_disconnect_request;
4092
0
    int decoded = 0;
4093
0
    int size = 0;
4094
4095
0
    ogs_trace("[NAS] Decode PDN_DISCONNECT_REQUEST\n");
4096
4097
0
    size = ogs_nas_eps_decode_linked_eps_bearer_identity(&pdn_disconnect_request->linked_eps_bearer_identity, pkbuf);
4098
0
    if (size < 0) {
4099
0
        ogs_error("ogs_nas_eps_decode_linked_eps_bearer_identity() failed");
4100
0
        return size;
4101
0
    }
4102
4103
0
    decoded += size;
4104
4105
0
    while (pkbuf->len > 0) {
4106
0
        uint8_t *buffer = pkbuf->data;
4107
0
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
4108
4109
0
        size = sizeof(uint8_t);
4110
0
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
4111
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
4112
0
           return OGS_ERROR;
4113
0
        }
4114
0
        decoded += size;
4115
4116
0
        switch (type) {
4117
0
        case OGS_NAS_EPS_PDN_DISCONNECT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
4118
0
            size = ogs_nas_eps_decode_protocol_configuration_options(&pdn_disconnect_request->protocol_configuration_options, pkbuf);
4119
0
            if (size < 0) {
4120
0
               ogs_error("ogs_nas_eps_decode_protocol_configuration_options() failed");
4121
0
               return size;
4122
0
            }
4123
4124
0
            pdn_disconnect_request->presencemask |= OGS_NAS_EPS_PDN_DISCONNECT_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
4125
0
            decoded += size;
4126
0
            break;
4127
0
        case OGS_NAS_EPS_PDN_DISCONNECT_REQUEST_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
4128
0
            size = ogs_nas_eps_decode_extended_protocol_configuration_options(&pdn_disconnect_request->extended_protocol_configuration_options, pkbuf);
4129
0
            if (size < 0) {
4130
0
               ogs_error("ogs_nas_eps_decode_extended_protocol_configuration_options() failed");
4131
0
               return size;
4132
0
            }
4133
4134
0
            pdn_disconnect_request->presencemask |= OGS_NAS_EPS_PDN_DISCONNECT_REQUEST_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
4135
0
            decoded += size;
4136
0
            break;
4137
0
        default:
4138
0
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
4139
0
            break;
4140
0
        }
4141
0
    }
4142
4143
0
    return decoded;
4144
0
}
4145
4146
int ogs_nas_eps_decode_pdn_disconnect_reject(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
4147
0
{
4148
0
    ogs_nas_eps_pdn_disconnect_reject_t *pdn_disconnect_reject = &message->esm.pdn_disconnect_reject;
4149
0
    int decoded = 0;
4150
0
    int size = 0;
4151
4152
0
    ogs_trace("[NAS] Decode PDN_DISCONNECT_REJECT\n");
4153
4154
0
    size = ogs_nas_eps_decode_esm_cause(&pdn_disconnect_reject->esm_cause, pkbuf);
4155
0
    if (size < 0) {
4156
0
        ogs_error("ogs_nas_eps_decode_esm_cause() failed");
4157
0
        return size;
4158
0
    }
4159
4160
0
    decoded += size;
4161
4162
0
    while (pkbuf->len > 0) {
4163
0
        uint8_t *buffer = pkbuf->data;
4164
0
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
4165
4166
0
        size = sizeof(uint8_t);
4167
0
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
4168
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
4169
0
           return OGS_ERROR;
4170
0
        }
4171
0
        decoded += size;
4172
4173
0
        switch (type) {
4174
0
        case OGS_NAS_EPS_PDN_DISCONNECT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
4175
0
            size = ogs_nas_eps_decode_protocol_configuration_options(&pdn_disconnect_reject->protocol_configuration_options, pkbuf);
4176
0
            if (size < 0) {
4177
0
               ogs_error("ogs_nas_eps_decode_protocol_configuration_options() failed");
4178
0
               return size;
4179
0
            }
4180
4181
0
            pdn_disconnect_reject->presencemask |= OGS_NAS_EPS_PDN_DISCONNECT_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
4182
0
            decoded += size;
4183
0
            break;
4184
0
        case OGS_NAS_EPS_PDN_DISCONNECT_REJECT_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
4185
0
            size = ogs_nas_eps_decode_extended_protocol_configuration_options(&pdn_disconnect_reject->extended_protocol_configuration_options, pkbuf);
4186
0
            if (size < 0) {
4187
0
               ogs_error("ogs_nas_eps_decode_extended_protocol_configuration_options() failed");
4188
0
               return size;
4189
0
            }
4190
4191
0
            pdn_disconnect_reject->presencemask |= OGS_NAS_EPS_PDN_DISCONNECT_REJECT_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
4192
0
            decoded += size;
4193
0
            break;
4194
0
        default:
4195
0
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
4196
0
            break;
4197
0
        }
4198
0
    }
4199
4200
0
    return decoded;
4201
0
}
4202
4203
int ogs_nas_eps_decode_bearer_resource_allocation_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
4204
0
{
4205
0
    ogs_nas_eps_bearer_resource_allocation_request_t *bearer_resource_allocation_request = &message->esm.bearer_resource_allocation_request;
4206
0
    int decoded = 0;
4207
0
    int size = 0;
4208
4209
0
    ogs_trace("[NAS] Decode BEARER_RESOURCE_ALLOCATION_REQUEST\n");
4210
4211
0
    size = ogs_nas_eps_decode_linked_eps_bearer_identity(&bearer_resource_allocation_request->linked_eps_bearer_identity, pkbuf);
4212
0
    if (size < 0) {
4213
0
        ogs_error("ogs_nas_eps_decode_linked_eps_bearer_identity() failed");
4214
0
        return size;
4215
0
    }
4216
4217
0
    decoded += size;
4218
4219
0
    size = ogs_nas_eps_decode_traffic_flow_aggregate_description(&bearer_resource_allocation_request->traffic_flow_aggregate, pkbuf);
4220
0
    if (size < 0) {
4221
0
        ogs_error("ogs_nas_eps_decode_traffic_flow_aggregate_description() failed");
4222
0
        return size;
4223
0
    }
4224
4225
0
    decoded += size;
4226
4227
0
    size = ogs_nas_eps_decode_eps_quality_of_service(&bearer_resource_allocation_request->required_traffic_flow_qos, pkbuf);
4228
0
    if (size < 0) {
4229
0
        ogs_error("ogs_nas_eps_decode_eps_quality_of_service() failed");
4230
0
        return size;
4231
0
    }
4232
4233
0
    decoded += size;
4234
4235
0
    while (pkbuf->len > 0) {
4236
0
        uint8_t *buffer = pkbuf->data;
4237
0
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
4238
4239
0
        size = sizeof(uint8_t);
4240
0
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
4241
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
4242
0
           return OGS_ERROR;
4243
0
        }
4244
0
        decoded += size;
4245
4246
0
        switch (type) {
4247
0
        case OGS_NAS_EPS_BEARER_RESOURCE_ALLOCATION_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
4248
0
            size = ogs_nas_eps_decode_protocol_configuration_options(&bearer_resource_allocation_request->protocol_configuration_options, pkbuf);
4249
0
            if (size < 0) {
4250
0
               ogs_error("ogs_nas_eps_decode_protocol_configuration_options() failed");
4251
0
               return size;
4252
0
            }
4253
4254
0
            bearer_resource_allocation_request->presencemask |= OGS_NAS_EPS_BEARER_RESOURCE_ALLOCATION_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
4255
0
            decoded += size;
4256
0
            break;
4257
0
        case OGS_NAS_EPS_BEARER_RESOURCE_ALLOCATION_REQUEST_DEVICE_PROPERTIES_TYPE:
4258
0
            decoded--;
4259
0
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
4260
0
            size = ogs_nas_eps_decode_device_properties(&bearer_resource_allocation_request->device_properties, pkbuf);
4261
0
            if (size < 0) {
4262
0
               ogs_error("ogs_nas_eps_decode_device_properties() failed");
4263
0
               return size;
4264
0
            }
4265
4266
0
            bearer_resource_allocation_request->presencemask |= OGS_NAS_EPS_BEARER_RESOURCE_ALLOCATION_REQUEST_DEVICE_PROPERTIES_PRESENT;
4267
0
            decoded += size;
4268
0
            break;
4269
0
        case OGS_NAS_EPS_BEARER_RESOURCE_ALLOCATION_REQUEST_NBIFOM_CONTAINER_TYPE:
4270
0
            size = ogs_nas_eps_decode_nbifom_container(&bearer_resource_allocation_request->nbifom_container, pkbuf);
4271
0
            if (size < 0) {
4272
0
               ogs_error("ogs_nas_eps_decode_nbifom_container() failed");
4273
0
               return size;
4274
0
            }
4275
4276
0
            bearer_resource_allocation_request->presencemask |= OGS_NAS_EPS_BEARER_RESOURCE_ALLOCATION_REQUEST_NBIFOM_CONTAINER_PRESENT;
4277
0
            decoded += size;
4278
0
            break;
4279
0
        case OGS_NAS_EPS_BEARER_RESOURCE_ALLOCATION_REQUEST_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
4280
0
            size = ogs_nas_eps_decode_extended_protocol_configuration_options(&bearer_resource_allocation_request->extended_protocol_configuration_options, pkbuf);
4281
0
            if (size < 0) {
4282
0
               ogs_error("ogs_nas_eps_decode_extended_protocol_configuration_options() failed");
4283
0
               return size;
4284
0
            }
4285
4286
0
            bearer_resource_allocation_request->presencemask |= OGS_NAS_EPS_BEARER_RESOURCE_ALLOCATION_REQUEST_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
4287
0
            decoded += size;
4288
0
            break;
4289
0
        case OGS_NAS_EPS_BEARER_RESOURCE_ALLOCATION_REQUEST_EXTENDED_EPS_QOS_TYPE:
4290
0
            size = ogs_nas_eps_decode_extended_quality_of_service(&bearer_resource_allocation_request->extended_eps_qos, pkbuf);
4291
0
            if (size < 0) {
4292
0
               ogs_error("ogs_nas_eps_decode_extended_quality_of_service() failed");
4293
0
               return size;
4294
0
            }
4295
4296
0
            bearer_resource_allocation_request->presencemask |= OGS_NAS_EPS_BEARER_RESOURCE_ALLOCATION_REQUEST_EXTENDED_EPS_QOS_PRESENT;
4297
0
            decoded += size;
4298
0
            break;
4299
0
        default:
4300
0
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
4301
0
            break;
4302
0
        }
4303
0
    }
4304
4305
0
    return decoded;
4306
0
}
4307
4308
int ogs_nas_eps_decode_bearer_resource_allocation_reject(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
4309
0
{
4310
0
    ogs_nas_eps_bearer_resource_allocation_reject_t *bearer_resource_allocation_reject = &message->esm.bearer_resource_allocation_reject;
4311
0
    int decoded = 0;
4312
0
    int size = 0;
4313
4314
0
    ogs_trace("[NAS] Decode BEARER_RESOURCE_ALLOCATION_REJECT\n");
4315
4316
0
    size = ogs_nas_eps_decode_esm_cause(&bearer_resource_allocation_reject->esm_cause, pkbuf);
4317
0
    if (size < 0) {
4318
0
        ogs_error("ogs_nas_eps_decode_esm_cause() failed");
4319
0
        return size;
4320
0
    }
4321
4322
0
    decoded += size;
4323
4324
0
    while (pkbuf->len > 0) {
4325
0
        uint8_t *buffer = pkbuf->data;
4326
0
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
4327
4328
0
        size = sizeof(uint8_t);
4329
0
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
4330
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
4331
0
           return OGS_ERROR;
4332
0
        }
4333
0
        decoded += size;
4334
4335
0
        switch (type) {
4336
0
        case OGS_NAS_EPS_BEARER_RESOURCE_ALLOCATION_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
4337
0
            size = ogs_nas_eps_decode_protocol_configuration_options(&bearer_resource_allocation_reject->protocol_configuration_options, pkbuf);
4338
0
            if (size < 0) {
4339
0
               ogs_error("ogs_nas_eps_decode_protocol_configuration_options() failed");
4340
0
               return size;
4341
0
            }
4342
4343
0
            bearer_resource_allocation_reject->presencemask |= OGS_NAS_EPS_BEARER_RESOURCE_ALLOCATION_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
4344
0
            decoded += size;
4345
0
            break;
4346
0
        case OGS_NAS_EPS_BEARER_RESOURCE_ALLOCATION_REJECT_BACK_OFF_TIMER_VALUE_TYPE:
4347
0
            size = ogs_nas_eps_decode_gprs_timer_3(&bearer_resource_allocation_reject->back_off_timer_value, pkbuf);
4348
0
            if (size < 0) {
4349
0
               ogs_error("ogs_nas_eps_decode_gprs_timer_3() failed");
4350
0
               return size;
4351
0
            }
4352
4353
0
            bearer_resource_allocation_reject->presencemask |= OGS_NAS_EPS_BEARER_RESOURCE_ALLOCATION_REJECT_BACK_OFF_TIMER_VALUE_PRESENT;
4354
0
            decoded += size;
4355
0
            break;
4356
0
        case OGS_NAS_EPS_BEARER_RESOURCE_ALLOCATION_REJECT_RE_ATTEMPT_INDICATOR_TYPE:
4357
0
            size = ogs_nas_eps_decode_re_attempt_indicator(&bearer_resource_allocation_reject->re_attempt_indicator, pkbuf);
4358
0
            if (size < 0) {
4359
0
               ogs_error("ogs_nas_eps_decode_re_attempt_indicator() failed");
4360
0
               return size;
4361
0
            }
4362
4363
0
            bearer_resource_allocation_reject->presencemask |= OGS_NAS_EPS_BEARER_RESOURCE_ALLOCATION_REJECT_RE_ATTEMPT_INDICATOR_PRESENT;
4364
0
            decoded += size;
4365
0
            break;
4366
0
        case OGS_NAS_EPS_BEARER_RESOURCE_ALLOCATION_REJECT_NBIFOM_CONTAINER_TYPE:
4367
0
            size = ogs_nas_eps_decode_nbifom_container(&bearer_resource_allocation_reject->nbifom_container, pkbuf);
4368
0
            if (size < 0) {
4369
0
               ogs_error("ogs_nas_eps_decode_nbifom_container() failed");
4370
0
               return size;
4371
0
            }
4372
4373
0
            bearer_resource_allocation_reject->presencemask |= OGS_NAS_EPS_BEARER_RESOURCE_ALLOCATION_REJECT_NBIFOM_CONTAINER_PRESENT;
4374
0
            decoded += size;
4375
0
            break;
4376
0
        case OGS_NAS_EPS_BEARER_RESOURCE_ALLOCATION_REJECT_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
4377
0
            size = ogs_nas_eps_decode_extended_protocol_configuration_options(&bearer_resource_allocation_reject->extended_protocol_configuration_options, pkbuf);
4378
0
            if (size < 0) {
4379
0
               ogs_error("ogs_nas_eps_decode_extended_protocol_configuration_options() failed");
4380
0
               return size;
4381
0
            }
4382
4383
0
            bearer_resource_allocation_reject->presencemask |= OGS_NAS_EPS_BEARER_RESOURCE_ALLOCATION_REJECT_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
4384
0
            decoded += size;
4385
0
            break;
4386
0
        default:
4387
0
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
4388
0
            break;
4389
0
        }
4390
0
    }
4391
4392
0
    return decoded;
4393
0
}
4394
4395
int ogs_nas_eps_decode_bearer_resource_modification_request(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
4396
0
{
4397
0
    ogs_nas_eps_bearer_resource_modification_request_t *bearer_resource_modification_request = &message->esm.bearer_resource_modification_request;
4398
0
    int decoded = 0;
4399
0
    int size = 0;
4400
4401
0
    ogs_trace("[NAS] Decode BEARER_RESOURCE_MODIFICATION_REQUEST\n");
4402
4403
0
    size = ogs_nas_eps_decode_linked_eps_bearer_identity(&bearer_resource_modification_request->eps_bearer_identity_for_packet_filter, pkbuf);
4404
0
    if (size < 0) {
4405
0
        ogs_error("ogs_nas_eps_decode_linked_eps_bearer_identity() failed");
4406
0
        return size;
4407
0
    }
4408
4409
0
    decoded += size;
4410
4411
0
    size = ogs_nas_eps_decode_traffic_flow_aggregate_description(&bearer_resource_modification_request->traffic_flow_aggregate, pkbuf);
4412
0
    if (size < 0) {
4413
0
        ogs_error("ogs_nas_eps_decode_traffic_flow_aggregate_description() failed");
4414
0
        return size;
4415
0
    }
4416
4417
0
    decoded += size;
4418
4419
0
    while (pkbuf->len > 0) {
4420
0
        uint8_t *buffer = pkbuf->data;
4421
0
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
4422
4423
0
        size = sizeof(uint8_t);
4424
0
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
4425
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
4426
0
           return OGS_ERROR;
4427
0
        }
4428
0
        decoded += size;
4429
4430
0
        switch (type) {
4431
0
        case OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REQUEST_REQUIRED_TRAFFIC_FLOW_QOS_TYPE:
4432
0
            size = ogs_nas_eps_decode_eps_quality_of_service(&bearer_resource_modification_request->required_traffic_flow_qos, pkbuf);
4433
0
            if (size < 0) {
4434
0
               ogs_error("ogs_nas_eps_decode_eps_quality_of_service() failed");
4435
0
               return size;
4436
0
            }
4437
4438
0
            bearer_resource_modification_request->presencemask |= OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REQUEST_REQUIRED_TRAFFIC_FLOW_QOS_PRESENT;
4439
0
            decoded += size;
4440
0
            break;
4441
0
        case OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REQUEST_ESM_CAUSE_TYPE:
4442
0
            size = ogs_nas_eps_decode_esm_cause(&bearer_resource_modification_request->esm_cause, pkbuf);
4443
0
            if (size < 0) {
4444
0
               ogs_error("ogs_nas_eps_decode_esm_cause() failed");
4445
0
               return size;
4446
0
            }
4447
4448
0
            bearer_resource_modification_request->presencemask |= OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REQUEST_ESM_CAUSE_PRESENT;
4449
0
            decoded += size;
4450
0
            break;
4451
0
        case OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
4452
0
            size = ogs_nas_eps_decode_protocol_configuration_options(&bearer_resource_modification_request->protocol_configuration_options, pkbuf);
4453
0
            if (size < 0) {
4454
0
               ogs_error("ogs_nas_eps_decode_protocol_configuration_options() failed");
4455
0
               return size;
4456
0
            }
4457
4458
0
            bearer_resource_modification_request->presencemask |= OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REQUEST_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
4459
0
            decoded += size;
4460
0
            break;
4461
0
        case OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REQUEST_DEVICE_PROPERTIES_TYPE:
4462
0
            decoded--;
4463
0
            ogs_assert(ogs_pkbuf_push(pkbuf, 1));
4464
0
            size = ogs_nas_eps_decode_device_properties(&bearer_resource_modification_request->device_properties, pkbuf);
4465
0
            if (size < 0) {
4466
0
               ogs_error("ogs_nas_eps_decode_device_properties() failed");
4467
0
               return size;
4468
0
            }
4469
4470
0
            bearer_resource_modification_request->presencemask |= OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REQUEST_DEVICE_PROPERTIES_PRESENT;
4471
0
            decoded += size;
4472
0
            break;
4473
0
        case OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REQUEST_NBIFOM_CONTAINER_TYPE:
4474
0
            size = ogs_nas_eps_decode_nbifom_container(&bearer_resource_modification_request->nbifom_container, pkbuf);
4475
0
            if (size < 0) {
4476
0
               ogs_error("ogs_nas_eps_decode_nbifom_container() failed");
4477
0
               return size;
4478
0
            }
4479
4480
0
            bearer_resource_modification_request->presencemask |= OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REQUEST_NBIFOM_CONTAINER_PRESENT;
4481
0
            decoded += size;
4482
0
            break;
4483
0
        case OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REQUEST_HEADER_COMPRESSION_CONFIGURATION_TYPE:
4484
0
            size = ogs_nas_eps_decode_header_compression_configuration(&bearer_resource_modification_request->header_compression_configuration, pkbuf);
4485
0
            if (size < 0) {
4486
0
               ogs_error("ogs_nas_eps_decode_header_compression_configuration() failed");
4487
0
               return size;
4488
0
            }
4489
4490
0
            bearer_resource_modification_request->presencemask |= OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REQUEST_HEADER_COMPRESSION_CONFIGURATION_PRESENT;
4491
0
            decoded += size;
4492
0
            break;
4493
0
        case OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REQUEST_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
4494
0
            size = ogs_nas_eps_decode_extended_protocol_configuration_options(&bearer_resource_modification_request->extended_protocol_configuration_options, pkbuf);
4495
0
            if (size < 0) {
4496
0
               ogs_error("ogs_nas_eps_decode_extended_protocol_configuration_options() failed");
4497
0
               return size;
4498
0
            }
4499
4500
0
            bearer_resource_modification_request->presencemask |= OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REQUEST_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
4501
0
            decoded += size;
4502
0
            break;
4503
0
        case OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REQUEST_EXTENDED_EPS_QOS_TYPE:
4504
0
            size = ogs_nas_eps_decode_extended_quality_of_service(&bearer_resource_modification_request->extended_eps_qos, pkbuf);
4505
0
            if (size < 0) {
4506
0
               ogs_error("ogs_nas_eps_decode_extended_quality_of_service() failed");
4507
0
               return size;
4508
0
            }
4509
4510
0
            bearer_resource_modification_request->presencemask |= OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REQUEST_EXTENDED_EPS_QOS_PRESENT;
4511
0
            decoded += size;
4512
0
            break;
4513
0
        default:
4514
0
            ogs_warn("Unknown type(0x%x) or not implemented\n", type);
4515
0
            break;
4516
0
        }
4517
0
    }
4518
4519
0
    return decoded;
4520
0
}
4521
4522
int ogs_nas_eps_decode_bearer_resource_modification_reject(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
4523
0
{
4524
0
    ogs_nas_eps_bearer_resource_modification_reject_t *bearer_resource_modification_reject = &message->esm.bearer_resource_modification_reject;
4525
0
    int decoded = 0;
4526
0
    int size = 0;
4527
4528
0
    ogs_trace("[NAS] Decode BEARER_RESOURCE_MODIFICATION_REJECT\n");
4529
4530
0
    size = ogs_nas_eps_decode_esm_cause(&bearer_resource_modification_reject->esm_cause, pkbuf);
4531
0
    if (size < 0) {
4532
0
        ogs_error("ogs_nas_eps_decode_esm_cause() failed");
4533
0
        return size;
4534
0
    }
4535
4536
0
    decoded += size;
4537
4538
0
    while (pkbuf->len > 0) {
4539
0
        uint8_t *buffer = pkbuf->data;
4540
0
        uint8_t type = (*buffer) >= 0x80 ? ((*buffer) & 0xf0) : (*buffer);
4541
4542
0
        size = sizeof(uint8_t);
4543
0
        if (ogs_pkbuf_pull(pkbuf, size) == NULL) {
4544
0
           ogs_error("ogs_pkbuf_pull() failed [size:%d]", (int)size);
4545
0
           return OGS_ERROR;
4546
0
        }
4547
0
        decoded += size;
4548
4549
0
        switch (type) {
4550
0
        case OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
4551
0
            size = ogs_nas_eps_decode_protocol_configuration_options(&bearer_resource_modification_reject->protocol_configuration_options, pkbuf);
4552
0
            if (size < 0) {
4553
0
               ogs_error("ogs_nas_eps_decode_protocol_configuration_options() failed");
4554
0
               return size;
4555
0
            }
4556
4557
0
            bearer_resource_modification_reject->presencemask |= OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REJECT_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
4558
0
            decoded += size;
4559
0
            break;
4560
0
        case OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REJECT_BACK_OFF_TIMER_VALUE_TYPE:
4561
0
            size = ogs_nas_eps_decode_gprs_timer_3(&bearer_resource_modification_reject->back_off_timer_value, pkbuf);
4562
0
            if (size < 0) {
4563
0
               ogs_error("ogs_nas_eps_decode_gprs_timer_3() failed");
4564
0
               return size;
4565
0
            }
4566
4567
0
            bearer_resource_modification_reject->presencemask |= OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REJECT_BACK_OFF_TIMER_VALUE_PRESENT;
4568
0
            decoded += size;
4569
0
            break;
4570
0
        case OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REJECT_RE_ATTEMPT_INDICATOR_TYPE:
4571
0
            size = ogs_nas_eps_decode_re_attempt_indicator(&bearer_resource_modification_reject->re_attempt_indicator, pkbuf);
4572
0
            if (size < 0) {
4573
0
               ogs_error("ogs_nas_eps_decode_re_attempt_indicator() failed");
4574
0
               return size;
4575
0
            }
4576
4577
0
            bearer_resource_modification_reject->presencemask |= OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REJECT_RE_ATTEMPT_INDICATOR_PRESENT;
4578
0
            decoded += size;
4579
0
            break;
4580
0
        case OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REJECT_NBIFOM_CONTAINER_TYPE:
4581
0
            size = ogs_nas_eps_decode_nbifom_container(&bearer_resource_modification_reject->nbifom_container, pkbuf);
4582
0
            if (size < 0) {
4583
0
               ogs_error("ogs_nas_eps_decode_nbifom_container() failed");
4584
0
               return size;
4585
0
            }
4586
4587
0
            bearer_resource_modification_reject->presencemask |= OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REJECT_NBIFOM_CONTAINER_PRESENT;
4588
0
            decoded += size;
4589
0
            break;
4590
0
        case OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REJECT_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_TYPE:
4591
0
            size = ogs_nas_eps_decode_extended_protocol_configuration_options(&bearer_resource_modification_reject->extended_protocol_configuration_options, pkbuf);
4592
0
            if (size < 0) {
4593
0
               ogs_error("ogs_nas_eps_decode_extended_protocol_configuration_options() failed");
4594
0
               return size;
4595
0
            }
4596
4597
0
            bearer_resource_modification_reject->presencemask |= OGS_NAS_EPS_BEARER_RESOURCE_MODIFICATION_REJECT_EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS_PRESENT;
4598