open5gs/lib/nas/nas-ies.c

2917 lines
93 KiB
C
Raw Normal View History

2017-03-21 04:50:40 +00:00
/*
2019-04-27 14:54:30 +00:00
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
2017-03-21 04:50:40 +00:00
*
2019-04-27 14:54:30 +00:00
* This file is part of Open5GS.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2017-03-21 04:50:40 +00:00
*/
/*******************************************************************************
2019-06-11 09:28:25 +00:00
* This file had been created by nas-message.py script v0.1.0
2017-03-21 04:50:40 +00:00
* Please do not modify this file but regenerate it via script.
2019-07-06 13:52:09 +00:00
* Created on: 2019-07-06 22:48:01.547045 by acetcom
2017-04-09 08:14:32 +00:00
* from 24301-d80.docx
2017-03-21 04:50:40 +00:00
******************************************************************************/
2019-06-11 09:28:25 +00:00
#include "nas-ies.h"
2017-02-15 11:16:50 +00:00
2019-04-27 14:54:30 +00:00
#undef OGS_LOG_DOMAIN
#define OGS_LOG_DOMAIN __base_nas_domain
int nas_encode_optional_type(ogs_pkbuf_t *pkbuf, uint8_t type)
2017-02-16 13:25:12 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(uint8_t);
2017-02-16 13:25:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &type, size);
2017-02-16 13:25:12 +00:00
return size;
}
2017-04-26 06:14:56 +00:00
/* 9.9.2.0 Additional information
* O TLV 3-n */
2019-04-27 14:54:30 +00:00
int nas_decode_additional_information(nas_additional_information_t *additional_information, ogs_pkbuf_t *pkbuf)
2017-04-26 06:14:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_additional_information_t *source = pkbuf->data;
2017-04-26 06:14:56 +00:00
additional_information->length = source->length;
size = additional_information->length + sizeof(additional_information->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(additional_information, pkbuf->data - size, size);
2017-04-26 06:14:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" ADDITIONAL_INFORMATION - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-26 06:14:56 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_additional_information(ogs_pkbuf_t *pkbuf, nas_additional_information_t *additional_information)
2017-04-26 06:14:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = additional_information->length + sizeof(additional_information->length);
2017-04-26 06:14:56 +00:00
nas_additional_information_t target;
memcpy(&target, additional_information, sizeof(nas_additional_information_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-26 06:14:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" ADDITIONAL_INFORMATION - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-26 06:14:56 +00:00
return size;
}
2017-02-16 04:59:44 +00:00
/* 9.9.2.0A Device properties
* O TV 1 */
2019-04-27 14:54:30 +00:00
int nas_decode_device_properties(nas_device_properties_t *device_properties, ogs_pkbuf_t *pkbuf)
2017-02-16 04:59:44 +00:00
{
2019-04-27 14:54:30 +00:00
memcpy(device_properties, pkbuf->data - 1, 1);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" DEVICE_PROPERTIES - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - 1, 1);
2017-08-01 02:34:15 +00:00
return 0;
2017-02-16 04:59:44 +00:00
}
2019-04-27 14:54:30 +00:00
int nas_encode_device_properties(ogs_pkbuf_t *pkbuf, nas_device_properties_t *device_properties)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_device_properties_t);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, device_properties, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" DEVICE_PROPERTIES - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2017-04-25 11:08:03 +00:00
/* 9.9.2.1 EPS bearer context status
* O TLV 4 */
2019-04-27 14:54:30 +00:00
int nas_decode_eps_bearer_context_status(nas_eps_bearer_context_status_t *eps_bearer_context_status, ogs_pkbuf_t *pkbuf)
2017-04-25 11:08:03 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_eps_bearer_context_status_t *source = pkbuf->data;
2017-04-25 11:08:03 +00:00
eps_bearer_context_status->length = source->length;
size = eps_bearer_context_status->length + sizeof(eps_bearer_context_status->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(eps_bearer_context_status, pkbuf->data - size, size);
2017-04-25 11:08:03 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" EPS_BEARER_CONTEXT_STATUS - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-25 11:08:03 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_eps_bearer_context_status(ogs_pkbuf_t *pkbuf, nas_eps_bearer_context_status_t *eps_bearer_context_status)
2017-04-25 11:08:03 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = eps_bearer_context_status->length + sizeof(eps_bearer_context_status->length);
2017-04-25 11:08:03 +00:00
nas_eps_bearer_context_status_t target;
memcpy(&target, eps_bearer_context_status, sizeof(nas_eps_bearer_context_status_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-25 11:08:03 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" EPS_BEARER_CONTEXT_STATUS - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-25 11:08:03 +00:00
return size;
}
2017-03-21 04:50:40 +00:00
/* 9.9.2.10 Supported Codec List
* O TLV 5-n */
2019-04-27 14:54:30 +00:00
int nas_decode_supported_codec_list(nas_supported_codec_list_t *supported_codec_list, ogs_pkbuf_t *pkbuf)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_supported_codec_list_t *source = pkbuf->data;
2017-03-21 04:50:40 +00:00
supported_codec_list->length = source->length;
size = supported_codec_list->length + sizeof(supported_codec_list->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(supported_codec_list, pkbuf->data - size, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" SUPPORTED_CODEC_LIST - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_supported_codec_list(ogs_pkbuf_t *pkbuf, nas_supported_codec_list_t *supported_codec_list)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = supported_codec_list->length + sizeof(supported_codec_list->length);
2017-03-21 04:50:40 +00:00
nas_supported_codec_list_t target;
memcpy(&target, supported_codec_list, sizeof(nas_supported_codec_list_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" SUPPORTED_CODEC_LIST - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2017-02-16 04:59:44 +00:00
/* 9.9.2.2 Location area identification
* O TV 6 */
2019-04-27 14:54:30 +00:00
int nas_decode_location_area_identification(nas_location_area_identification_t *location_area_identification, ogs_pkbuf_t *pkbuf)
2017-02-16 04:59:44 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_location_area_identification_t);
2017-02-16 04:59:44 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(location_area_identification, pkbuf->data - size, size);
2017-03-21 04:50:40 +00:00
location_area_identification->lac = ntohs(location_area_identification->lac);
2017-02-16 04:59:44 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" LOCATION_AREA_IDENTIFICATION - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 12:47:48 +00:00
return size;
2017-02-16 04:59:44 +00:00
}
2019-04-27 14:54:30 +00:00
int nas_encode_location_area_identification(ogs_pkbuf_t *pkbuf, nas_location_area_identification_t *location_area_identification)
2017-02-16 14:55:53 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_location_area_identification_t);
2017-02-16 14:55:53 +00:00
nas_location_area_identification_t target;
2017-03-21 04:50:40 +00:00
memcpy(&target, location_area_identification, size);
2017-02-16 14:55:53 +00:00
target.lac = htons(location_area_identification->lac);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-02-16 14:55:53 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" LOCATION_AREA_IDENTIFICATION - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 14:55:53 +00:00
return size;
}
/* 9.9.2.3 Mobile identity
* O TLV 7-10 */
2019-04-27 14:54:30 +00:00
int nas_decode_mobile_identity(nas_mobile_identity_t *mobile_identity, ogs_pkbuf_t *pkbuf)
2017-02-16 14:55:53 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_mobile_identity_t *source = pkbuf->data;
2017-02-16 14:55:53 +00:00
2017-03-21 04:50:40 +00:00
mobile_identity->length = source->length;
2017-02-16 14:55:53 +00:00
size = mobile_identity->length + sizeof(mobile_identity->length);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(mobile_identity, pkbuf->data - size, size);
2017-02-16 14:55:53 +00:00
2017-04-13 04:54:39 +00:00
if (mobile_identity->tmsi.type == NAS_MOBILE_IDENTITY_TMSI)
2017-02-16 14:55:53 +00:00
{
2017-03-21 04:50:40 +00:00
mobile_identity->tmsi.tmsi = ntohl(mobile_identity->tmsi.tmsi);
2017-02-16 14:55:53 +00:00
}
2019-04-27 14:54:30 +00:00
ogs_trace(" MOBILE_IDENTITY - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 14:55:53 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_mobile_identity(ogs_pkbuf_t *pkbuf, nas_mobile_identity_t *mobile_identity)
{
2019-04-27 14:54:30 +00:00
uint16_t size = mobile_identity->length + sizeof(mobile_identity->length);
2017-03-21 04:50:40 +00:00
nas_mobile_identity_t target;
2017-03-21 04:50:40 +00:00
memcpy(&target, mobile_identity, sizeof(nas_mobile_identity_t));
2017-04-13 04:54:39 +00:00
if (mobile_identity->tmsi.type == NAS_MOBILE_IDENTITY_TMSI)
2017-03-21 04:50:40 +00:00
{
target.tmsi.tmsi = htonl(mobile_identity->tmsi.tmsi);
target.tmsi.spare = 0xf;
}
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2019-04-27 14:54:30 +00:00
ogs_trace(" MOBILE_IDENTITY - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
return size;
}
2017-02-16 04:59:44 +00:00
/* 9.9.2.4 Mobile station classmark 2
* O TLV 5 */
2019-04-27 14:54:30 +00:00
int nas_decode_mobile_station_classmark_2(nas_mobile_station_classmark_2_t *mobile_station_classmark_2, ogs_pkbuf_t *pkbuf)
2017-02-16 04:59:44 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_mobile_station_classmark_2_t *source = pkbuf->data;
2017-02-16 04:59:44 +00:00
mobile_station_classmark_2->length = source->length;
2017-03-21 04:50:40 +00:00
size = mobile_station_classmark_2->length + sizeof(mobile_station_classmark_2->length);
2017-02-16 04:59:44 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(mobile_station_classmark_2, pkbuf->data - size, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" MOBILE_STATION_CLASSMARK_2 - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 12:47:48 +00:00
return size;
2017-02-16 04:59:44 +00:00
}
2019-04-27 14:54:30 +00:00
int nas_encode_mobile_station_classmark_2(ogs_pkbuf_t *pkbuf, nas_mobile_station_classmark_2_t *mobile_station_classmark_2)
2017-02-16 04:59:44 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = mobile_station_classmark_2->length + sizeof(mobile_station_classmark_2->length);
2017-03-21 04:50:40 +00:00
nas_mobile_station_classmark_2_t target;
2017-02-16 04:59:44 +00:00
2017-03-21 04:50:40 +00:00
memcpy(&target, mobile_station_classmark_2, sizeof(nas_mobile_station_classmark_2_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-02-16 04:59:44 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" MOBILE_STATION_CLASSMARK_2 - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 12:47:48 +00:00
return size;
2017-02-16 04:59:44 +00:00
}
2017-03-21 04:50:40 +00:00
/* 9.9.2.5 Mobile station classmark 3
* O TLV 2-34 */
2019-04-27 14:54:30 +00:00
int nas_decode_mobile_station_classmark_3(nas_mobile_station_classmark_3_t *mobile_station_classmark_3, ogs_pkbuf_t *pkbuf)
2017-02-16 14:55:53 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_mobile_station_classmark_3_t *source = pkbuf->data;
2017-02-16 14:55:53 +00:00
2017-03-21 04:50:40 +00:00
mobile_station_classmark_3->length = source->length;
size = mobile_station_classmark_3->length + sizeof(mobile_station_classmark_3->length);
2017-02-16 14:55:53 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(mobile_station_classmark_3, pkbuf->data - size, size);
2017-02-16 14:55:53 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" MOBILE_STATION_CLASSMARK_3 - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 14:55:53 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_mobile_station_classmark_3(ogs_pkbuf_t *pkbuf, nas_mobile_station_classmark_3_t *mobile_station_classmark_3)
2017-02-16 04:59:44 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = mobile_station_classmark_3->length + sizeof(mobile_station_classmark_3->length);
2017-03-21 04:50:40 +00:00
nas_mobile_station_classmark_3_t target;
2017-02-16 04:59:44 +00:00
2017-03-21 04:50:40 +00:00
memcpy(&target, mobile_station_classmark_3, sizeof(nas_mobile_station_classmark_3_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-02-16 04:59:44 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" MOBILE_STATION_CLASSMARK_3 - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 12:47:48 +00:00
return size;
2017-02-16 04:59:44 +00:00
}
2017-03-21 04:50:40 +00:00
/* 9.9.2.8 PLMN list
* O TLV 5-47 */
2019-04-27 14:54:30 +00:00
int nas_decode_plmn_list(nas_plmn_list_t *plmn_list, ogs_pkbuf_t *pkbuf)
2017-02-16 14:55:53 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_plmn_list_t *source = pkbuf->data;
2017-02-16 14:55:53 +00:00
2017-03-21 04:50:40 +00:00
plmn_list->length = source->length;
size = plmn_list->length + sizeof(plmn_list->length);
2017-02-16 14:55:53 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(plmn_list, pkbuf->data - size, size);
2017-02-16 14:55:53 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" PLMN_LIST - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 14:55:53 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_plmn_list(ogs_pkbuf_t *pkbuf, nas_plmn_list_t *plmn_list)
2017-03-06 03:25:50 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = plmn_list->length + sizeof(plmn_list->length);
2017-03-21 04:50:40 +00:00
nas_plmn_list_t target;
2017-03-06 03:25:50 +00:00
2017-03-21 04:50:40 +00:00
memcpy(&target, plmn_list, sizeof(nas_plmn_list_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-03-06 03:25:50 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" PLMN_LIST - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-06 03:25:50 +00:00
return size;
}
2017-03-21 04:50:40 +00:00
/* 9.9.3.0A Additional update result
* O TV 1 */
2019-04-27 14:54:30 +00:00
int nas_decode_additional_update_result(nas_additional_update_result_t *additional_update_result, ogs_pkbuf_t *pkbuf)
2017-03-06 03:25:50 +00:00
{
2019-04-27 14:54:30 +00:00
memcpy(additional_update_result, pkbuf->data - 1, 1);
2017-03-06 03:25:50 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" ADDITIONAL_UPDATE_RESULT - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - 1, 1);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return 0;
}
2017-03-06 03:25:50 +00:00
2019-04-27 14:54:30 +00:00
int nas_encode_additional_update_result(ogs_pkbuf_t *pkbuf, nas_additional_update_result_t *additional_update_result)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_additional_update_result_t);
2017-03-06 08:55:50 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, additional_update_result, size);
2017-03-06 03:25:50 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" ADDITIONAL_UPDATE_RESULT - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-06 03:25:50 +00:00
return size;
}
2017-03-21 04:50:40 +00:00
/* 9.9.3.0B Additional update type
* O TV 1 */
2019-04-27 14:54:30 +00:00
int nas_decode_additional_update_type(nas_additional_update_type_t *additional_update_type, ogs_pkbuf_t *pkbuf)
2017-03-06 03:25:50 +00:00
{
2019-04-27 14:54:30 +00:00
memcpy(additional_update_type, pkbuf->data - 1, 1);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" ADDITIONAL_UPDATE_TYPE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - 1, 1);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return 0;
}
2017-03-06 03:25:50 +00:00
2019-04-27 14:54:30 +00:00
int nas_encode_additional_update_type(ogs_pkbuf_t *pkbuf, nas_additional_update_type_t *additional_update_type)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_additional_update_type_t);
2017-03-06 03:25:50 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, additional_update_type, size);
2017-03-06 03:25:50 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" ADDITIONAL_UPDATE_TYPE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-06 03:25:50 +00:00
return size;
}
2017-03-21 04:50:40 +00:00
/* 9.9.3.1 Authentication failure parameter
* O TLV 16 */
2019-04-27 14:54:30 +00:00
int nas_decode_authentication_failure_parameter(nas_authentication_failure_parameter_t *authentication_failure_parameter, ogs_pkbuf_t *pkbuf)
2017-03-06 03:25:50 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_authentication_failure_parameter_t *source = pkbuf->data;
2017-03-06 03:25:50 +00:00
2017-03-21 04:50:40 +00:00
authentication_failure_parameter->length = source->length;
size = authentication_failure_parameter->length + sizeof(authentication_failure_parameter->length);
2017-03-06 03:25:50 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(authentication_failure_parameter, pkbuf->data - size, size);
2017-03-06 03:25:50 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" AUTHENTICATION_FAILURE_PARAMETER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-06 03:25:50 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_authentication_failure_parameter(ogs_pkbuf_t *pkbuf, nas_authentication_failure_parameter_t *authentication_failure_parameter)
2017-02-16 04:59:44 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = authentication_failure_parameter->length + sizeof(authentication_failure_parameter->length);
2017-03-21 04:50:40 +00:00
nas_authentication_failure_parameter_t target;
2017-02-16 04:59:44 +00:00
2017-03-21 04:50:40 +00:00
memcpy(&target, authentication_failure_parameter, sizeof(nas_authentication_failure_parameter_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-02-16 04:59:44 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" AUTHENTICATION_FAILURE_PARAMETER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 12:47:48 +00:00
return size;
2017-02-16 04:59:44 +00:00
}
2017-03-21 04:50:40 +00:00
/* 9.9.3.10 EPS attach result
* M V 1/2 */
2019-04-27 14:54:30 +00:00
int nas_decode_eps_attach_result(nas_eps_attach_result_t *eps_attach_result, ogs_pkbuf_t *pkbuf)
2017-02-16 14:55:53 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_eps_attach_result_t);
2017-02-16 14:55:53 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(eps_attach_result, pkbuf->data - size, size);
2017-02-16 14:55:53 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" EPS_ATTACH_RESULT - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 14:55:53 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_eps_attach_result(ogs_pkbuf_t *pkbuf, nas_eps_attach_result_t *eps_attach_result)
2017-03-06 03:25:50 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_eps_attach_result_t);
2017-03-21 04:50:40 +00:00
nas_eps_attach_result_t target;
2017-03-06 03:25:50 +00:00
2017-03-21 04:50:40 +00:00
memcpy(&target, eps_attach_result, size);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-03-06 03:25:50 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" EPS_ATTACH_RESULT - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-06 03:25:50 +00:00
return size;
}
2017-03-21 04:50:40 +00:00
/* 9.9.3.11 EPS attach type
2017-02-16 14:55:53 +00:00
* M V 1/2 */
2019-04-27 14:54:30 +00:00
int nas_decode_eps_attach_type(nas_eps_attach_type_t *eps_attach_type, ogs_pkbuf_t *pkbuf)
2017-02-16 14:55:53 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_eps_attach_type_t);
2017-02-16 14:55:53 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(eps_attach_type, pkbuf->data - size, size);
2017-02-16 14:55:53 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" EPS_ATTACH_TYPE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 14:55:53 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_eps_attach_type(ogs_pkbuf_t *pkbuf, nas_eps_attach_type_t *eps_attach_type)
2017-02-15 11:16:50 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_eps_attach_type_t);
2017-03-21 04:50:40 +00:00
nas_eps_attach_type_t target;
2017-02-15 11:16:50 +00:00
2017-03-21 04:50:40 +00:00
memcpy(&target, eps_attach_type, size);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-02-16 04:59:44 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" EPS_ATTACH_TYPE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 12:47:48 +00:00
return size;
2017-02-15 11:16:50 +00:00
}
2017-02-16 04:59:44 +00:00
/* 9.9.3.12 EPS mobile identity
* M LV 5-12 */
2019-04-27 14:54:30 +00:00
int nas_decode_eps_mobile_identity(nas_eps_mobile_identity_t *eps_mobile_identity, ogs_pkbuf_t *pkbuf)
2017-02-15 11:16:50 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_eps_mobile_identity_t *source = pkbuf->data;
2017-02-15 11:16:50 +00:00
2017-02-16 04:59:44 +00:00
eps_mobile_identity->length = source->length;
size = eps_mobile_identity->length + sizeof(eps_mobile_identity->length);
2017-02-15 11:16:50 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(eps_mobile_identity, pkbuf->data - size, size);
2017-03-21 04:50:40 +00:00
2017-04-13 04:54:39 +00:00
if (eps_mobile_identity->guti.type == NAS_EPS_MOBILE_IDENTITY_GUTI)
2017-02-15 11:16:50 +00:00
{
2017-04-13 04:54:39 +00:00
eps_mobile_identity->guti.mme_gid = ntohs(eps_mobile_identity->guti.mme_gid);
2017-03-21 04:50:40 +00:00
eps_mobile_identity->guti.m_tmsi = ntohl(eps_mobile_identity->guti.m_tmsi);
2017-02-15 11:16:50 +00:00
}
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" EPS_MOBILE_IDENTITY - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 12:47:48 +00:00
return size;
2017-02-16 04:59:44 +00:00
}
2019-04-27 14:54:30 +00:00
int nas_encode_eps_mobile_identity(ogs_pkbuf_t *pkbuf, nas_eps_mobile_identity_t *eps_mobile_identity)
2017-02-16 12:47:48 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = eps_mobile_identity->length + sizeof(eps_mobile_identity->length);
2017-02-16 12:47:48 +00:00
nas_eps_mobile_identity_t target;
memcpy(&target, eps_mobile_identity, sizeof(nas_eps_mobile_identity_t));
2017-04-13 04:54:39 +00:00
if (target.guti.type == NAS_EPS_MOBILE_IDENTITY_GUTI)
2017-02-16 12:47:48 +00:00
{
2017-03-05 09:09:34 +00:00
target.guti.spare = 0xf;
2017-04-13 04:54:39 +00:00
target.guti.mme_gid = htons(eps_mobile_identity->guti.mme_gid);
2017-03-21 04:50:40 +00:00
target.guti.m_tmsi = htonl(eps_mobile_identity->guti.m_tmsi);
2017-02-16 12:47:48 +00:00
}
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" EPS_MOBILE_IDENTITY - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 12:47:48 +00:00
return size;
}
2017-03-21 04:50:40 +00:00
/* 9.9.3.12A EPS network feature support
2017-02-16 14:55:53 +00:00
* O TLV 3 */
2019-04-27 14:54:30 +00:00
int nas_decode_eps_network_feature_support(nas_eps_network_feature_support_t *eps_network_feature_support, ogs_pkbuf_t *pkbuf)
2017-02-16 14:55:53 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_eps_network_feature_support_t *source = pkbuf->data;
2017-02-16 14:55:53 +00:00
2017-03-21 04:50:40 +00:00
eps_network_feature_support->length = source->length;
size = eps_network_feature_support->length + sizeof(eps_network_feature_support->length);
2017-02-16 14:55:53 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(eps_network_feature_support, pkbuf->data - size, size);
2017-02-16 14:55:53 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" EPS_NETWORK_FEATURE_SUPPORT - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_eps_network_feature_support(ogs_pkbuf_t *pkbuf, nas_eps_network_feature_support_t *eps_network_feature_support)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = eps_network_feature_support->length + sizeof(eps_network_feature_support->length);
2017-03-21 04:50:40 +00:00
nas_eps_network_feature_support_t target;
memcpy(&target, eps_network_feature_support, sizeof(nas_eps_network_feature_support_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-02-16 14:55:53 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" EPS_NETWORK_FEATURE_SUPPORT - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 14:55:53 +00:00
return size;
}
2017-02-16 12:47:48 +00:00
2017-04-25 11:08:03 +00:00
/* 9.9.3.13 EPS update result
* M V 1/2 */
2019-04-27 14:54:30 +00:00
int nas_decode_eps_update_result(nas_eps_update_result_t *eps_update_result, ogs_pkbuf_t *pkbuf)
2017-04-25 11:08:03 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_eps_update_result_t);
2017-04-25 11:08:03 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(eps_update_result, pkbuf->data - size, size);
2017-04-25 11:08:03 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" EPS_UPDATE_RESULT - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-25 11:08:03 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_eps_update_result(ogs_pkbuf_t *pkbuf, nas_eps_update_result_t *eps_update_result)
2017-04-25 11:08:03 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_eps_update_result_t);
2017-04-25 11:08:03 +00:00
nas_eps_update_result_t target;
memcpy(&target, eps_update_result, size);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-25 11:08:03 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" EPS_UPDATE_RESULT - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-25 11:08:03 +00:00
return size;
}
/* 9.9.3.14 EPS update type
* M V 1/2 */
2019-04-27 14:54:30 +00:00
int nas_decode_eps_update_type(nas_eps_update_type_t *eps_update_type, ogs_pkbuf_t *pkbuf)
2017-04-25 11:08:03 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_eps_update_type_t);
2017-04-25 11:08:03 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(eps_update_type, pkbuf->data - size, size);
2017-04-25 11:08:03 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" EPS_UPDATE_TYPE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-25 11:08:03 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_eps_update_type(ogs_pkbuf_t *pkbuf, nas_eps_update_type_t *eps_update_type)
2017-04-25 11:08:03 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_eps_update_type_t);
2017-04-25 11:08:03 +00:00
nas_eps_update_type_t target;
memcpy(&target, eps_update_type, size);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-25 11:08:03 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" EPS_UPDATE_TYPE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-25 11:08:03 +00:00
return size;
}
2017-02-16 04:59:44 +00:00
/* 9.9.3.15 ESM message container
* M LV-E 5-n */
2019-04-27 14:54:30 +00:00
int nas_decode_esm_message_container(nas_esm_message_container_t *esm_message_container, ogs_pkbuf_t *pkbuf)
2017-02-16 04:59:44 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_esm_message_container_t *source = pkbuf->data;
2017-02-16 04:59:44 +00:00
esm_message_container->length = ntohs(source->length);
size = esm_message_container->length + sizeof(esm_message_container->length);
2017-02-16 04:59:44 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
esm_message_container->buffer = pkbuf->data - size + sizeof(esm_message_container->length);
2017-02-16 04:59:44 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" ESM_MESSAGE_CONTAINER - ");
ogs_log_hexdump(OGS_LOG_TRACE, (void*)esm_message_container->buffer, esm_message_container->length);
2017-08-01 02:34:15 +00:00
2017-02-16 12:47:48 +00:00
return size;
2017-02-16 04:59:44 +00:00
}
2019-04-27 14:54:30 +00:00
int nas_encode_esm_message_container(ogs_pkbuf_t *pkbuf, nas_esm_message_container_t *esm_message_container)
2017-02-16 09:11:01 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
uint16_t target;
2017-02-16 09:11:01 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(esm_message_container);
ogs_assert(esm_message_container->buffer);
2017-02-16 09:11:01 +00:00
size = sizeof(esm_message_container->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
target = htons(esm_message_container->length);
2019-04-27 14:54:30 +00:00
memcpy(pkbuf->data - size, &target, size);
2017-02-16 09:11:01 +00:00
size = esm_message_container->length;
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, esm_message_container->buffer, size);
2017-02-16 09:11:01 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" ESM_MESSAGE_CONTAINER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
return esm_message_container->length + sizeof(esm_message_container->length);
2017-02-16 09:11:01 +00:00
}
2017-02-16 14:55:53 +00:00
/* 9.9.3.16 GPRS timer
2017-03-21 04:50:40 +00:00
* M V 1 */
2019-04-27 14:54:30 +00:00
int nas_decode_gprs_timer(nas_gprs_timer_t *gprs_timer, ogs_pkbuf_t *pkbuf)
2017-02-16 14:55:53 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_gprs_timer_t);
2017-02-16 14:55:53 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(gprs_timer, pkbuf->data - size, size);
2017-02-16 14:55:53 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" GPRS_TIMER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_gprs_timer(ogs_pkbuf_t *pkbuf, nas_gprs_timer_t *gprs_timer)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_gprs_timer_t);
2017-03-21 04:50:40 +00:00
nas_gprs_timer_t target;
memcpy(&target, gprs_timer, size);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-02-16 14:55:53 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" GPRS_TIMER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 14:55:53 +00:00
return size;
}
2017-02-16 04:59:44 +00:00
/* 9.9.3.16A GPRS timer 2
* O TLV 3 */
2019-04-27 14:54:30 +00:00
int nas_decode_gprs_timer_2(nas_gprs_timer_2_t *gprs_timer_2, ogs_pkbuf_t *pkbuf)
2017-02-16 04:59:44 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_gprs_timer_2_t *source = pkbuf->data;
2017-02-16 04:59:44 +00:00
2017-02-16 09:11:01 +00:00
gprs_timer_2->length = source->length;
size = gprs_timer_2->length + sizeof(gprs_timer_2->length);
2017-02-16 04:59:44 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(gprs_timer_2, pkbuf->data - size, size);
2017-02-16 04:59:44 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" GPRS_TIMER_2 - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 12:47:48 +00:00
return size;
2017-02-16 04:59:44 +00:00
}
2017-02-16 14:55:53 +00:00
2019-04-27 14:54:30 +00:00
int nas_encode_gprs_timer_2(ogs_pkbuf_t *pkbuf, nas_gprs_timer_2_t *gprs_timer_2)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = gprs_timer_2->length + sizeof(gprs_timer_2->length);
2017-03-21 04:50:40 +00:00
nas_gprs_timer_2_t target;
2017-02-16 14:55:53 +00:00
2017-03-21 04:50:40 +00:00
memcpy(&target, gprs_timer_2, sizeof(nas_gprs_timer_2_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-02-16 14:55:53 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" GPRS_TIMER_2 - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 14:55:53 +00:00
return size;
}
2017-02-16 04:59:44 +00:00
/* 9.9.3.16B GPRS timer 3
* O TLV 3 */
2019-04-27 14:54:30 +00:00
int nas_decode_gprs_timer_3(nas_gprs_timer_3_t *gprs_timer_3, ogs_pkbuf_t *pkbuf)
2017-02-16 04:59:44 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_gprs_timer_3_t *source = pkbuf->data;
2017-02-16 04:59:44 +00:00
2017-02-16 09:11:01 +00:00
gprs_timer_3->length = source->length;
size = gprs_timer_3->length + sizeof(gprs_timer_3->length);
2017-02-16 04:59:44 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(gprs_timer_3, pkbuf->data - size, size);
2017-02-16 04:59:44 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" GPRS_TIMER_3 - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 12:47:48 +00:00
return size;
2017-02-16 04:59:44 +00:00
}
2017-02-16 14:55:53 +00:00
2019-04-27 14:54:30 +00:00
int nas_encode_gprs_timer_3(ogs_pkbuf_t *pkbuf, nas_gprs_timer_3_t *gprs_timer_3)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = gprs_timer_3->length + sizeof(gprs_timer_3->length);
2017-03-21 04:50:40 +00:00
nas_gprs_timer_3_t target;
2017-02-16 14:55:53 +00:00
2017-03-21 04:50:40 +00:00
memcpy(&target, gprs_timer_3, sizeof(nas_gprs_timer_3_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-02-16 14:55:53 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" GPRS_TIMER_3 - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 14:55:53 +00:00
return size;
}
2017-02-16 04:59:44 +00:00
2017-03-21 06:02:16 +00:00
/* 9.9.3.17 Identity type 2
* M V 1/2 */
2019-04-27 14:54:30 +00:00
int nas_decode_identity_type_2(nas_identity_type_2_t *identity_type_2, ogs_pkbuf_t *pkbuf)
2017-03-21 06:02:16 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_identity_type_2_t);
2017-03-21 06:02:16 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(identity_type_2, pkbuf->data - size, size);
2017-03-21 06:02:16 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" IDENTITY_TYPE_2 - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 06:02:16 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_identity_type_2(ogs_pkbuf_t *pkbuf, nas_identity_type_2_t *identity_type_2)
2017-03-21 06:02:16 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_identity_type_2_t);
2017-03-21 06:02:16 +00:00
nas_identity_type_2_t target;
memcpy(&target, identity_type_2, size);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-03-21 06:02:16 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" IDENTITY_TYPE_2 - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 06:02:16 +00:00
return size;
}
/* 9.9.3.18 IMEISV request
* O TV 1 */
2019-04-27 14:54:30 +00:00
int nas_decode_imeisv_request(nas_imeisv_request_t *imeisv_request, ogs_pkbuf_t *pkbuf)
{
2019-04-27 14:54:30 +00:00
memcpy(imeisv_request, pkbuf->data - 1, 1);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" IMEISV_REQUEST - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - 1, 1);
2017-08-01 02:34:15 +00:00
return 0;
}
2019-04-27 14:54:30 +00:00
int nas_encode_imeisv_request(ogs_pkbuf_t *pkbuf, nas_imeisv_request_t *imeisv_request)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_imeisv_request_t);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, imeisv_request, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" IMEISV_REQUEST - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2017-04-26 00:33:26 +00:00
/* 9.9.3.19 KSI and sequence number
* M V 1 */
2019-04-27 14:54:30 +00:00
int nas_decode_ksi_and_sequence_number(nas_ksi_and_sequence_number_t *ksi_and_sequence_number, ogs_pkbuf_t *pkbuf)
2017-04-26 00:33:26 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_ksi_and_sequence_number_t);
2017-04-26 00:33:26 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(ksi_and_sequence_number, pkbuf->data - size, size);
2017-04-26 00:33:26 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" KSI_AND_SEQUENCE_NUMBER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-26 00:33:26 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_ksi_and_sequence_number(ogs_pkbuf_t *pkbuf, nas_ksi_and_sequence_number_t *ksi_and_sequence_number)
2017-04-26 00:33:26 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_ksi_and_sequence_number_t);
2017-04-26 00:33:26 +00:00
nas_ksi_and_sequence_number_t target;
memcpy(&target, ksi_and_sequence_number, size);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-26 00:33:26 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" KSI_AND_SEQUENCE_NUMBER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-26 00:33:26 +00:00
return size;
}
2017-03-21 04:50:40 +00:00
/* 9.9.3.2 Authentication parameter AUTN
* M LV 17 */
2019-04-27 14:54:30 +00:00
int nas_decode_authentication_parameter_autn(nas_authentication_parameter_autn_t *authentication_parameter_autn, ogs_pkbuf_t *pkbuf)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_authentication_parameter_autn_t *source = pkbuf->data;
2017-03-21 04:50:40 +00:00
authentication_parameter_autn->length = source->length;
size = authentication_parameter_autn->length + sizeof(authentication_parameter_autn->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(authentication_parameter_autn, pkbuf->data - size, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" AUTHENTICATION_PARAMETER_AUTN - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_authentication_parameter_autn(ogs_pkbuf_t *pkbuf, nas_authentication_parameter_autn_t *authentication_parameter_autn)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = authentication_parameter_autn->length + sizeof(authentication_parameter_autn->length);
2017-03-21 04:50:40 +00:00
nas_authentication_parameter_autn_t target;
memcpy(&target, authentication_parameter_autn, sizeof(nas_authentication_parameter_autn_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" AUTHENTICATION_PARAMETER_AUTN - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2017-02-16 04:59:44 +00:00
/* 9.9.3.20 MS network capability
* O TLV 4-10 */
2019-04-27 14:54:30 +00:00
int nas_decode_ms_network_capability(nas_ms_network_capability_t *ms_network_capability, ogs_pkbuf_t *pkbuf)
2017-02-16 04:59:44 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_ms_network_capability_t *source = pkbuf->data;
2017-02-16 04:59:44 +00:00
ms_network_capability->length = source->length;
size = ms_network_capability->length + sizeof(ms_network_capability->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(ms_network_capability, pkbuf->data - size, size);
2017-02-16 04:59:44 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" MS_NETWORK_CAPABILITY - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 12:47:48 +00:00
return size;
2017-02-16 04:59:44 +00:00
}
2019-04-27 14:54:30 +00:00
int nas_encode_ms_network_capability(ogs_pkbuf_t *pkbuf, nas_ms_network_capability_t *ms_network_capability)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = ms_network_capability->length + sizeof(ms_network_capability->length);
2017-03-21 04:50:40 +00:00
nas_ms_network_capability_t target;
memcpy(&target, ms_network_capability, sizeof(nas_ms_network_capability_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" MS_NETWORK_CAPABILITY - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
/* 9.9.3.20A MS network feature support
2017-02-16 04:59:44 +00:00
* O TV 1 */
2019-04-27 14:54:30 +00:00
int nas_decode_ms_network_feature_support(nas_ms_network_feature_support_t *ms_network_feature_support, ogs_pkbuf_t *pkbuf)
2017-02-16 04:59:44 +00:00
{
2019-04-27 14:54:30 +00:00
memcpy(ms_network_feature_support, pkbuf->data - 1, 1);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" MS_NETWORK_FEATURE_SUPPORT - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - 1, 1);
2017-08-01 02:34:15 +00:00
return 0;
2017-02-16 04:59:44 +00:00
}
2019-04-27 14:54:30 +00:00
int nas_encode_ms_network_feature_support(ogs_pkbuf_t *pkbuf, nas_ms_network_feature_support_t *ms_network_feature_support)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_ms_network_feature_support_t);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, ms_network_feature_support, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" MS_NETWORK_FEATURE_SUPPORT - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
/* 9.9.3.21 key set identifier
2017-04-25 11:08:03 +00:00
* O TV 1 */
2019-04-27 14:54:30 +00:00
int nas_decode_key_set_identifier(nas_key_set_identifier_t *key_set_identifier, ogs_pkbuf_t *pkbuf)
2017-03-06 03:25:50 +00:00
{
2019-04-27 14:54:30 +00:00
memcpy(key_set_identifier, pkbuf->data - 1, 1);
2017-03-06 03:25:50 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" KEY_SET_IDENTIFIER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - 1, 1);
2017-08-01 02:34:15 +00:00
2017-04-25 11:08:03 +00:00
return 0;
2017-03-21 04:50:40 +00:00
}
2017-03-06 03:25:50 +00:00
2019-04-27 14:54:30 +00:00
int nas_encode_key_set_identifier(ogs_pkbuf_t *pkbuf, nas_key_set_identifier_t *key_set_identifier)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_key_set_identifier_t);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, key_set_identifier, size);
2017-03-06 03:25:50 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" KEY_SET_IDENTIFIER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-06 03:25:50 +00:00
return size;
}
2017-04-26 06:14:56 +00:00
/* 9.9.3.22 message container
* M LV 3-252 */
2019-04-27 14:54:30 +00:00
int nas_decode_message_container(nas_message_container_t *message_container, ogs_pkbuf_t *pkbuf)
2017-04-26 06:14:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_message_container_t *source = pkbuf->data;
2017-04-26 06:14:56 +00:00
message_container->length = source->length;
size = message_container->length + sizeof(message_container->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(message_container, pkbuf->data - size, size);
2017-04-26 06:14:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" MESSAGE_CONTAINER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-26 06:14:56 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_message_container(ogs_pkbuf_t *pkbuf, nas_message_container_t *message_container)
2017-04-26 06:14:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = message_container->length + sizeof(message_container->length);
2017-04-26 06:14:56 +00:00
nas_message_container_t target;
memcpy(&target, message_container, sizeof(nas_message_container_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-26 06:14:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" MESSAGE_CONTAINER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-26 06:14:56 +00:00
return size;
}
2017-03-21 04:50:40 +00:00
/* 9.9.3.23 security algorithms
* M V 1 */
2019-04-27 14:54:30 +00:00
int nas_decode_security_algorithms(nas_security_algorithms_t *security_algorithms, ogs_pkbuf_t *pkbuf)
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_security_algorithms_t);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(security_algorithms, pkbuf->data - size, size);
2019-04-27 14:54:30 +00:00
ogs_trace(" SECURITY_ALGORITHMS - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_security_algorithms(ogs_pkbuf_t *pkbuf, nas_security_algorithms_t *security_algorithms)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_security_algorithms_t);
2017-03-21 04:50:40 +00:00
nas_security_algorithms_t target;
memcpy(&target, security_algorithms, size);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2019-04-27 14:54:30 +00:00
ogs_trace(" SECURITY_ALGORITHMS - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
return size;
}
2017-04-13 15:17:56 +00:00
/* 9.9.3.24 Network name
* O TLV 3-n */
2019-04-27 14:54:30 +00:00
int nas_decode_network_name(nas_network_name_t *network_name, ogs_pkbuf_t *pkbuf)
2017-04-13 15:17:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_network_name_t *source = pkbuf->data;
2017-04-13 15:17:56 +00:00
network_name->length = source->length;
size = network_name->length + sizeof(network_name->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(network_name, pkbuf->data - size, size);
2017-04-13 15:17:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" NETWORK_NAME - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-13 15:17:56 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_network_name(ogs_pkbuf_t *pkbuf, nas_network_name_t *network_name)
2017-04-13 15:17:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = network_name->length + sizeof(network_name->length);
2017-04-13 15:17:56 +00:00
nas_network_name_t target;
memcpy(&target, network_name, sizeof(nas_network_name_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-13 15:17:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" NETWORK_NAME - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-13 15:17:56 +00:00
return size;
}
2017-02-16 04:59:44 +00:00
/* 9.9.3.24A Network resource identifier container
* O TLV 4 */
2019-04-27 14:54:30 +00:00
int nas_decode_network_resource_identifier_container(nas_network_resource_identifier_container_t *network_resource_identifier_container, ogs_pkbuf_t *pkbuf)
2017-02-16 04:59:44 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_network_resource_identifier_container_t *source = pkbuf->data;
2017-02-16 04:59:44 +00:00
2017-02-16 09:11:01 +00:00
network_resource_identifier_container->length = source->length;
2017-03-21 04:50:40 +00:00
size = network_resource_identifier_container->length + sizeof(network_resource_identifier_container->length);
2017-02-16 04:59:44 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(network_resource_identifier_container, pkbuf->data - size, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" NETWORK_RESOURCE_IDENTIFIER_CONTAINER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_network_resource_identifier_container(ogs_pkbuf_t *pkbuf, nas_network_resource_identifier_container_t *network_resource_identifier_container)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = network_resource_identifier_container->length + sizeof(network_resource_identifier_container->length);
2017-03-21 04:50:40 +00:00
nas_network_resource_identifier_container_t target;
memcpy(&target, network_resource_identifier_container, sizeof(nas_network_resource_identifier_container_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" NETWORK_RESOURCE_IDENTIFIER_CONTAINER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 12:47:48 +00:00
return size;
2017-02-16 04:59:44 +00:00
}
/* 9.9.3.25 Nonce
* O TV 5 */
2019-04-27 14:54:30 +00:00
int nas_decode_nonce(nas_nonce_t *nonce, ogs_pkbuf_t *pkbuf)
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_nonce_t);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(nonce, pkbuf->data - size, size);
2017-03-21 04:50:40 +00:00
*nonce = ntohl(*nonce);
2019-04-27 14:54:30 +00:00
ogs_trace(" NONCE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_nonce(ogs_pkbuf_t *pkbuf, nas_nonce_t *nonce)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_nonce_t);
2017-03-21 04:50:40 +00:00
nas_nonce_t target;
2017-03-21 04:50:40 +00:00
memcpy(&target, nonce, size);
target = htonl(*nonce);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2019-04-27 14:54:30 +00:00
ogs_trace(" NONCE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
return size;
}
2017-04-26 06:14:56 +00:00
/* 9.9.3.25A Paging identity
* M V 1 */
2019-04-27 14:54:30 +00:00
int nas_decode_paging_identity(nas_paging_identity_t *paging_identity, ogs_pkbuf_t *pkbuf)
2017-04-26 06:14:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_paging_identity_t);
2017-04-26 06:14:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(paging_identity, pkbuf->data - size, size);
2017-04-26 06:14:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" PAGING_IDENTITY - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-26 06:14:56 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_paging_identity(ogs_pkbuf_t *pkbuf, nas_paging_identity_t *paging_identity)
2017-04-26 06:14:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_paging_identity_t);
2017-04-26 06:14:56 +00:00
nas_paging_identity_t target;
memcpy(&target, paging_identity, size);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-26 06:14:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" PAGING_IDENTITY - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-26 06:14:56 +00:00
return size;
}
2017-03-21 04:50:40 +00:00
/* 9.9.3.26 P-TMSI signature
2017-02-16 04:59:44 +00:00
* O TV 4 */
2019-04-27 14:54:30 +00:00
int nas_decode_p_tmsi_signature(nas_p_tmsi_signature_t *p_tmsi_signature, ogs_pkbuf_t *pkbuf)
2017-02-16 04:59:44 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 3;
2017-02-16 04:59:44 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(p_tmsi_signature, pkbuf->data - size, size);
2017-02-15 11:16:50 +00:00
2017-03-21 04:50:40 +00:00
*p_tmsi_signature = htonl(*p_tmsi_signature);
2019-04-27 14:54:30 +00:00
ogs_trace(" P_TMSI_SIGNATURE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_p_tmsi_signature(ogs_pkbuf_t *pkbuf, nas_p_tmsi_signature_t *p_tmsi_signature)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 3;
2017-03-21 04:50:40 +00:00
nas_p_tmsi_signature_t target;
memcpy(&target, p_tmsi_signature, size);
2017-02-16 09:11:01 +00:00
*p_tmsi_signature = ntohl(*p_tmsi_signature);
2017-02-16 04:59:44 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" P_TMSI_SIGNATURE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 12:47:48 +00:00
return size;
2017-02-16 04:59:44 +00:00
}
2017-03-21 04:50:40 +00:00
/* 9.9.3.26A Extended EMM cause
* O TV 1 */
2019-04-27 14:54:30 +00:00
int nas_decode_extended_emm_cause(nas_extended_emm_cause_t *extended_emm_cause, ogs_pkbuf_t *pkbuf)
{
2019-04-27 14:54:30 +00:00
memcpy(extended_emm_cause, pkbuf->data - 1, 1);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" EXTENDED_EMM_CAUSE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - 1, 1);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return 0;
}
2019-04-27 14:54:30 +00:00
int nas_encode_extended_emm_cause(ogs_pkbuf_t *pkbuf, nas_extended_emm_cause_t *extended_emm_cause)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_extended_emm_cause_t);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, extended_emm_cause, size);
2019-04-27 14:54:30 +00:00
ogs_trace(" EXTENDED_EMM_CAUSE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
return size;
}
2017-04-25 11:08:03 +00:00
/* 9.9.3.27 Service type
* M V 1/2 */
2019-04-27 14:54:30 +00:00
int nas_decode_service_type(nas_service_type_t *service_type, ogs_pkbuf_t *pkbuf)
2017-04-25 11:08:03 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_service_type_t);
2017-04-25 11:08:03 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(service_type, pkbuf->data - size, size);
2017-04-25 11:08:03 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" SERVICE_TYPE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-25 11:08:03 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_service_type(ogs_pkbuf_t *pkbuf, nas_service_type_t *service_type)
2017-04-25 11:08:03 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_service_type_t);
2017-04-25 11:08:03 +00:00
nas_service_type_t target;
memcpy(&target, service_type, size);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-25 11:08:03 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" SERVICE_TYPE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-25 11:08:03 +00:00
return size;
}
2017-04-26 00:33:26 +00:00
/* 9.9.3.28 Short MAC
* M V 2 */
2019-04-27 14:54:30 +00:00
int nas_decode_short_mac(nas_short_mac_t *short_mac, ogs_pkbuf_t *pkbuf)
2017-04-26 00:33:26 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_short_mac_t);
2017-04-26 00:33:26 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(short_mac, pkbuf->data - size, size);
2017-04-26 00:33:26 +00:00
*short_mac = ntohs(*short_mac);
2019-04-27 14:54:30 +00:00
ogs_trace(" SHORT_MAC - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-26 00:33:26 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_short_mac(ogs_pkbuf_t *pkbuf, nas_short_mac_t *short_mac)
2017-04-26 00:33:26 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_short_mac_t);
2017-04-26 00:33:26 +00:00
nas_short_mac_t target;
memcpy(&target, short_mac, size);
target = htons(*short_mac);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-26 00:33:26 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" SHORT_MAC - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-26 00:33:26 +00:00
return size;
}
2017-04-13 15:17:56 +00:00
/* 9.9.3.29 Time zone
* O TV 2 */
2019-04-27 14:54:30 +00:00
int nas_decode_time_zone(nas_time_zone_t *time_zone, ogs_pkbuf_t *pkbuf)
2017-04-13 15:17:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_time_zone_t);
2017-04-13 15:17:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(time_zone, pkbuf->data - size, size);
2017-04-13 15:17:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" TIME_ZONE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-13 15:17:56 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_time_zone(ogs_pkbuf_t *pkbuf, nas_time_zone_t *time_zone)
2017-04-13 15:17:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_time_zone_t);
2017-04-13 15:17:56 +00:00
nas_time_zone_t target;
memcpy(&target, time_zone, size);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-13 15:17:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" TIME_ZONE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-13 15:17:56 +00:00
return size;
}
2017-03-21 04:50:40 +00:00
/* 9.9.3.3 Authentication parameter RAND
* M V 16 */
2019-04-27 14:54:30 +00:00
int nas_decode_authentication_parameter_rand(nas_authentication_parameter_rand_t *authentication_parameter_rand, ogs_pkbuf_t *pkbuf)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_authentication_parameter_rand_t);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(authentication_parameter_rand, pkbuf->data - size, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" AUTHENTICATION_PARAMETER_RAND - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_authentication_parameter_rand(ogs_pkbuf_t *pkbuf, nas_authentication_parameter_rand_t *authentication_parameter_rand)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_authentication_parameter_rand_t);
2017-03-21 04:50:40 +00:00
nas_authentication_parameter_rand_t target;
memcpy(&target, authentication_parameter_rand, size);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" AUTHENTICATION_PARAMETER_RAND - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2017-04-13 15:17:56 +00:00
/* 9.9.3.30 Time zone and time
* O TV 8 */
2019-04-27 14:54:30 +00:00
int nas_decode_time_zone_and_time(nas_time_zone_and_time_t *time_zone_and_time, ogs_pkbuf_t *pkbuf)
2017-04-13 15:17:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_time_zone_and_time_t);
2017-04-13 15:17:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(time_zone_and_time, pkbuf->data - size, size);
2017-04-13 15:17:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" TIME_ZONE_AND_TIME - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-13 15:17:56 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_time_zone_and_time(ogs_pkbuf_t *pkbuf, nas_time_zone_and_time_t *time_zone_and_time)
2017-04-13 15:17:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_time_zone_and_time_t);
2017-04-13 15:17:56 +00:00
nas_time_zone_and_time_t target;
memcpy(&target, time_zone_and_time, size);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-13 15:17:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" TIME_ZONE_AND_TIME - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-13 15:17:56 +00:00
return size;
}
2017-02-16 04:59:44 +00:00
/* 9.9.3.31 TMSI status
* O TV 1 */
2019-04-27 14:54:30 +00:00
int nas_decode_tmsi_status(nas_tmsi_status_t *tmsi_status, ogs_pkbuf_t *pkbuf)
2017-02-16 04:59:44 +00:00
{
2019-04-27 14:54:30 +00:00
memcpy(tmsi_status, pkbuf->data - 1, 1);
2017-02-16 04:59:44 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" TMSI_STATUS - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - 1, 1);
2017-08-01 02:34:15 +00:00
return 0;
2017-02-16 04:59:44 +00:00
}
2019-04-27 14:54:30 +00:00
int nas_encode_tmsi_status(ogs_pkbuf_t *pkbuf, nas_tmsi_status_t *tmsi_status)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_tmsi_status_t);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, tmsi_status, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" TMSI_STATUS - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2017-02-16 04:59:44 +00:00
/* 9.9.3.32 Tracking area identity
* O TV 6 */
2019-04-27 14:54:30 +00:00
int nas_decode_tracking_area_identity(nas_tracking_area_identity_t *tracking_area_identity, ogs_pkbuf_t *pkbuf)
2017-02-16 04:59:44 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_tracking_area_identity_t);
2017-02-16 04:59:44 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(tracking_area_identity, pkbuf->data - size, size);
2017-03-21 04:50:40 +00:00
2017-02-16 09:11:01 +00:00
tracking_area_identity->tac = ntohs(tracking_area_identity->tac);
2017-02-16 04:59:44 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" TRACKING_AREA_IDENTITY - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 12:47:48 +00:00
return size;
2017-02-15 11:16:50 +00:00
}
2019-04-27 14:54:30 +00:00
int nas_encode_tracking_area_identity(ogs_pkbuf_t *pkbuf, nas_tracking_area_identity_t *tracking_area_identity)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_tracking_area_identity_t);
2017-03-21 04:50:40 +00:00
nas_tracking_area_identity_t target;
memcpy(&target, tracking_area_identity, size);
target.tac = htons(tracking_area_identity->tac);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" TRACKING_AREA_IDENTITY - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2017-02-16 14:55:53 +00:00
/* 9.9.3.33 Tracking area identity list
* M LV 7-97 */
2019-04-27 14:54:30 +00:00
int nas_decode_tracking_area_identity_list(nas_tracking_area_identity_list_t *tracking_area_identity_list, ogs_pkbuf_t *pkbuf)
2017-02-16 14:55:53 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_tracking_area_identity_list_t *source = pkbuf->data;
2017-02-16 14:55:53 +00:00
2017-03-21 04:50:40 +00:00
tracking_area_identity_list->length = source->length;
size = tracking_area_identity_list->length + sizeof(tracking_area_identity_list->length);
2017-02-16 14:55:53 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(tracking_area_identity_list, pkbuf->data - size, size);
2017-02-16 14:55:53 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" TRACKING_AREA_IDENTITY_LIST - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_tracking_area_identity_list(ogs_pkbuf_t *pkbuf, nas_tracking_area_identity_list_t *tracking_area_identity_list)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = tracking_area_identity_list->length + sizeof(tracking_area_identity_list->length);
2017-03-21 04:50:40 +00:00
nas_tracking_area_identity_list_t target;
memcpy(&target, tracking_area_identity_list, sizeof(nas_tracking_area_identity_list_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-02-16 14:55:53 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" TRACKING_AREA_IDENTITY_LIST - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 14:55:53 +00:00
return size;
}
2017-02-16 04:59:44 +00:00
/* 9.9.3.34 UE network capability
* M LV 3-14 */
2019-04-27 14:54:30 +00:00
int nas_decode_ue_network_capability(nas_ue_network_capability_t *ue_network_capability, ogs_pkbuf_t *pkbuf)
2017-02-15 11:16:50 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_ue_network_capability_t *source = pkbuf->data;
2017-02-16 04:59:44 +00:00
ue_network_capability->length = source->length;
2017-03-21 04:50:40 +00:00
size = ue_network_capability->length + sizeof(ue_network_capability->length);
2017-02-15 11:16:50 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(ue_network_capability, pkbuf->data - size, size);
2017-02-15 11:16:50 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" UE_NETWORK_CAPABILITY - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 12:47:48 +00:00
return size;
2017-02-15 11:16:50 +00:00
}
2017-02-16 04:59:44 +00:00
2019-04-27 14:54:30 +00:00
int nas_encode_ue_network_capability(ogs_pkbuf_t *pkbuf, nas_ue_network_capability_t *ue_network_capability)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = ue_network_capability->length + sizeof(ue_network_capability->length);
2017-03-21 04:50:40 +00:00
nas_ue_network_capability_t target;
memcpy(&target, ue_network_capability, sizeof(nas_ue_network_capability_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" UE_NETWORK_CAPABILITY - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2017-04-25 11:08:03 +00:00
/* 9.9.3.35 UE radio capability information update needed
* O TV 1 */
2019-04-27 14:54:30 +00:00
int nas_decode_ue_radio_capability_information_update_needed(nas_ue_radio_capability_information_update_needed_t *ue_radio_capability_information_update_needed, ogs_pkbuf_t *pkbuf)
2017-04-25 11:08:03 +00:00
{
2019-04-27 14:54:30 +00:00
memcpy(ue_radio_capability_information_update_needed, pkbuf->data - 1, 1);
2017-04-25 11:08:03 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" UE_RADIO_CAPABILITY_INFORMATION_UPDATE_NEEDED - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - 1, 1);
2017-08-01 02:34:15 +00:00
2017-04-25 11:08:03 +00:00
return 0;
}
2019-04-27 14:54:30 +00:00
int nas_encode_ue_radio_capability_information_update_needed(ogs_pkbuf_t *pkbuf, nas_ue_radio_capability_information_update_needed_t *ue_radio_capability_information_update_needed)
2017-04-25 11:08:03 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_ue_radio_capability_information_update_needed_t);
2017-04-25 11:08:03 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, ue_radio_capability_information_update_needed, size);
2017-04-25 11:08:03 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" UE_RADIO_CAPABILITY_INFORMATION_UPDATE_NEEDED - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-25 11:08:03 +00:00
return size;
}
/* 9.9.3.36 UE security capability
* M LV 3-6 */
2019-04-27 14:54:30 +00:00
int nas_decode_ue_security_capability(nas_ue_security_capability_t *ue_security_capability, ogs_pkbuf_t *pkbuf)
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_ue_security_capability_t *source = pkbuf->data;
2017-03-21 04:50:40 +00:00
ue_security_capability->length = source->length;
size = ue_security_capability->length + sizeof(ue_security_capability->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(ue_security_capability, pkbuf->data - size, size);
2017-03-06 08:55:50 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" UE_SECURITY_CAPABILITY - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_ue_security_capability(ogs_pkbuf_t *pkbuf, nas_ue_security_capability_t *ue_security_capability)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = ue_security_capability->length + sizeof(ue_security_capability->length);
2017-03-21 04:50:40 +00:00
nas_ue_security_capability_t target;
memcpy(&target, ue_security_capability, sizeof(nas_ue_security_capability_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2019-04-27 14:54:30 +00:00
ogs_trace(" UE_SECURITY_CAPABILITY - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
return size;
}
2017-03-21 04:50:40 +00:00
/* 9.9.3.37 Emergency number list
2017-03-20 08:07:27 +00:00
* O TLV 5-50 */
2019-04-27 14:54:30 +00:00
int nas_decode_emergency_number_list(nas_emergency_number_list_t *emergency_number_list, ogs_pkbuf_t *pkbuf)
2017-03-20 08:07:27 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_emergency_number_list_t *source = pkbuf->data;
2017-03-21 04:50:40 +00:00
emergency_number_list->length = source->length;
size = emergency_number_list->length + sizeof(emergency_number_list->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(emergency_number_list, pkbuf->data - size, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" EMERGENCY_NUMBER_LIST - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_emergency_number_list(ogs_pkbuf_t *pkbuf, nas_emergency_number_list_t *emergency_number_list)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = emergency_number_list->length + sizeof(emergency_number_list->length);
2017-03-20 08:07:27 +00:00
nas_emergency_number_list_t target;
memcpy(&target, emergency_number_list, sizeof(nas_emergency_number_list_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-03-20 08:07:27 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" EMERGENCY_NUMBER_LIST - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2017-03-20 08:07:27 +00:00
2017-04-26 06:14:56 +00:00
/* 9.9.3.38 CLI
* O TLV 3-14 */
2019-04-27 14:54:30 +00:00
int nas_decode_cli(nas_cli_t *cli, ogs_pkbuf_t *pkbuf)
2017-04-26 06:14:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_cli_t *source = pkbuf->data;
2017-04-26 06:14:56 +00:00
cli->length = source->length;
size = cli->length + sizeof(cli->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(cli, pkbuf->data - size, size);
2017-04-26 06:14:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" CLI - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-26 06:14:56 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_cli(ogs_pkbuf_t *pkbuf, nas_cli_t *cli)
2017-04-26 06:14:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = cli->length + sizeof(cli->length);
2017-04-26 06:14:56 +00:00
nas_cli_t target;
memcpy(&target, cli, sizeof(nas_cli_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-26 06:14:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" CLI - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-26 06:14:56 +00:00
return size;
}
/* 9.9.3.39 SS Code
* O TV 2 */
2019-04-27 14:54:30 +00:00
int nas_decode_ss_code(nas_ss_code_t *ss_code, ogs_pkbuf_t *pkbuf)
2017-04-26 06:14:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_ss_code_t);
2017-04-26 06:14:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(ss_code, pkbuf->data - size, size);
2017-04-26 06:14:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" SS_CODE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-26 06:14:56 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_ss_code(ogs_pkbuf_t *pkbuf, nas_ss_code_t *ss_code)
2017-04-26 06:14:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_ss_code_t);
2017-04-26 06:14:56 +00:00
nas_ss_code_t target;
memcpy(&target, ss_code, size);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-26 06:14:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" SS_CODE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-26 06:14:56 +00:00
return size;
}
2017-03-21 04:50:40 +00:00
/* 9.9.3.4 Authentication response parameter
* M LV 5-17 */
2019-04-27 14:54:30 +00:00
int nas_decode_authentication_response_parameter(nas_authentication_response_parameter_t *authentication_response_parameter, ogs_pkbuf_t *pkbuf)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_authentication_response_parameter_t *source = pkbuf->data;
2017-03-21 04:50:40 +00:00
authentication_response_parameter->length = source->length;
size = authentication_response_parameter->length + sizeof(authentication_response_parameter->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(authentication_response_parameter, pkbuf->data - size, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" AUTHENTICATION_RESPONSE_PARAMETER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_authentication_response_parameter(ogs_pkbuf_t *pkbuf, nas_authentication_response_parameter_t *authentication_response_parameter)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = authentication_response_parameter->length + sizeof(authentication_response_parameter->length);
2017-03-21 04:50:40 +00:00
nas_authentication_response_parameter_t target;
memcpy(&target, authentication_response_parameter, sizeof(nas_authentication_response_parameter_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-03-20 08:07:27 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" AUTHENTICATION_RESPONSE_PARAMETER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-20 08:07:27 +00:00
return size;
}
2017-04-26 06:14:56 +00:00
/* 9.9.3.40 LCS indicator
* O TV 2 */
2019-04-27 14:54:30 +00:00
int nas_decode_lcs_indicator(nas_lcs_indicator_t *lcs_indicator, ogs_pkbuf_t *pkbuf)
2017-04-26 06:14:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_lcs_indicator_t);
2017-04-26 06:14:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(lcs_indicator, pkbuf->data - size, size);
2017-04-26 06:14:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" LCS_INDICATOR - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-26 06:14:56 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_lcs_indicator(ogs_pkbuf_t *pkbuf, nas_lcs_indicator_t *lcs_indicator)
2017-04-26 06:14:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_lcs_indicator_t);
2017-04-26 06:14:56 +00:00
nas_lcs_indicator_t target;
memcpy(&target, lcs_indicator, size);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-26 06:14:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" LCS_INDICATOR - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-26 06:14:56 +00:00
return size;
}
/* 9.9.3.41 LCS client identity
* O TLV 3-257 */
2019-04-27 14:54:30 +00:00
int nas_decode_lcs_client_identity(nas_lcs_client_identity_t *lcs_client_identity, ogs_pkbuf_t *pkbuf)
2017-04-26 06:14:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_lcs_client_identity_t *source = pkbuf->data;
2017-04-26 06:14:56 +00:00
lcs_client_identity->length = source->length;
size = lcs_client_identity->length + sizeof(lcs_client_identity->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(lcs_client_identity, pkbuf->data - size, size);
2017-04-26 06:14:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" LCS_CLIENT_IDENTITY - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-26 06:14:56 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_lcs_client_identity(ogs_pkbuf_t *pkbuf, nas_lcs_client_identity_t *lcs_client_identity)
2017-04-26 06:14:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = lcs_client_identity->length + sizeof(lcs_client_identity->length);
2017-04-26 06:14:56 +00:00
nas_lcs_client_identity_t target;
memcpy(&target, lcs_client_identity, sizeof(nas_lcs_client_identity_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-26 06:14:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" LCS_CLIENT_IDENTITY - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-26 06:14:56 +00:00
return size;
}
/* 9.9.3.42 Generic message container type
* M V 1 */
2019-04-27 14:54:30 +00:00
int nas_decode_generic_message_container_type(nas_generic_message_container_type_t *generic_message_container_type, ogs_pkbuf_t *pkbuf)
2017-04-26 06:14:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_generic_message_container_type_t);
2017-04-26 06:14:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(generic_message_container_type, pkbuf->data - size, size);
2017-04-26 06:14:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" GENERIC_MESSAGE_CONTAINER_TYPE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-26 06:14:56 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_generic_message_container_type(ogs_pkbuf_t *pkbuf, nas_generic_message_container_type_t *generic_message_container_type)
2017-04-26 06:14:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_generic_message_container_type_t);
2017-04-26 06:14:56 +00:00
nas_generic_message_container_type_t target;
memcpy(&target, generic_message_container_type, size);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-26 06:14:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" GENERIC_MESSAGE_CONTAINER_TYPE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-26 06:14:56 +00:00
return size;
}
/* 9.9.3.43 Generic message container
* M LV-E 3-n */
2019-04-27 14:54:30 +00:00
int nas_decode_generic_message_container(nas_generic_message_container_t *generic_message_container, ogs_pkbuf_t *pkbuf)
2017-04-26 06:14:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_generic_message_container_t *source = pkbuf->data;
2017-04-26 06:14:56 +00:00
generic_message_container->length = ntohs(source->length);
size = generic_message_container->length + sizeof(generic_message_container->length);
2017-04-26 06:14:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
generic_message_container->buffer = pkbuf->data - size + sizeof(generic_message_container->length);
2017-04-26 06:14:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" GENERIC_MESSAGE_CONTAINER - ");
ogs_log_hexdump(OGS_LOG_TRACE, (void*)generic_message_container->buffer, generic_message_container->length);
2017-08-01 02:34:15 +00:00
2017-04-26 06:14:56 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_generic_message_container(ogs_pkbuf_t *pkbuf, nas_generic_message_container_t *generic_message_container)
2017-04-26 06:14:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
uint16_t target;
2017-04-26 06:14:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(generic_message_container);
ogs_assert(generic_message_container->buffer);
2017-04-26 06:14:56 +00:00
size = sizeof(generic_message_container->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
target = htons(generic_message_container->length);
2019-04-27 14:54:30 +00:00
memcpy(pkbuf->data - size, &target, size);
2017-04-26 06:14:56 +00:00
size = generic_message_container->length;
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, generic_message_container->buffer, size);
2017-04-26 06:14:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" GENERIC_MESSAGE_CONTAINER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
return generic_message_container->length + sizeof(generic_message_container->length);
2017-04-26 06:14:56 +00:00
}
2017-03-21 04:50:40 +00:00
/* 9.9.3.44 Voice domain preference and UE usage setting
2017-02-16 04:59:44 +00:00
* O TLV 3 */
2019-04-27 14:54:30 +00:00
int nas_decode_voice_domain_preference_and_ue_usage_setting(nas_voice_domain_preference_and_ue_usage_setting_t *voice_domain_preference_and_ue_usage_setting, ogs_pkbuf_t *pkbuf)
2017-02-16 04:59:44 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_voice_domain_preference_and_ue_usage_setting_t *source = pkbuf->data;
2017-02-16 04:59:44 +00:00
voice_domain_preference_and_ue_usage_setting->length = source->length;
2017-03-21 04:50:40 +00:00
size = voice_domain_preference_and_ue_usage_setting->length + sizeof(voice_domain_preference_and_ue_usage_setting->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(voice_domain_preference_and_ue_usage_setting, pkbuf->data - size, size);
2017-02-16 04:59:44 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" VOICE_DOMAIN_PREFERENCE_AND_UE_USAGE_SETTING - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 12:47:48 +00:00
return size;
2017-02-16 04:59:44 +00:00
}
2019-04-27 14:54:30 +00:00
int nas_encode_voice_domain_preference_and_ue_usage_setting(ogs_pkbuf_t *pkbuf, nas_voice_domain_preference_and_ue_usage_setting_t *voice_domain_preference_and_ue_usage_setting)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = voice_domain_preference_and_ue_usage_setting->length + sizeof(voice_domain_preference_and_ue_usage_setting->length);
2017-03-21 04:50:40 +00:00
nas_voice_domain_preference_and_ue_usage_setting_t target;
memcpy(&target, voice_domain_preference_and_ue_usage_setting, sizeof(nas_voice_domain_preference_and_ue_usage_setting_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" VOICE_DOMAIN_PREFERENCE_AND_UE_USAGE_SETTING - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
/* 9.9.3.45 GUTI type
2017-02-16 04:59:44 +00:00
* O TV 1 */
2019-04-27 14:54:30 +00:00
int nas_decode_guti_type(nas_guti_type_t *guti_type, ogs_pkbuf_t *pkbuf)
2017-02-16 04:59:44 +00:00
{
2019-04-27 14:54:30 +00:00
memcpy(guti_type, pkbuf->data - 1, 1);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" GUTI_TYPE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - 1, 1);
2017-08-01 02:34:15 +00:00
return 0;
2017-02-16 04:59:44 +00:00
}
2019-04-27 14:54:30 +00:00
int nas_encode_guti_type(ogs_pkbuf_t *pkbuf, nas_guti_type_t *guti_type)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_guti_type_t);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, guti_type, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" GUTI_TYPE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2017-02-16 04:59:44 +00:00
/* 9.9.3.46 Extended DRX parameters
* O TLV 3 */
2019-04-27 14:54:30 +00:00
int nas_decode_extended_drx_parameters(nas_extended_drx_parameters_t *extended_drx_parameters, ogs_pkbuf_t *pkbuf)
2017-02-16 04:59:44 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_extended_drx_parameters_t *source = pkbuf->data;
2017-02-16 04:59:44 +00:00
extended_drx_parameters->length = source->length;
2017-03-21 04:50:40 +00:00
size = extended_drx_parameters->length + sizeof(extended_drx_parameters->length);
2017-02-16 04:59:44 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(extended_drx_parameters, pkbuf->data - size, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" EXTENDED_DRX_PARAMETERS - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 12:47:48 +00:00
return size;
2017-02-16 04:59:44 +00:00
}
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
int nas_encode_extended_drx_parameters(ogs_pkbuf_t *pkbuf, nas_extended_drx_parameters_t *extended_drx_parameters)
2017-02-16 09:11:01 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = extended_drx_parameters->length + sizeof(extended_drx_parameters->length);
2017-03-21 04:50:40 +00:00
nas_extended_drx_parameters_t target;
memcpy(&target, extended_drx_parameters, sizeof(nas_extended_drx_parameters_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" EXTENDED_DRX_PARAMETERS - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2017-04-25 11:08:03 +00:00
/* 9.9.3.4a Ciphering key sequence number
* O TV 1 */
2019-04-27 14:54:30 +00:00
int nas_decode_ciphering_key_sequence_number(nas_ciphering_key_sequence_number_t *ciphering_key_sequence_number, ogs_pkbuf_t *pkbuf)
2017-04-25 11:08:03 +00:00
{
2019-04-27 14:54:30 +00:00
memcpy(ciphering_key_sequence_number, pkbuf->data - 1, 1);
2017-04-25 11:08:03 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" CIPHERING_KEY_SEQUENCE_NUMBER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - 1, 1);
2017-08-01 02:34:15 +00:00
2017-04-25 11:08:03 +00:00
return 0;
}
2019-04-27 14:54:30 +00:00
int nas_encode_ciphering_key_sequence_number(ogs_pkbuf_t *pkbuf, nas_ciphering_key_sequence_number_t *ciphering_key_sequence_number)
2017-04-25 11:08:03 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_ciphering_key_sequence_number_t);
2017-04-25 11:08:03 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, ciphering_key_sequence_number, size);
2017-04-25 11:08:03 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" CIPHERING_KEY_SEQUENCE_NUMBER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-25 11:08:03 +00:00
return size;
}
/* 9.9.3.5 CSFB response
* O TV 1 */
2019-04-27 14:54:30 +00:00
int nas_decode_csfb_response(nas_csfb_response_t *csfb_response, ogs_pkbuf_t *pkbuf)
2017-04-25 11:08:03 +00:00
{
2019-04-27 14:54:30 +00:00
memcpy(csfb_response, pkbuf->data - 1, 1);
2017-04-25 11:08:03 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" CSFB_RESPONSE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - 1, 1);
2017-08-01 02:34:15 +00:00
2017-04-25 11:08:03 +00:00
return 0;
}
2019-04-27 14:54:30 +00:00
int nas_encode_csfb_response(ogs_pkbuf_t *pkbuf, nas_csfb_response_t *csfb_response)
2017-04-25 11:08:03 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_csfb_response_t);
2017-04-25 11:08:03 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, csfb_response, size);
2017-04-25 11:08:03 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" CSFB_RESPONSE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-25 11:08:03 +00:00
return size;
}
2017-04-13 15:17:56 +00:00
/* 9.9.3.6 Daylight saving time
* O TLV 3 */
2019-04-27 14:54:30 +00:00
int nas_decode_daylight_saving_time(nas_daylight_saving_time_t *daylight_saving_time, ogs_pkbuf_t *pkbuf)
2017-04-13 15:17:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_daylight_saving_time_t *source = pkbuf->data;
2017-04-13 15:17:56 +00:00
daylight_saving_time->length = source->length;
size = daylight_saving_time->length + sizeof(daylight_saving_time->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(daylight_saving_time, pkbuf->data - size, size);
2017-04-13 15:17:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" DAYLIGHT_SAVING_TIME - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-13 15:17:56 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_daylight_saving_time(ogs_pkbuf_t *pkbuf, nas_daylight_saving_time_t *daylight_saving_time)
2017-04-13 15:17:56 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = daylight_saving_time->length + sizeof(daylight_saving_time->length);
2017-04-13 15:17:56 +00:00
nas_daylight_saving_time_t target;
memcpy(&target, daylight_saving_time, sizeof(nas_daylight_saving_time_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-13 15:17:56 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" DAYLIGHT_SAVING_TIME - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-13 15:17:56 +00:00
return size;
}
2017-04-25 11:08:03 +00:00
/* 9.9.3.7 Detach type
* M V 1/2 */
2019-04-27 14:54:30 +00:00
int nas_decode_detach_type(nas_detach_type_t *detach_type, ogs_pkbuf_t *pkbuf)
2017-04-25 11:08:03 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_detach_type_t);
2017-04-25 11:08:03 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(detach_type, pkbuf->data - size, size);
2017-04-25 11:08:03 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" DETACH_TYPE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-25 11:08:03 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_detach_type(ogs_pkbuf_t *pkbuf, nas_detach_type_t *detach_type)
2017-04-25 11:08:03 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_detach_type_t);
2017-04-25 11:08:03 +00:00
nas_detach_type_t target;
memcpy(&target, detach_type, size);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-25 11:08:03 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" DETACH_TYPE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-25 11:08:03 +00:00
return size;
}
2017-03-21 04:50:40 +00:00
/* 9.9.3.8 DRX parameter
* O TV 3 */
2019-04-27 14:54:30 +00:00
int nas_decode_drx_parameter(nas_drx_parameter_t *drx_parameter, ogs_pkbuf_t *pkbuf)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_drx_parameter_t);
2017-02-16 09:11:01 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(drx_parameter, pkbuf->data - size, size);
2017-02-16 09:11:01 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" DRX_PARAMETER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2017-02-16 12:47:48 +00:00
2019-04-27 14:54:30 +00:00
int nas_encode_drx_parameter(ogs_pkbuf_t *pkbuf, nas_drx_parameter_t *drx_parameter)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_drx_parameter_t);
2017-03-21 04:50:40 +00:00
nas_drx_parameter_t target;
memcpy(&target, drx_parameter, size);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-02-16 09:11:01 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" DRX_PARAMETER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-02-16 09:11:01 +00:00
return size;
}
2017-03-21 04:50:40 +00:00
/* 9.9.3.9 EMM cause
* O TV 2 */
2019-04-27 14:54:30 +00:00
int nas_decode_emm_cause(nas_emm_cause_t *emm_cause, ogs_pkbuf_t *pkbuf)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_emm_cause_t);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(emm_cause, pkbuf->data - size, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" EMM_CAUSE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_emm_cause(ogs_pkbuf_t *pkbuf, nas_emm_cause_t *emm_cause)
2017-03-21 04:50:40 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_emm_cause_t);
2017-03-21 04:50:40 +00:00
nas_emm_cause_t target;
memcpy(&target, emm_cause, size);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-03-21 04:50:40 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" EMM_CAUSE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-03-21 04:50:40 +00:00
return size;
}
2017-04-07 14:36:08 +00:00
/* 9.9.4.1 Access point name
2017-04-12 15:08:12 +00:00
* M LV 2-101 */
2019-04-27 14:54:30 +00:00
int nas_decode_access_point_name(nas_access_point_name_t *access_point_name, ogs_pkbuf_t *pkbuf)
2017-04-07 14:36:08 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_access_point_name_t *source = pkbuf->data;
2017-04-07 14:36:08 +00:00
access_point_name->length = source->length;
size = access_point_name->length + sizeof(access_point_name->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(access_point_name, pkbuf->data - size, size);
2017-04-07 14:36:08 +00:00
2017-08-19 11:16:00 +00:00
{
2019-04-27 14:54:30 +00:00
char apn[MAX_APN_LEN];
2019-06-21 09:23:29 +00:00
access_point_name->length = fqdn_parse(apn, access_point_name->apn, access_point_name->length);
2019-04-27 14:54:30 +00:00
ogs_cpystrn(access_point_name->apn, apn, ogs_min(access_point_name->length, MAX_APN_LEN) + 1);
2017-08-19 11:16:00 +00:00
}
2017-08-19 07:49:44 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" ACCESS_POINT_NAME - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-07 14:36:08 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_access_point_name(ogs_pkbuf_t *pkbuf, nas_access_point_name_t *access_point_name)
2017-04-07 14:36:08 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = access_point_name->length + sizeof(access_point_name->length);
2017-04-07 14:36:08 +00:00
nas_access_point_name_t target;
memcpy(&target, access_point_name, sizeof(nas_access_point_name_t));
2019-06-21 09:23:29 +00:00
target.length = fqdn_build(target.apn, access_point_name->apn, access_point_name->length);
2017-08-19 11:16:00 +00:00
size = target.length + sizeof(target.length);
2017-08-19 07:49:44 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-07 14:36:08 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" ACCESS_POINT_NAME - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-07 14:36:08 +00:00
return size;
}
/* 9.9.4.11 Protocol configuration options
* O TLV 3-253 */
2019-04-27 14:54:30 +00:00
int nas_decode_protocol_configuration_options(nas_protocol_configuration_options_t *protocol_configuration_options, ogs_pkbuf_t *pkbuf)
2017-04-07 14:36:08 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_protocol_configuration_options_t *source = pkbuf->data;
2017-04-07 14:36:08 +00:00
protocol_configuration_options->length = source->length;
size = protocol_configuration_options->length + sizeof(protocol_configuration_options->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(protocol_configuration_options, pkbuf->data - size, size);
2017-04-07 14:36:08 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" PROTOCOL_CONFIGURATION_OPTIONS - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-07 14:36:08 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_protocol_configuration_options(ogs_pkbuf_t *pkbuf, nas_protocol_configuration_options_t *protocol_configuration_options)
2017-04-07 14:36:08 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = protocol_configuration_options->length + sizeof(protocol_configuration_options->length);
2017-04-07 14:36:08 +00:00
nas_protocol_configuration_options_t target;
memcpy(&target, protocol_configuration_options, sizeof(nas_protocol_configuration_options_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-07 14:36:08 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" PROTOCOL_CONFIGURATION_OPTIONS - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-07 14:36:08 +00:00
return size;
}
2017-04-12 15:08:12 +00:00
/* 9.9.4.12 Quality of service
* O TLV 14-22 */
2019-04-27 14:54:30 +00:00
int nas_decode_quality_of_service(nas_quality_of_service_t *quality_of_service, ogs_pkbuf_t *pkbuf)
2017-04-12 15:08:12 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_quality_of_service_t *source = pkbuf->data;
2017-04-12 15:08:12 +00:00
quality_of_service->length = source->length;
size = quality_of_service->length + sizeof(quality_of_service->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(quality_of_service, pkbuf->data - size, size);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" QUALITY_OF_SERVICE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-12 15:08:12 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_quality_of_service(ogs_pkbuf_t *pkbuf, nas_quality_of_service_t *quality_of_service)
2017-04-12 15:08:12 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = quality_of_service->length + sizeof(quality_of_service->length);
2017-04-12 15:08:12 +00:00
nas_quality_of_service_t target;
memcpy(&target, quality_of_service, sizeof(nas_quality_of_service_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" QUALITY_OF_SERVICE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-12 15:08:12 +00:00
return size;
}
/* 9.9.4.13 Radio priority
* O TV 1 */
2019-04-27 14:54:30 +00:00
int nas_decode_radio_priority(nas_radio_priority_t *radio_priority, ogs_pkbuf_t *pkbuf)
2017-04-12 15:08:12 +00:00
{
2019-04-27 14:54:30 +00:00
memcpy(radio_priority, pkbuf->data - 1, 1);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" RADIO_PRIORITY - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - 1, 1);
2017-08-01 02:34:15 +00:00
2017-04-12 15:08:12 +00:00
return 0;
}
2019-04-27 14:54:30 +00:00
int nas_encode_radio_priority(ogs_pkbuf_t *pkbuf, nas_radio_priority_t *radio_priority)
2017-04-12 15:08:12 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_radio_priority_t);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, radio_priority, size);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" RADIO_PRIORITY - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-12 15:08:12 +00:00
return size;
}
2017-04-09 07:34:31 +00:00
/* 9.9.4.13A Re-attempt indicator
* O TLV 3 */
2019-04-27 14:54:30 +00:00
int nas_decode_re_attempt_indicator(nas_re_attempt_indicator_t *re_attempt_indicator, ogs_pkbuf_t *pkbuf)
2017-04-09 07:34:31 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_re_attempt_indicator_t *source = pkbuf->data;
2017-04-09 07:34:31 +00:00
re_attempt_indicator->length = source->length;
size = re_attempt_indicator->length + sizeof(re_attempt_indicator->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(re_attempt_indicator, pkbuf->data - size, size);
2017-04-09 07:34:31 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" RE_ATTEMPT_INDICATOR - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-09 07:34:31 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_re_attempt_indicator(ogs_pkbuf_t *pkbuf, nas_re_attempt_indicator_t *re_attempt_indicator)
2017-04-09 07:34:31 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = re_attempt_indicator->length + sizeof(re_attempt_indicator->length);
2017-04-09 07:34:31 +00:00
nas_re_attempt_indicator_t target;
memcpy(&target, re_attempt_indicator, sizeof(nas_re_attempt_indicator_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-09 07:34:31 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" RE_ATTEMPT_INDICATOR - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-09 07:34:31 +00:00
return size;
}
2017-04-07 14:36:08 +00:00
/* 9.9.4.14 Request type
* M V 1/2 */
2019-04-27 14:54:30 +00:00
int nas_decode_request_type(nas_request_type_t *request_type, ogs_pkbuf_t *pkbuf)
2017-04-07 14:36:08 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_request_type_t);
2017-04-07 14:36:08 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(request_type, pkbuf->data - size, size);
2017-04-07 14:36:08 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" REQUEST_TYPE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-07 14:36:08 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_request_type(ogs_pkbuf_t *pkbuf, nas_request_type_t *request_type)
2017-04-07 14:36:08 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_request_type_t);
2017-04-07 14:36:08 +00:00
nas_request_type_t target;
memcpy(&target, request_type, size);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-07 14:36:08 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" REQUEST_TYPE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-07 14:36:08 +00:00
return size;
}
2017-04-26 06:45:46 +00:00
/* 9.9.4.15 Traffic flow aggregate description
* M LV 2-256 */
2019-04-27 14:54:30 +00:00
int nas_decode_traffic_flow_aggregate_description(nas_traffic_flow_aggregate_description_t *traffic_flow_aggregate_description, ogs_pkbuf_t *pkbuf)
2017-04-26 06:45:46 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_traffic_flow_aggregate_description_t *source = pkbuf->data;
2017-04-26 06:45:46 +00:00
traffic_flow_aggregate_description->length = source->length;
size = traffic_flow_aggregate_description->length + sizeof(traffic_flow_aggregate_description->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(traffic_flow_aggregate_description, pkbuf->data - size, size);
2017-04-26 06:45:46 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" TRAFFIC_FLOW_AGGREGATE_DESCRIPTION - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-26 06:45:46 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_traffic_flow_aggregate_description(ogs_pkbuf_t *pkbuf, nas_traffic_flow_aggregate_description_t *traffic_flow_aggregate_description)
2017-04-26 06:45:46 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = traffic_flow_aggregate_description->length + sizeof(traffic_flow_aggregate_description->length);
2017-04-26 06:45:46 +00:00
nas_traffic_flow_aggregate_description_t target;
memcpy(&target, traffic_flow_aggregate_description, sizeof(nas_traffic_flow_aggregate_description_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-26 06:45:46 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" TRAFFIC_FLOW_AGGREGATE_DESCRIPTION - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-26 06:45:46 +00:00
return size;
}
2017-04-26 06:40:46 +00:00
/* 9.9.4.16 Traffic flow template
* M LV 2-256 */
2019-04-27 14:54:30 +00:00
int nas_decode_traffic_flow_template(nas_traffic_flow_template_t *traffic_flow_template, ogs_pkbuf_t *pkbuf)
2017-04-26 06:40:46 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_traffic_flow_template_t *source = pkbuf->data;
2017-04-26 06:40:46 +00:00
traffic_flow_template->length = source->length;
size = traffic_flow_template->length + sizeof(traffic_flow_template->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(traffic_flow_template, pkbuf->data - size, size);
2017-04-26 06:40:46 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" TRAFFIC_FLOW_TEMPLATE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-26 06:40:46 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_traffic_flow_template(ogs_pkbuf_t *pkbuf, nas_traffic_flow_template_t *traffic_flow_template)
2017-04-26 06:40:46 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = traffic_flow_template->length + sizeof(traffic_flow_template->length);
2017-04-26 06:40:46 +00:00
nas_traffic_flow_template_t target;
memcpy(&target, traffic_flow_template, sizeof(nas_traffic_flow_template_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-26 06:40:46 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" TRAFFIC_FLOW_TEMPLATE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-26 06:40:46 +00:00
return size;
}
2017-04-12 15:08:12 +00:00
/* 9.9.4.17 Transaction identifier
* O TLV 3-4 */
2019-04-27 14:54:30 +00:00
int nas_decode_transaction_identifier(nas_transaction_identifier_t *transaction_identifier, ogs_pkbuf_t *pkbuf)
2017-04-12 15:08:12 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_transaction_identifier_t *source = pkbuf->data;
2017-04-12 15:08:12 +00:00
transaction_identifier->length = source->length;
size = transaction_identifier->length + sizeof(transaction_identifier->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(transaction_identifier, pkbuf->data - size, size);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" TRANSACTION_IDENTIFIER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-12 15:08:12 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_transaction_identifier(ogs_pkbuf_t *pkbuf, nas_transaction_identifier_t *transaction_identifier)
2017-04-12 15:08:12 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = transaction_identifier->length + sizeof(transaction_identifier->length);
2017-04-12 15:08:12 +00:00
nas_transaction_identifier_t target;
memcpy(&target, transaction_identifier, sizeof(nas_transaction_identifier_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" TRANSACTION_IDENTIFIER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-12 15:08:12 +00:00
return size;
}
/* 9.9.4.18 WLAN offload acceptability
* O TV 1 */
2019-04-27 14:54:30 +00:00
int nas_decode_wlan_offload_acceptability(nas_wlan_offload_acceptability_t *wlan_offload_acceptability, ogs_pkbuf_t *pkbuf)
2017-04-12 15:08:12 +00:00
{
2019-04-27 14:54:30 +00:00
memcpy(wlan_offload_acceptability, pkbuf->data - 1, 1);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" WLAN_OFFLOAD_ACCEPTABILITY - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - 1, 1);
2017-08-01 02:34:15 +00:00
2017-04-12 15:08:12 +00:00
return 0;
}
2019-04-27 14:54:30 +00:00
int nas_encode_wlan_offload_acceptability(ogs_pkbuf_t *pkbuf, nas_wlan_offload_acceptability_t *wlan_offload_acceptability)
2017-04-12 15:08:12 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_wlan_offload_acceptability_t);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, wlan_offload_acceptability, size);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" WLAN_OFFLOAD_ACCEPTABILITY - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-12 15:08:12 +00:00
return size;
}
2017-04-07 14:36:08 +00:00
/* 9.9.4.19 NBIFOM container
* O TLV 3-257 */
2019-04-27 14:54:30 +00:00
int nas_decode_nbifom_container(nas_nbifom_container_t *nbifom_container, ogs_pkbuf_t *pkbuf)
2017-04-07 14:36:08 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_nbifom_container_t *source = pkbuf->data;
2017-04-07 14:36:08 +00:00
nbifom_container->length = source->length;
size = nbifom_container->length + sizeof(nbifom_container->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(nbifom_container, pkbuf->data - size, size);
2017-04-07 14:36:08 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" NBIFOM_CONTAINER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-07 14:36:08 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_nbifom_container(ogs_pkbuf_t *pkbuf, nas_nbifom_container_t *nbifom_container)
2017-04-07 14:36:08 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = nbifom_container->length + sizeof(nbifom_container->length);
2017-04-07 14:36:08 +00:00
nas_nbifom_container_t target;
memcpy(&target, nbifom_container, sizeof(nas_nbifom_container_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-07 14:36:08 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" NBIFOM_CONTAINER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-07 14:36:08 +00:00
return size;
}
2017-04-12 15:08:12 +00:00
/* 9.9.4.2 APN aggregate maximum bit rate
* O TLV 4-8 */
2019-04-27 14:54:30 +00:00
int nas_decode_apn_aggregate_maximum_bit_rate(nas_apn_aggregate_maximum_bit_rate_t *apn_aggregate_maximum_bit_rate, ogs_pkbuf_t *pkbuf)
2017-04-12 15:08:12 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_apn_aggregate_maximum_bit_rate_t *source = pkbuf->data;
2017-04-12 15:08:12 +00:00
apn_aggregate_maximum_bit_rate->length = source->length;
size = apn_aggregate_maximum_bit_rate->length + sizeof(apn_aggregate_maximum_bit_rate->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(apn_aggregate_maximum_bit_rate, pkbuf->data - size, size);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" APN_AGGREGATE_MAXIMUM_BIT_RATE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-12 15:08:12 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_apn_aggregate_maximum_bit_rate(ogs_pkbuf_t *pkbuf, nas_apn_aggregate_maximum_bit_rate_t *apn_aggregate_maximum_bit_rate)
2017-04-12 15:08:12 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = apn_aggregate_maximum_bit_rate->length + sizeof(apn_aggregate_maximum_bit_rate->length);
2017-04-12 15:08:12 +00:00
nas_apn_aggregate_maximum_bit_rate_t target;
memcpy(&target, apn_aggregate_maximum_bit_rate, sizeof(nas_apn_aggregate_maximum_bit_rate_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" APN_AGGREGATE_MAXIMUM_BIT_RATE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-12 15:08:12 +00:00
return size;
}
2017-04-07 14:36:08 +00:00
/* 9.9.4.22 Header compression configuration
* O TLV 5-257 */
2019-04-27 14:54:30 +00:00
int nas_decode_header_compression_configuration(nas_header_compression_configuration_t *header_compression_configuration, ogs_pkbuf_t *pkbuf)
2017-04-07 14:36:08 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_header_compression_configuration_t *source = pkbuf->data;
2017-04-07 14:36:08 +00:00
header_compression_configuration->length = source->length;
size = header_compression_configuration->length + sizeof(header_compression_configuration->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(header_compression_configuration, pkbuf->data - size, size);
2017-04-07 14:36:08 +00:00
2017-04-09 08:14:32 +00:00
header_compression_configuration->max_cid = ntohs(header_compression_configuration->max_cid);
2019-04-27 14:54:30 +00:00
ogs_trace(" HEADER_COMPRESSION_CONFIGURATION - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-07 14:36:08 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_header_compression_configuration(ogs_pkbuf_t *pkbuf, nas_header_compression_configuration_t *header_compression_configuration)
2017-04-07 14:36:08 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = header_compression_configuration->length + sizeof(header_compression_configuration->length);
2017-04-07 14:36:08 +00:00
nas_header_compression_configuration_t target;
memcpy(&target, header_compression_configuration, sizeof(nas_header_compression_configuration_t));
2017-04-09 08:14:32 +00:00
target.max_cid = htons(header_compression_configuration->max_cid);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-07 14:36:08 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" HEADER_COMPRESSION_CONFIGURATION - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-07 14:36:08 +00:00
return size;
}
2017-04-12 15:08:12 +00:00
/* 9.9.4.23 Control plane only indication
* O TV 1 */
2019-04-27 14:54:30 +00:00
int nas_decode_control_plane_only_indication(nas_control_plane_only_indication_t *control_plane_only_indication, ogs_pkbuf_t *pkbuf)
2017-04-12 15:08:12 +00:00
{
2019-04-27 14:54:30 +00:00
memcpy(control_plane_only_indication, pkbuf->data - 1, 1);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" CONTROL_PLANE_ONLY_INDICATION - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - 1, 1);
2017-08-01 02:34:15 +00:00
2017-04-12 15:08:12 +00:00
return 0;
}
2019-04-27 14:54:30 +00:00
int nas_encode_control_plane_only_indication(ogs_pkbuf_t *pkbuf, nas_control_plane_only_indication_t *control_plane_only_indication)
2017-04-12 15:08:12 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_control_plane_only_indication_t);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, control_plane_only_indication, size);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" CONTROL_PLANE_ONLY_INDICATION - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-12 15:08:12 +00:00
return size;
}
2017-04-07 14:36:08 +00:00
/* 9.9.4.26 Extended protocol configuration options
* O TLV-E 4-65538 */
2019-04-27 14:54:30 +00:00
int nas_decode_extended_protocol_configuration_options(nas_extended_protocol_configuration_options_t *extended_protocol_configuration_options, ogs_pkbuf_t *pkbuf)
2017-04-07 14:36:08 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_extended_protocol_configuration_options_t *source = pkbuf->data;
2017-04-07 14:36:08 +00:00
extended_protocol_configuration_options->length = ntohs(source->length);
size = extended_protocol_configuration_options->length + sizeof(extended_protocol_configuration_options->length);
2017-04-07 14:36:08 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
extended_protocol_configuration_options->buffer = pkbuf->data - size + sizeof(extended_protocol_configuration_options->length);
2017-04-07 14:36:08 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS - ");
ogs_log_hexdump(OGS_LOG_TRACE, (void*)extended_protocol_configuration_options->buffer, extended_protocol_configuration_options->length);
2017-08-01 02:34:15 +00:00
2017-04-07 14:36:08 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_extended_protocol_configuration_options(ogs_pkbuf_t *pkbuf, nas_extended_protocol_configuration_options_t *extended_protocol_configuration_options)
2017-04-07 14:36:08 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
uint16_t target;
2017-04-07 14:36:08 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(extended_protocol_configuration_options);
ogs_assert(extended_protocol_configuration_options->buffer);
2017-04-07 14:36:08 +00:00
size = sizeof(extended_protocol_configuration_options->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
target = htons(extended_protocol_configuration_options->length);
2019-04-27 14:54:30 +00:00
memcpy(pkbuf->data - size, &target, size);
2017-04-07 14:36:08 +00:00
size = extended_protocol_configuration_options->length;
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, extended_protocol_configuration_options->buffer, size);
2017-04-07 14:36:08 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" EXTENDED_PROTOCOL_CONFIGURATION_OPTIONS - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
return extended_protocol_configuration_options->length + sizeof(extended_protocol_configuration_options->length);
2017-04-07 14:36:08 +00:00
}
2017-04-25 11:08:03 +00:00
/* 9.9.4.27 Header compression configuration status
* O TLV 4 */
2019-04-27 14:54:30 +00:00
int nas_decode_header_compression_configuration_status(nas_header_compression_configuration_status_t *header_compression_configuration_status, ogs_pkbuf_t *pkbuf)
2017-04-25 11:08:03 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_header_compression_configuration_status_t *source = pkbuf->data;
2017-04-25 11:08:03 +00:00
header_compression_configuration_status->length = source->length;
size = header_compression_configuration_status->length + sizeof(header_compression_configuration_status->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(header_compression_configuration_status, pkbuf->data - size, size);
2017-04-25 11:08:03 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" HEADER_COMPRESSION_CONFIGURATION_STATUS - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-25 11:08:03 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_header_compression_configuration_status(ogs_pkbuf_t *pkbuf, nas_header_compression_configuration_status_t *header_compression_configuration_status)
2017-04-25 11:08:03 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = header_compression_configuration_status->length + sizeof(header_compression_configuration_status->length);
2017-04-25 11:08:03 +00:00
nas_header_compression_configuration_status_t target;
memcpy(&target, header_compression_configuration_status, sizeof(nas_header_compression_configuration_status_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-25 11:08:03 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" HEADER_COMPRESSION_CONFIGURATION_STATUS - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-25 11:08:03 +00:00
return size;
}
2017-04-12 15:08:12 +00:00
/* 9.9.4.28 Serving PLMN rate control
* O TLV 4 */
2019-04-27 14:54:30 +00:00
int nas_decode_serving_plmn_rate_control(nas_serving_plmn_rate_control_t *serving_plmn_rate_control, ogs_pkbuf_t *pkbuf)
2017-04-12 15:08:12 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_serving_plmn_rate_control_t *source = pkbuf->data;
2017-04-12 15:08:12 +00:00
serving_plmn_rate_control->length = source->length;
size = serving_plmn_rate_control->length + sizeof(serving_plmn_rate_control->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(serving_plmn_rate_control, pkbuf->data - size, size);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" SERVING_PLMN_RATE_CONTROL - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-12 15:08:12 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_serving_plmn_rate_control(ogs_pkbuf_t *pkbuf, nas_serving_plmn_rate_control_t *serving_plmn_rate_control)
2017-04-12 15:08:12 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = serving_plmn_rate_control->length + sizeof(serving_plmn_rate_control->length);
2017-04-12 15:08:12 +00:00
nas_serving_plmn_rate_control_t target;
memcpy(&target, serving_plmn_rate_control, sizeof(nas_serving_plmn_rate_control_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" SERVING_PLMN_RATE_CONTROL - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-12 15:08:12 +00:00
return size;
}
/* 9.9.4.2A Connectivity type
* O TV 1 */
2019-04-27 14:54:30 +00:00
int nas_decode_connectivity_type(nas_connectivity_type_t *connectivity_type, ogs_pkbuf_t *pkbuf)
2017-04-12 15:08:12 +00:00
{
2019-04-27 14:54:30 +00:00
memcpy(connectivity_type, pkbuf->data - 1, 1);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" CONNECTIVITY_TYPE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - 1, 1);
2017-08-01 02:34:15 +00:00
2017-04-12 15:08:12 +00:00
return 0;
}
2019-04-27 14:54:30 +00:00
int nas_encode_connectivity_type(ogs_pkbuf_t *pkbuf, nas_connectivity_type_t *connectivity_type)
2017-04-12 15:08:12 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_connectivity_type_t);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, connectivity_type, size);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" CONNECTIVITY_TYPE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-12 15:08:12 +00:00
return size;
}
/* 9.9.4.3 EPS quality of service
* M LV 2-14 */
2019-04-27 14:54:30 +00:00
int nas_decode_eps_quality_of_service(nas_eps_quality_of_service_t *eps_quality_of_service, ogs_pkbuf_t *pkbuf)
2017-04-12 15:08:12 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_eps_quality_of_service_t *source = pkbuf->data;
2017-04-12 15:08:12 +00:00
eps_quality_of_service->length = source->length;
size = eps_quality_of_service->length + sizeof(eps_quality_of_service->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(eps_quality_of_service, pkbuf->data - size, size);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" EPS_QUALITY_OF_SERVICE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-12 15:08:12 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_eps_quality_of_service(ogs_pkbuf_t *pkbuf, nas_eps_quality_of_service_t *eps_quality_of_service)
2017-04-12 15:08:12 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = eps_quality_of_service->length + sizeof(eps_quality_of_service->length);
2017-04-12 15:08:12 +00:00
nas_eps_quality_of_service_t target;
memcpy(&target, eps_quality_of_service, sizeof(nas_eps_quality_of_service_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" EPS_QUALITY_OF_SERVICE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-12 15:08:12 +00:00
return size;
}
2017-04-09 07:34:31 +00:00
/* 9.9.4.4 ESM cause
2017-04-12 15:08:12 +00:00
* O TV 2 */
2019-04-27 14:54:30 +00:00
int nas_decode_esm_cause(nas_esm_cause_t *esm_cause, ogs_pkbuf_t *pkbuf)
2017-04-09 07:34:31 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_esm_cause_t);
2017-04-09 07:34:31 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(esm_cause, pkbuf->data - size, size);
2017-04-09 07:34:31 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" ESM_CAUSE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-09 07:34:31 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_esm_cause(ogs_pkbuf_t *pkbuf, nas_esm_cause_t *esm_cause)
2017-04-09 07:34:31 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_esm_cause_t);
2017-04-09 07:34:31 +00:00
nas_esm_cause_t target;
memcpy(&target, esm_cause, size);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-09 07:34:31 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" ESM_CAUSE - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-09 07:34:31 +00:00
return size;
}
2017-04-07 14:36:08 +00:00
/* 9.9.4.5 ESM information transfer flag
* O TV 1 */
2019-04-27 14:54:30 +00:00
int nas_decode_esm_information_transfer_flag(nas_esm_information_transfer_flag_t *esm_information_transfer_flag, ogs_pkbuf_t *pkbuf)
2017-04-07 14:36:08 +00:00
{
2019-04-27 14:54:30 +00:00
memcpy(esm_information_transfer_flag, pkbuf->data - 1, 1);
2017-04-07 14:36:08 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" ESM_INFORMATION_TRANSFER_FLAG - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - 1, 1);
2017-08-01 02:34:15 +00:00
2017-04-07 14:36:08 +00:00
return 0;
}
2019-04-27 14:54:30 +00:00
int nas_encode_esm_information_transfer_flag(ogs_pkbuf_t *pkbuf, nas_esm_information_transfer_flag_t *esm_information_transfer_flag)
2017-04-07 14:36:08 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_esm_information_transfer_flag_t);
2017-04-07 14:36:08 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, esm_information_transfer_flag, size);
2017-04-07 14:36:08 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" ESM_INFORMATION_TRANSFER_FLAG - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-07 14:36:08 +00:00
return size;
}
2017-04-09 07:34:31 +00:00
/* 9.9.4.6 Linked EPS bearer identity
* M V 1/2 */
2019-04-27 14:54:30 +00:00
int nas_decode_linked_eps_bearer_identity(nas_linked_eps_bearer_identity_t *linked_eps_bearer_identity, ogs_pkbuf_t *pkbuf)
2017-04-09 07:34:31 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_linked_eps_bearer_identity_t);
2017-04-09 07:34:31 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(linked_eps_bearer_identity, pkbuf->data - size, size);
2017-04-09 07:34:31 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" LINKED_EPS_BEARER_IDENTITY - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-09 07:34:31 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_linked_eps_bearer_identity(ogs_pkbuf_t *pkbuf, nas_linked_eps_bearer_identity_t *linked_eps_bearer_identity)
2017-04-09 07:34:31 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_linked_eps_bearer_identity_t);
2017-04-09 07:34:31 +00:00
nas_linked_eps_bearer_identity_t target;
memcpy(&target, linked_eps_bearer_identity, size);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-09 07:34:31 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" LINKED_EPS_BEARER_IDENTITY - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-09 07:34:31 +00:00
return size;
}
2017-04-12 15:08:12 +00:00
/* 9.9.4.7 LLC service access point identifier
* O TV 2 */
2019-04-27 14:54:30 +00:00
int nas_decode_llc_service_access_point_identifier(nas_llc_service_access_point_identifier_t *llc_service_access_point_identifier, ogs_pkbuf_t *pkbuf)
2017-04-12 15:08:12 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_llc_service_access_point_identifier_t);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(llc_service_access_point_identifier, pkbuf->data - size, size);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" LLC_SERVICE_ACCESS_POINT_IDENTIFIER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-12 15:08:12 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_llc_service_access_point_identifier(ogs_pkbuf_t *pkbuf, nas_llc_service_access_point_identifier_t *llc_service_access_point_identifier)
2017-04-12 15:08:12 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = sizeof(nas_llc_service_access_point_identifier_t);
2017-04-12 15:08:12 +00:00
nas_llc_service_access_point_identifier_t target;
memcpy(&target, llc_service_access_point_identifier, size);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" LLC_SERVICE_ACCESS_POINT_IDENTIFIER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-12 15:08:12 +00:00
return size;
}
/* 9.9.4.8 Packet flow Identifier
* O TLV 3 */
2019-04-27 14:54:30 +00:00
int nas_decode_packet_flow_identifier(nas_packet_flow_identifier_t *packet_flow_identifier, ogs_pkbuf_t *pkbuf)
2017-04-12 15:08:12 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_packet_flow_identifier_t *source = pkbuf->data;
2017-04-12 15:08:12 +00:00
packet_flow_identifier->length = source->length;
size = packet_flow_identifier->length + sizeof(packet_flow_identifier->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(packet_flow_identifier, pkbuf->data - size, size);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" PACKET_FLOW_IDENTIFIER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-12 15:08:12 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_packet_flow_identifier(ogs_pkbuf_t *pkbuf, nas_packet_flow_identifier_t *packet_flow_identifier)
2017-04-12 15:08:12 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = packet_flow_identifier->length + sizeof(packet_flow_identifier->length);
2017-04-12 15:08:12 +00:00
nas_packet_flow_identifier_t target;
memcpy(&target, packet_flow_identifier, sizeof(nas_packet_flow_identifier_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" PACKET_FLOW_IDENTIFIER - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-12 15:08:12 +00:00
return size;
}
/* 9.9.4.9 PDN address
* M LV 6-14 */
2019-04-27 14:54:30 +00:00
int nas_decode_pdn_address(nas_pdn_address_t *pdn_address, ogs_pkbuf_t *pkbuf)
2017-04-12 15:08:12 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = 0;
nas_pdn_address_t *source = pkbuf->data;
2017-04-12 15:08:12 +00:00
pdn_address->length = source->length;
size = pdn_address->length + sizeof(pdn_address->length);
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pdn_address, pkbuf->data - size, size);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" PDN_ADDRESS - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-12 15:08:12 +00:00
return size;
}
2019-04-27 14:54:30 +00:00
int nas_encode_pdn_address(ogs_pkbuf_t *pkbuf, nas_pdn_address_t *pdn_address)
2017-04-12 15:08:12 +00:00
{
2019-04-27 14:54:30 +00:00
uint16_t size = pdn_address->length + sizeof(pdn_address->length);
2017-04-12 15:08:12 +00:00
nas_pdn_address_t target;
memcpy(&target, pdn_address, sizeof(nas_pdn_address_t));
2019-04-27 14:54:30 +00:00
ogs_assert(ogs_pkbuf_pull(pkbuf, size));
memcpy(pkbuf->data - size, &target, size);
2017-04-12 15:08:12 +00:00
2019-04-27 14:54:30 +00:00
ogs_trace(" PDN_ADDRESS - ");
ogs_log_hexdump(OGS_LOG_TRACE, pkbuf->data - size, size);
2017-08-01 02:34:15 +00:00
2017-04-12 15:08:12 +00:00
return size;
}