mirror of
https://github.com/open5gs/open5gs.git
synced 2026-05-02 21:30:10 +00:00
Add AUSF, UDM, and UDR
This commit is contained in:
parent
0c0241d5e5
commit
72370ff0b2
1151 changed files with 140173 additions and 24799 deletions
115
lib/sbi/openapi/model/route_information.c
Normal file
115
lib/sbi/openapi/model/route_information.c
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "route_information.h"
|
||||
|
||||
OpenAPI_route_information_t *OpenAPI_route_information_create(
|
||||
char *ipv4_addr,
|
||||
char *ipv6_addr,
|
||||
int port_number
|
||||
)
|
||||
{
|
||||
OpenAPI_route_information_t *route_information_local_var = OpenAPI_malloc(sizeof(OpenAPI_route_information_t));
|
||||
if (!route_information_local_var) {
|
||||
return NULL;
|
||||
}
|
||||
route_information_local_var->ipv4_addr = ipv4_addr;
|
||||
route_information_local_var->ipv6_addr = ipv6_addr;
|
||||
route_information_local_var->port_number = port_number;
|
||||
|
||||
return route_information_local_var;
|
||||
}
|
||||
|
||||
void OpenAPI_route_information_free(OpenAPI_route_information_t *route_information)
|
||||
{
|
||||
if (NULL == route_information) {
|
||||
return;
|
||||
}
|
||||
OpenAPI_lnode_t *node;
|
||||
ogs_free(route_information->ipv4_addr);
|
||||
ogs_free(route_information->ipv6_addr);
|
||||
ogs_free(route_information);
|
||||
}
|
||||
|
||||
cJSON *OpenAPI_route_information_convertToJSON(OpenAPI_route_information_t *route_information)
|
||||
{
|
||||
cJSON *item = NULL;
|
||||
|
||||
if (route_information == NULL) {
|
||||
ogs_error("OpenAPI_route_information_convertToJSON() failed [RouteInformation]");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
item = cJSON_CreateObject();
|
||||
if (route_information->ipv4_addr) {
|
||||
if (cJSON_AddStringToObject(item, "ipv4Addr", route_information->ipv4_addr) == NULL) {
|
||||
ogs_error("OpenAPI_route_information_convertToJSON() failed [ipv4_addr]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (route_information->ipv6_addr) {
|
||||
if (cJSON_AddStringToObject(item, "ipv6Addr", route_information->ipv6_addr) == NULL) {
|
||||
ogs_error("OpenAPI_route_information_convertToJSON() failed [ipv6_addr]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if (!route_information->port_number) {
|
||||
ogs_error("OpenAPI_route_information_convertToJSON() failed [port_number]");
|
||||
goto end;
|
||||
}
|
||||
if (cJSON_AddNumberToObject(item, "portNumber", route_information->port_number) == NULL) {
|
||||
ogs_error("OpenAPI_route_information_convertToJSON() failed [port_number]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
end:
|
||||
return item;
|
||||
}
|
||||
|
||||
OpenAPI_route_information_t *OpenAPI_route_information_parseFromJSON(cJSON *route_informationJSON)
|
||||
{
|
||||
OpenAPI_route_information_t *route_information_local_var = NULL;
|
||||
cJSON *ipv4_addr = cJSON_GetObjectItemCaseSensitive(route_informationJSON, "ipv4Addr");
|
||||
|
||||
if (ipv4_addr) {
|
||||
if (!cJSON_IsString(ipv4_addr)) {
|
||||
ogs_error("OpenAPI_route_information_parseFromJSON() failed [ipv4_addr]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *ipv6_addr = cJSON_GetObjectItemCaseSensitive(route_informationJSON, "ipv6Addr");
|
||||
|
||||
if (ipv6_addr) {
|
||||
if (!cJSON_IsString(ipv6_addr)) {
|
||||
ogs_error("OpenAPI_route_information_parseFromJSON() failed [ipv6_addr]");
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
cJSON *port_number = cJSON_GetObjectItemCaseSensitive(route_informationJSON, "portNumber");
|
||||
if (!port_number) {
|
||||
ogs_error("OpenAPI_route_information_parseFromJSON() failed [port_number]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
if (!cJSON_IsNumber(port_number)) {
|
||||
ogs_error("OpenAPI_route_information_parseFromJSON() failed [port_number]");
|
||||
goto end;
|
||||
}
|
||||
|
||||
route_information_local_var = OpenAPI_route_information_create (
|
||||
ipv4_addr ? ogs_strdup(ipv4_addr->valuestring) : NULL,
|
||||
ipv6_addr ? ogs_strdup(ipv6_addr->valuestring) : NULL,
|
||||
port_number->valuedouble
|
||||
);
|
||||
|
||||
return route_information_local_var;
|
||||
end:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue