2020-06-04 18:12:05 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 by Sukchan Lee <acetcom@gmail.com>
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "nudm-build.h"
|
|
|
|
|
2020-06-17 05:22:28 +00:00
|
|
|
ogs_sbi_request_t *ausf_nudm_ueau_build_get(ausf_ue_t *ausf_ue, void *data)
|
2020-06-04 18:12:05 +00:00
|
|
|
{
|
|
|
|
ogs_sbi_message_t message;
|
|
|
|
ogs_sbi_request_t *request = NULL;
|
|
|
|
|
2020-06-22 03:07:14 +00:00
|
|
|
OpenAPI_authentication_info_request_t AuthenticationInfoRequest;
|
|
|
|
OpenAPI_resynchronization_info_t ResynchronizationInfo;
|
2020-06-04 18:12:05 +00:00
|
|
|
|
|
|
|
ogs_assert(ausf_ue);
|
|
|
|
|
|
|
|
memset(&message, 0, sizeof(message));
|
|
|
|
message.h.method = (char *)OGS_SBI_HTTP_METHOD_POST;
|
|
|
|
message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NUDM_UEAU;
|
2020-06-17 05:22:28 +00:00
|
|
|
message.h.api.version = (char *)OGS_SBI_API_V1;
|
2020-06-04 18:12:05 +00:00
|
|
|
message.h.resource.component[0] = ausf_ue->suci;
|
|
|
|
message.h.resource.component[1] =
|
|
|
|
(char *)OGS_SBI_RESOURCE_NAME_SECURITY_INFORMATION;
|
|
|
|
message.h.resource.component[2] =
|
|
|
|
(char *)OGS_SBI_RESOURCE_NAME_GENERATE_AUTH_DATA;
|
|
|
|
|
2020-06-22 03:07:14 +00:00
|
|
|
memset(&AuthenticationInfoRequest, 0, sizeof(AuthenticationInfoRequest));
|
2020-06-04 18:12:05 +00:00
|
|
|
|
2020-06-22 03:07:14 +00:00
|
|
|
AuthenticationInfoRequest.serving_network_name =
|
2020-06-04 18:12:05 +00:00
|
|
|
ausf_ue->serving_network_name;
|
2020-06-22 03:07:14 +00:00
|
|
|
AuthenticationInfoRequest.ausf_instance_id =
|
2022-10-08 02:48:12 +00:00
|
|
|
NF_INSTANCE_ID(ogs_sbi_self()->nf_instance);
|
2020-06-04 18:12:05 +00:00
|
|
|
|
2020-06-22 03:07:14 +00:00
|
|
|
if (data) {
|
|
|
|
OpenAPI_resynchronization_info_t *recvinfo = data;
|
|
|
|
|
|
|
|
memset(&ResynchronizationInfo, 0, sizeof(ResynchronizationInfo));
|
|
|
|
ResynchronizationInfo.rand = recvinfo->rand;
|
|
|
|
ResynchronizationInfo.auts = recvinfo->auts;
|
|
|
|
|
|
|
|
AuthenticationInfoRequest.resynchronization_info =
|
|
|
|
&ResynchronizationInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
message.AuthenticationInfoRequest = &AuthenticationInfoRequest;
|
2020-06-04 18:12:05 +00:00
|
|
|
|
|
|
|
request = ogs_sbi_build_request(&message);
|
2022-10-22 02:26:04 +00:00
|
|
|
ogs_expect(request);
|
2020-06-04 18:12:05 +00:00
|
|
|
|
|
|
|
return request;
|
|
|
|
}
|
|
|
|
|
|
|
|
ogs_sbi_request_t *ausf_nudm_ueau_build_result_confirmation_inform(
|
2020-06-17 05:22:28 +00:00
|
|
|
ausf_ue_t *ausf_ue, void *data)
|
2020-06-04 18:12:05 +00:00
|
|
|
{
|
|
|
|
ogs_sbi_message_t message;
|
|
|
|
ogs_sbi_request_t *request = NULL;
|
|
|
|
|
|
|
|
OpenAPI_auth_event_t *AuthEvent = NULL;
|
|
|
|
|
|
|
|
ogs_assert(ausf_ue);
|
2022-12-25 11:12:26 +00:00
|
|
|
ogs_assert(ausf_ue->supi);
|
2020-06-04 18:12:05 +00:00
|
|
|
|
|
|
|
memset(&message, 0, sizeof(message));
|
|
|
|
message.h.method = (char *)OGS_SBI_HTTP_METHOD_POST;
|
|
|
|
message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NUDM_UEAU;
|
2020-06-17 05:22:28 +00:00
|
|
|
message.h.api.version = (char *)OGS_SBI_API_V1;
|
2020-06-04 18:12:05 +00:00
|
|
|
message.h.resource.component[0] = ausf_ue->supi;
|
|
|
|
message.h.resource.component[1] = (char *)OGS_SBI_RESOURCE_NAME_AUTH_EVENTS;
|
|
|
|
|
|
|
|
AuthEvent = ogs_calloc(1, sizeof(*AuthEvent));
|
2022-10-22 02:26:04 +00:00
|
|
|
if (!AuthEvent) {
|
|
|
|
ogs_error("No AuthEvent");
|
|
|
|
goto end;
|
|
|
|
}
|
2020-06-04 18:12:05 +00:00
|
|
|
|
2020-07-09 05:38:09 +00:00
|
|
|
AuthEvent->time_stamp = ogs_sbi_localtime_string(ogs_time_now());
|
2022-10-22 02:26:04 +00:00
|
|
|
if (!AuthEvent->time_stamp) {
|
|
|
|
ogs_error("No time_stamp");
|
|
|
|
goto end;
|
|
|
|
}
|
2020-06-04 18:12:05 +00:00
|
|
|
|
2022-10-08 02:48:12 +00:00
|
|
|
AuthEvent->nf_instance_id = NF_INSTANCE_ID(ogs_sbi_self()->nf_instance);
|
2020-06-04 18:12:05 +00:00
|
|
|
if (ausf_ue->auth_result == OpenAPI_auth_result_AUTHENTICATION_SUCCESS)
|
|
|
|
AuthEvent->success = true;
|
|
|
|
else
|
|
|
|
AuthEvent->success = false;
|
|
|
|
AuthEvent->auth_type = ausf_ue->auth_type;
|
|
|
|
AuthEvent->serving_network_name = ausf_ue->serving_network_name;
|
|
|
|
|
|
|
|
message.AuthEvent = AuthEvent;
|
|
|
|
|
|
|
|
request = ogs_sbi_build_request(&message);
|
2022-10-22 02:26:04 +00:00
|
|
|
ogs_expect(request);
|
2020-06-04 18:12:05 +00:00
|
|
|
|
2022-10-22 02:26:04 +00:00
|
|
|
end:
|
|
|
|
|
|
|
|
if (AuthEvent) {
|
|
|
|
if (AuthEvent->time_stamp)
|
|
|
|
ogs_free(AuthEvent->time_stamp);
|
|
|
|
ogs_free(AuthEvent);
|
|
|
|
}
|
2020-06-04 18:12:05 +00:00
|
|
|
|
|
|
|
return request;
|
|
|
|
}
|
2022-11-28 09:31:49 +00:00
|
|
|
|
|
|
|
ogs_sbi_request_t *ausf_nudm_ueau_build_auth_removal_ind(
|
|
|
|
ausf_ue_t *ausf_ue, void *data)
|
|
|
|
{
|
|
|
|
ogs_sbi_message_t message;
|
|
|
|
ogs_sbi_request_t *request = NULL;
|
|
|
|
|
|
|
|
OpenAPI_auth_event_t *AuthEvent = NULL;
|
|
|
|
|
|
|
|
ogs_assert(ausf_ue);
|
2022-12-25 11:12:26 +00:00
|
|
|
ogs_assert(ausf_ue->supi);
|
2022-11-28 09:31:49 +00:00
|
|
|
|
|
|
|
memset(&message, 0, sizeof(message));
|
|
|
|
message.h.method = (char *)OGS_SBI_HTTP_METHOD_PUT;
|
|
|
|
message.h.service.name = (char *)OGS_SBI_SERVICE_NAME_NUDM_UEAU;
|
|
|
|
message.h.api.version = (char *)OGS_SBI_API_V1;
|
|
|
|
message.h.resource.component[0] = ausf_ue->supi;
|
|
|
|
message.h.resource.component[1] = (char *)OGS_SBI_RESOURCE_NAME_AUTH_EVENTS;
|
|
|
|
|
|
|
|
AuthEvent = ogs_calloc(1, sizeof(*AuthEvent));
|
|
|
|
if (!AuthEvent) {
|
|
|
|
ogs_error("No AuthEvent");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
AuthEvent->time_stamp = ogs_sbi_localtime_string(ogs_time_now());
|
|
|
|
if (!AuthEvent->time_stamp) {
|
|
|
|
ogs_error("No time_stamp");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
AuthEvent->nf_instance_id = NF_INSTANCE_ID(ogs_sbi_self()->nf_instance);
|
|
|
|
AuthEvent->success = true;
|
|
|
|
AuthEvent->auth_type = ausf_ue->auth_type;
|
|
|
|
AuthEvent->serving_network_name = ausf_ue->serving_network_name;
|
|
|
|
|
|
|
|
AuthEvent->is_auth_removal_ind = true;
|
|
|
|
AuthEvent->auth_removal_ind = true;
|
|
|
|
|
|
|
|
message.AuthEvent = AuthEvent;
|
|
|
|
|
|
|
|
request = ogs_sbi_build_request(&message);
|
|
|
|
ogs_expect(request);
|
|
|
|
|
|
|
|
end:
|
|
|
|
|
|
|
|
if (AuthEvent) {
|
|
|
|
if (AuthEvent->time_stamp)
|
|
|
|
ogs_free(AuthEvent->time_stamp);
|
|
|
|
ogs_free(AuthEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
return request;
|
|
|
|
}
|