mirror of
https://github.com/open5gs/open5gs.git
synced 2026-05-04 22:30:09 +00:00
Added NRF
This commit is contained in:
parent
46f20cc979
commit
d0673e3066
397 changed files with 85455 additions and 209 deletions
131
lib/sbi/openapi/model/ip_end_point.c
Normal file
131
lib/sbi/openapi/model/ip_end_point.c
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "ip_end_point.h"
|
||||
|
||||
OpenAPI_ip_end_point_t *OpenAPI_ip_end_point_create(
|
||||
char *ipv4_address,
|
||||
char *ipv6_address,
|
||||
OpenAPI_transport_protocol_e transport,
|
||||
int port
|
||||
)
|
||||
{
|
||||
OpenAPI_ip_end_point_t *ip_end_point_local_var = OpenAPI_malloc(sizeof(OpenAPI_ip_end_point_t));
|
||||
if (!ip_end_point_local_var) {
|
||||
return NULL;
|
||||
}
|
||||
ip_end_point_local_var->ipv4_address = ipv4_address;
|
||||
ip_end_point_local_var->ipv6_address = ipv6_address;
|
||||
ip_end_point_local_var->transport = transport;
|
||||
ip_end_point_local_var->port = port;
|
||||
|
||||
return ip_end_point_local_var;
|
||||
}
|
||||
|
||||
void OpenAPI_ip_end_point_free(OpenAPI_ip_end_point_t *ip_end_point)
|
||||
{
|
||||
if (NULL == ip_end_point) {
|
||||
return;
|
||||
}
|
||||
OpenAPI_lnode_t *node;
|
||||
ogs_free(ip_end_point->ipv4_address);
|
||||
ogs_free(ip_end_point->ipv6_address);
|
||||
ogs_free(ip_end_point);
|
||||
}
|
||||
|
||||
cJSON *OpenAPI_ip_end_point_convertToJSON(OpenAPI_ip_end_point_t *ip_end_point)
|
||||
{
|
||||
cJSON *item = NULL;
|
||||
|
||||
if (ip_end_point == NULL) {
|
||||
ogs_error("OpenAPI_ip_end_point_convertToJSON() failed [IpEndPoint]");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
item = cJSON_CreateObject();
|
||||
if (ip_end_point->ipv4_address) {
|
||||
if (cJSON_AddStringToObject(item, "ipv4Address", ip_end_point->ipv4_address) == NULL) {
|
||||
ogs_error("OpenAPI_ip_end_point_convertToJSON() failed [ipv4_address]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (ip_end_point->ipv6_address) {
|
||||
if (cJSON_AddStringToObject(item, "ipv6Address", ip_end_point->ipv6_address) == NULL) {
|
||||
ogs_error("OpenAPI_ip_end_point_convertToJSON() failed [ipv6_address]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (ip_end_point->transport) {
|
||||
if (cJSON_AddStringToObject(item, "transport", OpenAPI_transport_protocol_ToString(ip_end_point->transport)) == NULL) {
|
||||
ogs_error("OpenAPI_ip_end_point_convertToJSON() failed [transport]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (ip_end_point->port) {
|
||||
if (cJSON_AddNumberToObject(item, "port", ip_end_point->port) == NULL) {
|
||||
ogs_error("OpenAPI_ip_end_point_convertToJSON() failed [port]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
return item;
|
||||
}
|
||||
|
||||
OpenAPI_ip_end_point_t *OpenAPI_ip_end_point_parseFromJSON(cJSON *ip_end_pointJSON)
|
||||
{
|
||||
OpenAPI_ip_end_point_t *ip_end_point_local_var = NULL;
|
||||
cJSON *ipv4_address = cJSON_GetObjectItemCaseSensitive(ip_end_pointJSON, "ipv4Address");
|
||||
|
||||
if (ipv4_address) {
|
||||
if (!cJSON_IsString(ipv4_address)) {
|
||||
ogs_error("OpenAPI_ip_end_point_parseFromJSON() failed [ipv4_address]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *ipv6_address = cJSON_GetObjectItemCaseSensitive(ip_end_pointJSON, "ipv6Address");
|
||||
|
||||
if (ipv6_address) {
|
||||
if (!cJSON_IsString(ipv6_address)) {
|
||||
ogs_error("OpenAPI_ip_end_point_parseFromJSON() failed [ipv6_address]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *transport = cJSON_GetObjectItemCaseSensitive(ip_end_pointJSON, "transport");
|
||||
|
||||
OpenAPI_transport_protocol_e transportVariable;
|
||||
if (transport) {
|
||||
if (!cJSON_IsString(transport)) {
|
||||
ogs_error("OpenAPI_ip_end_point_parseFromJSON() failed [transport]");
|
||||
goto end;
|
||||
}
|
||||
transportVariable = OpenAPI_transport_protocol_FromString(transport->valuestring);
|
||||
}
|
||||
|
||||
cJSON *port = cJSON_GetObjectItemCaseSensitive(ip_end_pointJSON, "port");
|
||||
|
||||
if (port) {
|
||||
if (!cJSON_IsNumber(port)) {
|
||||
ogs_error("OpenAPI_ip_end_point_parseFromJSON() failed [port]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
ip_end_point_local_var = OpenAPI_ip_end_point_create (
|
||||
ipv4_address ? ogs_strdup(ipv4_address->valuestring) : NULL,
|
||||
ipv6_address ? ogs_strdup(ipv6_address->valuestring) : NULL,
|
||||
transport ? transportVariable : 0,
|
||||
port ? port->valuedouble : 0
|
||||
);
|
||||
|
||||
return ip_end_point_local_var;
|
||||
end:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue