Added N32 Interface to implement SEPP

This commit is contained in:
Sukchan Lee 2023-03-05 22:55:36 +09:00
parent a8790713d7
commit e41afff7ac
63 changed files with 5503 additions and 290 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,145 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "_application_data_influence_data_subs_to_notify_post_request_inner.h"
OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_t *OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_create(
char *res_uri,
OpenAPI_traffic_influ_data_t *traffic_influ_data
)
{
OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_t *_application_data_influence_data_subs_to_notify_post_request_inner_local_var = ogs_malloc(sizeof(OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_t));
ogs_assert(_application_data_influence_data_subs_to_notify_post_request_inner_local_var);
_application_data_influence_data_subs_to_notify_post_request_inner_local_var->res_uri = res_uri;
_application_data_influence_data_subs_to_notify_post_request_inner_local_var->traffic_influ_data = traffic_influ_data;
return _application_data_influence_data_subs_to_notify_post_request_inner_local_var;
}
void OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_free(OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_t *_application_data_influence_data_subs_to_notify_post_request_inner)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == _application_data_influence_data_subs_to_notify_post_request_inner) {
return;
}
if (_application_data_influence_data_subs_to_notify_post_request_inner->res_uri) {
ogs_free(_application_data_influence_data_subs_to_notify_post_request_inner->res_uri);
_application_data_influence_data_subs_to_notify_post_request_inner->res_uri = NULL;
}
if (_application_data_influence_data_subs_to_notify_post_request_inner->traffic_influ_data) {
OpenAPI_traffic_influ_data_free(_application_data_influence_data_subs_to_notify_post_request_inner->traffic_influ_data);
_application_data_influence_data_subs_to_notify_post_request_inner->traffic_influ_data = NULL;
}
ogs_free(_application_data_influence_data_subs_to_notify_post_request_inner);
}
cJSON *OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_convertToJSON(OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_t *_application_data_influence_data_subs_to_notify_post_request_inner)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (_application_data_influence_data_subs_to_notify_post_request_inner == NULL) {
ogs_error("OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_convertToJSON() failed [_application_data_influenceData_subs_to_notify_post_request_inner]");
return NULL;
}
item = cJSON_CreateObject();
if (!_application_data_influence_data_subs_to_notify_post_request_inner->res_uri) {
ogs_error("OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_convertToJSON() failed [res_uri]");
return NULL;
}
if (cJSON_AddStringToObject(item, "resUri", _application_data_influence_data_subs_to_notify_post_request_inner->res_uri) == NULL) {
ogs_error("OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_convertToJSON() failed [res_uri]");
goto end;
}
if (_application_data_influence_data_subs_to_notify_post_request_inner->traffic_influ_data) {
cJSON *traffic_influ_data_local_JSON = OpenAPI_traffic_influ_data_convertToJSON(_application_data_influence_data_subs_to_notify_post_request_inner->traffic_influ_data);
if (traffic_influ_data_local_JSON == NULL) {
ogs_error("OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_convertToJSON() failed [traffic_influ_data]");
goto end;
}
cJSON_AddItemToObject(item, "trafficInfluData", traffic_influ_data_local_JSON);
if (item->child == NULL) {
ogs_error("OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_convertToJSON() failed [traffic_influ_data]");
goto end;
}
}
end:
return item;
}
OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_t *OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_parseFromJSON(cJSON *_application_data_influence_data_subs_to_notify_post_request_innerJSON)
{
OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_t *_application_data_influence_data_subs_to_notify_post_request_inner_local_var = NULL;
OpenAPI_lnode_t *node = NULL;
cJSON *res_uri = NULL;
cJSON *traffic_influ_data = NULL;
OpenAPI_traffic_influ_data_t *traffic_influ_data_local_nonprim = NULL;
res_uri = cJSON_GetObjectItemCaseSensitive(_application_data_influence_data_subs_to_notify_post_request_innerJSON, "resUri");
if (!res_uri) {
ogs_error("OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_parseFromJSON() failed [res_uri]");
goto end;
}
if (!cJSON_IsString(res_uri)) {
ogs_error("OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_parseFromJSON() failed [res_uri]");
goto end;
}
traffic_influ_data = cJSON_GetObjectItemCaseSensitive(_application_data_influence_data_subs_to_notify_post_request_innerJSON, "trafficInfluData");
if (traffic_influ_data) {
traffic_influ_data_local_nonprim = OpenAPI_traffic_influ_data_parseFromJSON(traffic_influ_data);
}
_application_data_influence_data_subs_to_notify_post_request_inner_local_var = OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_create (
ogs_strdup(res_uri->valuestring),
traffic_influ_data ? traffic_influ_data_local_nonprim : NULL
);
return _application_data_influence_data_subs_to_notify_post_request_inner_local_var;
end:
if (traffic_influ_data_local_nonprim) {
OpenAPI_traffic_influ_data_free(traffic_influ_data_local_nonprim);
traffic_influ_data_local_nonprim = NULL;
}
return NULL;
}
OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_t *OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_copy(OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_t *dst, OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_t *src)
{
cJSON *item = NULL;
char *content = NULL;
ogs_assert(src);
item = OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_convertToJSON(src);
if (!item) {
ogs_error("OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_convertToJSON() failed");
return NULL;
}
content = cJSON_Print(item);
cJSON_Delete(item);
if (!content) {
ogs_error("cJSON_Print() failed");
return NULL;
}
item = cJSON_Parse(content);
ogs_free(content);
if (!item) {
ogs_error("cJSON_Parse() failed");
return NULL;
}
OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_free(dst);
dst = OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_parseFromJSON(item);
cJSON_Delete(item);
return dst;
}

View File

@ -0,0 +1,42 @@
/*
* _application_data_influence_data_subs_to_notify_post_request_inner.h
*
*
*/
#ifndef _OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_H_
#define _OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#include "traffic_influ_data.h"
#include "traffic_influ_data_notif.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_s OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_t;
typedef struct OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_s {
char *res_uri;
struct OpenAPI_traffic_influ_data_s *traffic_influ_data;
} OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_t;
OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_t *OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_create(
char *res_uri,
OpenAPI_traffic_influ_data_t *traffic_influ_data
);
void OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_free(OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_t *_application_data_influence_data_subs_to_notify_post_request_inner);
OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_t *OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_parseFromJSON(cJSON *_application_data_influence_data_subs_to_notify_post_request_innerJSON);
cJSON *OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_convertToJSON(OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_t *_application_data_influence_data_subs_to_notify_post_request_inner);
OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_t *OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_copy(OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_t *dst, OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_t *src);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI__application_data_influence_data_subs_to_notify_post_request_inner_H_ */

View File

@ -0,0 +1,211 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "api_ie_mapping.h"
OpenAPI_api_ie_mapping_t *OpenAPI_api_ie_mapping_create(
OpenAPI_api_signature_t *api_signature,
OpenAPI_http_method_e api_method,
OpenAPI_list_t *ie_list
)
{
OpenAPI_api_ie_mapping_t *api_ie_mapping_local_var = ogs_malloc(sizeof(OpenAPI_api_ie_mapping_t));
ogs_assert(api_ie_mapping_local_var);
api_ie_mapping_local_var->api_signature = api_signature;
api_ie_mapping_local_var->api_method = api_method;
api_ie_mapping_local_var->ie_list = ie_list;
return api_ie_mapping_local_var;
}
void OpenAPI_api_ie_mapping_free(OpenAPI_api_ie_mapping_t *api_ie_mapping)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == api_ie_mapping) {
return;
}
if (api_ie_mapping->api_signature) {
OpenAPI_api_signature_free(api_ie_mapping->api_signature);
api_ie_mapping->api_signature = NULL;
}
if (api_ie_mapping->ie_list) {
OpenAPI_list_for_each(api_ie_mapping->ie_list, node) {
OpenAPI_ie_info_free(node->data);
}
OpenAPI_list_free(api_ie_mapping->ie_list);
api_ie_mapping->ie_list = NULL;
}
ogs_free(api_ie_mapping);
}
cJSON *OpenAPI_api_ie_mapping_convertToJSON(OpenAPI_api_ie_mapping_t *api_ie_mapping)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (api_ie_mapping == NULL) {
ogs_error("OpenAPI_api_ie_mapping_convertToJSON() failed [ApiIeMapping]");
return NULL;
}
item = cJSON_CreateObject();
if (!api_ie_mapping->api_signature) {
ogs_error("OpenAPI_api_ie_mapping_convertToJSON() failed [api_signature]");
return NULL;
}
cJSON *api_signature_local_JSON = OpenAPI_api_signature_convertToJSON(api_ie_mapping->api_signature);
if (api_signature_local_JSON == NULL) {
ogs_error("OpenAPI_api_ie_mapping_convertToJSON() failed [api_signature]");
goto end;
}
cJSON_AddItemToObject(item, "apiSignature", api_signature_local_JSON);
if (item->child == NULL) {
ogs_error("OpenAPI_api_ie_mapping_convertToJSON() failed [api_signature]");
goto end;
}
if (api_ie_mapping->api_method == OpenAPI_http_method_NULL) {
ogs_error("OpenAPI_api_ie_mapping_convertToJSON() failed [api_method]");
return NULL;
}
if (cJSON_AddStringToObject(item, "apiMethod", OpenAPI_http_method_ToString(api_ie_mapping->api_method)) == NULL) {
ogs_error("OpenAPI_api_ie_mapping_convertToJSON() failed [api_method]");
goto end;
}
if (!api_ie_mapping->ie_list) {
ogs_error("OpenAPI_api_ie_mapping_convertToJSON() failed [ie_list]");
return NULL;
}
cJSON *ie_listList = cJSON_AddArrayToObject(item, "IeList");
if (ie_listList == NULL) {
ogs_error("OpenAPI_api_ie_mapping_convertToJSON() failed [ie_list]");
goto end;
}
OpenAPI_list_for_each(api_ie_mapping->ie_list, node) {
cJSON *itemLocal = OpenAPI_ie_info_convertToJSON(node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_api_ie_mapping_convertToJSON() failed [ie_list]");
goto end;
}
cJSON_AddItemToArray(ie_listList, itemLocal);
}
end:
return item;
}
OpenAPI_api_ie_mapping_t *OpenAPI_api_ie_mapping_parseFromJSON(cJSON *api_ie_mappingJSON)
{
OpenAPI_api_ie_mapping_t *api_ie_mapping_local_var = NULL;
OpenAPI_lnode_t *node = NULL;
cJSON *api_signature = NULL;
OpenAPI_api_signature_t *api_signature_local_nonprim = NULL;
cJSON *api_method = NULL;
OpenAPI_http_method_e api_methodVariable = 0;
cJSON *ie_list = NULL;
OpenAPI_list_t *ie_listList = NULL;
api_signature = cJSON_GetObjectItemCaseSensitive(api_ie_mappingJSON, "apiSignature");
if (!api_signature) {
ogs_error("OpenAPI_api_ie_mapping_parseFromJSON() failed [api_signature]");
goto end;
}
api_signature_local_nonprim = OpenAPI_api_signature_parseFromJSON(api_signature);
api_method = cJSON_GetObjectItemCaseSensitive(api_ie_mappingJSON, "apiMethod");
if (!api_method) {
ogs_error("OpenAPI_api_ie_mapping_parseFromJSON() failed [api_method]");
goto end;
}
if (!cJSON_IsString(api_method)) {
ogs_error("OpenAPI_api_ie_mapping_parseFromJSON() failed [api_method]");
goto end;
}
api_methodVariable = OpenAPI_http_method_FromString(api_method->valuestring);
ie_list = cJSON_GetObjectItemCaseSensitive(api_ie_mappingJSON, "IeList");
if (!ie_list) {
ogs_error("OpenAPI_api_ie_mapping_parseFromJSON() failed [ie_list]");
goto end;
}
cJSON *ie_list_local = NULL;
if (!cJSON_IsArray(ie_list)) {
ogs_error("OpenAPI_api_ie_mapping_parseFromJSON() failed [ie_list]");
goto end;
}
ie_listList = OpenAPI_list_create();
cJSON_ArrayForEach(ie_list_local, ie_list) {
if (!cJSON_IsObject(ie_list_local)) {
ogs_error("OpenAPI_api_ie_mapping_parseFromJSON() failed [ie_list]");
goto end;
}
OpenAPI_ie_info_t *ie_listItem = OpenAPI_ie_info_parseFromJSON(ie_list_local);
if (!ie_listItem) {
ogs_error("No ie_listItem");
OpenAPI_list_free(ie_listList);
goto end;
}
OpenAPI_list_add(ie_listList, ie_listItem);
}
api_ie_mapping_local_var = OpenAPI_api_ie_mapping_create (
api_signature_local_nonprim,
api_methodVariable,
ie_listList
);
return api_ie_mapping_local_var;
end:
if (api_signature_local_nonprim) {
OpenAPI_api_signature_free(api_signature_local_nonprim);
api_signature_local_nonprim = NULL;
}
if (ie_listList) {
OpenAPI_list_for_each(ie_listList, node) {
OpenAPI_ie_info_free(node->data);
}
OpenAPI_list_free(ie_listList);
ie_listList = NULL;
}
return NULL;
}
OpenAPI_api_ie_mapping_t *OpenAPI_api_ie_mapping_copy(OpenAPI_api_ie_mapping_t *dst, OpenAPI_api_ie_mapping_t *src)
{
cJSON *item = NULL;
char *content = NULL;
ogs_assert(src);
item = OpenAPI_api_ie_mapping_convertToJSON(src);
if (!item) {
ogs_error("OpenAPI_api_ie_mapping_convertToJSON() failed");
return NULL;
}
content = cJSON_Print(item);
cJSON_Delete(item);
if (!content) {
ogs_error("cJSON_Print() failed");
return NULL;
}
item = cJSON_Parse(content);
ogs_free(content);
if (!item) {
ogs_error("cJSON_Parse() failed");
return NULL;
}
OpenAPI_api_ie_mapping_free(dst);
dst = OpenAPI_api_ie_mapping_parseFromJSON(item);
cJSON_Delete(item);
return dst;
}

View File

@ -0,0 +1,45 @@
/*
* api_ie_mapping.h
*
* API URI to IE mapping on which the protection policy needs to be applied
*/
#ifndef _OpenAPI_api_ie_mapping_H_
#define _OpenAPI_api_ie_mapping_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#include "api_signature.h"
#include "http_method.h"
#include "ie_info.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct OpenAPI_api_ie_mapping_s OpenAPI_api_ie_mapping_t;
typedef struct OpenAPI_api_ie_mapping_s {
struct OpenAPI_api_signature_s *api_signature;
OpenAPI_http_method_e api_method;
OpenAPI_list_t *ie_list;
} OpenAPI_api_ie_mapping_t;
OpenAPI_api_ie_mapping_t *OpenAPI_api_ie_mapping_create(
OpenAPI_api_signature_t *api_signature,
OpenAPI_http_method_e api_method,
OpenAPI_list_t *ie_list
);
void OpenAPI_api_ie_mapping_free(OpenAPI_api_ie_mapping_t *api_ie_mapping);
OpenAPI_api_ie_mapping_t *OpenAPI_api_ie_mapping_parseFromJSON(cJSON *api_ie_mappingJSON);
cJSON *OpenAPI_api_ie_mapping_convertToJSON(OpenAPI_api_ie_mapping_t *api_ie_mapping);
OpenAPI_api_ie_mapping_t *OpenAPI_api_ie_mapping_copy(OpenAPI_api_ie_mapping_t *dst, OpenAPI_api_ie_mapping_t *src);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_api_ie_mapping_H_ */

View File

@ -0,0 +1,114 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "api_signature.h"
OpenAPI_api_signature_t *OpenAPI_api_signature_create(
char *callback_type
)
{
OpenAPI_api_signature_t *api_signature_local_var = ogs_malloc(sizeof(OpenAPI_api_signature_t));
ogs_assert(api_signature_local_var);
api_signature_local_var->callback_type = callback_type;
return api_signature_local_var;
}
void OpenAPI_api_signature_free(OpenAPI_api_signature_t *api_signature)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == api_signature) {
return;
}
if (api_signature->callback_type) {
ogs_free(api_signature->callback_type);
api_signature->callback_type = NULL;
}
ogs_free(api_signature);
}
cJSON *OpenAPI_api_signature_convertToJSON(OpenAPI_api_signature_t *api_signature)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (api_signature == NULL) {
ogs_error("OpenAPI_api_signature_convertToJSON() failed [ApiSignature]");
return NULL;
}
item = cJSON_CreateObject();
if (!api_signature->callback_type) {
ogs_error("OpenAPI_api_signature_convertToJSON() failed [callback_type]");
return NULL;
}
if (cJSON_AddStringToObject(item, "callbackType", api_signature->callback_type) == NULL) {
ogs_error("OpenAPI_api_signature_convertToJSON() failed [callback_type]");
goto end;
}
end:
return item;
}
OpenAPI_api_signature_t *OpenAPI_api_signature_parseFromJSON(cJSON *api_signatureJSON)
{
OpenAPI_api_signature_t *api_signature_local_var = NULL;
OpenAPI_lnode_t *node = NULL;
cJSON *callback_type = NULL;
callback_type = cJSON_GetObjectItemCaseSensitive(api_signatureJSON, "callbackType");
if (!callback_type) {
ogs_error("OpenAPI_api_signature_parseFromJSON() failed [callback_type]");
goto end;
}
if (!cJSON_IsString(callback_type)) {
ogs_error("OpenAPI_api_signature_parseFromJSON() failed [callback_type]");
goto end;
}
api_signature_local_var = OpenAPI_api_signature_create (
ogs_strdup(callback_type->valuestring)
);
return api_signature_local_var;
end:
return NULL;
}
OpenAPI_api_signature_t *OpenAPI_api_signature_copy(OpenAPI_api_signature_t *dst, OpenAPI_api_signature_t *src)
{
cJSON *item = NULL;
char *content = NULL;
ogs_assert(src);
item = OpenAPI_api_signature_convertToJSON(src);
if (!item) {
ogs_error("OpenAPI_api_signature_convertToJSON() failed");
return NULL;
}
content = cJSON_Print(item);
cJSON_Delete(item);
if (!content) {
ogs_error("cJSON_Print() failed");
return NULL;
}
item = cJSON_Parse(content);
ogs_free(content);
if (!item) {
ogs_error("cJSON_Parse() failed");
return NULL;
}
OpenAPI_api_signature_free(dst);
dst = OpenAPI_api_signature_parseFromJSON(item);
cJSON_Delete(item);
return dst;
}

View File

@ -0,0 +1,39 @@
/*
* api_signature.h
*
* API URI of the service operation
*/
#ifndef _OpenAPI_api_signature_H_
#define _OpenAPI_api_signature_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#include "callback_name.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct OpenAPI_api_signature_s OpenAPI_api_signature_t;
typedef struct OpenAPI_api_signature_s {
char *callback_type;
} OpenAPI_api_signature_t;
OpenAPI_api_signature_t *OpenAPI_api_signature_create(
char *callback_type
);
void OpenAPI_api_signature_free(OpenAPI_api_signature_t *api_signature);
OpenAPI_api_signature_t *OpenAPI_api_signature_parseFromJSON(cJSON *api_signatureJSON);
cJSON *OpenAPI_api_signature_convertToJSON(OpenAPI_api_signature_t *api_signature);
OpenAPI_api_signature_t *OpenAPI_api_signature_copy(OpenAPI_api_signature_t *dst, OpenAPI_api_signature_t *src);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_api_signature_H_ */

View File

@ -0,0 +1,114 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "callback_name.h"
OpenAPI_callback_name_t *OpenAPI_callback_name_create(
char *callback_type
)
{
OpenAPI_callback_name_t *callback_name_local_var = ogs_malloc(sizeof(OpenAPI_callback_name_t));
ogs_assert(callback_name_local_var);
callback_name_local_var->callback_type = callback_type;
return callback_name_local_var;
}
void OpenAPI_callback_name_free(OpenAPI_callback_name_t *callback_name)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == callback_name) {
return;
}
if (callback_name->callback_type) {
ogs_free(callback_name->callback_type);
callback_name->callback_type = NULL;
}
ogs_free(callback_name);
}
cJSON *OpenAPI_callback_name_convertToJSON(OpenAPI_callback_name_t *callback_name)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (callback_name == NULL) {
ogs_error("OpenAPI_callback_name_convertToJSON() failed [CallbackName]");
return NULL;
}
item = cJSON_CreateObject();
if (!callback_name->callback_type) {
ogs_error("OpenAPI_callback_name_convertToJSON() failed [callback_type]");
return NULL;
}
if (cJSON_AddStringToObject(item, "callbackType", callback_name->callback_type) == NULL) {
ogs_error("OpenAPI_callback_name_convertToJSON() failed [callback_type]");
goto end;
}
end:
return item;
}
OpenAPI_callback_name_t *OpenAPI_callback_name_parseFromJSON(cJSON *callback_nameJSON)
{
OpenAPI_callback_name_t *callback_name_local_var = NULL;
OpenAPI_lnode_t *node = NULL;
cJSON *callback_type = NULL;
callback_type = cJSON_GetObjectItemCaseSensitive(callback_nameJSON, "callbackType");
if (!callback_type) {
ogs_error("OpenAPI_callback_name_parseFromJSON() failed [callback_type]");
goto end;
}
if (!cJSON_IsString(callback_type)) {
ogs_error("OpenAPI_callback_name_parseFromJSON() failed [callback_type]");
goto end;
}
callback_name_local_var = OpenAPI_callback_name_create (
ogs_strdup(callback_type->valuestring)
);
return callback_name_local_var;
end:
return NULL;
}
OpenAPI_callback_name_t *OpenAPI_callback_name_copy(OpenAPI_callback_name_t *dst, OpenAPI_callback_name_t *src)
{
cJSON *item = NULL;
char *content = NULL;
ogs_assert(src);
item = OpenAPI_callback_name_convertToJSON(src);
if (!item) {
ogs_error("OpenAPI_callback_name_convertToJSON() failed");
return NULL;
}
content = cJSON_Print(item);
cJSON_Delete(item);
if (!content) {
ogs_error("cJSON_Print() failed");
return NULL;
}
item = cJSON_Parse(content);
ogs_free(content);
if (!item) {
ogs_error("cJSON_Parse() failed");
return NULL;
}
OpenAPI_callback_name_free(dst);
dst = OpenAPI_callback_name_parseFromJSON(item);
cJSON_Delete(item);
return dst;
}

View File

@ -0,0 +1,38 @@
/*
* callback_name.h
*
* Callback Name
*/
#ifndef _OpenAPI_callback_name_H_
#define _OpenAPI_callback_name_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct OpenAPI_callback_name_s OpenAPI_callback_name_t;
typedef struct OpenAPI_callback_name_s {
char *callback_type;
} OpenAPI_callback_name_t;
OpenAPI_callback_name_t *OpenAPI_callback_name_create(
char *callback_type
);
void OpenAPI_callback_name_free(OpenAPI_callback_name_t *callback_name);
OpenAPI_callback_name_t *OpenAPI_callback_name_parseFromJSON(cJSON *callback_nameJSON);
cJSON *OpenAPI_callback_name_convertToJSON(OpenAPI_callback_name_t *callback_name);
OpenAPI_callback_name_t *OpenAPI_callback_name_copy(OpenAPI_callback_name_t *dst, OpenAPI_callback_name_t *src);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_callback_name_H_ */

View File

@ -0,0 +1,139 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "failed_modification_info.h"
OpenAPI_failed_modification_info_t *OpenAPI_failed_modification_info_create(
char *ipx_id,
OpenAPI_n32f_error_type_e n32f_error_type
)
{
OpenAPI_failed_modification_info_t *failed_modification_info_local_var = ogs_malloc(sizeof(OpenAPI_failed_modification_info_t));
ogs_assert(failed_modification_info_local_var);
failed_modification_info_local_var->ipx_id = ipx_id;
failed_modification_info_local_var->n32f_error_type = n32f_error_type;
return failed_modification_info_local_var;
}
void OpenAPI_failed_modification_info_free(OpenAPI_failed_modification_info_t *failed_modification_info)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == failed_modification_info) {
return;
}
if (failed_modification_info->ipx_id) {
ogs_free(failed_modification_info->ipx_id);
failed_modification_info->ipx_id = NULL;
}
ogs_free(failed_modification_info);
}
cJSON *OpenAPI_failed_modification_info_convertToJSON(OpenAPI_failed_modification_info_t *failed_modification_info)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (failed_modification_info == NULL) {
ogs_error("OpenAPI_failed_modification_info_convertToJSON() failed [FailedModificationInfo]");
return NULL;
}
item = cJSON_CreateObject();
if (!failed_modification_info->ipx_id) {
ogs_error("OpenAPI_failed_modification_info_convertToJSON() failed [ipx_id]");
return NULL;
}
if (cJSON_AddStringToObject(item, "ipxId", failed_modification_info->ipx_id) == NULL) {
ogs_error("OpenAPI_failed_modification_info_convertToJSON() failed [ipx_id]");
goto end;
}
if (failed_modification_info->n32f_error_type == OpenAPI_n32f_error_type_NULL) {
ogs_error("OpenAPI_failed_modification_info_convertToJSON() failed [n32f_error_type]");
return NULL;
}
if (cJSON_AddStringToObject(item, "n32fErrorType", OpenAPI_n32f_error_type_ToString(failed_modification_info->n32f_error_type)) == NULL) {
ogs_error("OpenAPI_failed_modification_info_convertToJSON() failed [n32f_error_type]");
goto end;
}
end:
return item;
}
OpenAPI_failed_modification_info_t *OpenAPI_failed_modification_info_parseFromJSON(cJSON *failed_modification_infoJSON)
{
OpenAPI_failed_modification_info_t *failed_modification_info_local_var = NULL;
OpenAPI_lnode_t *node = NULL;
cJSON *ipx_id = NULL;
cJSON *n32f_error_type = NULL;
OpenAPI_n32f_error_type_e n32f_error_typeVariable = 0;
ipx_id = cJSON_GetObjectItemCaseSensitive(failed_modification_infoJSON, "ipxId");
if (!ipx_id) {
ogs_error("OpenAPI_failed_modification_info_parseFromJSON() failed [ipx_id]");
goto end;
}
if (!cJSON_IsString(ipx_id)) {
ogs_error("OpenAPI_failed_modification_info_parseFromJSON() failed [ipx_id]");
goto end;
}
n32f_error_type = cJSON_GetObjectItemCaseSensitive(failed_modification_infoJSON, "n32fErrorType");
if (!n32f_error_type) {
ogs_error("OpenAPI_failed_modification_info_parseFromJSON() failed [n32f_error_type]");
goto end;
}
if (!cJSON_IsString(n32f_error_type)) {
ogs_error("OpenAPI_failed_modification_info_parseFromJSON() failed [n32f_error_type]");
goto end;
}
n32f_error_typeVariable = OpenAPI_n32f_error_type_FromString(n32f_error_type->valuestring);
failed_modification_info_local_var = OpenAPI_failed_modification_info_create (
ogs_strdup(ipx_id->valuestring),
n32f_error_typeVariable
);
return failed_modification_info_local_var;
end:
return NULL;
}
OpenAPI_failed_modification_info_t *OpenAPI_failed_modification_info_copy(OpenAPI_failed_modification_info_t *dst, OpenAPI_failed_modification_info_t *src)
{
cJSON *item = NULL;
char *content = NULL;
ogs_assert(src);
item = OpenAPI_failed_modification_info_convertToJSON(src);
if (!item) {
ogs_error("OpenAPI_failed_modification_info_convertToJSON() failed");
return NULL;
}
content = cJSON_Print(item);
cJSON_Delete(item);
if (!content) {
ogs_error("cJSON_Print() failed");
return NULL;
}
item = cJSON_Parse(content);
ogs_free(content);
if (!item) {
ogs_error("cJSON_Parse() failed");
return NULL;
}
OpenAPI_failed_modification_info_free(dst);
dst = OpenAPI_failed_modification_info_parseFromJSON(item);
cJSON_Delete(item);
return dst;
}

View File

@ -0,0 +1,41 @@
/*
* failed_modification_info.h
*
* Information on N32-f modifications block that failed to process
*/
#ifndef _OpenAPI_failed_modification_info_H_
#define _OpenAPI_failed_modification_info_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#include "n32f_error_type.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct OpenAPI_failed_modification_info_s OpenAPI_failed_modification_info_t;
typedef struct OpenAPI_failed_modification_info_s {
char *ipx_id;
OpenAPI_n32f_error_type_e n32f_error_type;
} OpenAPI_failed_modification_info_t;
OpenAPI_failed_modification_info_t *OpenAPI_failed_modification_info_create(
char *ipx_id,
OpenAPI_n32f_error_type_e n32f_error_type
);
void OpenAPI_failed_modification_info_free(OpenAPI_failed_modification_info_t *failed_modification_info);
OpenAPI_failed_modification_info_t *OpenAPI_failed_modification_info_parseFromJSON(cJSON *failed_modification_infoJSON);
cJSON *OpenAPI_failed_modification_info_convertToJSON(OpenAPI_failed_modification_info_t *failed_modification_info);
OpenAPI_failed_modification_info_t *OpenAPI_failed_modification_info_copy(OpenAPI_failed_modification_info_t *dst, OpenAPI_failed_modification_info_t *src);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_failed_modification_info_H_ */

View File

@ -0,0 +1,30 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "failure_reason.h"
char* OpenAPI_failure_reason_ToString(OpenAPI_failure_reason_e failure_reason)
{
const char *failure_reasonArray[] = { "NULL", "INVALID_JSON_POINTER", "INVALID_INDEX_TO_ENCRYPTED_BLOCK", "INVALID_HTTP_HEADER" };
size_t sizeofArray = sizeof(failure_reasonArray) / sizeof(failure_reasonArray[0]);
if (failure_reason < sizeofArray)
return (char *)failure_reasonArray[failure_reason];
else
return (char *)"Unknown";
}
OpenAPI_failure_reason_e OpenAPI_failure_reason_FromString(char* failure_reason)
{
int stringToReturn = 0;
const char *failure_reasonArray[] = { "NULL", "INVALID_JSON_POINTER", "INVALID_INDEX_TO_ENCRYPTED_BLOCK", "INVALID_HTTP_HEADER" };
size_t sizeofArray = sizeof(failure_reasonArray) / sizeof(failure_reasonArray[0]);
while (stringToReturn < sizeofArray) {
if (strcmp(failure_reason, failure_reasonArray[stringToReturn]) == 0) {
return stringToReturn;
}
stringToReturn++;
}
return 0;
}

View File

@ -0,0 +1,31 @@
/*
* failure_reason.h
*
*
*/
#ifndef _OpenAPI_failure_reason_H_
#define _OpenAPI_failure_reason_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum { OpenAPI_failure_reason_NULL = 0, OpenAPI_failure_reason_INVALID_JSON_POINTER, OpenAPI_failure_reason_INVALID_INDEX_TO_ENCRYPTED_BLOCK, OpenAPI_failure_reason_INVALID_HTTP_HEADER } OpenAPI_failure_reason_e;
char* OpenAPI_failure_reason_ToString(OpenAPI_failure_reason_e failure_reason);
OpenAPI_failure_reason_e OpenAPI_failure_reason_FromString(char* failure_reason);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_failure_reason_H_ */

View File

@ -0,0 +1,30 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "failure_reason_any_of.h"
char* OpenAPI_failure_reason_any_of_ToString(OpenAPI_failure_reason_any_of_e failure_reason_any_of)
{
const char *failure_reason_any_ofArray[] = { "NULL", "INVALID_JSON_POINTER", "INVALID_INDEX_TO_ENCRYPTED_BLOCK", "INVALID_HTTP_HEADER" };
size_t sizeofArray = sizeof(failure_reason_any_ofArray) / sizeof(failure_reason_any_ofArray[0]);
if (failure_reason_any_of < sizeofArray)
return (char *)failure_reason_any_ofArray[failure_reason_any_of];
else
return (char *)"Unknown";
}
OpenAPI_failure_reason_any_of_e OpenAPI_failure_reason_any_of_FromString(char* failure_reason_any_of)
{
int stringToReturn = 0;
const char *failure_reason_any_ofArray[] = { "NULL", "INVALID_JSON_POINTER", "INVALID_INDEX_TO_ENCRYPTED_BLOCK", "INVALID_HTTP_HEADER" };
size_t sizeofArray = sizeof(failure_reason_any_ofArray) / sizeof(failure_reason_any_ofArray[0]);
while (stringToReturn < sizeofArray) {
if (strcmp(failure_reason_any_of, failure_reason_any_ofArray[stringToReturn]) == 0) {
return stringToReturn;
}
stringToReturn++;
}
return 0;
}

View File

@ -0,0 +1,31 @@
/*
* failure_reason_any_of.h
*
*
*/
#ifndef _OpenAPI_failure_reason_any_of_H_
#define _OpenAPI_failure_reason_any_of_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum { OpenAPI_failure_reason_any_of_NULL = 0, OpenAPI_failure_reason_any_of_INVALID_JSON_POINTER, OpenAPI_failure_reason_any_of_INVALID_INDEX_TO_ENCRYPTED_BLOCK, OpenAPI_failure_reason_any_of_INVALID_HTTP_HEADER } OpenAPI_failure_reason_any_of_e;
char* OpenAPI_failure_reason_any_of_ToString(OpenAPI_failure_reason_any_of_e failure_reason_any_of);
OpenAPI_failure_reason_any_of_e OpenAPI_failure_reason_any_of_FromString(char* failure_reason_any_of);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_failure_reason_any_of_H_ */

View File

@ -0,0 +1,30 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "http_method.h"
char* OpenAPI_http_method_ToString(OpenAPI_http_method_e http_method)
{
const char *http_methodArray[] = { "NULL", "GET", "PUT", "POST", "DELETE", "PATCH", "HEAD", "OPTIONS", "CONNECT", "TRACE" };
size_t sizeofArray = sizeof(http_methodArray) / sizeof(http_methodArray[0]);
if (http_method < sizeofArray)
return (char *)http_methodArray[http_method];
else
return (char *)"Unknown";
}
OpenAPI_http_method_e OpenAPI_http_method_FromString(char* http_method)
{
int stringToReturn = 0;
const char *http_methodArray[] = { "NULL", "GET", "PUT", "POST", "DELETE", "PATCH", "HEAD", "OPTIONS", "CONNECT", "TRACE" };
size_t sizeofArray = sizeof(http_methodArray) / sizeof(http_methodArray[0]);
while (stringToReturn < sizeofArray) {
if (strcmp(http_method, http_methodArray[stringToReturn]) == 0) {
return stringToReturn;
}
stringToReturn++;
}
return 0;
}

View File

@ -0,0 +1,31 @@
/*
* http_method.h
*
*
*/
#ifndef _OpenAPI_http_method_H_
#define _OpenAPI_http_method_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum { OpenAPI_http_method_NULL = 0, OpenAPI_http_method_GET, OpenAPI_http_method_PUT, OpenAPI_http_method_POST, OpenAPI_http_method__DELETE, OpenAPI_http_method_PATCH, OpenAPI_http_method_HEAD, OpenAPI_http_method_OPTIONS, OpenAPI_http_method_CONNECT, OpenAPI_http_method_TRACE } OpenAPI_http_method_e;
char* OpenAPI_http_method_ToString(OpenAPI_http_method_e http_method);
OpenAPI_http_method_e OpenAPI_http_method_FromString(char* http_method);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_http_method_H_ */

View File

@ -0,0 +1,30 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "http_method_any_of.h"
char* OpenAPI_http_method_any_of_ToString(OpenAPI_http_method_any_of_e http_method_any_of)
{
const char *http_method_any_ofArray[] = { "NULL", "GET", "PUT", "POST", "DELETE", "PATCH", "HEAD", "OPTIONS", "CONNECT", "TRACE" };
size_t sizeofArray = sizeof(http_method_any_ofArray) / sizeof(http_method_any_ofArray[0]);
if (http_method_any_of < sizeofArray)
return (char *)http_method_any_ofArray[http_method_any_of];
else
return (char *)"Unknown";
}
OpenAPI_http_method_any_of_e OpenAPI_http_method_any_of_FromString(char* http_method_any_of)
{
int stringToReturn = 0;
const char *http_method_any_ofArray[] = { "NULL", "GET", "PUT", "POST", "DELETE", "PATCH", "HEAD", "OPTIONS", "CONNECT", "TRACE" };
size_t sizeofArray = sizeof(http_method_any_ofArray) / sizeof(http_method_any_ofArray[0]);
while (stringToReturn < sizeofArray) {
if (strcmp(http_method_any_of, http_method_any_ofArray[stringToReturn]) == 0) {
return stringToReturn;
}
stringToReturn++;
}
return 0;
}

View File

@ -0,0 +1,31 @@
/*
* http_method_any_of.h
*
*
*/
#ifndef _OpenAPI_http_method_any_of_H_
#define _OpenAPI_http_method_any_of_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum { OpenAPI_http_method_any_of_NULL = 0, OpenAPI_http_method_any_of_GET, OpenAPI_http_method_any_of_PUT, OpenAPI_http_method_any_of_POST, OpenAPI_http_method_any_of__DELETE, OpenAPI_http_method_any_of_PATCH, OpenAPI_http_method_any_of_HEAD, OpenAPI_http_method_any_of_OPTIONS, OpenAPI_http_method_any_of_CONNECT, OpenAPI_http_method_any_of_TRACE } OpenAPI_http_method_any_of_e;
char* OpenAPI_http_method_any_of_ToString(OpenAPI_http_method_any_of_e http_method_any_of);
OpenAPI_http_method_any_of_e OpenAPI_http_method_any_of_FromString(char* http_method_any_of);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_http_method_any_of_H_ */

View File

@ -0,0 +1,278 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "ie_info.h"
OpenAPI_ie_info_t *OpenAPI_ie_info_create(
OpenAPI_ie_location_e ie_loc,
OpenAPI_ie_type_e ie_type,
char *req_ie,
char *rsp_ie,
bool is_is_modifiable,
int is_modifiable,
OpenAPI_list_t* is_modifiable_by_ipx
)
{
OpenAPI_ie_info_t *ie_info_local_var = ogs_malloc(sizeof(OpenAPI_ie_info_t));
ogs_assert(ie_info_local_var);
ie_info_local_var->ie_loc = ie_loc;
ie_info_local_var->ie_type = ie_type;
ie_info_local_var->req_ie = req_ie;
ie_info_local_var->rsp_ie = rsp_ie;
ie_info_local_var->is_is_modifiable = is_is_modifiable;
ie_info_local_var->is_modifiable = is_modifiable;
ie_info_local_var->is_modifiable_by_ipx = is_modifiable_by_ipx;
return ie_info_local_var;
}
void OpenAPI_ie_info_free(OpenAPI_ie_info_t *ie_info)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == ie_info) {
return;
}
if (ie_info->req_ie) {
ogs_free(ie_info->req_ie);
ie_info->req_ie = NULL;
}
if (ie_info->rsp_ie) {
ogs_free(ie_info->rsp_ie);
ie_info->rsp_ie = NULL;
}
if (ie_info->is_modifiable_by_ipx) {
OpenAPI_list_for_each(ie_info->is_modifiable_by_ipx, node) {
OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data;
ogs_free(localKeyValue->key);
ogs_free(localKeyValue->value);
OpenAPI_map_free(localKeyValue);
}
OpenAPI_list_free(ie_info->is_modifiable_by_ipx);
ie_info->is_modifiable_by_ipx = NULL;
}
ogs_free(ie_info);
}
cJSON *OpenAPI_ie_info_convertToJSON(OpenAPI_ie_info_t *ie_info)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (ie_info == NULL) {
ogs_error("OpenAPI_ie_info_convertToJSON() failed [IeInfo]");
return NULL;
}
item = cJSON_CreateObject();
if (ie_info->ie_loc == OpenAPI_ie_location_NULL) {
ogs_error("OpenAPI_ie_info_convertToJSON() failed [ie_loc]");
return NULL;
}
if (cJSON_AddStringToObject(item, "ieLoc", OpenAPI_ie_location_ToString(ie_info->ie_loc)) == NULL) {
ogs_error("OpenAPI_ie_info_convertToJSON() failed [ie_loc]");
goto end;
}
if (ie_info->ie_type == OpenAPI_ie_type_NULL) {
ogs_error("OpenAPI_ie_info_convertToJSON() failed [ie_type]");
return NULL;
}
if (cJSON_AddStringToObject(item, "ieType", OpenAPI_ie_type_ToString(ie_info->ie_type)) == NULL) {
ogs_error("OpenAPI_ie_info_convertToJSON() failed [ie_type]");
goto end;
}
if (ie_info->req_ie) {
if (cJSON_AddStringToObject(item, "reqIe", ie_info->req_ie) == NULL) {
ogs_error("OpenAPI_ie_info_convertToJSON() failed [req_ie]");
goto end;
}
}
if (ie_info->rsp_ie) {
if (cJSON_AddStringToObject(item, "rspIe", ie_info->rsp_ie) == NULL) {
ogs_error("OpenAPI_ie_info_convertToJSON() failed [rsp_ie]");
goto end;
}
}
if (ie_info->is_is_modifiable) {
if (cJSON_AddBoolToObject(item, "isModifiable", ie_info->is_modifiable) == NULL) {
ogs_error("OpenAPI_ie_info_convertToJSON() failed [is_modifiable]");
goto end;
}
}
if (ie_info->is_modifiable_by_ipx) {
cJSON *is_modifiable_by_ipx = cJSON_AddObjectToObject(item, "isModifiableByIpx");
if (is_modifiable_by_ipx == NULL) {
ogs_error("OpenAPI_ie_info_convertToJSON() failed [is_modifiable_by_ipx]");
goto end;
}
cJSON *localMapObject = is_modifiable_by_ipx;
if (ie_info->is_modifiable_by_ipx) {
OpenAPI_list_for_each(ie_info->is_modifiable_by_ipx, node) {
OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*)node->data;
if (cJSON_AddBoolToObject(localMapObject, localKeyValue->key, (uintptr_t)localKeyValue->value) == NULL) {
ogs_error("OpenAPI_ie_info_convertToJSON() failed [inner]");
goto end;
}
}
}
}
end:
return item;
}
OpenAPI_ie_info_t *OpenAPI_ie_info_parseFromJSON(cJSON *ie_infoJSON)
{
OpenAPI_ie_info_t *ie_info_local_var = NULL;
OpenAPI_lnode_t *node = NULL;
cJSON *ie_loc = NULL;
OpenAPI_ie_location_e ie_locVariable = 0;
cJSON *ie_type = NULL;
OpenAPI_ie_type_e ie_typeVariable = 0;
cJSON *req_ie = NULL;
cJSON *rsp_ie = NULL;
cJSON *is_modifiable = NULL;
cJSON *is_modifiable_by_ipx = NULL;
OpenAPI_list_t *is_modifiable_by_ipxList = NULL;
ie_loc = cJSON_GetObjectItemCaseSensitive(ie_infoJSON, "ieLoc");
if (!ie_loc) {
ogs_error("OpenAPI_ie_info_parseFromJSON() failed [ie_loc]");
goto end;
}
if (!cJSON_IsString(ie_loc)) {
ogs_error("OpenAPI_ie_info_parseFromJSON() failed [ie_loc]");
goto end;
}
ie_locVariable = OpenAPI_ie_location_FromString(ie_loc->valuestring);
ie_type = cJSON_GetObjectItemCaseSensitive(ie_infoJSON, "ieType");
if (!ie_type) {
ogs_error("OpenAPI_ie_info_parseFromJSON() failed [ie_type]");
goto end;
}
if (!cJSON_IsString(ie_type)) {
ogs_error("OpenAPI_ie_info_parseFromJSON() failed [ie_type]");
goto end;
}
ie_typeVariable = OpenAPI_ie_type_FromString(ie_type->valuestring);
req_ie = cJSON_GetObjectItemCaseSensitive(ie_infoJSON, "reqIe");
if (req_ie) {
if (!cJSON_IsString(req_ie) && !cJSON_IsNull(req_ie)) {
ogs_error("OpenAPI_ie_info_parseFromJSON() failed [req_ie]");
goto end;
}
}
rsp_ie = cJSON_GetObjectItemCaseSensitive(ie_infoJSON, "rspIe");
if (rsp_ie) {
if (!cJSON_IsString(rsp_ie) && !cJSON_IsNull(rsp_ie)) {
ogs_error("OpenAPI_ie_info_parseFromJSON() failed [rsp_ie]");
goto end;
}
}
is_modifiable = cJSON_GetObjectItemCaseSensitive(ie_infoJSON, "isModifiable");
if (is_modifiable) {
if (!cJSON_IsBool(is_modifiable)) {
ogs_error("OpenAPI_ie_info_parseFromJSON() failed [is_modifiable]");
goto end;
}
}
is_modifiable_by_ipx = cJSON_GetObjectItemCaseSensitive(ie_infoJSON, "isModifiableByIpx");
if (is_modifiable_by_ipx) {
cJSON *is_modifiable_by_ipx_local_map = NULL;
if (!cJSON_IsObject(is_modifiable_by_ipx) && !cJSON_IsNull(is_modifiable_by_ipx)) {
ogs_error("OpenAPI_ie_info_parseFromJSON() failed [is_modifiable_by_ipx]");
goto end;
}
if (cJSON_IsObject(is_modifiable_by_ipx)) {
is_modifiable_by_ipxList = OpenAPI_list_create();
OpenAPI_map_t *localMapKeyPair = NULL;
cJSON_ArrayForEach(is_modifiable_by_ipx_local_map, is_modifiable_by_ipx) {
cJSON *localMapObject = is_modifiable_by_ipx_local_map;
double *localDouble = NULL;
int *localInt = NULL;
if (!cJSON_IsBool(localMapObject)) {
ogs_error("OpenAPI_ie_info_parseFromJSON() failed [inner]");
goto end;
}
localInt = (int *)ogs_calloc(1, sizeof(int));
if (!localInt) {
ogs_error("OpenAPI_ie_info_parseFromJSON() failed [inner]");
goto end;
}
*localInt = localMapObject->valueint;
localMapKeyPair = OpenAPI_map_create(ogs_strdup(localMapObject->string), localInt);
OpenAPI_list_add(is_modifiable_by_ipxList, localMapKeyPair);
}
}
}
ie_info_local_var = OpenAPI_ie_info_create (
ie_locVariable,
ie_typeVariable,
req_ie && !cJSON_IsNull(req_ie) ? ogs_strdup(req_ie->valuestring) : NULL,
rsp_ie && !cJSON_IsNull(rsp_ie) ? ogs_strdup(rsp_ie->valuestring) : NULL,
is_modifiable ? true : false,
is_modifiable ? is_modifiable->valueint : 0,
is_modifiable_by_ipx ? is_modifiable_by_ipxList : NULL
);
return ie_info_local_var;
end:
if (is_modifiable_by_ipxList) {
OpenAPI_list_for_each(is_modifiable_by_ipxList, node) {
OpenAPI_map_t *localKeyValue = (OpenAPI_map_t*) node->data;
ogs_free(localKeyValue->key);
ogs_free(localKeyValue->value);
OpenAPI_map_free(localKeyValue);
}
OpenAPI_list_free(is_modifiable_by_ipxList);
is_modifiable_by_ipxList = NULL;
}
return NULL;
}
OpenAPI_ie_info_t *OpenAPI_ie_info_copy(OpenAPI_ie_info_t *dst, OpenAPI_ie_info_t *src)
{
cJSON *item = NULL;
char *content = NULL;
ogs_assert(src);
item = OpenAPI_ie_info_convertToJSON(src);
if (!item) {
ogs_error("OpenAPI_ie_info_convertToJSON() failed");
return NULL;
}
content = cJSON_Print(item);
cJSON_Delete(item);
if (!content) {
ogs_error("cJSON_Print() failed");
return NULL;
}
item = cJSON_Parse(content);
ogs_free(content);
if (!item) {
ogs_error("cJSON_Parse() failed");
return NULL;
}
OpenAPI_ie_info_free(dst);
dst = OpenAPI_ie_info_parseFromJSON(item);
cJSON_Delete(item);
return dst;
}

View File

@ -0,0 +1,52 @@
/*
* ie_info.h
*
* Protection and modification policy for the IE
*/
#ifndef _OpenAPI_ie_info_H_
#define _OpenAPI_ie_info_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#include "ie_location.h"
#include "ie_type.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct OpenAPI_ie_info_s OpenAPI_ie_info_t;
typedef struct OpenAPI_ie_info_s {
OpenAPI_ie_location_e ie_loc;
OpenAPI_ie_type_e ie_type;
char *req_ie;
char *rsp_ie;
bool is_is_modifiable;
int is_modifiable;
OpenAPI_list_t* is_modifiable_by_ipx;
} OpenAPI_ie_info_t;
OpenAPI_ie_info_t *OpenAPI_ie_info_create(
OpenAPI_ie_location_e ie_loc,
OpenAPI_ie_type_e ie_type,
char *req_ie,
char *rsp_ie,
bool is_is_modifiable,
int is_modifiable,
OpenAPI_list_t* is_modifiable_by_ipx
);
void OpenAPI_ie_info_free(OpenAPI_ie_info_t *ie_info);
OpenAPI_ie_info_t *OpenAPI_ie_info_parseFromJSON(cJSON *ie_infoJSON);
cJSON *OpenAPI_ie_info_convertToJSON(OpenAPI_ie_info_t *ie_info);
OpenAPI_ie_info_t *OpenAPI_ie_info_copy(OpenAPI_ie_info_t *dst, OpenAPI_ie_info_t *src);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_ie_info_H_ */

View File

@ -0,0 +1,30 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "ie_location.h"
char* OpenAPI_ie_location_ToString(OpenAPI_ie_location_e ie_location)
{
const char *ie_locationArray[] = { "NULL", "URI_PARAM", "HEADER", "BODY", "MULTIPART_BINARY" };
size_t sizeofArray = sizeof(ie_locationArray) / sizeof(ie_locationArray[0]);
if (ie_location < sizeofArray)
return (char *)ie_locationArray[ie_location];
else
return (char *)"Unknown";
}
OpenAPI_ie_location_e OpenAPI_ie_location_FromString(char* ie_location)
{
int stringToReturn = 0;
const char *ie_locationArray[] = { "NULL", "URI_PARAM", "HEADER", "BODY", "MULTIPART_BINARY" };
size_t sizeofArray = sizeof(ie_locationArray) / sizeof(ie_locationArray[0]);
while (stringToReturn < sizeofArray) {
if (strcmp(ie_location, ie_locationArray[stringToReturn]) == 0) {
return stringToReturn;
}
stringToReturn++;
}
return 0;
}

View File

@ -0,0 +1,31 @@
/*
* ie_location.h
*
*
*/
#ifndef _OpenAPI_ie_location_H_
#define _OpenAPI_ie_location_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum { OpenAPI_ie_location_NULL = 0, OpenAPI_ie_location_URI_PARAM, OpenAPI_ie_location_HEADER, OpenAPI_ie_location_BODY, OpenAPI_ie_location_MULTIPART_BINARY } OpenAPI_ie_location_e;
char* OpenAPI_ie_location_ToString(OpenAPI_ie_location_e ie_location);
OpenAPI_ie_location_e OpenAPI_ie_location_FromString(char* ie_location);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_ie_location_H_ */

View File

@ -0,0 +1,30 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "ie_location_any_of.h"
char* OpenAPI_ie_location_any_of_ToString(OpenAPI_ie_location_any_of_e ie_location_any_of)
{
const char *ie_location_any_ofArray[] = { "NULL", "URI_PARAM", "HEADER", "BODY", "MULTIPART_BINARY" };
size_t sizeofArray = sizeof(ie_location_any_ofArray) / sizeof(ie_location_any_ofArray[0]);
if (ie_location_any_of < sizeofArray)
return (char *)ie_location_any_ofArray[ie_location_any_of];
else
return (char *)"Unknown";
}
OpenAPI_ie_location_any_of_e OpenAPI_ie_location_any_of_FromString(char* ie_location_any_of)
{
int stringToReturn = 0;
const char *ie_location_any_ofArray[] = { "NULL", "URI_PARAM", "HEADER", "BODY", "MULTIPART_BINARY" };
size_t sizeofArray = sizeof(ie_location_any_ofArray) / sizeof(ie_location_any_ofArray[0]);
while (stringToReturn < sizeofArray) {
if (strcmp(ie_location_any_of, ie_location_any_ofArray[stringToReturn]) == 0) {
return stringToReturn;
}
stringToReturn++;
}
return 0;
}

View File

@ -0,0 +1,31 @@
/*
* ie_location_any_of.h
*
*
*/
#ifndef _OpenAPI_ie_location_any_of_H_
#define _OpenAPI_ie_location_any_of_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum { OpenAPI_ie_location_any_of_NULL = 0, OpenAPI_ie_location_any_of_URI_PARAM, OpenAPI_ie_location_any_of_HEADER, OpenAPI_ie_location_any_of_BODY, OpenAPI_ie_location_any_of_MULTIPART_BINARY } OpenAPI_ie_location_any_of_e;
char* OpenAPI_ie_location_any_of_ToString(OpenAPI_ie_location_any_of_e ie_location_any_of);
OpenAPI_ie_location_any_of_e OpenAPI_ie_location_any_of_FromString(char* ie_location_any_of);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_ie_location_any_of_H_ */

View File

@ -0,0 +1,30 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "ie_type.h"
char* OpenAPI_ie_type_ToString(OpenAPI_ie_type_e ie_type)
{
const char *ie_typeArray[] = { "NULL", "UEID", "LOCATION", "KEY_MATERIAL", "AUTHENTICATION_MATERIAL", "AUTHORIZATION_TOKEN", "OTHER", "NONSENSITIVE" };
size_t sizeofArray = sizeof(ie_typeArray) / sizeof(ie_typeArray[0]);
if (ie_type < sizeofArray)
return (char *)ie_typeArray[ie_type];
else
return (char *)"Unknown";
}
OpenAPI_ie_type_e OpenAPI_ie_type_FromString(char* ie_type)
{
int stringToReturn = 0;
const char *ie_typeArray[] = { "NULL", "UEID", "LOCATION", "KEY_MATERIAL", "AUTHENTICATION_MATERIAL", "AUTHORIZATION_TOKEN", "OTHER", "NONSENSITIVE" };
size_t sizeofArray = sizeof(ie_typeArray) / sizeof(ie_typeArray[0]);
while (stringToReturn < sizeofArray) {
if (strcmp(ie_type, ie_typeArray[stringToReturn]) == 0) {
return stringToReturn;
}
stringToReturn++;
}
return 0;
}

View File

@ -0,0 +1,31 @@
/*
* ie_type.h
*
*
*/
#ifndef _OpenAPI_ie_type_H_
#define _OpenAPI_ie_type_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum { OpenAPI_ie_type_NULL = 0, OpenAPI_ie_type_UEID, OpenAPI_ie_type_LOCATION, OpenAPI_ie_type_KEY_MATERIAL, OpenAPI_ie_type_AUTHENTICATION_MATERIAL, OpenAPI_ie_type_AUTHORIZATION_TOKEN, OpenAPI_ie_type_OTHER, OpenAPI_ie_type_NONSENSITIVE } OpenAPI_ie_type_e;
char* OpenAPI_ie_type_ToString(OpenAPI_ie_type_e ie_type);
OpenAPI_ie_type_e OpenAPI_ie_type_FromString(char* ie_type);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_ie_type_H_ */

View File

@ -0,0 +1,30 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "ie_type_any_of.h"
char* OpenAPI_ie_type_any_of_ToString(OpenAPI_ie_type_any_of_e ie_type_any_of)
{
const char *ie_type_any_ofArray[] = { "NULL", "UEID", "LOCATION", "KEY_MATERIAL", "AUTHENTICATION_MATERIAL", "AUTHORIZATION_TOKEN", "OTHER", "NONSENSITIVE" };
size_t sizeofArray = sizeof(ie_type_any_ofArray) / sizeof(ie_type_any_ofArray[0]);
if (ie_type_any_of < sizeofArray)
return (char *)ie_type_any_ofArray[ie_type_any_of];
else
return (char *)"Unknown";
}
OpenAPI_ie_type_any_of_e OpenAPI_ie_type_any_of_FromString(char* ie_type_any_of)
{
int stringToReturn = 0;
const char *ie_type_any_ofArray[] = { "NULL", "UEID", "LOCATION", "KEY_MATERIAL", "AUTHENTICATION_MATERIAL", "AUTHORIZATION_TOKEN", "OTHER", "NONSENSITIVE" };
size_t sizeofArray = sizeof(ie_type_any_ofArray) / sizeof(ie_type_any_ofArray[0]);
while (stringToReturn < sizeofArray) {
if (strcmp(ie_type_any_of, ie_type_any_ofArray[stringToReturn]) == 0) {
return stringToReturn;
}
stringToReturn++;
}
return 0;
}

View File

@ -0,0 +1,31 @@
/*
* ie_type_any_of.h
*
*
*/
#ifndef _OpenAPI_ie_type_any_of_H_
#define _OpenAPI_ie_type_any_of_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum { OpenAPI_ie_type_any_of_NULL = 0, OpenAPI_ie_type_any_of_UEID, OpenAPI_ie_type_any_of_LOCATION, OpenAPI_ie_type_any_of_KEY_MATERIAL, OpenAPI_ie_type_any_of_AUTHENTICATION_MATERIAL, OpenAPI_ie_type_any_of_AUTHORIZATION_TOKEN, OpenAPI_ie_type_any_of_OTHER, OpenAPI_ie_type_any_of_NONSENSITIVE } OpenAPI_ie_type_any_of_e;
char* OpenAPI_ie_type_any_of_ToString(OpenAPI_ie_type_any_of_e ie_type_any_of);
OpenAPI_ie_type_any_of_e OpenAPI_ie_type_any_of_FromString(char* ie_type_any_of);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_ie_type_any_of_H_ */

View File

@ -0,0 +1,158 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "intended_n32_purpose.h"
OpenAPI_intended_n32_purpose_t *OpenAPI_intended_n32_purpose_create(
OpenAPI_n32_purpose_e usage_purpose,
char *additional_info,
char *cause
)
{
OpenAPI_intended_n32_purpose_t *intended_n32_purpose_local_var = ogs_malloc(sizeof(OpenAPI_intended_n32_purpose_t));
ogs_assert(intended_n32_purpose_local_var);
intended_n32_purpose_local_var->usage_purpose = usage_purpose;
intended_n32_purpose_local_var->additional_info = additional_info;
intended_n32_purpose_local_var->cause = cause;
return intended_n32_purpose_local_var;
}
void OpenAPI_intended_n32_purpose_free(OpenAPI_intended_n32_purpose_t *intended_n32_purpose)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == intended_n32_purpose) {
return;
}
if (intended_n32_purpose->additional_info) {
ogs_free(intended_n32_purpose->additional_info);
intended_n32_purpose->additional_info = NULL;
}
if (intended_n32_purpose->cause) {
ogs_free(intended_n32_purpose->cause);
intended_n32_purpose->cause = NULL;
}
ogs_free(intended_n32_purpose);
}
cJSON *OpenAPI_intended_n32_purpose_convertToJSON(OpenAPI_intended_n32_purpose_t *intended_n32_purpose)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (intended_n32_purpose == NULL) {
ogs_error("OpenAPI_intended_n32_purpose_convertToJSON() failed [IntendedN32Purpose]");
return NULL;
}
item = cJSON_CreateObject();
if (intended_n32_purpose->usage_purpose == OpenAPI_n32_purpose_NULL) {
ogs_error("OpenAPI_intended_n32_purpose_convertToJSON() failed [usage_purpose]");
return NULL;
}
if (cJSON_AddStringToObject(item, "usagePurpose", OpenAPI_n32_purpose_ToString(intended_n32_purpose->usage_purpose)) == NULL) {
ogs_error("OpenAPI_intended_n32_purpose_convertToJSON() failed [usage_purpose]");
goto end;
}
if (intended_n32_purpose->additional_info) {
if (cJSON_AddStringToObject(item, "additionalInfo", intended_n32_purpose->additional_info) == NULL) {
ogs_error("OpenAPI_intended_n32_purpose_convertToJSON() failed [additional_info]");
goto end;
}
}
if (intended_n32_purpose->cause) {
if (cJSON_AddStringToObject(item, "cause", intended_n32_purpose->cause) == NULL) {
ogs_error("OpenAPI_intended_n32_purpose_convertToJSON() failed [cause]");
goto end;
}
}
end:
return item;
}
OpenAPI_intended_n32_purpose_t *OpenAPI_intended_n32_purpose_parseFromJSON(cJSON *intended_n32_purposeJSON)
{
OpenAPI_intended_n32_purpose_t *intended_n32_purpose_local_var = NULL;
OpenAPI_lnode_t *node = NULL;
cJSON *usage_purpose = NULL;
OpenAPI_n32_purpose_e usage_purposeVariable = 0;
cJSON *additional_info = NULL;
cJSON *cause = NULL;
usage_purpose = cJSON_GetObjectItemCaseSensitive(intended_n32_purposeJSON, "usagePurpose");
if (!usage_purpose) {
ogs_error("OpenAPI_intended_n32_purpose_parseFromJSON() failed [usage_purpose]");
goto end;
}
if (!cJSON_IsString(usage_purpose)) {
ogs_error("OpenAPI_intended_n32_purpose_parseFromJSON() failed [usage_purpose]");
goto end;
}
usage_purposeVariable = OpenAPI_n32_purpose_FromString(usage_purpose->valuestring);
additional_info = cJSON_GetObjectItemCaseSensitive(intended_n32_purposeJSON, "additionalInfo");
if (additional_info) {
if (!cJSON_IsString(additional_info) && !cJSON_IsNull(additional_info)) {
ogs_error("OpenAPI_intended_n32_purpose_parseFromJSON() failed [additional_info]");
goto end;
}
}
cause = cJSON_GetObjectItemCaseSensitive(intended_n32_purposeJSON, "cause");
if (cause) {
if (!cJSON_IsString(cause) && !cJSON_IsNull(cause)) {
ogs_error("OpenAPI_intended_n32_purpose_parseFromJSON() failed [cause]");
goto end;
}
}
intended_n32_purpose_local_var = OpenAPI_intended_n32_purpose_create (
usage_purposeVariable,
additional_info && !cJSON_IsNull(additional_info) ? ogs_strdup(additional_info->valuestring) : NULL,
cause && !cJSON_IsNull(cause) ? ogs_strdup(cause->valuestring) : NULL
);
return intended_n32_purpose_local_var;
end:
return NULL;
}
OpenAPI_intended_n32_purpose_t *OpenAPI_intended_n32_purpose_copy(OpenAPI_intended_n32_purpose_t *dst, OpenAPI_intended_n32_purpose_t *src)
{
cJSON *item = NULL;
char *content = NULL;
ogs_assert(src);
item = OpenAPI_intended_n32_purpose_convertToJSON(src);
if (!item) {
ogs_error("OpenAPI_intended_n32_purpose_convertToJSON() failed");
return NULL;
}
content = cJSON_Print(item);
cJSON_Delete(item);
if (!content) {
ogs_error("cJSON_Print() failed");
return NULL;
}
item = cJSON_Parse(content);
ogs_free(content);
if (!item) {
ogs_error("cJSON_Parse() failed");
return NULL;
}
OpenAPI_intended_n32_purpose_free(dst);
dst = OpenAPI_intended_n32_purpose_parseFromJSON(item);
cJSON_Delete(item);
return dst;
}

View File

@ -0,0 +1,43 @@
/*
* intended_n32_purpose.h
*
* Indicates the intended N32 establishment purpose
*/
#ifndef _OpenAPI_intended_n32_purpose_H_
#define _OpenAPI_intended_n32_purpose_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#include "n32_purpose.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct OpenAPI_intended_n32_purpose_s OpenAPI_intended_n32_purpose_t;
typedef struct OpenAPI_intended_n32_purpose_s {
OpenAPI_n32_purpose_e usage_purpose;
char *additional_info;
char *cause;
} OpenAPI_intended_n32_purpose_t;
OpenAPI_intended_n32_purpose_t *OpenAPI_intended_n32_purpose_create(
OpenAPI_n32_purpose_e usage_purpose,
char *additional_info,
char *cause
);
void OpenAPI_intended_n32_purpose_free(OpenAPI_intended_n32_purpose_t *intended_n32_purpose);
OpenAPI_intended_n32_purpose_t *OpenAPI_intended_n32_purpose_parseFromJSON(cJSON *intended_n32_purposeJSON);
cJSON *OpenAPI_intended_n32_purpose_convertToJSON(OpenAPI_intended_n32_purpose_t *intended_n32_purpose);
OpenAPI_intended_n32_purpose_t *OpenAPI_intended_n32_purpose_copy(OpenAPI_intended_n32_purpose_t *dst, OpenAPI_intended_n32_purpose_t *src);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_intended_n32_purpose_H_ */

View File

@ -0,0 +1,222 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "ipx_provider_sec_info.h"
OpenAPI_ipx_provider_sec_info_t *OpenAPI_ipx_provider_sec_info_create(
char *ipx_provider_id,
OpenAPI_list_t *raw_public_key_list,
OpenAPI_list_t *certificate_list
)
{
OpenAPI_ipx_provider_sec_info_t *ipx_provider_sec_info_local_var = ogs_malloc(sizeof(OpenAPI_ipx_provider_sec_info_t));
ogs_assert(ipx_provider_sec_info_local_var);
ipx_provider_sec_info_local_var->ipx_provider_id = ipx_provider_id;
ipx_provider_sec_info_local_var->raw_public_key_list = raw_public_key_list;
ipx_provider_sec_info_local_var->certificate_list = certificate_list;
return ipx_provider_sec_info_local_var;
}
void OpenAPI_ipx_provider_sec_info_free(OpenAPI_ipx_provider_sec_info_t *ipx_provider_sec_info)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == ipx_provider_sec_info) {
return;
}
if (ipx_provider_sec_info->ipx_provider_id) {
ogs_free(ipx_provider_sec_info->ipx_provider_id);
ipx_provider_sec_info->ipx_provider_id = NULL;
}
if (ipx_provider_sec_info->raw_public_key_list) {
OpenAPI_list_for_each(ipx_provider_sec_info->raw_public_key_list, node) {
ogs_free(node->data);
}
OpenAPI_list_free(ipx_provider_sec_info->raw_public_key_list);
ipx_provider_sec_info->raw_public_key_list = NULL;
}
if (ipx_provider_sec_info->certificate_list) {
OpenAPI_list_for_each(ipx_provider_sec_info->certificate_list, node) {
ogs_free(node->data);
}
OpenAPI_list_free(ipx_provider_sec_info->certificate_list);
ipx_provider_sec_info->certificate_list = NULL;
}
ogs_free(ipx_provider_sec_info);
}
cJSON *OpenAPI_ipx_provider_sec_info_convertToJSON(OpenAPI_ipx_provider_sec_info_t *ipx_provider_sec_info)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (ipx_provider_sec_info == NULL) {
ogs_error("OpenAPI_ipx_provider_sec_info_convertToJSON() failed [IpxProviderSecInfo]");
return NULL;
}
item = cJSON_CreateObject();
if (!ipx_provider_sec_info->ipx_provider_id) {
ogs_error("OpenAPI_ipx_provider_sec_info_convertToJSON() failed [ipx_provider_id]");
return NULL;
}
if (cJSON_AddStringToObject(item, "ipxProviderId", ipx_provider_sec_info->ipx_provider_id) == NULL) {
ogs_error("OpenAPI_ipx_provider_sec_info_convertToJSON() failed [ipx_provider_id]");
goto end;
}
if (ipx_provider_sec_info->raw_public_key_list) {
cJSON *raw_public_key_listList = cJSON_AddArrayToObject(item, "rawPublicKeyList");
if (raw_public_key_listList == NULL) {
ogs_error("OpenAPI_ipx_provider_sec_info_convertToJSON() failed [raw_public_key_list]");
goto end;
}
OpenAPI_list_for_each(ipx_provider_sec_info->raw_public_key_list, node) {
if (cJSON_AddStringToObject(raw_public_key_listList, "", (char*)node->data) == NULL) {
ogs_error("OpenAPI_ipx_provider_sec_info_convertToJSON() failed [raw_public_key_list]");
goto end;
}
}
}
if (ipx_provider_sec_info->certificate_list) {
cJSON *certificate_listList = cJSON_AddArrayToObject(item, "certificateList");
if (certificate_listList == NULL) {
ogs_error("OpenAPI_ipx_provider_sec_info_convertToJSON() failed [certificate_list]");
goto end;
}
OpenAPI_list_for_each(ipx_provider_sec_info->certificate_list, node) {
if (cJSON_AddStringToObject(certificate_listList, "", (char*)node->data) == NULL) {
ogs_error("OpenAPI_ipx_provider_sec_info_convertToJSON() failed [certificate_list]");
goto end;
}
}
}
end:
return item;
}
OpenAPI_ipx_provider_sec_info_t *OpenAPI_ipx_provider_sec_info_parseFromJSON(cJSON *ipx_provider_sec_infoJSON)
{
OpenAPI_ipx_provider_sec_info_t *ipx_provider_sec_info_local_var = NULL;
OpenAPI_lnode_t *node = NULL;
cJSON *ipx_provider_id = NULL;
cJSON *raw_public_key_list = NULL;
OpenAPI_list_t *raw_public_key_listList = NULL;
cJSON *certificate_list = NULL;
OpenAPI_list_t *certificate_listList = NULL;
ipx_provider_id = cJSON_GetObjectItemCaseSensitive(ipx_provider_sec_infoJSON, "ipxProviderId");
if (!ipx_provider_id) {
ogs_error("OpenAPI_ipx_provider_sec_info_parseFromJSON() failed [ipx_provider_id]");
goto end;
}
if (!cJSON_IsString(ipx_provider_id)) {
ogs_error("OpenAPI_ipx_provider_sec_info_parseFromJSON() failed [ipx_provider_id]");
goto end;
}
raw_public_key_list = cJSON_GetObjectItemCaseSensitive(ipx_provider_sec_infoJSON, "rawPublicKeyList");
if (raw_public_key_list) {
cJSON *raw_public_key_list_local = NULL;
if (!cJSON_IsArray(raw_public_key_list)) {
ogs_error("OpenAPI_ipx_provider_sec_info_parseFromJSON() failed [raw_public_key_list]");
goto end;
}
raw_public_key_listList = OpenAPI_list_create();
cJSON_ArrayForEach(raw_public_key_list_local, raw_public_key_list) {
double *localDouble = NULL;
int *localInt = NULL;
if (!cJSON_IsString(raw_public_key_list_local)) {
ogs_error("OpenAPI_ipx_provider_sec_info_parseFromJSON() failed [raw_public_key_list]");
goto end;
}
OpenAPI_list_add(raw_public_key_listList, ogs_strdup(raw_public_key_list_local->valuestring));
}
}
certificate_list = cJSON_GetObjectItemCaseSensitive(ipx_provider_sec_infoJSON, "certificateList");
if (certificate_list) {
cJSON *certificate_list_local = NULL;
if (!cJSON_IsArray(certificate_list)) {
ogs_error("OpenAPI_ipx_provider_sec_info_parseFromJSON() failed [certificate_list]");
goto end;
}
certificate_listList = OpenAPI_list_create();
cJSON_ArrayForEach(certificate_list_local, certificate_list) {
double *localDouble = NULL;
int *localInt = NULL;
if (!cJSON_IsString(certificate_list_local)) {
ogs_error("OpenAPI_ipx_provider_sec_info_parseFromJSON() failed [certificate_list]");
goto end;
}
OpenAPI_list_add(certificate_listList, ogs_strdup(certificate_list_local->valuestring));
}
}
ipx_provider_sec_info_local_var = OpenAPI_ipx_provider_sec_info_create (
ogs_strdup(ipx_provider_id->valuestring),
raw_public_key_list ? raw_public_key_listList : NULL,
certificate_list ? certificate_listList : NULL
);
return ipx_provider_sec_info_local_var;
end:
if (raw_public_key_listList) {
OpenAPI_list_for_each(raw_public_key_listList, node) {
ogs_free(node->data);
}
OpenAPI_list_free(raw_public_key_listList);
raw_public_key_listList = NULL;
}
if (certificate_listList) {
OpenAPI_list_for_each(certificate_listList, node) {
ogs_free(node->data);
}
OpenAPI_list_free(certificate_listList);
certificate_listList = NULL;
}
return NULL;
}
OpenAPI_ipx_provider_sec_info_t *OpenAPI_ipx_provider_sec_info_copy(OpenAPI_ipx_provider_sec_info_t *dst, OpenAPI_ipx_provider_sec_info_t *src)
{
cJSON *item = NULL;
char *content = NULL;
ogs_assert(src);
item = OpenAPI_ipx_provider_sec_info_convertToJSON(src);
if (!item) {
ogs_error("OpenAPI_ipx_provider_sec_info_convertToJSON() failed");
return NULL;
}
content = cJSON_Print(item);
cJSON_Delete(item);
if (!content) {
ogs_error("cJSON_Print() failed");
return NULL;
}
item = cJSON_Parse(content);
ogs_free(content);
if (!item) {
ogs_error("cJSON_Parse() failed");
return NULL;
}
OpenAPI_ipx_provider_sec_info_free(dst);
dst = OpenAPI_ipx_provider_sec_info_parseFromJSON(item);
cJSON_Delete(item);
return dst;
}

View File

@ -0,0 +1,42 @@
/*
* ipx_provider_sec_info.h
*
* Defines the security information list of an IPX
*/
#ifndef _OpenAPI_ipx_provider_sec_info_H_
#define _OpenAPI_ipx_provider_sec_info_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct OpenAPI_ipx_provider_sec_info_s OpenAPI_ipx_provider_sec_info_t;
typedef struct OpenAPI_ipx_provider_sec_info_s {
char *ipx_provider_id;
OpenAPI_list_t *raw_public_key_list;
OpenAPI_list_t *certificate_list;
} OpenAPI_ipx_provider_sec_info_t;
OpenAPI_ipx_provider_sec_info_t *OpenAPI_ipx_provider_sec_info_create(
char *ipx_provider_id,
OpenAPI_list_t *raw_public_key_list,
OpenAPI_list_t *certificate_list
);
void OpenAPI_ipx_provider_sec_info_free(OpenAPI_ipx_provider_sec_info_t *ipx_provider_sec_info);
OpenAPI_ipx_provider_sec_info_t *OpenAPI_ipx_provider_sec_info_parseFromJSON(cJSON *ipx_provider_sec_infoJSON);
cJSON *OpenAPI_ipx_provider_sec_info_convertToJSON(OpenAPI_ipx_provider_sec_info_t *ipx_provider_sec_info);
OpenAPI_ipx_provider_sec_info_t *OpenAPI_ipx_provider_sec_info_copy(OpenAPI_ipx_provider_sec_info_t *dst, OpenAPI_ipx_provider_sec_info_t *src);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_ipx_provider_sec_info_H_ */

View File

@ -0,0 +1,30 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "n32_purpose.h"
char* OpenAPI_n32_purpose_ToString(OpenAPI_n32_purpose_e n32_purpose)
{
const char *n32_purposeArray[] = { "NULL", "ROAMING", "INTER_PLMN_MOBILITY", "SMS_INTERCONNECT", "ROAMING_TEST", "INTER_PLMN_MOBILITY_TEST", "SMS_INTERCONNECT_TEST", "SNPN_INTERCONNECT", "SNPN_INTERCONNECT_TEST", "DISASTER_ROAMING", "DISASTER_ROAMING_TEST" };
size_t sizeofArray = sizeof(n32_purposeArray) / sizeof(n32_purposeArray[0]);
if (n32_purpose < sizeofArray)
return (char *)n32_purposeArray[n32_purpose];
else
return (char *)"Unknown";
}
OpenAPI_n32_purpose_e OpenAPI_n32_purpose_FromString(char* n32_purpose)
{
int stringToReturn = 0;
const char *n32_purposeArray[] = { "NULL", "ROAMING", "INTER_PLMN_MOBILITY", "SMS_INTERCONNECT", "ROAMING_TEST", "INTER_PLMN_MOBILITY_TEST", "SMS_INTERCONNECT_TEST", "SNPN_INTERCONNECT", "SNPN_INTERCONNECT_TEST", "DISASTER_ROAMING", "DISASTER_ROAMING_TEST" };
size_t sizeofArray = sizeof(n32_purposeArray) / sizeof(n32_purposeArray[0]);
while (stringToReturn < sizeofArray) {
if (strcmp(n32_purpose, n32_purposeArray[stringToReturn]) == 0) {
return stringToReturn;
}
stringToReturn++;
}
return 0;
}

View File

@ -0,0 +1,31 @@
/*
* n32_purpose.h
*
*
*/
#ifndef _OpenAPI_n32_purpose_H_
#define _OpenAPI_n32_purpose_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum { OpenAPI_n32_purpose_NULL = 0, OpenAPI_n32_purpose_ROAMING, OpenAPI_n32_purpose_INTER_PLMN_MOBILITY, OpenAPI_n32_purpose_SMS_INTERCONNECT, OpenAPI_n32_purpose_ROAMING_TEST, OpenAPI_n32_purpose_INTER_PLMN_MOBILITY_TEST, OpenAPI_n32_purpose_SMS_INTERCONNECT_TEST, OpenAPI_n32_purpose_SNPN_INTERCONNECT, OpenAPI_n32_purpose_SNPN_INTERCONNECT_TEST, OpenAPI_n32_purpose_DISASTER_ROAMING, OpenAPI_n32_purpose_DISASTER_ROAMING_TEST } OpenAPI_n32_purpose_e;
char* OpenAPI_n32_purpose_ToString(OpenAPI_n32_purpose_e n32_purpose);
OpenAPI_n32_purpose_e OpenAPI_n32_purpose_FromString(char* n32_purpose);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_n32_purpose_H_ */

View File

@ -0,0 +1,30 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "n32_purpose_any_of.h"
char* OpenAPI_n32_purpose_any_of_ToString(OpenAPI_n32_purpose_any_of_e n32_purpose_any_of)
{
const char *n32_purpose_any_ofArray[] = { "NULL", "ROAMING", "INTER_PLMN_MOBILITY", "SMS_INTERCONNECT", "ROAMING_TEST", "INTER_PLMN_MOBILITY_TEST", "SMS_INTERCONNECT_TEST", "SNPN_INTERCONNECT", "SNPN_INTERCONNECT_TEST", "DISASTER_ROAMING", "DISASTER_ROAMING_TEST" };
size_t sizeofArray = sizeof(n32_purpose_any_ofArray) / sizeof(n32_purpose_any_ofArray[0]);
if (n32_purpose_any_of < sizeofArray)
return (char *)n32_purpose_any_ofArray[n32_purpose_any_of];
else
return (char *)"Unknown";
}
OpenAPI_n32_purpose_any_of_e OpenAPI_n32_purpose_any_of_FromString(char* n32_purpose_any_of)
{
int stringToReturn = 0;
const char *n32_purpose_any_ofArray[] = { "NULL", "ROAMING", "INTER_PLMN_MOBILITY", "SMS_INTERCONNECT", "ROAMING_TEST", "INTER_PLMN_MOBILITY_TEST", "SMS_INTERCONNECT_TEST", "SNPN_INTERCONNECT", "SNPN_INTERCONNECT_TEST", "DISASTER_ROAMING", "DISASTER_ROAMING_TEST" };
size_t sizeofArray = sizeof(n32_purpose_any_ofArray) / sizeof(n32_purpose_any_ofArray[0]);
while (stringToReturn < sizeofArray) {
if (strcmp(n32_purpose_any_of, n32_purpose_any_ofArray[stringToReturn]) == 0) {
return stringToReturn;
}
stringToReturn++;
}
return 0;
}

View File

@ -0,0 +1,31 @@
/*
* n32_purpose_any_of.h
*
*
*/
#ifndef _OpenAPI_n32_purpose_any_of_H_
#define _OpenAPI_n32_purpose_any_of_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum { OpenAPI_n32_purpose_any_of_NULL = 0, OpenAPI_n32_purpose_any_of_ROAMING, OpenAPI_n32_purpose_any_of_INTER_PLMN_MOBILITY, OpenAPI_n32_purpose_any_of_SMS_INTERCONNECT, OpenAPI_n32_purpose_any_of_ROAMING_TEST, OpenAPI_n32_purpose_any_of_INTER_PLMN_MOBILITY_TEST, OpenAPI_n32_purpose_any_of_SMS_INTERCONNECT_TEST, OpenAPI_n32_purpose_any_of_SNPN_INTERCONNECT, OpenAPI_n32_purpose_any_of_SNPN_INTERCONNECT_TEST, OpenAPI_n32_purpose_any_of_DISASTER_ROAMING, OpenAPI_n32_purpose_any_of_DISASTER_ROAMING_TEST } OpenAPI_n32_purpose_any_of_e;
char* OpenAPI_n32_purpose_any_of_ToString(OpenAPI_n32_purpose_any_of_e n32_purpose_any_of);
OpenAPI_n32_purpose_any_of_e OpenAPI_n32_purpose_any_of_FromString(char* n32_purpose_any_of);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_n32_purpose_any_of_H_ */

View File

@ -0,0 +1,114 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "n32f_context_info.h"
OpenAPI_n32f_context_info_t *OpenAPI_n32f_context_info_create(
char *n32f_context_id
)
{
OpenAPI_n32f_context_info_t *n32f_context_info_local_var = ogs_malloc(sizeof(OpenAPI_n32f_context_info_t));
ogs_assert(n32f_context_info_local_var);
n32f_context_info_local_var->n32f_context_id = n32f_context_id;
return n32f_context_info_local_var;
}
void OpenAPI_n32f_context_info_free(OpenAPI_n32f_context_info_t *n32f_context_info)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == n32f_context_info) {
return;
}
if (n32f_context_info->n32f_context_id) {
ogs_free(n32f_context_info->n32f_context_id);
n32f_context_info->n32f_context_id = NULL;
}
ogs_free(n32f_context_info);
}
cJSON *OpenAPI_n32f_context_info_convertToJSON(OpenAPI_n32f_context_info_t *n32f_context_info)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (n32f_context_info == NULL) {
ogs_error("OpenAPI_n32f_context_info_convertToJSON() failed [N32fContextInfo]");
return NULL;
}
item = cJSON_CreateObject();
if (!n32f_context_info->n32f_context_id) {
ogs_error("OpenAPI_n32f_context_info_convertToJSON() failed [n32f_context_id]");
return NULL;
}
if (cJSON_AddStringToObject(item, "n32fContextId", n32f_context_info->n32f_context_id) == NULL) {
ogs_error("OpenAPI_n32f_context_info_convertToJSON() failed [n32f_context_id]");
goto end;
}
end:
return item;
}
OpenAPI_n32f_context_info_t *OpenAPI_n32f_context_info_parseFromJSON(cJSON *n32f_context_infoJSON)
{
OpenAPI_n32f_context_info_t *n32f_context_info_local_var = NULL;
OpenAPI_lnode_t *node = NULL;
cJSON *n32f_context_id = NULL;
n32f_context_id = cJSON_GetObjectItemCaseSensitive(n32f_context_infoJSON, "n32fContextId");
if (!n32f_context_id) {
ogs_error("OpenAPI_n32f_context_info_parseFromJSON() failed [n32f_context_id]");
goto end;
}
if (!cJSON_IsString(n32f_context_id)) {
ogs_error("OpenAPI_n32f_context_info_parseFromJSON() failed [n32f_context_id]");
goto end;
}
n32f_context_info_local_var = OpenAPI_n32f_context_info_create (
ogs_strdup(n32f_context_id->valuestring)
);
return n32f_context_info_local_var;
end:
return NULL;
}
OpenAPI_n32f_context_info_t *OpenAPI_n32f_context_info_copy(OpenAPI_n32f_context_info_t *dst, OpenAPI_n32f_context_info_t *src)
{
cJSON *item = NULL;
char *content = NULL;
ogs_assert(src);
item = OpenAPI_n32f_context_info_convertToJSON(src);
if (!item) {
ogs_error("OpenAPI_n32f_context_info_convertToJSON() failed");
return NULL;
}
content = cJSON_Print(item);
cJSON_Delete(item);
if (!content) {
ogs_error("cJSON_Print() failed");
return NULL;
}
item = cJSON_Parse(content);
ogs_free(content);
if (!item) {
ogs_error("cJSON_Parse() failed");
return NULL;
}
OpenAPI_n32f_context_info_free(dst);
dst = OpenAPI_n32f_context_info_parseFromJSON(item);
cJSON_Delete(item);
return dst;
}

View File

@ -0,0 +1,38 @@
/*
* n32f_context_info.h
*
* N32-f context information
*/
#ifndef _OpenAPI_n32f_context_info_H_
#define _OpenAPI_n32f_context_info_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct OpenAPI_n32f_context_info_s OpenAPI_n32f_context_info_t;
typedef struct OpenAPI_n32f_context_info_s {
char *n32f_context_id;
} OpenAPI_n32f_context_info_t;
OpenAPI_n32f_context_info_t *OpenAPI_n32f_context_info_create(
char *n32f_context_id
);
void OpenAPI_n32f_context_info_free(OpenAPI_n32f_context_info_t *n32f_context_info);
OpenAPI_n32f_context_info_t *OpenAPI_n32f_context_info_parseFromJSON(cJSON *n32f_context_infoJSON);
cJSON *OpenAPI_n32f_context_info_convertToJSON(OpenAPI_n32f_context_info_t *n32f_context_info);
OpenAPI_n32f_context_info_t *OpenAPI_n32f_context_info_copy(OpenAPI_n32f_context_info_t *dst, OpenAPI_n32f_context_info_t *src);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_n32f_context_info_H_ */

View File

@ -0,0 +1,139 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "n32f_error_detail.h"
OpenAPI_n32f_error_detail_t *OpenAPI_n32f_error_detail_create(
char *attribute,
OpenAPI_failure_reason_e msg_reconstruct_fail_reason
)
{
OpenAPI_n32f_error_detail_t *n32f_error_detail_local_var = ogs_malloc(sizeof(OpenAPI_n32f_error_detail_t));
ogs_assert(n32f_error_detail_local_var);
n32f_error_detail_local_var->attribute = attribute;
n32f_error_detail_local_var->msg_reconstruct_fail_reason = msg_reconstruct_fail_reason;
return n32f_error_detail_local_var;
}
void OpenAPI_n32f_error_detail_free(OpenAPI_n32f_error_detail_t *n32f_error_detail)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == n32f_error_detail) {
return;
}
if (n32f_error_detail->attribute) {
ogs_free(n32f_error_detail->attribute);
n32f_error_detail->attribute = NULL;
}
ogs_free(n32f_error_detail);
}
cJSON *OpenAPI_n32f_error_detail_convertToJSON(OpenAPI_n32f_error_detail_t *n32f_error_detail)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (n32f_error_detail == NULL) {
ogs_error("OpenAPI_n32f_error_detail_convertToJSON() failed [N32fErrorDetail]");
return NULL;
}
item = cJSON_CreateObject();
if (!n32f_error_detail->attribute) {
ogs_error("OpenAPI_n32f_error_detail_convertToJSON() failed [attribute]");
return NULL;
}
if (cJSON_AddStringToObject(item, "attribute", n32f_error_detail->attribute) == NULL) {
ogs_error("OpenAPI_n32f_error_detail_convertToJSON() failed [attribute]");
goto end;
}
if (n32f_error_detail->msg_reconstruct_fail_reason == OpenAPI_failure_reason_NULL) {
ogs_error("OpenAPI_n32f_error_detail_convertToJSON() failed [msg_reconstruct_fail_reason]");
return NULL;
}
if (cJSON_AddStringToObject(item, "msgReconstructFailReason", OpenAPI_failure_reason_ToString(n32f_error_detail->msg_reconstruct_fail_reason)) == NULL) {
ogs_error("OpenAPI_n32f_error_detail_convertToJSON() failed [msg_reconstruct_fail_reason]");
goto end;
}
end:
return item;
}
OpenAPI_n32f_error_detail_t *OpenAPI_n32f_error_detail_parseFromJSON(cJSON *n32f_error_detailJSON)
{
OpenAPI_n32f_error_detail_t *n32f_error_detail_local_var = NULL;
OpenAPI_lnode_t *node = NULL;
cJSON *attribute = NULL;
cJSON *msg_reconstruct_fail_reason = NULL;
OpenAPI_failure_reason_e msg_reconstruct_fail_reasonVariable = 0;
attribute = cJSON_GetObjectItemCaseSensitive(n32f_error_detailJSON, "attribute");
if (!attribute) {
ogs_error("OpenAPI_n32f_error_detail_parseFromJSON() failed [attribute]");
goto end;
}
if (!cJSON_IsString(attribute)) {
ogs_error("OpenAPI_n32f_error_detail_parseFromJSON() failed [attribute]");
goto end;
}
msg_reconstruct_fail_reason = cJSON_GetObjectItemCaseSensitive(n32f_error_detailJSON, "msgReconstructFailReason");
if (!msg_reconstruct_fail_reason) {
ogs_error("OpenAPI_n32f_error_detail_parseFromJSON() failed [msg_reconstruct_fail_reason]");
goto end;
}
if (!cJSON_IsString(msg_reconstruct_fail_reason)) {
ogs_error("OpenAPI_n32f_error_detail_parseFromJSON() failed [msg_reconstruct_fail_reason]");
goto end;
}
msg_reconstruct_fail_reasonVariable = OpenAPI_failure_reason_FromString(msg_reconstruct_fail_reason->valuestring);
n32f_error_detail_local_var = OpenAPI_n32f_error_detail_create (
ogs_strdup(attribute->valuestring),
msg_reconstruct_fail_reasonVariable
);
return n32f_error_detail_local_var;
end:
return NULL;
}
OpenAPI_n32f_error_detail_t *OpenAPI_n32f_error_detail_copy(OpenAPI_n32f_error_detail_t *dst, OpenAPI_n32f_error_detail_t *src)
{
cJSON *item = NULL;
char *content = NULL;
ogs_assert(src);
item = OpenAPI_n32f_error_detail_convertToJSON(src);
if (!item) {
ogs_error("OpenAPI_n32f_error_detail_convertToJSON() failed");
return NULL;
}
content = cJSON_Print(item);
cJSON_Delete(item);
if (!content) {
ogs_error("cJSON_Print() failed");
return NULL;
}
item = cJSON_Parse(content);
ogs_free(content);
if (!item) {
ogs_error("cJSON_Parse() failed");
return NULL;
}
OpenAPI_n32f_error_detail_free(dst);
dst = OpenAPI_n32f_error_detail_parseFromJSON(item);
cJSON_Delete(item);
return dst;
}

View File

@ -0,0 +1,41 @@
/*
* n32f_error_detail.h
*
* Details about the N32f error
*/
#ifndef _OpenAPI_n32f_error_detail_H_
#define _OpenAPI_n32f_error_detail_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#include "failure_reason.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct OpenAPI_n32f_error_detail_s OpenAPI_n32f_error_detail_t;
typedef struct OpenAPI_n32f_error_detail_s {
char *attribute;
OpenAPI_failure_reason_e msg_reconstruct_fail_reason;
} OpenAPI_n32f_error_detail_t;
OpenAPI_n32f_error_detail_t *OpenAPI_n32f_error_detail_create(
char *attribute,
OpenAPI_failure_reason_e msg_reconstruct_fail_reason
);
void OpenAPI_n32f_error_detail_free(OpenAPI_n32f_error_detail_t *n32f_error_detail);
OpenAPI_n32f_error_detail_t *OpenAPI_n32f_error_detail_parseFromJSON(cJSON *n32f_error_detailJSON);
cJSON *OpenAPI_n32f_error_detail_convertToJSON(OpenAPI_n32f_error_detail_t *n32f_error_detail);
OpenAPI_n32f_error_detail_t *OpenAPI_n32f_error_detail_copy(OpenAPI_n32f_error_detail_t *dst, OpenAPI_n32f_error_detail_t *src);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_n32f_error_detail_H_ */

View File

@ -0,0 +1,282 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "n32f_error_info.h"
OpenAPI_n32f_error_info_t *OpenAPI_n32f_error_info_create(
char *n32f_message_id,
OpenAPI_n32f_error_type_e n32f_error_type,
char *n32f_context_id,
OpenAPI_list_t *failed_modification_list,
OpenAPI_list_t *error_details_list
)
{
OpenAPI_n32f_error_info_t *n32f_error_info_local_var = ogs_malloc(sizeof(OpenAPI_n32f_error_info_t));
ogs_assert(n32f_error_info_local_var);
n32f_error_info_local_var->n32f_message_id = n32f_message_id;
n32f_error_info_local_var->n32f_error_type = n32f_error_type;
n32f_error_info_local_var->n32f_context_id = n32f_context_id;
n32f_error_info_local_var->failed_modification_list = failed_modification_list;
n32f_error_info_local_var->error_details_list = error_details_list;
return n32f_error_info_local_var;
}
void OpenAPI_n32f_error_info_free(OpenAPI_n32f_error_info_t *n32f_error_info)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == n32f_error_info) {
return;
}
if (n32f_error_info->n32f_message_id) {
ogs_free(n32f_error_info->n32f_message_id);
n32f_error_info->n32f_message_id = NULL;
}
if (n32f_error_info->n32f_context_id) {
ogs_free(n32f_error_info->n32f_context_id);
n32f_error_info->n32f_context_id = NULL;
}
if (n32f_error_info->failed_modification_list) {
OpenAPI_list_for_each(n32f_error_info->failed_modification_list, node) {
OpenAPI_failed_modification_info_free(node->data);
}
OpenAPI_list_free(n32f_error_info->failed_modification_list);
n32f_error_info->failed_modification_list = NULL;
}
if (n32f_error_info->error_details_list) {
OpenAPI_list_for_each(n32f_error_info->error_details_list, node) {
OpenAPI_n32f_error_detail_free(node->data);
}
OpenAPI_list_free(n32f_error_info->error_details_list);
n32f_error_info->error_details_list = NULL;
}
ogs_free(n32f_error_info);
}
cJSON *OpenAPI_n32f_error_info_convertToJSON(OpenAPI_n32f_error_info_t *n32f_error_info)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (n32f_error_info == NULL) {
ogs_error("OpenAPI_n32f_error_info_convertToJSON() failed [N32fErrorInfo]");
return NULL;
}
item = cJSON_CreateObject();
if (!n32f_error_info->n32f_message_id) {
ogs_error("OpenAPI_n32f_error_info_convertToJSON() failed [n32f_message_id]");
return NULL;
}
if (cJSON_AddStringToObject(item, "n32fMessageId", n32f_error_info->n32f_message_id) == NULL) {
ogs_error("OpenAPI_n32f_error_info_convertToJSON() failed [n32f_message_id]");
goto end;
}
if (n32f_error_info->n32f_error_type == OpenAPI_n32f_error_type_NULL) {
ogs_error("OpenAPI_n32f_error_info_convertToJSON() failed [n32f_error_type]");
return NULL;
}
if (cJSON_AddStringToObject(item, "n32fErrorType", OpenAPI_n32f_error_type_ToString(n32f_error_info->n32f_error_type)) == NULL) {
ogs_error("OpenAPI_n32f_error_info_convertToJSON() failed [n32f_error_type]");
goto end;
}
if (n32f_error_info->n32f_context_id) {
if (cJSON_AddStringToObject(item, "n32fContextId", n32f_error_info->n32f_context_id) == NULL) {
ogs_error("OpenAPI_n32f_error_info_convertToJSON() failed [n32f_context_id]");
goto end;
}
}
if (n32f_error_info->failed_modification_list) {
cJSON *failed_modification_listList = cJSON_AddArrayToObject(item, "failedModificationList");
if (failed_modification_listList == NULL) {
ogs_error("OpenAPI_n32f_error_info_convertToJSON() failed [failed_modification_list]");
goto end;
}
OpenAPI_list_for_each(n32f_error_info->failed_modification_list, node) {
cJSON *itemLocal = OpenAPI_failed_modification_info_convertToJSON(node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_n32f_error_info_convertToJSON() failed [failed_modification_list]");
goto end;
}
cJSON_AddItemToArray(failed_modification_listList, itemLocal);
}
}
if (n32f_error_info->error_details_list) {
cJSON *error_details_listList = cJSON_AddArrayToObject(item, "errorDetailsList");
if (error_details_listList == NULL) {
ogs_error("OpenAPI_n32f_error_info_convertToJSON() failed [error_details_list]");
goto end;
}
OpenAPI_list_for_each(n32f_error_info->error_details_list, node) {
cJSON *itemLocal = OpenAPI_n32f_error_detail_convertToJSON(node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_n32f_error_info_convertToJSON() failed [error_details_list]");
goto end;
}
cJSON_AddItemToArray(error_details_listList, itemLocal);
}
}
end:
return item;
}
OpenAPI_n32f_error_info_t *OpenAPI_n32f_error_info_parseFromJSON(cJSON *n32f_error_infoJSON)
{
OpenAPI_n32f_error_info_t *n32f_error_info_local_var = NULL;
OpenAPI_lnode_t *node = NULL;
cJSON *n32f_message_id = NULL;
cJSON *n32f_error_type = NULL;
OpenAPI_n32f_error_type_e n32f_error_typeVariable = 0;
cJSON *n32f_context_id = NULL;
cJSON *failed_modification_list = NULL;
OpenAPI_list_t *failed_modification_listList = NULL;
cJSON *error_details_list = NULL;
OpenAPI_list_t *error_details_listList = NULL;
n32f_message_id = cJSON_GetObjectItemCaseSensitive(n32f_error_infoJSON, "n32fMessageId");
if (!n32f_message_id) {
ogs_error("OpenAPI_n32f_error_info_parseFromJSON() failed [n32f_message_id]");
goto end;
}
if (!cJSON_IsString(n32f_message_id)) {
ogs_error("OpenAPI_n32f_error_info_parseFromJSON() failed [n32f_message_id]");
goto end;
}
n32f_error_type = cJSON_GetObjectItemCaseSensitive(n32f_error_infoJSON, "n32fErrorType");
if (!n32f_error_type) {
ogs_error("OpenAPI_n32f_error_info_parseFromJSON() failed [n32f_error_type]");
goto end;
}
if (!cJSON_IsString(n32f_error_type)) {
ogs_error("OpenAPI_n32f_error_info_parseFromJSON() failed [n32f_error_type]");
goto end;
}
n32f_error_typeVariable = OpenAPI_n32f_error_type_FromString(n32f_error_type->valuestring);
n32f_context_id = cJSON_GetObjectItemCaseSensitive(n32f_error_infoJSON, "n32fContextId");
if (n32f_context_id) {
if (!cJSON_IsString(n32f_context_id) && !cJSON_IsNull(n32f_context_id)) {
ogs_error("OpenAPI_n32f_error_info_parseFromJSON() failed [n32f_context_id]");
goto end;
}
}
failed_modification_list = cJSON_GetObjectItemCaseSensitive(n32f_error_infoJSON, "failedModificationList");
if (failed_modification_list) {
cJSON *failed_modification_list_local = NULL;
if (!cJSON_IsArray(failed_modification_list)) {
ogs_error("OpenAPI_n32f_error_info_parseFromJSON() failed [failed_modification_list]");
goto end;
}
failed_modification_listList = OpenAPI_list_create();
cJSON_ArrayForEach(failed_modification_list_local, failed_modification_list) {
if (!cJSON_IsObject(failed_modification_list_local)) {
ogs_error("OpenAPI_n32f_error_info_parseFromJSON() failed [failed_modification_list]");
goto end;
}
OpenAPI_failed_modification_info_t *failed_modification_listItem = OpenAPI_failed_modification_info_parseFromJSON(failed_modification_list_local);
if (!failed_modification_listItem) {
ogs_error("No failed_modification_listItem");
OpenAPI_list_free(failed_modification_listList);
goto end;
}
OpenAPI_list_add(failed_modification_listList, failed_modification_listItem);
}
}
error_details_list = cJSON_GetObjectItemCaseSensitive(n32f_error_infoJSON, "errorDetailsList");
if (error_details_list) {
cJSON *error_details_list_local = NULL;
if (!cJSON_IsArray(error_details_list)) {
ogs_error("OpenAPI_n32f_error_info_parseFromJSON() failed [error_details_list]");
goto end;
}
error_details_listList = OpenAPI_list_create();
cJSON_ArrayForEach(error_details_list_local, error_details_list) {
if (!cJSON_IsObject(error_details_list_local)) {
ogs_error("OpenAPI_n32f_error_info_parseFromJSON() failed [error_details_list]");
goto end;
}
OpenAPI_n32f_error_detail_t *error_details_listItem = OpenAPI_n32f_error_detail_parseFromJSON(error_details_list_local);
if (!error_details_listItem) {
ogs_error("No error_details_listItem");
OpenAPI_list_free(error_details_listList);
goto end;
}
OpenAPI_list_add(error_details_listList, error_details_listItem);
}
}
n32f_error_info_local_var = OpenAPI_n32f_error_info_create (
ogs_strdup(n32f_message_id->valuestring),
n32f_error_typeVariable,
n32f_context_id && !cJSON_IsNull(n32f_context_id) ? ogs_strdup(n32f_context_id->valuestring) : NULL,
failed_modification_list ? failed_modification_listList : NULL,
error_details_list ? error_details_listList : NULL
);
return n32f_error_info_local_var;
end:
if (failed_modification_listList) {
OpenAPI_list_for_each(failed_modification_listList, node) {
OpenAPI_failed_modification_info_free(node->data);
}
OpenAPI_list_free(failed_modification_listList);
failed_modification_listList = NULL;
}
if (error_details_listList) {
OpenAPI_list_for_each(error_details_listList, node) {
OpenAPI_n32f_error_detail_free(node->data);
}
OpenAPI_list_free(error_details_listList);
error_details_listList = NULL;
}
return NULL;
}
OpenAPI_n32f_error_info_t *OpenAPI_n32f_error_info_copy(OpenAPI_n32f_error_info_t *dst, OpenAPI_n32f_error_info_t *src)
{
cJSON *item = NULL;
char *content = NULL;
ogs_assert(src);
item = OpenAPI_n32f_error_info_convertToJSON(src);
if (!item) {
ogs_error("OpenAPI_n32f_error_info_convertToJSON() failed");
return NULL;
}
content = cJSON_Print(item);
cJSON_Delete(item);
if (!content) {
ogs_error("cJSON_Print() failed");
return NULL;
}
item = cJSON_Parse(content);
ogs_free(content);
if (!item) {
ogs_error("cJSON_Parse() failed");
return NULL;
}
OpenAPI_n32f_error_info_free(dst);
dst = OpenAPI_n32f_error_info_parseFromJSON(item);
cJSON_Delete(item);
return dst;
}

View File

@ -0,0 +1,49 @@
/*
* n32f_error_info.h
*
* N32-f error information
*/
#ifndef _OpenAPI_n32f_error_info_H_
#define _OpenAPI_n32f_error_info_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#include "failed_modification_info.h"
#include "n32f_error_detail.h"
#include "n32f_error_type.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct OpenAPI_n32f_error_info_s OpenAPI_n32f_error_info_t;
typedef struct OpenAPI_n32f_error_info_s {
char *n32f_message_id;
OpenAPI_n32f_error_type_e n32f_error_type;
char *n32f_context_id;
OpenAPI_list_t *failed_modification_list;
OpenAPI_list_t *error_details_list;
} OpenAPI_n32f_error_info_t;
OpenAPI_n32f_error_info_t *OpenAPI_n32f_error_info_create(
char *n32f_message_id,
OpenAPI_n32f_error_type_e n32f_error_type,
char *n32f_context_id,
OpenAPI_list_t *failed_modification_list,
OpenAPI_list_t *error_details_list
);
void OpenAPI_n32f_error_info_free(OpenAPI_n32f_error_info_t *n32f_error_info);
OpenAPI_n32f_error_info_t *OpenAPI_n32f_error_info_parseFromJSON(cJSON *n32f_error_infoJSON);
cJSON *OpenAPI_n32f_error_info_convertToJSON(OpenAPI_n32f_error_info_t *n32f_error_info);
OpenAPI_n32f_error_info_t *OpenAPI_n32f_error_info_copy(OpenAPI_n32f_error_info_t *dst, OpenAPI_n32f_error_info_t *src);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_n32f_error_info_H_ */

View File

@ -0,0 +1,30 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "n32f_error_type.h"
char* OpenAPI_n32f_error_type_ToString(OpenAPI_n32f_error_type_e n32f_error_type)
{
const char *n32f_error_typeArray[] = { "NULL", "INTEGRITY_CHECK_FAILED", "INTEGRITY_CHECK_ON_MODIFICATIONS_FAILED", "MODIFICATIONS_INSTRUCTIONS_FAILED", "DECIPHERING_FAILED", "MESSAGE_RECONSTRUCTION_FAILED", "CONTEXT_NOT_FOUND", "INTEGRITY_KEY_EXPIRED", "ENCRYPTION_KEY_EXPIRED", "POLICY_MISMATCH" };
size_t sizeofArray = sizeof(n32f_error_typeArray) / sizeof(n32f_error_typeArray[0]);
if (n32f_error_type < sizeofArray)
return (char *)n32f_error_typeArray[n32f_error_type];
else
return (char *)"Unknown";
}
OpenAPI_n32f_error_type_e OpenAPI_n32f_error_type_FromString(char* n32f_error_type)
{
int stringToReturn = 0;
const char *n32f_error_typeArray[] = { "NULL", "INTEGRITY_CHECK_FAILED", "INTEGRITY_CHECK_ON_MODIFICATIONS_FAILED", "MODIFICATIONS_INSTRUCTIONS_FAILED", "DECIPHERING_FAILED", "MESSAGE_RECONSTRUCTION_FAILED", "CONTEXT_NOT_FOUND", "INTEGRITY_KEY_EXPIRED", "ENCRYPTION_KEY_EXPIRED", "POLICY_MISMATCH" };
size_t sizeofArray = sizeof(n32f_error_typeArray) / sizeof(n32f_error_typeArray[0]);
while (stringToReturn < sizeofArray) {
if (strcmp(n32f_error_type, n32f_error_typeArray[stringToReturn]) == 0) {
return stringToReturn;
}
stringToReturn++;
}
return 0;
}

View File

@ -0,0 +1,31 @@
/*
* n32f_error_type.h
*
*
*/
#ifndef _OpenAPI_n32f_error_type_H_
#define _OpenAPI_n32f_error_type_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum { OpenAPI_n32f_error_type_NULL = 0, OpenAPI_n32f_error_type_INTEGRITY_CHECK_FAILED, OpenAPI_n32f_error_type_INTEGRITY_CHECK_ON_MODIFICATIONS_FAILED, OpenAPI_n32f_error_type_MODIFICATIONS_INSTRUCTIONS_FAILED, OpenAPI_n32f_error_type_DECIPHERING_FAILED, OpenAPI_n32f_error_type_MESSAGE_RECONSTRUCTION_FAILED, OpenAPI_n32f_error_type_CONTEXT_NOT_FOUND, OpenAPI_n32f_error_type_INTEGRITY_KEY_EXPIRED, OpenAPI_n32f_error_type_ENCRYPTION_KEY_EXPIRED, OpenAPI_n32f_error_type_POLICY_MISMATCH } OpenAPI_n32f_error_type_e;
char* OpenAPI_n32f_error_type_ToString(OpenAPI_n32f_error_type_e n32f_error_type);
OpenAPI_n32f_error_type_e OpenAPI_n32f_error_type_FromString(char* n32f_error_type);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_n32f_error_type_H_ */

View File

@ -0,0 +1,30 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "n32f_error_type_any_of.h"
char* OpenAPI_n32f_error_type_any_of_ToString(OpenAPI_n32f_error_type_any_of_e n32f_error_type_any_of)
{
const char *n32f_error_type_any_ofArray[] = { "NULL", "INTEGRITY_CHECK_FAILED", "INTEGRITY_CHECK_ON_MODIFICATIONS_FAILED", "MODIFICATIONS_INSTRUCTIONS_FAILED", "DECIPHERING_FAILED", "MESSAGE_RECONSTRUCTION_FAILED", "CONTEXT_NOT_FOUND", "INTEGRITY_KEY_EXPIRED", "ENCRYPTION_KEY_EXPIRED", "POLICY_MISMATCH" };
size_t sizeofArray = sizeof(n32f_error_type_any_ofArray) / sizeof(n32f_error_type_any_ofArray[0]);
if (n32f_error_type_any_of < sizeofArray)
return (char *)n32f_error_type_any_ofArray[n32f_error_type_any_of];
else
return (char *)"Unknown";
}
OpenAPI_n32f_error_type_any_of_e OpenAPI_n32f_error_type_any_of_FromString(char* n32f_error_type_any_of)
{
int stringToReturn = 0;
const char *n32f_error_type_any_ofArray[] = { "NULL", "INTEGRITY_CHECK_FAILED", "INTEGRITY_CHECK_ON_MODIFICATIONS_FAILED", "MODIFICATIONS_INSTRUCTIONS_FAILED", "DECIPHERING_FAILED", "MESSAGE_RECONSTRUCTION_FAILED", "CONTEXT_NOT_FOUND", "INTEGRITY_KEY_EXPIRED", "ENCRYPTION_KEY_EXPIRED", "POLICY_MISMATCH" };
size_t sizeofArray = sizeof(n32f_error_type_any_ofArray) / sizeof(n32f_error_type_any_ofArray[0]);
while (stringToReturn < sizeofArray) {
if (strcmp(n32f_error_type_any_of, n32f_error_type_any_ofArray[stringToReturn]) == 0) {
return stringToReturn;
}
stringToReturn++;
}
return 0;
}

View File

@ -0,0 +1,31 @@
/*
* n32f_error_type_any_of.h
*
*
*/
#ifndef _OpenAPI_n32f_error_type_any_of_H_
#define _OpenAPI_n32f_error_type_any_of_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum { OpenAPI_n32f_error_type_any_of_NULL = 0, OpenAPI_n32f_error_type_any_of_INTEGRITY_CHECK_FAILED, OpenAPI_n32f_error_type_any_of_INTEGRITY_CHECK_ON_MODIFICATIONS_FAILED, OpenAPI_n32f_error_type_any_of_MODIFICATIONS_INSTRUCTIONS_FAILED, OpenAPI_n32f_error_type_any_of_DECIPHERING_FAILED, OpenAPI_n32f_error_type_any_of_MESSAGE_RECONSTRUCTION_FAILED, OpenAPI_n32f_error_type_any_of_CONTEXT_NOT_FOUND, OpenAPI_n32f_error_type_any_of_INTEGRITY_KEY_EXPIRED, OpenAPI_n32f_error_type_any_of_ENCRYPTION_KEY_EXPIRED, OpenAPI_n32f_error_type_any_of_POLICY_MISMATCH } OpenAPI_n32f_error_type_any_of_e;
char* OpenAPI_n32f_error_type_any_of_ToString(OpenAPI_n32f_error_type_any_of_e n32f_error_type_any_of);
OpenAPI_n32f_error_type_any_of_e OpenAPI_n32f_error_type_any_of_FromString(char* n32f_error_type_any_of);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_n32f_error_type_any_of_H_ */

View File

@ -0,0 +1,197 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "protection_policy.h"
OpenAPI_protection_policy_t *OpenAPI_protection_policy_create(
OpenAPI_list_t *api_ie_mapping_list,
OpenAPI_list_t *data_type_enc_policy
)
{
OpenAPI_protection_policy_t *protection_policy_local_var = ogs_malloc(sizeof(OpenAPI_protection_policy_t));
ogs_assert(protection_policy_local_var);
protection_policy_local_var->api_ie_mapping_list = api_ie_mapping_list;
protection_policy_local_var->data_type_enc_policy = data_type_enc_policy;
return protection_policy_local_var;
}
void OpenAPI_protection_policy_free(OpenAPI_protection_policy_t *protection_policy)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == protection_policy) {
return;
}
if (protection_policy->api_ie_mapping_list) {
OpenAPI_list_for_each(protection_policy->api_ie_mapping_list, node) {
OpenAPI_api_ie_mapping_free(node->data);
}
OpenAPI_list_free(protection_policy->api_ie_mapping_list);
protection_policy->api_ie_mapping_list = NULL;
}
if (protection_policy->data_type_enc_policy) {
OpenAPI_list_free(protection_policy->data_type_enc_policy);
protection_policy->data_type_enc_policy = NULL;
}
ogs_free(protection_policy);
}
cJSON *OpenAPI_protection_policy_convertToJSON(OpenAPI_protection_policy_t *protection_policy)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (protection_policy == NULL) {
ogs_error("OpenAPI_protection_policy_convertToJSON() failed [ProtectionPolicy]");
return NULL;
}
item = cJSON_CreateObject();
if (!protection_policy->api_ie_mapping_list) {
ogs_error("OpenAPI_protection_policy_convertToJSON() failed [api_ie_mapping_list]");
return NULL;
}
cJSON *api_ie_mapping_listList = cJSON_AddArrayToObject(item, "apiIeMappingList");
if (api_ie_mapping_listList == NULL) {
ogs_error("OpenAPI_protection_policy_convertToJSON() failed [api_ie_mapping_list]");
goto end;
}
OpenAPI_list_for_each(protection_policy->api_ie_mapping_list, node) {
cJSON *itemLocal = OpenAPI_api_ie_mapping_convertToJSON(node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_protection_policy_convertToJSON() failed [api_ie_mapping_list]");
goto end;
}
cJSON_AddItemToArray(api_ie_mapping_listList, itemLocal);
}
if (protection_policy->data_type_enc_policy != OpenAPI_ie_type_NULL) {
cJSON *data_type_enc_policyList = cJSON_AddArrayToObject(item, "dataTypeEncPolicy");
if (data_type_enc_policyList == NULL) {
ogs_error("OpenAPI_protection_policy_convertToJSON() failed [data_type_enc_policy]");
goto end;
}
OpenAPI_list_for_each(protection_policy->data_type_enc_policy, node) {
if (cJSON_AddStringToObject(data_type_enc_policyList, "", OpenAPI_ie_type_ToString((intptr_t)node->data)) == NULL) {
ogs_error("OpenAPI_protection_policy_convertToJSON() failed [data_type_enc_policy]");
goto end;
}
}
}
end:
return item;
}
OpenAPI_protection_policy_t *OpenAPI_protection_policy_parseFromJSON(cJSON *protection_policyJSON)
{
OpenAPI_protection_policy_t *protection_policy_local_var = NULL;
OpenAPI_lnode_t *node = NULL;
cJSON *api_ie_mapping_list = NULL;
OpenAPI_list_t *api_ie_mapping_listList = NULL;
cJSON *data_type_enc_policy = NULL;
OpenAPI_list_t *data_type_enc_policyList = NULL;
api_ie_mapping_list = cJSON_GetObjectItemCaseSensitive(protection_policyJSON, "apiIeMappingList");
if (!api_ie_mapping_list) {
ogs_error("OpenAPI_protection_policy_parseFromJSON() failed [api_ie_mapping_list]");
goto end;
}
cJSON *api_ie_mapping_list_local = NULL;
if (!cJSON_IsArray(api_ie_mapping_list)) {
ogs_error("OpenAPI_protection_policy_parseFromJSON() failed [api_ie_mapping_list]");
goto end;
}
api_ie_mapping_listList = OpenAPI_list_create();
cJSON_ArrayForEach(api_ie_mapping_list_local, api_ie_mapping_list) {
if (!cJSON_IsObject(api_ie_mapping_list_local)) {
ogs_error("OpenAPI_protection_policy_parseFromJSON() failed [api_ie_mapping_list]");
goto end;
}
OpenAPI_api_ie_mapping_t *api_ie_mapping_listItem = OpenAPI_api_ie_mapping_parseFromJSON(api_ie_mapping_list_local);
if (!api_ie_mapping_listItem) {
ogs_error("No api_ie_mapping_listItem");
OpenAPI_list_free(api_ie_mapping_listList);
goto end;
}
OpenAPI_list_add(api_ie_mapping_listList, api_ie_mapping_listItem);
}
data_type_enc_policy = cJSON_GetObjectItemCaseSensitive(protection_policyJSON, "dataTypeEncPolicy");
if (data_type_enc_policy) {
cJSON *data_type_enc_policy_local = NULL;
if (!cJSON_IsArray(data_type_enc_policy)) {
ogs_error("OpenAPI_protection_policy_parseFromJSON() failed [data_type_enc_policy]");
goto end;
}
data_type_enc_policyList = OpenAPI_list_create();
cJSON_ArrayForEach(data_type_enc_policy_local, data_type_enc_policy) {
if (!cJSON_IsString(data_type_enc_policy_local)) {
ogs_error("OpenAPI_protection_policy_parseFromJSON() failed [data_type_enc_policy]");
goto end;
}
OpenAPI_list_add(data_type_enc_policyList, (void *)OpenAPI_ie_type_FromString(data_type_enc_policy_local->valuestring));
}
}
protection_policy_local_var = OpenAPI_protection_policy_create (
api_ie_mapping_listList,
data_type_enc_policy ? data_type_enc_policyList : NULL
);
return protection_policy_local_var;
end:
if (api_ie_mapping_listList) {
OpenAPI_list_for_each(api_ie_mapping_listList, node) {
OpenAPI_api_ie_mapping_free(node->data);
}
OpenAPI_list_free(api_ie_mapping_listList);
api_ie_mapping_listList = NULL;
}
if (data_type_enc_policyList) {
OpenAPI_list_free(data_type_enc_policyList);
data_type_enc_policyList = NULL;
}
return NULL;
}
OpenAPI_protection_policy_t *OpenAPI_protection_policy_copy(OpenAPI_protection_policy_t *dst, OpenAPI_protection_policy_t *src)
{
cJSON *item = NULL;
char *content = NULL;
ogs_assert(src);
item = OpenAPI_protection_policy_convertToJSON(src);
if (!item) {
ogs_error("OpenAPI_protection_policy_convertToJSON() failed");
return NULL;
}
content = cJSON_Print(item);
cJSON_Delete(item);
if (!content) {
ogs_error("cJSON_Print() failed");
return NULL;
}
item = cJSON_Parse(content);
ogs_free(content);
if (!item) {
ogs_error("cJSON_Parse() failed");
return NULL;
}
OpenAPI_protection_policy_free(dst);
dst = OpenAPI_protection_policy_parseFromJSON(item);
cJSON_Delete(item);
return dst;
}

View File

@ -0,0 +1,42 @@
/*
* protection_policy.h
*
* The protection policy to be negotiated between the SEPPs
*/
#ifndef _OpenAPI_protection_policy_H_
#define _OpenAPI_protection_policy_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#include "api_ie_mapping.h"
#include "ie_type.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct OpenAPI_protection_policy_s OpenAPI_protection_policy_t;
typedef struct OpenAPI_protection_policy_s {
OpenAPI_list_t *api_ie_mapping_list;
OpenAPI_list_t *data_type_enc_policy;
} OpenAPI_protection_policy_t;
OpenAPI_protection_policy_t *OpenAPI_protection_policy_create(
OpenAPI_list_t *api_ie_mapping_list,
OpenAPI_list_t *data_type_enc_policy
);
void OpenAPI_protection_policy_free(OpenAPI_protection_policy_t *protection_policy);
OpenAPI_protection_policy_t *OpenAPI_protection_policy_parseFromJSON(cJSON *protection_policyJSON);
cJSON *OpenAPI_protection_policy_convertToJSON(OpenAPI_protection_policy_t *protection_policy);
OpenAPI_protection_policy_t *OpenAPI_protection_policy_copy(OpenAPI_protection_policy_t *dst, OpenAPI_protection_policy_t *src);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_protection_policy_H_ */

View File

@ -0,0 +1,451 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "sec_negotiate_req_data.h"
OpenAPI_sec_negotiate_req_data_t *OpenAPI_sec_negotiate_req_data_create(
char *sender,
OpenAPI_list_t *supported_sec_capability_list,
bool is__3_gpp_sbi_target_api_root_supported,
int _3_gpp_sbi_target_api_root_supported,
OpenAPI_list_t *plmn_id_list,
OpenAPI_list_t *snpn_id_list,
OpenAPI_plmn_id_t *target_plmn_id,
OpenAPI_plmn_id_nid_t *target_snpn_id,
OpenAPI_list_t *intended_usage_purpose,
char *supported_features
)
{
OpenAPI_sec_negotiate_req_data_t *sec_negotiate_req_data_local_var = ogs_malloc(sizeof(OpenAPI_sec_negotiate_req_data_t));
ogs_assert(sec_negotiate_req_data_local_var);
sec_negotiate_req_data_local_var->sender = sender;
sec_negotiate_req_data_local_var->supported_sec_capability_list = supported_sec_capability_list;
sec_negotiate_req_data_local_var->is__3_gpp_sbi_target_api_root_supported = is__3_gpp_sbi_target_api_root_supported;
sec_negotiate_req_data_local_var->_3_gpp_sbi_target_api_root_supported = _3_gpp_sbi_target_api_root_supported;
sec_negotiate_req_data_local_var->plmn_id_list = plmn_id_list;
sec_negotiate_req_data_local_var->snpn_id_list = snpn_id_list;
sec_negotiate_req_data_local_var->target_plmn_id = target_plmn_id;
sec_negotiate_req_data_local_var->target_snpn_id = target_snpn_id;
sec_negotiate_req_data_local_var->intended_usage_purpose = intended_usage_purpose;
sec_negotiate_req_data_local_var->supported_features = supported_features;
return sec_negotiate_req_data_local_var;
}
void OpenAPI_sec_negotiate_req_data_free(OpenAPI_sec_negotiate_req_data_t *sec_negotiate_req_data)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == sec_negotiate_req_data) {
return;
}
if (sec_negotiate_req_data->sender) {
ogs_free(sec_negotiate_req_data->sender);
sec_negotiate_req_data->sender = NULL;
}
if (sec_negotiate_req_data->supported_sec_capability_list) {
OpenAPI_list_free(sec_negotiate_req_data->supported_sec_capability_list);
sec_negotiate_req_data->supported_sec_capability_list = NULL;
}
if (sec_negotiate_req_data->plmn_id_list) {
OpenAPI_list_for_each(sec_negotiate_req_data->plmn_id_list, node) {
OpenAPI_plmn_id_free(node->data);
}
OpenAPI_list_free(sec_negotiate_req_data->plmn_id_list);
sec_negotiate_req_data->plmn_id_list = NULL;
}
if (sec_negotiate_req_data->snpn_id_list) {
OpenAPI_list_for_each(sec_negotiate_req_data->snpn_id_list, node) {
OpenAPI_plmn_id_nid_free(node->data);
}
OpenAPI_list_free(sec_negotiate_req_data->snpn_id_list);
sec_negotiate_req_data->snpn_id_list = NULL;
}
if (sec_negotiate_req_data->target_plmn_id) {
OpenAPI_plmn_id_free(sec_negotiate_req_data->target_plmn_id);
sec_negotiate_req_data->target_plmn_id = NULL;
}
if (sec_negotiate_req_data->target_snpn_id) {
OpenAPI_plmn_id_nid_free(sec_negotiate_req_data->target_snpn_id);
sec_negotiate_req_data->target_snpn_id = NULL;
}
if (sec_negotiate_req_data->intended_usage_purpose) {
OpenAPI_list_for_each(sec_negotiate_req_data->intended_usage_purpose, node) {
OpenAPI_intended_n32_purpose_free(node->data);
}
OpenAPI_list_free(sec_negotiate_req_data->intended_usage_purpose);
sec_negotiate_req_data->intended_usage_purpose = NULL;
}
if (sec_negotiate_req_data->supported_features) {
ogs_free(sec_negotiate_req_data->supported_features);
sec_negotiate_req_data->supported_features = NULL;
}
ogs_free(sec_negotiate_req_data);
}
cJSON *OpenAPI_sec_negotiate_req_data_convertToJSON(OpenAPI_sec_negotiate_req_data_t *sec_negotiate_req_data)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (sec_negotiate_req_data == NULL) {
ogs_error("OpenAPI_sec_negotiate_req_data_convertToJSON() failed [SecNegotiateReqData]");
return NULL;
}
item = cJSON_CreateObject();
if (!sec_negotiate_req_data->sender) {
ogs_error("OpenAPI_sec_negotiate_req_data_convertToJSON() failed [sender]");
return NULL;
}
if (cJSON_AddStringToObject(item, "sender", sec_negotiate_req_data->sender) == NULL) {
ogs_error("OpenAPI_sec_negotiate_req_data_convertToJSON() failed [sender]");
goto end;
}
if (sec_negotiate_req_data->supported_sec_capability_list == OpenAPI_security_capability_NULL) {
ogs_error("OpenAPI_sec_negotiate_req_data_convertToJSON() failed [supported_sec_capability_list]");
return NULL;
}
cJSON *supported_sec_capability_listList = cJSON_AddArrayToObject(item, "supportedSecCapabilityList");
if (supported_sec_capability_listList == NULL) {
ogs_error("OpenAPI_sec_negotiate_req_data_convertToJSON() failed [supported_sec_capability_list]");
goto end;
}
OpenAPI_list_for_each(sec_negotiate_req_data->supported_sec_capability_list, node) {
if (cJSON_AddStringToObject(supported_sec_capability_listList, "", OpenAPI_security_capability_ToString((intptr_t)node->data)) == NULL) {
ogs_error("OpenAPI_sec_negotiate_req_data_convertToJSON() failed [supported_sec_capability_list]");
goto end;
}
}
if (sec_negotiate_req_data->is__3_gpp_sbi_target_api_root_supported) {
if (cJSON_AddBoolToObject(item, "3GppSbiTargetApiRootSupported", sec_negotiate_req_data->_3_gpp_sbi_target_api_root_supported) == NULL) {
ogs_error("OpenAPI_sec_negotiate_req_data_convertToJSON() failed [_3_gpp_sbi_target_api_root_supported]");
goto end;
}
}
if (sec_negotiate_req_data->plmn_id_list) {
cJSON *plmn_id_listList = cJSON_AddArrayToObject(item, "plmnIdList");
if (plmn_id_listList == NULL) {
ogs_error("OpenAPI_sec_negotiate_req_data_convertToJSON() failed [plmn_id_list]");
goto end;
}
OpenAPI_list_for_each(sec_negotiate_req_data->plmn_id_list, node) {
cJSON *itemLocal = OpenAPI_plmn_id_convertToJSON(node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_sec_negotiate_req_data_convertToJSON() failed [plmn_id_list]");
goto end;
}
cJSON_AddItemToArray(plmn_id_listList, itemLocal);
}
}
if (sec_negotiate_req_data->snpn_id_list) {
cJSON *snpn_id_listList = cJSON_AddArrayToObject(item, "snpnIdList");
if (snpn_id_listList == NULL) {
ogs_error("OpenAPI_sec_negotiate_req_data_convertToJSON() failed [snpn_id_list]");
goto end;
}
OpenAPI_list_for_each(sec_negotiate_req_data->snpn_id_list, node) {
cJSON *itemLocal = OpenAPI_plmn_id_nid_convertToJSON(node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_sec_negotiate_req_data_convertToJSON() failed [snpn_id_list]");
goto end;
}
cJSON_AddItemToArray(snpn_id_listList, itemLocal);
}
}
if (sec_negotiate_req_data->target_plmn_id) {
cJSON *target_plmn_id_local_JSON = OpenAPI_plmn_id_convertToJSON(sec_negotiate_req_data->target_plmn_id);
if (target_plmn_id_local_JSON == NULL) {
ogs_error("OpenAPI_sec_negotiate_req_data_convertToJSON() failed [target_plmn_id]");
goto end;
}
cJSON_AddItemToObject(item, "targetPlmnId", target_plmn_id_local_JSON);
if (item->child == NULL) {
ogs_error("OpenAPI_sec_negotiate_req_data_convertToJSON() failed [target_plmn_id]");
goto end;
}
}
if (sec_negotiate_req_data->target_snpn_id) {
cJSON *target_snpn_id_local_JSON = OpenAPI_plmn_id_nid_convertToJSON(sec_negotiate_req_data->target_snpn_id);
if (target_snpn_id_local_JSON == NULL) {
ogs_error("OpenAPI_sec_negotiate_req_data_convertToJSON() failed [target_snpn_id]");
goto end;
}
cJSON_AddItemToObject(item, "targetSnpnId", target_snpn_id_local_JSON);
if (item->child == NULL) {
ogs_error("OpenAPI_sec_negotiate_req_data_convertToJSON() failed [target_snpn_id]");
goto end;
}
}
if (sec_negotiate_req_data->intended_usage_purpose) {
cJSON *intended_usage_purposeList = cJSON_AddArrayToObject(item, "intendedUsagePurpose");
if (intended_usage_purposeList == NULL) {
ogs_error("OpenAPI_sec_negotiate_req_data_convertToJSON() failed [intended_usage_purpose]");
goto end;
}
OpenAPI_list_for_each(sec_negotiate_req_data->intended_usage_purpose, node) {
cJSON *itemLocal = OpenAPI_intended_n32_purpose_convertToJSON(node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_sec_negotiate_req_data_convertToJSON() failed [intended_usage_purpose]");
goto end;
}
cJSON_AddItemToArray(intended_usage_purposeList, itemLocal);
}
}
if (sec_negotiate_req_data->supported_features) {
if (cJSON_AddStringToObject(item, "supportedFeatures", sec_negotiate_req_data->supported_features) == NULL) {
ogs_error("OpenAPI_sec_negotiate_req_data_convertToJSON() failed [supported_features]");
goto end;
}
}
end:
return item;
}
OpenAPI_sec_negotiate_req_data_t *OpenAPI_sec_negotiate_req_data_parseFromJSON(cJSON *sec_negotiate_req_dataJSON)
{
OpenAPI_sec_negotiate_req_data_t *sec_negotiate_req_data_local_var = NULL;
OpenAPI_lnode_t *node = NULL;
cJSON *sender = NULL;
cJSON *supported_sec_capability_list = NULL;
OpenAPI_list_t *supported_sec_capability_listList = NULL;
cJSON *_3_gpp_sbi_target_api_root_supported = NULL;
cJSON *plmn_id_list = NULL;
OpenAPI_list_t *plmn_id_listList = NULL;
cJSON *snpn_id_list = NULL;
OpenAPI_list_t *snpn_id_listList = NULL;
cJSON *target_plmn_id = NULL;
OpenAPI_plmn_id_t *target_plmn_id_local_nonprim = NULL;
cJSON *target_snpn_id = NULL;
OpenAPI_plmn_id_nid_t *target_snpn_id_local_nonprim = NULL;
cJSON *intended_usage_purpose = NULL;
OpenAPI_list_t *intended_usage_purposeList = NULL;
cJSON *supported_features = NULL;
sender = cJSON_GetObjectItemCaseSensitive(sec_negotiate_req_dataJSON, "sender");
if (!sender) {
ogs_error("OpenAPI_sec_negotiate_req_data_parseFromJSON() failed [sender]");
goto end;
}
if (!cJSON_IsString(sender)) {
ogs_error("OpenAPI_sec_negotiate_req_data_parseFromJSON() failed [sender]");
goto end;
}
supported_sec_capability_list = cJSON_GetObjectItemCaseSensitive(sec_negotiate_req_dataJSON, "supportedSecCapabilityList");
if (!supported_sec_capability_list) {
ogs_error("OpenAPI_sec_negotiate_req_data_parseFromJSON() failed [supported_sec_capability_list]");
goto end;
}
cJSON *supported_sec_capability_list_local = NULL;
if (!cJSON_IsArray(supported_sec_capability_list)) {
ogs_error("OpenAPI_sec_negotiate_req_data_parseFromJSON() failed [supported_sec_capability_list]");
goto end;
}
supported_sec_capability_listList = OpenAPI_list_create();
cJSON_ArrayForEach(supported_sec_capability_list_local, supported_sec_capability_list) {
if (!cJSON_IsString(supported_sec_capability_list_local)) {
ogs_error("OpenAPI_sec_negotiate_req_data_parseFromJSON() failed [supported_sec_capability_list]");
goto end;
}
OpenAPI_list_add(supported_sec_capability_listList, (void *)OpenAPI_security_capability_FromString(supported_sec_capability_list_local->valuestring));
}
_3_gpp_sbi_target_api_root_supported = cJSON_GetObjectItemCaseSensitive(sec_negotiate_req_dataJSON, "3GppSbiTargetApiRootSupported");
if (_3_gpp_sbi_target_api_root_supported) {
if (!cJSON_IsBool(_3_gpp_sbi_target_api_root_supported)) {
ogs_error("OpenAPI_sec_negotiate_req_data_parseFromJSON() failed [_3_gpp_sbi_target_api_root_supported]");
goto end;
}
}
plmn_id_list = cJSON_GetObjectItemCaseSensitive(sec_negotiate_req_dataJSON, "plmnIdList");
if (plmn_id_list) {
cJSON *plmn_id_list_local = NULL;
if (!cJSON_IsArray(plmn_id_list)) {
ogs_error("OpenAPI_sec_negotiate_req_data_parseFromJSON() failed [plmn_id_list]");
goto end;
}
plmn_id_listList = OpenAPI_list_create();
cJSON_ArrayForEach(plmn_id_list_local, plmn_id_list) {
if (!cJSON_IsObject(plmn_id_list_local)) {
ogs_error("OpenAPI_sec_negotiate_req_data_parseFromJSON() failed [plmn_id_list]");
goto end;
}
OpenAPI_plmn_id_t *plmn_id_listItem = OpenAPI_plmn_id_parseFromJSON(plmn_id_list_local);
if (!plmn_id_listItem) {
ogs_error("No plmn_id_listItem");
OpenAPI_list_free(plmn_id_listList);
goto end;
}
OpenAPI_list_add(plmn_id_listList, plmn_id_listItem);
}
}
snpn_id_list = cJSON_GetObjectItemCaseSensitive(sec_negotiate_req_dataJSON, "snpnIdList");
if (snpn_id_list) {
cJSON *snpn_id_list_local = NULL;
if (!cJSON_IsArray(snpn_id_list)) {
ogs_error("OpenAPI_sec_negotiate_req_data_parseFromJSON() failed [snpn_id_list]");
goto end;
}
snpn_id_listList = OpenAPI_list_create();
cJSON_ArrayForEach(snpn_id_list_local, snpn_id_list) {
if (!cJSON_IsObject(snpn_id_list_local)) {
ogs_error("OpenAPI_sec_negotiate_req_data_parseFromJSON() failed [snpn_id_list]");
goto end;
}
OpenAPI_plmn_id_nid_t *snpn_id_listItem = OpenAPI_plmn_id_nid_parseFromJSON(snpn_id_list_local);
if (!snpn_id_listItem) {
ogs_error("No snpn_id_listItem");
OpenAPI_list_free(snpn_id_listList);
goto end;
}
OpenAPI_list_add(snpn_id_listList, snpn_id_listItem);
}
}
target_plmn_id = cJSON_GetObjectItemCaseSensitive(sec_negotiate_req_dataJSON, "targetPlmnId");
if (target_plmn_id) {
target_plmn_id_local_nonprim = OpenAPI_plmn_id_parseFromJSON(target_plmn_id);
}
target_snpn_id = cJSON_GetObjectItemCaseSensitive(sec_negotiate_req_dataJSON, "targetSnpnId");
if (target_snpn_id) {
target_snpn_id_local_nonprim = OpenAPI_plmn_id_nid_parseFromJSON(target_snpn_id);
}
intended_usage_purpose = cJSON_GetObjectItemCaseSensitive(sec_negotiate_req_dataJSON, "intendedUsagePurpose");
if (intended_usage_purpose) {
cJSON *intended_usage_purpose_local = NULL;
if (!cJSON_IsArray(intended_usage_purpose)) {
ogs_error("OpenAPI_sec_negotiate_req_data_parseFromJSON() failed [intended_usage_purpose]");
goto end;
}
intended_usage_purposeList = OpenAPI_list_create();
cJSON_ArrayForEach(intended_usage_purpose_local, intended_usage_purpose) {
if (!cJSON_IsObject(intended_usage_purpose_local)) {
ogs_error("OpenAPI_sec_negotiate_req_data_parseFromJSON() failed [intended_usage_purpose]");
goto end;
}
OpenAPI_intended_n32_purpose_t *intended_usage_purposeItem = OpenAPI_intended_n32_purpose_parseFromJSON(intended_usage_purpose_local);
if (!intended_usage_purposeItem) {
ogs_error("No intended_usage_purposeItem");
OpenAPI_list_free(intended_usage_purposeList);
goto end;
}
OpenAPI_list_add(intended_usage_purposeList, intended_usage_purposeItem);
}
}
supported_features = cJSON_GetObjectItemCaseSensitive(sec_negotiate_req_dataJSON, "supportedFeatures");
if (supported_features) {
if (!cJSON_IsString(supported_features) && !cJSON_IsNull(supported_features)) {
ogs_error("OpenAPI_sec_negotiate_req_data_parseFromJSON() failed [supported_features]");
goto end;
}
}
sec_negotiate_req_data_local_var = OpenAPI_sec_negotiate_req_data_create (
ogs_strdup(sender->valuestring),
supported_sec_capability_listList,
_3_gpp_sbi_target_api_root_supported ? true : false,
_3_gpp_sbi_target_api_root_supported ? _3_gpp_sbi_target_api_root_supported->valueint : 0,
plmn_id_list ? plmn_id_listList : NULL,
snpn_id_list ? snpn_id_listList : NULL,
target_plmn_id ? target_plmn_id_local_nonprim : NULL,
target_snpn_id ? target_snpn_id_local_nonprim : NULL,
intended_usage_purpose ? intended_usage_purposeList : NULL,
supported_features && !cJSON_IsNull(supported_features) ? ogs_strdup(supported_features->valuestring) : NULL
);
return sec_negotiate_req_data_local_var;
end:
if (supported_sec_capability_listList) {
OpenAPI_list_free(supported_sec_capability_listList);
supported_sec_capability_listList = NULL;
}
if (plmn_id_listList) {
OpenAPI_list_for_each(plmn_id_listList, node) {
OpenAPI_plmn_id_free(node->data);
}
OpenAPI_list_free(plmn_id_listList);
plmn_id_listList = NULL;
}
if (snpn_id_listList) {
OpenAPI_list_for_each(snpn_id_listList, node) {
OpenAPI_plmn_id_nid_free(node->data);
}
OpenAPI_list_free(snpn_id_listList);
snpn_id_listList = NULL;
}
if (target_plmn_id_local_nonprim) {
OpenAPI_plmn_id_free(target_plmn_id_local_nonprim);
target_plmn_id_local_nonprim = NULL;
}
if (target_snpn_id_local_nonprim) {
OpenAPI_plmn_id_nid_free(target_snpn_id_local_nonprim);
target_snpn_id_local_nonprim = NULL;
}
if (intended_usage_purposeList) {
OpenAPI_list_for_each(intended_usage_purposeList, node) {
OpenAPI_intended_n32_purpose_free(node->data);
}
OpenAPI_list_free(intended_usage_purposeList);
intended_usage_purposeList = NULL;
}
return NULL;
}
OpenAPI_sec_negotiate_req_data_t *OpenAPI_sec_negotiate_req_data_copy(OpenAPI_sec_negotiate_req_data_t *dst, OpenAPI_sec_negotiate_req_data_t *src)
{
cJSON *item = NULL;
char *content = NULL;
ogs_assert(src);
item = OpenAPI_sec_negotiate_req_data_convertToJSON(src);
if (!item) {
ogs_error("OpenAPI_sec_negotiate_req_data_convertToJSON() failed");
return NULL;
}
content = cJSON_Print(item);
cJSON_Delete(item);
if (!content) {
ogs_error("cJSON_Print() failed");
return NULL;
}
item = cJSON_Parse(content);
ogs_free(content);
if (!item) {
ogs_error("cJSON_Parse() failed");
return NULL;
}
OpenAPI_sec_negotiate_req_data_free(dst);
dst = OpenAPI_sec_negotiate_req_data_parseFromJSON(item);
cJSON_Delete(item);
return dst;
}

View File

@ -0,0 +1,60 @@
/*
* sec_negotiate_req_data.h
*
* Defines the security capabilities of a SEPP sent to a receiving SEPP
*/
#ifndef _OpenAPI_sec_negotiate_req_data_H_
#define _OpenAPI_sec_negotiate_req_data_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#include "intended_n32_purpose.h"
#include "plmn_id.h"
#include "plmn_id_nid.h"
#include "security_capability.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct OpenAPI_sec_negotiate_req_data_s OpenAPI_sec_negotiate_req_data_t;
typedef struct OpenAPI_sec_negotiate_req_data_s {
char *sender;
OpenAPI_list_t *supported_sec_capability_list;
bool is__3_gpp_sbi_target_api_root_supported;
int _3_gpp_sbi_target_api_root_supported;
OpenAPI_list_t *plmn_id_list;
OpenAPI_list_t *snpn_id_list;
struct OpenAPI_plmn_id_s *target_plmn_id;
struct OpenAPI_plmn_id_nid_s *target_snpn_id;
OpenAPI_list_t *intended_usage_purpose;
char *supported_features;
} OpenAPI_sec_negotiate_req_data_t;
OpenAPI_sec_negotiate_req_data_t *OpenAPI_sec_negotiate_req_data_create(
char *sender,
OpenAPI_list_t *supported_sec_capability_list,
bool is__3_gpp_sbi_target_api_root_supported,
int _3_gpp_sbi_target_api_root_supported,
OpenAPI_list_t *plmn_id_list,
OpenAPI_list_t *snpn_id_list,
OpenAPI_plmn_id_t *target_plmn_id,
OpenAPI_plmn_id_nid_t *target_snpn_id,
OpenAPI_list_t *intended_usage_purpose,
char *supported_features
);
void OpenAPI_sec_negotiate_req_data_free(OpenAPI_sec_negotiate_req_data_t *sec_negotiate_req_data);
OpenAPI_sec_negotiate_req_data_t *OpenAPI_sec_negotiate_req_data_parseFromJSON(cJSON *sec_negotiate_req_dataJSON);
cJSON *OpenAPI_sec_negotiate_req_data_convertToJSON(OpenAPI_sec_negotiate_req_data_t *sec_negotiate_req_data);
OpenAPI_sec_negotiate_req_data_t *OpenAPI_sec_negotiate_req_data_copy(OpenAPI_sec_negotiate_req_data_t *dst, OpenAPI_sec_negotiate_req_data_t *src);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_sec_negotiate_req_data_H_ */

View File

@ -0,0 +1,424 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "sec_negotiate_rsp_data.h"
OpenAPI_sec_negotiate_rsp_data_t *OpenAPI_sec_negotiate_rsp_data_create(
char *sender,
OpenAPI_security_capability_e selected_sec_capability,
bool is__3_gpp_sbi_target_api_root_supported,
int _3_gpp_sbi_target_api_root_supported,
OpenAPI_list_t *plmn_id_list,
OpenAPI_list_t *snpn_id_list,
OpenAPI_list_t *allowed_usage_purpose,
OpenAPI_list_t *rejected_usage_purpose,
char *supported_features
)
{
OpenAPI_sec_negotiate_rsp_data_t *sec_negotiate_rsp_data_local_var = ogs_malloc(sizeof(OpenAPI_sec_negotiate_rsp_data_t));
ogs_assert(sec_negotiate_rsp_data_local_var);
sec_negotiate_rsp_data_local_var->sender = sender;
sec_negotiate_rsp_data_local_var->selected_sec_capability = selected_sec_capability;
sec_negotiate_rsp_data_local_var->is__3_gpp_sbi_target_api_root_supported = is__3_gpp_sbi_target_api_root_supported;
sec_negotiate_rsp_data_local_var->_3_gpp_sbi_target_api_root_supported = _3_gpp_sbi_target_api_root_supported;
sec_negotiate_rsp_data_local_var->plmn_id_list = plmn_id_list;
sec_negotiate_rsp_data_local_var->snpn_id_list = snpn_id_list;
sec_negotiate_rsp_data_local_var->allowed_usage_purpose = allowed_usage_purpose;
sec_negotiate_rsp_data_local_var->rejected_usage_purpose = rejected_usage_purpose;
sec_negotiate_rsp_data_local_var->supported_features = supported_features;
return sec_negotiate_rsp_data_local_var;
}
void OpenAPI_sec_negotiate_rsp_data_free(OpenAPI_sec_negotiate_rsp_data_t *sec_negotiate_rsp_data)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == sec_negotiate_rsp_data) {
return;
}
if (sec_negotiate_rsp_data->sender) {
ogs_free(sec_negotiate_rsp_data->sender);
sec_negotiate_rsp_data->sender = NULL;
}
if (sec_negotiate_rsp_data->plmn_id_list) {
OpenAPI_list_for_each(sec_negotiate_rsp_data->plmn_id_list, node) {
OpenAPI_plmn_id_free(node->data);
}
OpenAPI_list_free(sec_negotiate_rsp_data->plmn_id_list);
sec_negotiate_rsp_data->plmn_id_list = NULL;
}
if (sec_negotiate_rsp_data->snpn_id_list) {
OpenAPI_list_for_each(sec_negotiate_rsp_data->snpn_id_list, node) {
OpenAPI_plmn_id_nid_free(node->data);
}
OpenAPI_list_free(sec_negotiate_rsp_data->snpn_id_list);
sec_negotiate_rsp_data->snpn_id_list = NULL;
}
if (sec_negotiate_rsp_data->allowed_usage_purpose) {
OpenAPI_list_for_each(sec_negotiate_rsp_data->allowed_usage_purpose, node) {
OpenAPI_intended_n32_purpose_free(node->data);
}
OpenAPI_list_free(sec_negotiate_rsp_data->allowed_usage_purpose);
sec_negotiate_rsp_data->allowed_usage_purpose = NULL;
}
if (sec_negotiate_rsp_data->rejected_usage_purpose) {
OpenAPI_list_for_each(sec_negotiate_rsp_data->rejected_usage_purpose, node) {
OpenAPI_intended_n32_purpose_free(node->data);
}
OpenAPI_list_free(sec_negotiate_rsp_data->rejected_usage_purpose);
sec_negotiate_rsp_data->rejected_usage_purpose = NULL;
}
if (sec_negotiate_rsp_data->supported_features) {
ogs_free(sec_negotiate_rsp_data->supported_features);
sec_negotiate_rsp_data->supported_features = NULL;
}
ogs_free(sec_negotiate_rsp_data);
}
cJSON *OpenAPI_sec_negotiate_rsp_data_convertToJSON(OpenAPI_sec_negotiate_rsp_data_t *sec_negotiate_rsp_data)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (sec_negotiate_rsp_data == NULL) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_convertToJSON() failed [SecNegotiateRspData]");
return NULL;
}
item = cJSON_CreateObject();
if (!sec_negotiate_rsp_data->sender) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_convertToJSON() failed [sender]");
return NULL;
}
if (cJSON_AddStringToObject(item, "sender", sec_negotiate_rsp_data->sender) == NULL) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_convertToJSON() failed [sender]");
goto end;
}
if (sec_negotiate_rsp_data->selected_sec_capability == OpenAPI_security_capability_NULL) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_convertToJSON() failed [selected_sec_capability]");
return NULL;
}
if (cJSON_AddStringToObject(item, "selectedSecCapability", OpenAPI_security_capability_ToString(sec_negotiate_rsp_data->selected_sec_capability)) == NULL) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_convertToJSON() failed [selected_sec_capability]");
goto end;
}
if (sec_negotiate_rsp_data->is__3_gpp_sbi_target_api_root_supported) {
if (cJSON_AddBoolToObject(item, "3GppSbiTargetApiRootSupported", sec_negotiate_rsp_data->_3_gpp_sbi_target_api_root_supported) == NULL) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_convertToJSON() failed [_3_gpp_sbi_target_api_root_supported]");
goto end;
}
}
if (sec_negotiate_rsp_data->plmn_id_list) {
cJSON *plmn_id_listList = cJSON_AddArrayToObject(item, "plmnIdList");
if (plmn_id_listList == NULL) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_convertToJSON() failed [plmn_id_list]");
goto end;
}
OpenAPI_list_for_each(sec_negotiate_rsp_data->plmn_id_list, node) {
cJSON *itemLocal = OpenAPI_plmn_id_convertToJSON(node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_convertToJSON() failed [plmn_id_list]");
goto end;
}
cJSON_AddItemToArray(plmn_id_listList, itemLocal);
}
}
if (sec_negotiate_rsp_data->snpn_id_list) {
cJSON *snpn_id_listList = cJSON_AddArrayToObject(item, "snpnIdList");
if (snpn_id_listList == NULL) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_convertToJSON() failed [snpn_id_list]");
goto end;
}
OpenAPI_list_for_each(sec_negotiate_rsp_data->snpn_id_list, node) {
cJSON *itemLocal = OpenAPI_plmn_id_nid_convertToJSON(node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_convertToJSON() failed [snpn_id_list]");
goto end;
}
cJSON_AddItemToArray(snpn_id_listList, itemLocal);
}
}
if (sec_negotiate_rsp_data->allowed_usage_purpose) {
cJSON *allowed_usage_purposeList = cJSON_AddArrayToObject(item, "allowedUsagePurpose");
if (allowed_usage_purposeList == NULL) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_convertToJSON() failed [allowed_usage_purpose]");
goto end;
}
OpenAPI_list_for_each(sec_negotiate_rsp_data->allowed_usage_purpose, node) {
cJSON *itemLocal = OpenAPI_intended_n32_purpose_convertToJSON(node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_convertToJSON() failed [allowed_usage_purpose]");
goto end;
}
cJSON_AddItemToArray(allowed_usage_purposeList, itemLocal);
}
}
if (sec_negotiate_rsp_data->rejected_usage_purpose) {
cJSON *rejected_usage_purposeList = cJSON_AddArrayToObject(item, "rejectedUsagePurpose");
if (rejected_usage_purposeList == NULL) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_convertToJSON() failed [rejected_usage_purpose]");
goto end;
}
OpenAPI_list_for_each(sec_negotiate_rsp_data->rejected_usage_purpose, node) {
cJSON *itemLocal = OpenAPI_intended_n32_purpose_convertToJSON(node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_convertToJSON() failed [rejected_usage_purpose]");
goto end;
}
cJSON_AddItemToArray(rejected_usage_purposeList, itemLocal);
}
}
if (sec_negotiate_rsp_data->supported_features) {
if (cJSON_AddStringToObject(item, "supportedFeatures", sec_negotiate_rsp_data->supported_features) == NULL) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_convertToJSON() failed [supported_features]");
goto end;
}
}
end:
return item;
}
OpenAPI_sec_negotiate_rsp_data_t *OpenAPI_sec_negotiate_rsp_data_parseFromJSON(cJSON *sec_negotiate_rsp_dataJSON)
{
OpenAPI_sec_negotiate_rsp_data_t *sec_negotiate_rsp_data_local_var = NULL;
OpenAPI_lnode_t *node = NULL;
cJSON *sender = NULL;
cJSON *selected_sec_capability = NULL;
OpenAPI_security_capability_e selected_sec_capabilityVariable = 0;
cJSON *_3_gpp_sbi_target_api_root_supported = NULL;
cJSON *plmn_id_list = NULL;
OpenAPI_list_t *plmn_id_listList = NULL;
cJSON *snpn_id_list = NULL;
OpenAPI_list_t *snpn_id_listList = NULL;
cJSON *allowed_usage_purpose = NULL;
OpenAPI_list_t *allowed_usage_purposeList = NULL;
cJSON *rejected_usage_purpose = NULL;
OpenAPI_list_t *rejected_usage_purposeList = NULL;
cJSON *supported_features = NULL;
sender = cJSON_GetObjectItemCaseSensitive(sec_negotiate_rsp_dataJSON, "sender");
if (!sender) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_parseFromJSON() failed [sender]");
goto end;
}
if (!cJSON_IsString(sender)) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_parseFromJSON() failed [sender]");
goto end;
}
selected_sec_capability = cJSON_GetObjectItemCaseSensitive(sec_negotiate_rsp_dataJSON, "selectedSecCapability");
if (!selected_sec_capability) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_parseFromJSON() failed [selected_sec_capability]");
goto end;
}
if (!cJSON_IsString(selected_sec_capability)) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_parseFromJSON() failed [selected_sec_capability]");
goto end;
}
selected_sec_capabilityVariable = OpenAPI_security_capability_FromString(selected_sec_capability->valuestring);
_3_gpp_sbi_target_api_root_supported = cJSON_GetObjectItemCaseSensitive(sec_negotiate_rsp_dataJSON, "3GppSbiTargetApiRootSupported");
if (_3_gpp_sbi_target_api_root_supported) {
if (!cJSON_IsBool(_3_gpp_sbi_target_api_root_supported)) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_parseFromJSON() failed [_3_gpp_sbi_target_api_root_supported]");
goto end;
}
}
plmn_id_list = cJSON_GetObjectItemCaseSensitive(sec_negotiate_rsp_dataJSON, "plmnIdList");
if (plmn_id_list) {
cJSON *plmn_id_list_local = NULL;
if (!cJSON_IsArray(plmn_id_list)) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_parseFromJSON() failed [plmn_id_list]");
goto end;
}
plmn_id_listList = OpenAPI_list_create();
cJSON_ArrayForEach(plmn_id_list_local, plmn_id_list) {
if (!cJSON_IsObject(plmn_id_list_local)) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_parseFromJSON() failed [plmn_id_list]");
goto end;
}
OpenAPI_plmn_id_t *plmn_id_listItem = OpenAPI_plmn_id_parseFromJSON(plmn_id_list_local);
if (!plmn_id_listItem) {
ogs_error("No plmn_id_listItem");
OpenAPI_list_free(plmn_id_listList);
goto end;
}
OpenAPI_list_add(plmn_id_listList, plmn_id_listItem);
}
}
snpn_id_list = cJSON_GetObjectItemCaseSensitive(sec_negotiate_rsp_dataJSON, "snpnIdList");
if (snpn_id_list) {
cJSON *snpn_id_list_local = NULL;
if (!cJSON_IsArray(snpn_id_list)) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_parseFromJSON() failed [snpn_id_list]");
goto end;
}
snpn_id_listList = OpenAPI_list_create();
cJSON_ArrayForEach(snpn_id_list_local, snpn_id_list) {
if (!cJSON_IsObject(snpn_id_list_local)) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_parseFromJSON() failed [snpn_id_list]");
goto end;
}
OpenAPI_plmn_id_nid_t *snpn_id_listItem = OpenAPI_plmn_id_nid_parseFromJSON(snpn_id_list_local);
if (!snpn_id_listItem) {
ogs_error("No snpn_id_listItem");
OpenAPI_list_free(snpn_id_listList);
goto end;
}
OpenAPI_list_add(snpn_id_listList, snpn_id_listItem);
}
}
allowed_usage_purpose = cJSON_GetObjectItemCaseSensitive(sec_negotiate_rsp_dataJSON, "allowedUsagePurpose");
if (allowed_usage_purpose) {
cJSON *allowed_usage_purpose_local = NULL;
if (!cJSON_IsArray(allowed_usage_purpose)) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_parseFromJSON() failed [allowed_usage_purpose]");
goto end;
}
allowed_usage_purposeList = OpenAPI_list_create();
cJSON_ArrayForEach(allowed_usage_purpose_local, allowed_usage_purpose) {
if (!cJSON_IsObject(allowed_usage_purpose_local)) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_parseFromJSON() failed [allowed_usage_purpose]");
goto end;
}
OpenAPI_intended_n32_purpose_t *allowed_usage_purposeItem = OpenAPI_intended_n32_purpose_parseFromJSON(allowed_usage_purpose_local);
if (!allowed_usage_purposeItem) {
ogs_error("No allowed_usage_purposeItem");
OpenAPI_list_free(allowed_usage_purposeList);
goto end;
}
OpenAPI_list_add(allowed_usage_purposeList, allowed_usage_purposeItem);
}
}
rejected_usage_purpose = cJSON_GetObjectItemCaseSensitive(sec_negotiate_rsp_dataJSON, "rejectedUsagePurpose");
if (rejected_usage_purpose) {
cJSON *rejected_usage_purpose_local = NULL;
if (!cJSON_IsArray(rejected_usage_purpose)) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_parseFromJSON() failed [rejected_usage_purpose]");
goto end;
}
rejected_usage_purposeList = OpenAPI_list_create();
cJSON_ArrayForEach(rejected_usage_purpose_local, rejected_usage_purpose) {
if (!cJSON_IsObject(rejected_usage_purpose_local)) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_parseFromJSON() failed [rejected_usage_purpose]");
goto end;
}
OpenAPI_intended_n32_purpose_t *rejected_usage_purposeItem = OpenAPI_intended_n32_purpose_parseFromJSON(rejected_usage_purpose_local);
if (!rejected_usage_purposeItem) {
ogs_error("No rejected_usage_purposeItem");
OpenAPI_list_free(rejected_usage_purposeList);
goto end;
}
OpenAPI_list_add(rejected_usage_purposeList, rejected_usage_purposeItem);
}
}
supported_features = cJSON_GetObjectItemCaseSensitive(sec_negotiate_rsp_dataJSON, "supportedFeatures");
if (supported_features) {
if (!cJSON_IsString(supported_features) && !cJSON_IsNull(supported_features)) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_parseFromJSON() failed [supported_features]");
goto end;
}
}
sec_negotiate_rsp_data_local_var = OpenAPI_sec_negotiate_rsp_data_create (
ogs_strdup(sender->valuestring),
selected_sec_capabilityVariable,
_3_gpp_sbi_target_api_root_supported ? true : false,
_3_gpp_sbi_target_api_root_supported ? _3_gpp_sbi_target_api_root_supported->valueint : 0,
plmn_id_list ? plmn_id_listList : NULL,
snpn_id_list ? snpn_id_listList : NULL,
allowed_usage_purpose ? allowed_usage_purposeList : NULL,
rejected_usage_purpose ? rejected_usage_purposeList : NULL,
supported_features && !cJSON_IsNull(supported_features) ? ogs_strdup(supported_features->valuestring) : NULL
);
return sec_negotiate_rsp_data_local_var;
end:
if (plmn_id_listList) {
OpenAPI_list_for_each(plmn_id_listList, node) {
OpenAPI_plmn_id_free(node->data);
}
OpenAPI_list_free(plmn_id_listList);
plmn_id_listList = NULL;
}
if (snpn_id_listList) {
OpenAPI_list_for_each(snpn_id_listList, node) {
OpenAPI_plmn_id_nid_free(node->data);
}
OpenAPI_list_free(snpn_id_listList);
snpn_id_listList = NULL;
}
if (allowed_usage_purposeList) {
OpenAPI_list_for_each(allowed_usage_purposeList, node) {
OpenAPI_intended_n32_purpose_free(node->data);
}
OpenAPI_list_free(allowed_usage_purposeList);
allowed_usage_purposeList = NULL;
}
if (rejected_usage_purposeList) {
OpenAPI_list_for_each(rejected_usage_purposeList, node) {
OpenAPI_intended_n32_purpose_free(node->data);
}
OpenAPI_list_free(rejected_usage_purposeList);
rejected_usage_purposeList = NULL;
}
return NULL;
}
OpenAPI_sec_negotiate_rsp_data_t *OpenAPI_sec_negotiate_rsp_data_copy(OpenAPI_sec_negotiate_rsp_data_t *dst, OpenAPI_sec_negotiate_rsp_data_t *src)
{
cJSON *item = NULL;
char *content = NULL;
ogs_assert(src);
item = OpenAPI_sec_negotiate_rsp_data_convertToJSON(src);
if (!item) {
ogs_error("OpenAPI_sec_negotiate_rsp_data_convertToJSON() failed");
return NULL;
}
content = cJSON_Print(item);
cJSON_Delete(item);
if (!content) {
ogs_error("cJSON_Print() failed");
return NULL;
}
item = cJSON_Parse(content);
ogs_free(content);
if (!item) {
ogs_error("cJSON_Parse() failed");
return NULL;
}
OpenAPI_sec_negotiate_rsp_data_free(dst);
dst = OpenAPI_sec_negotiate_rsp_data_parseFromJSON(item);
cJSON_Delete(item);
return dst;
}

View File

@ -0,0 +1,58 @@
/*
* sec_negotiate_rsp_data.h
*
* Defines the selected security capabilities by a SEPP
*/
#ifndef _OpenAPI_sec_negotiate_rsp_data_H_
#define _OpenAPI_sec_negotiate_rsp_data_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#include "intended_n32_purpose.h"
#include "plmn_id.h"
#include "plmn_id_nid.h"
#include "security_capability.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct OpenAPI_sec_negotiate_rsp_data_s OpenAPI_sec_negotiate_rsp_data_t;
typedef struct OpenAPI_sec_negotiate_rsp_data_s {
char *sender;
OpenAPI_security_capability_e selected_sec_capability;
bool is__3_gpp_sbi_target_api_root_supported;
int _3_gpp_sbi_target_api_root_supported;
OpenAPI_list_t *plmn_id_list;
OpenAPI_list_t *snpn_id_list;
OpenAPI_list_t *allowed_usage_purpose;
OpenAPI_list_t *rejected_usage_purpose;
char *supported_features;
} OpenAPI_sec_negotiate_rsp_data_t;
OpenAPI_sec_negotiate_rsp_data_t *OpenAPI_sec_negotiate_rsp_data_create(
char *sender,
OpenAPI_security_capability_e selected_sec_capability,
bool is__3_gpp_sbi_target_api_root_supported,
int _3_gpp_sbi_target_api_root_supported,
OpenAPI_list_t *plmn_id_list,
OpenAPI_list_t *snpn_id_list,
OpenAPI_list_t *allowed_usage_purpose,
OpenAPI_list_t *rejected_usage_purpose,
char *supported_features
);
void OpenAPI_sec_negotiate_rsp_data_free(OpenAPI_sec_negotiate_rsp_data_t *sec_negotiate_rsp_data);
OpenAPI_sec_negotiate_rsp_data_t *OpenAPI_sec_negotiate_rsp_data_parseFromJSON(cJSON *sec_negotiate_rsp_dataJSON);
cJSON *OpenAPI_sec_negotiate_rsp_data_convertToJSON(OpenAPI_sec_negotiate_rsp_data_t *sec_negotiate_rsp_data);
OpenAPI_sec_negotiate_rsp_data_t *OpenAPI_sec_negotiate_rsp_data_copy(OpenAPI_sec_negotiate_rsp_data_t *dst, OpenAPI_sec_negotiate_rsp_data_t *src);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_sec_negotiate_rsp_data_H_ */

View File

@ -0,0 +1,336 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "sec_param_exch_req_data.h"
OpenAPI_sec_param_exch_req_data_t *OpenAPI_sec_param_exch_req_data_create(
char *n32f_context_id,
OpenAPI_list_t *jwe_cipher_suite_list,
OpenAPI_list_t *jws_cipher_suite_list,
OpenAPI_protection_policy_t *protection_policy_info,
OpenAPI_list_t *ipx_provider_sec_info_list,
char *sender
)
{
OpenAPI_sec_param_exch_req_data_t *sec_param_exch_req_data_local_var = ogs_malloc(sizeof(OpenAPI_sec_param_exch_req_data_t));
ogs_assert(sec_param_exch_req_data_local_var);
sec_param_exch_req_data_local_var->n32f_context_id = n32f_context_id;
sec_param_exch_req_data_local_var->jwe_cipher_suite_list = jwe_cipher_suite_list;
sec_param_exch_req_data_local_var->jws_cipher_suite_list = jws_cipher_suite_list;
sec_param_exch_req_data_local_var->protection_policy_info = protection_policy_info;
sec_param_exch_req_data_local_var->ipx_provider_sec_info_list = ipx_provider_sec_info_list;
sec_param_exch_req_data_local_var->sender = sender;
return sec_param_exch_req_data_local_var;
}
void OpenAPI_sec_param_exch_req_data_free(OpenAPI_sec_param_exch_req_data_t *sec_param_exch_req_data)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == sec_param_exch_req_data) {
return;
}
if (sec_param_exch_req_data->n32f_context_id) {
ogs_free(sec_param_exch_req_data->n32f_context_id);
sec_param_exch_req_data->n32f_context_id = NULL;
}
if (sec_param_exch_req_data->jwe_cipher_suite_list) {
OpenAPI_list_for_each(sec_param_exch_req_data->jwe_cipher_suite_list, node) {
ogs_free(node->data);
}
OpenAPI_list_free(sec_param_exch_req_data->jwe_cipher_suite_list);
sec_param_exch_req_data->jwe_cipher_suite_list = NULL;
}
if (sec_param_exch_req_data->jws_cipher_suite_list) {
OpenAPI_list_for_each(sec_param_exch_req_data->jws_cipher_suite_list, node) {
ogs_free(node->data);
}
OpenAPI_list_free(sec_param_exch_req_data->jws_cipher_suite_list);
sec_param_exch_req_data->jws_cipher_suite_list = NULL;
}
if (sec_param_exch_req_data->protection_policy_info) {
OpenAPI_protection_policy_free(sec_param_exch_req_data->protection_policy_info);
sec_param_exch_req_data->protection_policy_info = NULL;
}
if (sec_param_exch_req_data->ipx_provider_sec_info_list) {
OpenAPI_list_for_each(sec_param_exch_req_data->ipx_provider_sec_info_list, node) {
OpenAPI_ipx_provider_sec_info_free(node->data);
}
OpenAPI_list_free(sec_param_exch_req_data->ipx_provider_sec_info_list);
sec_param_exch_req_data->ipx_provider_sec_info_list = NULL;
}
if (sec_param_exch_req_data->sender) {
ogs_free(sec_param_exch_req_data->sender);
sec_param_exch_req_data->sender = NULL;
}
ogs_free(sec_param_exch_req_data);
}
cJSON *OpenAPI_sec_param_exch_req_data_convertToJSON(OpenAPI_sec_param_exch_req_data_t *sec_param_exch_req_data)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (sec_param_exch_req_data == NULL) {
ogs_error("OpenAPI_sec_param_exch_req_data_convertToJSON() failed [SecParamExchReqData]");
return NULL;
}
item = cJSON_CreateObject();
if (!sec_param_exch_req_data->n32f_context_id) {
ogs_error("OpenAPI_sec_param_exch_req_data_convertToJSON() failed [n32f_context_id]");
return NULL;
}
if (cJSON_AddStringToObject(item, "n32fContextId", sec_param_exch_req_data->n32f_context_id) == NULL) {
ogs_error("OpenAPI_sec_param_exch_req_data_convertToJSON() failed [n32f_context_id]");
goto end;
}
if (sec_param_exch_req_data->jwe_cipher_suite_list) {
cJSON *jwe_cipher_suite_listList = cJSON_AddArrayToObject(item, "jweCipherSuiteList");
if (jwe_cipher_suite_listList == NULL) {
ogs_error("OpenAPI_sec_param_exch_req_data_convertToJSON() failed [jwe_cipher_suite_list]");
goto end;
}
OpenAPI_list_for_each(sec_param_exch_req_data->jwe_cipher_suite_list, node) {
if (cJSON_AddStringToObject(jwe_cipher_suite_listList, "", (char*)node->data) == NULL) {
ogs_error("OpenAPI_sec_param_exch_req_data_convertToJSON() failed [jwe_cipher_suite_list]");
goto end;
}
}
}
if (sec_param_exch_req_data->jws_cipher_suite_list) {
cJSON *jws_cipher_suite_listList = cJSON_AddArrayToObject(item, "jwsCipherSuiteList");
if (jws_cipher_suite_listList == NULL) {
ogs_error("OpenAPI_sec_param_exch_req_data_convertToJSON() failed [jws_cipher_suite_list]");
goto end;
}
OpenAPI_list_for_each(sec_param_exch_req_data->jws_cipher_suite_list, node) {
if (cJSON_AddStringToObject(jws_cipher_suite_listList, "", (char*)node->data) == NULL) {
ogs_error("OpenAPI_sec_param_exch_req_data_convertToJSON() failed [jws_cipher_suite_list]");
goto end;
}
}
}
if (sec_param_exch_req_data->protection_policy_info) {
cJSON *protection_policy_info_local_JSON = OpenAPI_protection_policy_convertToJSON(sec_param_exch_req_data->protection_policy_info);
if (protection_policy_info_local_JSON == NULL) {
ogs_error("OpenAPI_sec_param_exch_req_data_convertToJSON() failed [protection_policy_info]");
goto end;
}
cJSON_AddItemToObject(item, "protectionPolicyInfo", protection_policy_info_local_JSON);
if (item->child == NULL) {
ogs_error("OpenAPI_sec_param_exch_req_data_convertToJSON() failed [protection_policy_info]");
goto end;
}
}
if (sec_param_exch_req_data->ipx_provider_sec_info_list) {
cJSON *ipx_provider_sec_info_listList = cJSON_AddArrayToObject(item, "ipxProviderSecInfoList");
if (ipx_provider_sec_info_listList == NULL) {
ogs_error("OpenAPI_sec_param_exch_req_data_convertToJSON() failed [ipx_provider_sec_info_list]");
goto end;
}
OpenAPI_list_for_each(sec_param_exch_req_data->ipx_provider_sec_info_list, node) {
cJSON *itemLocal = OpenAPI_ipx_provider_sec_info_convertToJSON(node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_sec_param_exch_req_data_convertToJSON() failed [ipx_provider_sec_info_list]");
goto end;
}
cJSON_AddItemToArray(ipx_provider_sec_info_listList, itemLocal);
}
}
if (sec_param_exch_req_data->sender) {
if (cJSON_AddStringToObject(item, "sender", sec_param_exch_req_data->sender) == NULL) {
ogs_error("OpenAPI_sec_param_exch_req_data_convertToJSON() failed [sender]");
goto end;
}
}
end:
return item;
}
OpenAPI_sec_param_exch_req_data_t *OpenAPI_sec_param_exch_req_data_parseFromJSON(cJSON *sec_param_exch_req_dataJSON)
{
OpenAPI_sec_param_exch_req_data_t *sec_param_exch_req_data_local_var = NULL;
OpenAPI_lnode_t *node = NULL;
cJSON *n32f_context_id = NULL;
cJSON *jwe_cipher_suite_list = NULL;
OpenAPI_list_t *jwe_cipher_suite_listList = NULL;
cJSON *jws_cipher_suite_list = NULL;
OpenAPI_list_t *jws_cipher_suite_listList = NULL;
cJSON *protection_policy_info = NULL;
OpenAPI_protection_policy_t *protection_policy_info_local_nonprim = NULL;
cJSON *ipx_provider_sec_info_list = NULL;
OpenAPI_list_t *ipx_provider_sec_info_listList = NULL;
cJSON *sender = NULL;
n32f_context_id = cJSON_GetObjectItemCaseSensitive(sec_param_exch_req_dataJSON, "n32fContextId");
if (!n32f_context_id) {
ogs_error("OpenAPI_sec_param_exch_req_data_parseFromJSON() failed [n32f_context_id]");
goto end;
}
if (!cJSON_IsString(n32f_context_id)) {
ogs_error("OpenAPI_sec_param_exch_req_data_parseFromJSON() failed [n32f_context_id]");
goto end;
}
jwe_cipher_suite_list = cJSON_GetObjectItemCaseSensitive(sec_param_exch_req_dataJSON, "jweCipherSuiteList");
if (jwe_cipher_suite_list) {
cJSON *jwe_cipher_suite_list_local = NULL;
if (!cJSON_IsArray(jwe_cipher_suite_list)) {
ogs_error("OpenAPI_sec_param_exch_req_data_parseFromJSON() failed [jwe_cipher_suite_list]");
goto end;
}
jwe_cipher_suite_listList = OpenAPI_list_create();
cJSON_ArrayForEach(jwe_cipher_suite_list_local, jwe_cipher_suite_list) {
double *localDouble = NULL;
int *localInt = NULL;
if (!cJSON_IsString(jwe_cipher_suite_list_local)) {
ogs_error("OpenAPI_sec_param_exch_req_data_parseFromJSON() failed [jwe_cipher_suite_list]");
goto end;
}
OpenAPI_list_add(jwe_cipher_suite_listList, ogs_strdup(jwe_cipher_suite_list_local->valuestring));
}
}
jws_cipher_suite_list = cJSON_GetObjectItemCaseSensitive(sec_param_exch_req_dataJSON, "jwsCipherSuiteList");
if (jws_cipher_suite_list) {
cJSON *jws_cipher_suite_list_local = NULL;
if (!cJSON_IsArray(jws_cipher_suite_list)) {
ogs_error("OpenAPI_sec_param_exch_req_data_parseFromJSON() failed [jws_cipher_suite_list]");
goto end;
}
jws_cipher_suite_listList = OpenAPI_list_create();
cJSON_ArrayForEach(jws_cipher_suite_list_local, jws_cipher_suite_list) {
double *localDouble = NULL;
int *localInt = NULL;
if (!cJSON_IsString(jws_cipher_suite_list_local)) {
ogs_error("OpenAPI_sec_param_exch_req_data_parseFromJSON() failed [jws_cipher_suite_list]");
goto end;
}
OpenAPI_list_add(jws_cipher_suite_listList, ogs_strdup(jws_cipher_suite_list_local->valuestring));
}
}
protection_policy_info = cJSON_GetObjectItemCaseSensitive(sec_param_exch_req_dataJSON, "protectionPolicyInfo");
if (protection_policy_info) {
protection_policy_info_local_nonprim = OpenAPI_protection_policy_parseFromJSON(protection_policy_info);
}
ipx_provider_sec_info_list = cJSON_GetObjectItemCaseSensitive(sec_param_exch_req_dataJSON, "ipxProviderSecInfoList");
if (ipx_provider_sec_info_list) {
cJSON *ipx_provider_sec_info_list_local = NULL;
if (!cJSON_IsArray(ipx_provider_sec_info_list)) {
ogs_error("OpenAPI_sec_param_exch_req_data_parseFromJSON() failed [ipx_provider_sec_info_list]");
goto end;
}
ipx_provider_sec_info_listList = OpenAPI_list_create();
cJSON_ArrayForEach(ipx_provider_sec_info_list_local, ipx_provider_sec_info_list) {
if (!cJSON_IsObject(ipx_provider_sec_info_list_local)) {
ogs_error("OpenAPI_sec_param_exch_req_data_parseFromJSON() failed [ipx_provider_sec_info_list]");
goto end;
}
OpenAPI_ipx_provider_sec_info_t *ipx_provider_sec_info_listItem = OpenAPI_ipx_provider_sec_info_parseFromJSON(ipx_provider_sec_info_list_local);
if (!ipx_provider_sec_info_listItem) {
ogs_error("No ipx_provider_sec_info_listItem");
OpenAPI_list_free(ipx_provider_sec_info_listList);
goto end;
}
OpenAPI_list_add(ipx_provider_sec_info_listList, ipx_provider_sec_info_listItem);
}
}
sender = cJSON_GetObjectItemCaseSensitive(sec_param_exch_req_dataJSON, "sender");
if (sender) {
if (!cJSON_IsString(sender) && !cJSON_IsNull(sender)) {
ogs_error("OpenAPI_sec_param_exch_req_data_parseFromJSON() failed [sender]");
goto end;
}
}
sec_param_exch_req_data_local_var = OpenAPI_sec_param_exch_req_data_create (
ogs_strdup(n32f_context_id->valuestring),
jwe_cipher_suite_list ? jwe_cipher_suite_listList : NULL,
jws_cipher_suite_list ? jws_cipher_suite_listList : NULL,
protection_policy_info ? protection_policy_info_local_nonprim : NULL,
ipx_provider_sec_info_list ? ipx_provider_sec_info_listList : NULL,
sender && !cJSON_IsNull(sender) ? ogs_strdup(sender->valuestring) : NULL
);
return sec_param_exch_req_data_local_var;
end:
if (jwe_cipher_suite_listList) {
OpenAPI_list_for_each(jwe_cipher_suite_listList, node) {
ogs_free(node->data);
}
OpenAPI_list_free(jwe_cipher_suite_listList);
jwe_cipher_suite_listList = NULL;
}
if (jws_cipher_suite_listList) {
OpenAPI_list_for_each(jws_cipher_suite_listList, node) {
ogs_free(node->data);
}
OpenAPI_list_free(jws_cipher_suite_listList);
jws_cipher_suite_listList = NULL;
}
if (protection_policy_info_local_nonprim) {
OpenAPI_protection_policy_free(protection_policy_info_local_nonprim);
protection_policy_info_local_nonprim = NULL;
}
if (ipx_provider_sec_info_listList) {
OpenAPI_list_for_each(ipx_provider_sec_info_listList, node) {
OpenAPI_ipx_provider_sec_info_free(node->data);
}
OpenAPI_list_free(ipx_provider_sec_info_listList);
ipx_provider_sec_info_listList = NULL;
}
return NULL;
}
OpenAPI_sec_param_exch_req_data_t *OpenAPI_sec_param_exch_req_data_copy(OpenAPI_sec_param_exch_req_data_t *dst, OpenAPI_sec_param_exch_req_data_t *src)
{
cJSON *item = NULL;
char *content = NULL;
ogs_assert(src);
item = OpenAPI_sec_param_exch_req_data_convertToJSON(src);
if (!item) {
ogs_error("OpenAPI_sec_param_exch_req_data_convertToJSON() failed");
return NULL;
}
content = cJSON_Print(item);
cJSON_Delete(item);
if (!content) {
ogs_error("cJSON_Print() failed");
return NULL;
}
item = cJSON_Parse(content);
ogs_free(content);
if (!item) {
ogs_error("cJSON_Parse() failed");
return NULL;
}
OpenAPI_sec_param_exch_req_data_free(dst);
dst = OpenAPI_sec_param_exch_req_data_parseFromJSON(item);
cJSON_Delete(item);
return dst;
}

View File

@ -0,0 +1,50 @@
/*
* sec_param_exch_req_data.h
*
* Request data structure for parameter exchange
*/
#ifndef _OpenAPI_sec_param_exch_req_data_H_
#define _OpenAPI_sec_param_exch_req_data_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#include "ipx_provider_sec_info.h"
#include "protection_policy.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct OpenAPI_sec_param_exch_req_data_s OpenAPI_sec_param_exch_req_data_t;
typedef struct OpenAPI_sec_param_exch_req_data_s {
char *n32f_context_id;
OpenAPI_list_t *jwe_cipher_suite_list;
OpenAPI_list_t *jws_cipher_suite_list;
struct OpenAPI_protection_policy_s *protection_policy_info;
OpenAPI_list_t *ipx_provider_sec_info_list;
char *sender;
} OpenAPI_sec_param_exch_req_data_t;
OpenAPI_sec_param_exch_req_data_t *OpenAPI_sec_param_exch_req_data_create(
char *n32f_context_id,
OpenAPI_list_t *jwe_cipher_suite_list,
OpenAPI_list_t *jws_cipher_suite_list,
OpenAPI_protection_policy_t *protection_policy_info,
OpenAPI_list_t *ipx_provider_sec_info_list,
char *sender
);
void OpenAPI_sec_param_exch_req_data_free(OpenAPI_sec_param_exch_req_data_t *sec_param_exch_req_data);
OpenAPI_sec_param_exch_req_data_t *OpenAPI_sec_param_exch_req_data_parseFromJSON(cJSON *sec_param_exch_req_dataJSON);
cJSON *OpenAPI_sec_param_exch_req_data_convertToJSON(OpenAPI_sec_param_exch_req_data_t *sec_param_exch_req_data);
OpenAPI_sec_param_exch_req_data_t *OpenAPI_sec_param_exch_req_data_copy(OpenAPI_sec_param_exch_req_data_t *dst, OpenAPI_sec_param_exch_req_data_t *src);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_sec_param_exch_req_data_H_ */

View File

@ -0,0 +1,274 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "sec_param_exch_rsp_data.h"
OpenAPI_sec_param_exch_rsp_data_t *OpenAPI_sec_param_exch_rsp_data_create(
char *n32f_context_id,
char *selected_jwe_cipher_suite,
char *selected_jws_cipher_suite,
OpenAPI_protection_policy_t *sel_protection_policy_info,
OpenAPI_list_t *ipx_provider_sec_info_list,
char *sender
)
{
OpenAPI_sec_param_exch_rsp_data_t *sec_param_exch_rsp_data_local_var = ogs_malloc(sizeof(OpenAPI_sec_param_exch_rsp_data_t));
ogs_assert(sec_param_exch_rsp_data_local_var);
sec_param_exch_rsp_data_local_var->n32f_context_id = n32f_context_id;
sec_param_exch_rsp_data_local_var->selected_jwe_cipher_suite = selected_jwe_cipher_suite;
sec_param_exch_rsp_data_local_var->selected_jws_cipher_suite = selected_jws_cipher_suite;
sec_param_exch_rsp_data_local_var->sel_protection_policy_info = sel_protection_policy_info;
sec_param_exch_rsp_data_local_var->ipx_provider_sec_info_list = ipx_provider_sec_info_list;
sec_param_exch_rsp_data_local_var->sender = sender;
return sec_param_exch_rsp_data_local_var;
}
void OpenAPI_sec_param_exch_rsp_data_free(OpenAPI_sec_param_exch_rsp_data_t *sec_param_exch_rsp_data)
{
OpenAPI_lnode_t *node = NULL;
if (NULL == sec_param_exch_rsp_data) {
return;
}
if (sec_param_exch_rsp_data->n32f_context_id) {
ogs_free(sec_param_exch_rsp_data->n32f_context_id);
sec_param_exch_rsp_data->n32f_context_id = NULL;
}
if (sec_param_exch_rsp_data->selected_jwe_cipher_suite) {
ogs_free(sec_param_exch_rsp_data->selected_jwe_cipher_suite);
sec_param_exch_rsp_data->selected_jwe_cipher_suite = NULL;
}
if (sec_param_exch_rsp_data->selected_jws_cipher_suite) {
ogs_free(sec_param_exch_rsp_data->selected_jws_cipher_suite);
sec_param_exch_rsp_data->selected_jws_cipher_suite = NULL;
}
if (sec_param_exch_rsp_data->sel_protection_policy_info) {
OpenAPI_protection_policy_free(sec_param_exch_rsp_data->sel_protection_policy_info);
sec_param_exch_rsp_data->sel_protection_policy_info = NULL;
}
if (sec_param_exch_rsp_data->ipx_provider_sec_info_list) {
OpenAPI_list_for_each(sec_param_exch_rsp_data->ipx_provider_sec_info_list, node) {
OpenAPI_ipx_provider_sec_info_free(node->data);
}
OpenAPI_list_free(sec_param_exch_rsp_data->ipx_provider_sec_info_list);
sec_param_exch_rsp_data->ipx_provider_sec_info_list = NULL;
}
if (sec_param_exch_rsp_data->sender) {
ogs_free(sec_param_exch_rsp_data->sender);
sec_param_exch_rsp_data->sender = NULL;
}
ogs_free(sec_param_exch_rsp_data);
}
cJSON *OpenAPI_sec_param_exch_rsp_data_convertToJSON(OpenAPI_sec_param_exch_rsp_data_t *sec_param_exch_rsp_data)
{
cJSON *item = NULL;
OpenAPI_lnode_t *node = NULL;
if (sec_param_exch_rsp_data == NULL) {
ogs_error("OpenAPI_sec_param_exch_rsp_data_convertToJSON() failed [SecParamExchRspData]");
return NULL;
}
item = cJSON_CreateObject();
if (!sec_param_exch_rsp_data->n32f_context_id) {
ogs_error("OpenAPI_sec_param_exch_rsp_data_convertToJSON() failed [n32f_context_id]");
return NULL;
}
if (cJSON_AddStringToObject(item, "n32fContextId", sec_param_exch_rsp_data->n32f_context_id) == NULL) {
ogs_error("OpenAPI_sec_param_exch_rsp_data_convertToJSON() failed [n32f_context_id]");
goto end;
}
if (sec_param_exch_rsp_data->selected_jwe_cipher_suite) {
if (cJSON_AddStringToObject(item, "selectedJweCipherSuite", sec_param_exch_rsp_data->selected_jwe_cipher_suite) == NULL) {
ogs_error("OpenAPI_sec_param_exch_rsp_data_convertToJSON() failed [selected_jwe_cipher_suite]");
goto end;
}
}
if (sec_param_exch_rsp_data->selected_jws_cipher_suite) {
if (cJSON_AddStringToObject(item, "selectedJwsCipherSuite", sec_param_exch_rsp_data->selected_jws_cipher_suite) == NULL) {
ogs_error("OpenAPI_sec_param_exch_rsp_data_convertToJSON() failed [selected_jws_cipher_suite]");
goto end;
}
}
if (sec_param_exch_rsp_data->sel_protection_policy_info) {
cJSON *sel_protection_policy_info_local_JSON = OpenAPI_protection_policy_convertToJSON(sec_param_exch_rsp_data->sel_protection_policy_info);
if (sel_protection_policy_info_local_JSON == NULL) {
ogs_error("OpenAPI_sec_param_exch_rsp_data_convertToJSON() failed [sel_protection_policy_info]");
goto end;
}
cJSON_AddItemToObject(item, "selProtectionPolicyInfo", sel_protection_policy_info_local_JSON);
if (item->child == NULL) {
ogs_error("OpenAPI_sec_param_exch_rsp_data_convertToJSON() failed [sel_protection_policy_info]");
goto end;
}
}
if (sec_param_exch_rsp_data->ipx_provider_sec_info_list) {
cJSON *ipx_provider_sec_info_listList = cJSON_AddArrayToObject(item, "ipxProviderSecInfoList");
if (ipx_provider_sec_info_listList == NULL) {
ogs_error("OpenAPI_sec_param_exch_rsp_data_convertToJSON() failed [ipx_provider_sec_info_list]");
goto end;
}
OpenAPI_list_for_each(sec_param_exch_rsp_data->ipx_provider_sec_info_list, node) {
cJSON *itemLocal = OpenAPI_ipx_provider_sec_info_convertToJSON(node->data);
if (itemLocal == NULL) {
ogs_error("OpenAPI_sec_param_exch_rsp_data_convertToJSON() failed [ipx_provider_sec_info_list]");
goto end;
}
cJSON_AddItemToArray(ipx_provider_sec_info_listList, itemLocal);
}
}
if (sec_param_exch_rsp_data->sender) {
if (cJSON_AddStringToObject(item, "sender", sec_param_exch_rsp_data->sender) == NULL) {
ogs_error("OpenAPI_sec_param_exch_rsp_data_convertToJSON() failed [sender]");
goto end;
}
}
end:
return item;
}
OpenAPI_sec_param_exch_rsp_data_t *OpenAPI_sec_param_exch_rsp_data_parseFromJSON(cJSON *sec_param_exch_rsp_dataJSON)
{
OpenAPI_sec_param_exch_rsp_data_t *sec_param_exch_rsp_data_local_var = NULL;
OpenAPI_lnode_t *node = NULL;
cJSON *n32f_context_id = NULL;
cJSON *selected_jwe_cipher_suite = NULL;
cJSON *selected_jws_cipher_suite = NULL;
cJSON *sel_protection_policy_info = NULL;
OpenAPI_protection_policy_t *sel_protection_policy_info_local_nonprim = NULL;
cJSON *ipx_provider_sec_info_list = NULL;
OpenAPI_list_t *ipx_provider_sec_info_listList = NULL;
cJSON *sender = NULL;
n32f_context_id = cJSON_GetObjectItemCaseSensitive(sec_param_exch_rsp_dataJSON, "n32fContextId");
if (!n32f_context_id) {
ogs_error("OpenAPI_sec_param_exch_rsp_data_parseFromJSON() failed [n32f_context_id]");
goto end;
}
if (!cJSON_IsString(n32f_context_id)) {
ogs_error("OpenAPI_sec_param_exch_rsp_data_parseFromJSON() failed [n32f_context_id]");
goto end;
}
selected_jwe_cipher_suite = cJSON_GetObjectItemCaseSensitive(sec_param_exch_rsp_dataJSON, "selectedJweCipherSuite");
if (selected_jwe_cipher_suite) {
if (!cJSON_IsString(selected_jwe_cipher_suite) && !cJSON_IsNull(selected_jwe_cipher_suite)) {
ogs_error("OpenAPI_sec_param_exch_rsp_data_parseFromJSON() failed [selected_jwe_cipher_suite]");
goto end;
}
}
selected_jws_cipher_suite = cJSON_GetObjectItemCaseSensitive(sec_param_exch_rsp_dataJSON, "selectedJwsCipherSuite");
if (selected_jws_cipher_suite) {
if (!cJSON_IsString(selected_jws_cipher_suite) && !cJSON_IsNull(selected_jws_cipher_suite)) {
ogs_error("OpenAPI_sec_param_exch_rsp_data_parseFromJSON() failed [selected_jws_cipher_suite]");
goto end;
}
}
sel_protection_policy_info = cJSON_GetObjectItemCaseSensitive(sec_param_exch_rsp_dataJSON, "selProtectionPolicyInfo");
if (sel_protection_policy_info) {
sel_protection_policy_info_local_nonprim = OpenAPI_protection_policy_parseFromJSON(sel_protection_policy_info);
}
ipx_provider_sec_info_list = cJSON_GetObjectItemCaseSensitive(sec_param_exch_rsp_dataJSON, "ipxProviderSecInfoList");
if (ipx_provider_sec_info_list) {
cJSON *ipx_provider_sec_info_list_local = NULL;
if (!cJSON_IsArray(ipx_provider_sec_info_list)) {
ogs_error("OpenAPI_sec_param_exch_rsp_data_parseFromJSON() failed [ipx_provider_sec_info_list]");
goto end;
}
ipx_provider_sec_info_listList = OpenAPI_list_create();
cJSON_ArrayForEach(ipx_provider_sec_info_list_local, ipx_provider_sec_info_list) {
if (!cJSON_IsObject(ipx_provider_sec_info_list_local)) {
ogs_error("OpenAPI_sec_param_exch_rsp_data_parseFromJSON() failed [ipx_provider_sec_info_list]");
goto end;
}
OpenAPI_ipx_provider_sec_info_t *ipx_provider_sec_info_listItem = OpenAPI_ipx_provider_sec_info_parseFromJSON(ipx_provider_sec_info_list_local);
if (!ipx_provider_sec_info_listItem) {
ogs_error("No ipx_provider_sec_info_listItem");
OpenAPI_list_free(ipx_provider_sec_info_listList);
goto end;
}
OpenAPI_list_add(ipx_provider_sec_info_listList, ipx_provider_sec_info_listItem);
}
}
sender = cJSON_GetObjectItemCaseSensitive(sec_param_exch_rsp_dataJSON, "sender");
if (sender) {
if (!cJSON_IsString(sender) && !cJSON_IsNull(sender)) {
ogs_error("OpenAPI_sec_param_exch_rsp_data_parseFromJSON() failed [sender]");
goto end;
}
}
sec_param_exch_rsp_data_local_var = OpenAPI_sec_param_exch_rsp_data_create (
ogs_strdup(n32f_context_id->valuestring),
selected_jwe_cipher_suite && !cJSON_IsNull(selected_jwe_cipher_suite) ? ogs_strdup(selected_jwe_cipher_suite->valuestring) : NULL,
selected_jws_cipher_suite && !cJSON_IsNull(selected_jws_cipher_suite) ? ogs_strdup(selected_jws_cipher_suite->valuestring) : NULL,
sel_protection_policy_info ? sel_protection_policy_info_local_nonprim : NULL,
ipx_provider_sec_info_list ? ipx_provider_sec_info_listList : NULL,
sender && !cJSON_IsNull(sender) ? ogs_strdup(sender->valuestring) : NULL
);
return sec_param_exch_rsp_data_local_var;
end:
if (sel_protection_policy_info_local_nonprim) {
OpenAPI_protection_policy_free(sel_protection_policy_info_local_nonprim);
sel_protection_policy_info_local_nonprim = NULL;
}
if (ipx_provider_sec_info_listList) {
OpenAPI_list_for_each(ipx_provider_sec_info_listList, node) {
OpenAPI_ipx_provider_sec_info_free(node->data);
}
OpenAPI_list_free(ipx_provider_sec_info_listList);
ipx_provider_sec_info_listList = NULL;
}
return NULL;
}
OpenAPI_sec_param_exch_rsp_data_t *OpenAPI_sec_param_exch_rsp_data_copy(OpenAPI_sec_param_exch_rsp_data_t *dst, OpenAPI_sec_param_exch_rsp_data_t *src)
{
cJSON *item = NULL;
char *content = NULL;
ogs_assert(src);
item = OpenAPI_sec_param_exch_rsp_data_convertToJSON(src);
if (!item) {
ogs_error("OpenAPI_sec_param_exch_rsp_data_convertToJSON() failed");
return NULL;
}
content = cJSON_Print(item);
cJSON_Delete(item);
if (!content) {
ogs_error("cJSON_Print() failed");
return NULL;
}
item = cJSON_Parse(content);
ogs_free(content);
if (!item) {
ogs_error("cJSON_Parse() failed");
return NULL;
}
OpenAPI_sec_param_exch_rsp_data_free(dst);
dst = OpenAPI_sec_param_exch_rsp_data_parseFromJSON(item);
cJSON_Delete(item);
return dst;
}

View File

@ -0,0 +1,50 @@
/*
* sec_param_exch_rsp_data.h
*
* Response data structure for parameter exchange
*/
#ifndef _OpenAPI_sec_param_exch_rsp_data_H_
#define _OpenAPI_sec_param_exch_rsp_data_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#include "ipx_provider_sec_info.h"
#include "protection_policy.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct OpenAPI_sec_param_exch_rsp_data_s OpenAPI_sec_param_exch_rsp_data_t;
typedef struct OpenAPI_sec_param_exch_rsp_data_s {
char *n32f_context_id;
char *selected_jwe_cipher_suite;
char *selected_jws_cipher_suite;
struct OpenAPI_protection_policy_s *sel_protection_policy_info;
OpenAPI_list_t *ipx_provider_sec_info_list;
char *sender;
} OpenAPI_sec_param_exch_rsp_data_t;
OpenAPI_sec_param_exch_rsp_data_t *OpenAPI_sec_param_exch_rsp_data_create(
char *n32f_context_id,
char *selected_jwe_cipher_suite,
char *selected_jws_cipher_suite,
OpenAPI_protection_policy_t *sel_protection_policy_info,
OpenAPI_list_t *ipx_provider_sec_info_list,
char *sender
);
void OpenAPI_sec_param_exch_rsp_data_free(OpenAPI_sec_param_exch_rsp_data_t *sec_param_exch_rsp_data);
OpenAPI_sec_param_exch_rsp_data_t *OpenAPI_sec_param_exch_rsp_data_parseFromJSON(cJSON *sec_param_exch_rsp_dataJSON);
cJSON *OpenAPI_sec_param_exch_rsp_data_convertToJSON(OpenAPI_sec_param_exch_rsp_data_t *sec_param_exch_rsp_data);
OpenAPI_sec_param_exch_rsp_data_t *OpenAPI_sec_param_exch_rsp_data_copy(OpenAPI_sec_param_exch_rsp_data_t *dst, OpenAPI_sec_param_exch_rsp_data_t *src);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_sec_param_exch_rsp_data_H_ */

View File

@ -0,0 +1,30 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "security_capability.h"
char* OpenAPI_security_capability_ToString(OpenAPI_security_capability_e security_capability)
{
const char *security_capabilityArray[] = { "NULL", "TLS", "PRINS", "NONE" };
size_t sizeofArray = sizeof(security_capabilityArray) / sizeof(security_capabilityArray[0]);
if (security_capability < sizeofArray)
return (char *)security_capabilityArray[security_capability];
else
return (char *)"Unknown";
}
OpenAPI_security_capability_e OpenAPI_security_capability_FromString(char* security_capability)
{
int stringToReturn = 0;
const char *security_capabilityArray[] = { "NULL", "TLS", "PRINS", "NONE" };
size_t sizeofArray = sizeof(security_capabilityArray) / sizeof(security_capabilityArray[0]);
while (stringToReturn < sizeofArray) {
if (strcmp(security_capability, security_capabilityArray[stringToReturn]) == 0) {
return stringToReturn;
}
stringToReturn++;
}
return 0;
}

View File

@ -0,0 +1,31 @@
/*
* security_capability.h
*
*
*/
#ifndef _OpenAPI_security_capability_H_
#define _OpenAPI_security_capability_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum { OpenAPI_security_capability_NULL = 0, OpenAPI_security_capability_TLS, OpenAPI_security_capability_PRINS, OpenAPI_security_capability_NONE } OpenAPI_security_capability_e;
char* OpenAPI_security_capability_ToString(OpenAPI_security_capability_e security_capability);
OpenAPI_security_capability_e OpenAPI_security_capability_FromString(char* security_capability);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_security_capability_H_ */

View File

@ -0,0 +1,30 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "security_capability_any_of.h"
char* OpenAPI_security_capability_any_of_ToString(OpenAPI_security_capability_any_of_e security_capability_any_of)
{
const char *security_capability_any_ofArray[] = { "NULL", "TLS", "PRINS", "NONE" };
size_t sizeofArray = sizeof(security_capability_any_ofArray) / sizeof(security_capability_any_ofArray[0]);
if (security_capability_any_of < sizeofArray)
return (char *)security_capability_any_ofArray[security_capability_any_of];
else
return (char *)"Unknown";
}
OpenAPI_security_capability_any_of_e OpenAPI_security_capability_any_of_FromString(char* security_capability_any_of)
{
int stringToReturn = 0;
const char *security_capability_any_ofArray[] = { "NULL", "TLS", "PRINS", "NONE" };
size_t sizeofArray = sizeof(security_capability_any_ofArray) / sizeof(security_capability_any_ofArray[0]);
while (stringToReturn < sizeofArray) {
if (strcmp(security_capability_any_of, security_capability_any_ofArray[stringToReturn]) == 0) {
return stringToReturn;
}
stringToReturn++;
}
return 0;
}

View File

@ -0,0 +1,31 @@
/*
* security_capability_any_of.h
*
*
*/
#ifndef _OpenAPI_security_capability_any_of_H_
#define _OpenAPI_security_capability_any_of_H_
#include <string.h>
#include "../external/cJSON.h"
#include "../include/list.h"
#include "../include/keyValuePair.h"
#include "../include/binary.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum { OpenAPI_security_capability_any_of_NULL = 0, OpenAPI_security_capability_any_of_TLS, OpenAPI_security_capability_any_of_PRINS, OpenAPI_security_capability_any_of_NONE } OpenAPI_security_capability_any_of_e;
char* OpenAPI_security_capability_any_of_ToString(OpenAPI_security_capability_any_of_e security_capability_any_of);
OpenAPI_security_capability_any_of_e OpenAPI_security_capability_any_of_FromString(char* security_capability_any_of);
#ifdef __cplusplus
}
#endif
#endif /* _OpenAPI_security_capability_any_of_H_ */

View File

@ -6,6 +6,7 @@
openapi_generator_cli="openapi-generator-cli"
$openapi_generator_cli generate -i ./modified/TS29573_N32_Handshake.yaml -c ./openapi-generator/config.yaml -g c -o ../../openapi || exit 1
$openapi_generator_cli generate -i ./modified/TS29504_Nudr_DR.yaml -c ./openapi-generator/config.yaml -g c -o ../../openapi || exit 1
$openapi_generator_cli generate -i ./modified/TS29521_Nbsf_Management.yaml -c ./openapi-generator/config.yaml -g c -o ../../openapi || exit 1
$openapi_generator_cli generate -i ./modified/TS29531_Nnssf_NSSelection.yaml -c ./openapi-generator/config.yaml -g c -o ../../openapi || exit 1

View File

@ -165,23 +165,23 @@ paths:
components:
schemas:
SecurityCapability:
description: Enumeration of security capabilities
anyOf:
- type: string
# description: Enumeration of security capabilities
# anyOf:
# - type: string
enum:
- TLS
- PRINS
- NONE
- type: string
# - type: string
ApiSignature:
description: API URI of the service operation
oneOf:
- $ref: 'TS29571_CommonData.yaml#/components/schemas/Uri'
- $ref: '#/components/schemas/CallbackName'
HttpMethod:
description: Enumeration of HTTP methods
anyOf:
- type: string
# description: Enumeration of HTTP methods
# anyOf:
# - type: string
enum:
- GET
- PUT
@ -192,12 +192,12 @@ components:
- OPTIONS
- CONNECT
- TRACE
- type: string
# - type: string
IeType:
description: Enumeration of types of IEs (i.e kind of IE) to specify the protection policy
anyOf:
- type: string
# description: Enumeration of types of IEs (i.e kind of IE) to specify the protection policy
# anyOf:
# - type: string
enum:
- UEID
- LOCATION
@ -206,18 +206,18 @@ components:
- AUTHORIZATION_TOKEN
- OTHER
- NONSENSITIVE
- type: string
# - type: string
IeLocation:
description: Location of the IE in a HTTP message
anyOf:
- type: string
# description: Location of the IE in a HTTP message
# anyOf:
# - type: string
enum:
- URI_PARAM
- HEADER
- BODY
- MULTIPART_BINARY
- type: string
# - type: string
IeInfo:
description: Protection and modification policy for the IE
@ -504,9 +504,9 @@ components:
type: string
N32fErrorType:
description: Type of error while processing N32-f message
anyOf:
- type: string
# description: Type of error while processing N32-f message
# anyOf:
# - type: string
enum:
- INTEGRITY_CHECK_FAILED
- INTEGRITY_CHECK_ON_MODIFICATIONS_FAILED
@ -517,21 +517,21 @@ components:
- INTEGRITY_KEY_EXPIRED
- ENCRYPTION_KEY_EXPIRED
- POLICY_MISMATCH
- type: string
# - type: string
FailureReason:
description: Reason for failure to reconstruct a HTTP/2 message from N32-f message
anyOf:
- type: string
# description: Reason for failure to reconstruct a HTTP/2 message from N32-f message
# anyOf:
# - type: string
enum:
- INVALID_JSON_POINTER
- INVALID_INDEX_TO_ENCRYPTED_BLOCK
- INVALID_HTTP_HEADER
- type: string
# - type: string
N32Purpose:
description: Usage purpose of establishing N32 connectivity
anyOf:
- type: string
# description: Usage purpose of establishing N32 connectivity
# anyOf:
# - type: string
enum:
- ROAMING
- INTER_PLMN_MOBILITY
@ -543,4 +543,4 @@ components:
- SNPN_INTERCONNECT_TEST
- DISASTER_ROAMING
- DISASTER_ROAMING_TEST
- type: string
# - type: string