Add more memory log
This commit is contained in:
parent
80a9497afd
commit
118d62d42d
|
@ -41,9 +41,9 @@ int get_asn1c_environment_version(void); /* Run-time version */
|
|||
#define FREEMEM(ptr) free(ptr)
|
||||
#else
|
||||
#include "ogs-core.h"
|
||||
#define CALLOC(nmemb, size) ogs_calloc(nmemb, size)
|
||||
#define MALLOC(size) ogs_malloc(size)
|
||||
#define REALLOC(oldptr, size) ogs_realloc(oldptr, size)
|
||||
#define CALLOC(nmemb, size) ogs_calloc_or_assert(nmemb, size)
|
||||
#define MALLOC(size) ogs_malloc_or_assert(size)
|
||||
#define REALLOC(oldptr, size) ogs_realloc_or_assert(oldptr, size)
|
||||
#define FREEMEM(ptr) ogs_free(ptr)
|
||||
#endif
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ ogs_pkbuf_t *ogs_asn_encode(const asn_TYPE_descriptor_t *td, void *sptr)
|
|||
ogs_assert(sptr);
|
||||
|
||||
pkbuf = ogs_pkbuf_alloc(NULL, OGS_MAX_SDU_LEN);
|
||||
ogs_assert(pkbuf);
|
||||
ogs_expect_or_return_val(pkbuf, NULL);
|
||||
ogs_pkbuf_put(pkbuf, OGS_MAX_SDU_LEN);
|
||||
|
||||
enc_ret = aper_encode_to_buffer(td, NULL,
|
||||
|
|
|
@ -137,7 +137,7 @@ char *ogs_amf_id_to_string(ogs_amf_id_t *amf_id)
|
|||
ogs_assert(amf_id);
|
||||
|
||||
str = ogs_calloc(1, OGS_AMFIDSTRLEN);
|
||||
ogs_assert(str);
|
||||
ogs_expect_or_return_val(str, NULL);
|
||||
|
||||
ogs_hex_to_ascii(amf_id, sizeof(ogs_amf_id_t), str, OGS_AMFIDSTRLEN);
|
||||
|
||||
|
@ -182,6 +182,7 @@ char *ogs_supi_from_suci(char *suci)
|
|||
|
||||
ogs_assert(suci);
|
||||
tmp = ogs_strdup(suci);
|
||||
ogs_expect_or_return_val(tmp, NULL);
|
||||
|
||||
p = strtok_r(tmp, "-", &saveptr);
|
||||
|
||||
|
@ -222,10 +223,12 @@ char *ogs_id_get_type(char *str)
|
|||
|
||||
ogs_assert(str);
|
||||
tmp = ogs_strdup(str);
|
||||
ogs_expect_or_return_val(tmp, NULL);
|
||||
|
||||
p = strtok_r(tmp, "-", &saveptr);
|
||||
ogs_assert(p);
|
||||
type = ogs_strdup(p);
|
||||
ogs_expect_or_return_val(type, NULL);
|
||||
|
||||
ogs_free(tmp);
|
||||
return type;
|
||||
|
@ -239,12 +242,14 @@ char *ogs_id_get_value(char *str)
|
|||
|
||||
ogs_assert(str);
|
||||
tmp = ogs_strdup(str);
|
||||
ogs_expect_or_return_val(tmp, NULL);
|
||||
|
||||
p = strtok_r(tmp, "-", &saveptr);
|
||||
ogs_assert(p);
|
||||
p = strtok_r(NULL, "-", &saveptr);
|
||||
ogs_assert(p);
|
||||
ueid = ogs_strdup(p);
|
||||
ogs_expect_or_return_val(ueid, NULL);
|
||||
|
||||
ogs_free(tmp);
|
||||
return ueid;
|
||||
|
@ -252,10 +257,15 @@ char *ogs_id_get_value(char *str)
|
|||
|
||||
char *ogs_s_nssai_sd_to_string(ogs_uint24_t sd)
|
||||
{
|
||||
char *string = NULL;
|
||||
|
||||
if (sd.v == OGS_S_NSSAI_NO_SD_VALUE)
|
||||
return NULL;
|
||||
|
||||
return ogs_uint24_to_0string(sd);
|
||||
string = ogs_uint24_to_0string(sd);
|
||||
ogs_expect(string);
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
ogs_uint24_t ogs_s_nssai_sd_from_string(const char *hex)
|
||||
|
@ -391,12 +401,12 @@ int ogs_ip_to_sockaddr(ogs_ip_t *ip, uint16_t port, ogs_sockaddr_t **list)
|
|||
ogs_assert(list);
|
||||
|
||||
addr = ogs_calloc(1, sizeof(ogs_sockaddr_t));
|
||||
ogs_assert(addr);
|
||||
ogs_expect_or_return_val(addr, OGS_ERROR);
|
||||
addr->ogs_sa_family = AF_INET;
|
||||
addr->ogs_sin_port = htobe16(port);
|
||||
|
||||
addr6 = ogs_calloc(1, sizeof(ogs_sockaddr_t));
|
||||
ogs_assert(addr6);
|
||||
ogs_expect_or_return_val(addr6, OGS_ERROR);
|
||||
addr6->ogs_sa_family = AF_INET6;
|
||||
addr6->ogs_sin_port = htobe16(port);
|
||||
|
||||
|
@ -457,7 +467,7 @@ char *ogs_ipv4_to_string(uint32_t addr)
|
|||
char *buf = NULL;
|
||||
|
||||
buf = ogs_calloc(1, OGS_ADDRSTRLEN);
|
||||
ogs_assert(buf);
|
||||
ogs_expect_or_return_val(buf, NULL);
|
||||
|
||||
return (char*)OGS_INET_NTOP(&addr, buf);
|
||||
}
|
||||
|
@ -468,7 +478,7 @@ char *ogs_ipv6addr_to_string(uint8_t *addr6)
|
|||
ogs_assert(addr6);
|
||||
|
||||
buf = ogs_calloc(1, OGS_ADDRSTRLEN);
|
||||
ogs_assert(buf);
|
||||
ogs_expect_or_return_val(buf, NULL);
|
||||
|
||||
return (char *)OGS_INET6_NTOP(addr6, buf);
|
||||
}
|
||||
|
@ -483,7 +493,7 @@ char *ogs_ipv6prefix_to_string(uint8_t *addr6, uint8_t prefixlen)
|
|||
memcpy(tmp, addr6, prefixlen >> 3);
|
||||
|
||||
buf = ogs_calloc(1, OGS_ADDRSTRLEN);
|
||||
ogs_assert(buf);
|
||||
ogs_expect_or_return_val(buf, NULL);
|
||||
|
||||
if (OGS_INET6_NTOP(tmp, buf) == NULL) {
|
||||
ogs_fatal("Invalid IPv6 address");
|
||||
|
@ -541,7 +551,7 @@ int ogs_ipv6prefix_from_string(uint8_t *addr6, uint8_t *prefixlen, char *string)
|
|||
ogs_assert(prefixlen);
|
||||
ogs_assert(string);
|
||||
pv = v = ogs_strdup(string);
|
||||
ogs_assert(v);
|
||||
ogs_expect_or_return_val(v, OGS_ERROR);
|
||||
|
||||
ipstr = strsep(&v, "/");
|
||||
if (ipstr)
|
||||
|
|
|
@ -190,10 +190,10 @@ char *ogs_uint64_to_string(uint64_t x)
|
|||
char *str, *p;
|
||||
|
||||
str = ogs_uint64_to_0string(x);
|
||||
ogs_assert(str);
|
||||
ogs_expect_or_return_val(str, NULL);
|
||||
|
||||
p = ogs_left_trimcharacter(str, '0');
|
||||
ogs_assert(p);
|
||||
ogs_expect_or_return_val(p, NULL);
|
||||
|
||||
ogs_free(str);
|
||||
return ogs_strdup(p);
|
||||
|
|
|
@ -112,7 +112,7 @@ static int epoll_add(ogs_poll_t *poll)
|
|||
map = ogs_hash_get(context->map_hash, &poll->fd, sizeof(poll->fd));
|
||||
if (!map) {
|
||||
map = ogs_calloc(1, sizeof(*map));
|
||||
ogs_assert(map);
|
||||
ogs_expect_or_return_val(map, OGS_ERROR);
|
||||
|
||||
op = EPOLL_CTL_ADD;
|
||||
ogs_hash_set(context->map_hash, &poll->fd, sizeof(poll->fd), map);
|
||||
|
|
|
@ -61,7 +61,7 @@ struct ogs_hash_t {
|
|||
|
||||
static ogs_hash_entry_t **alloc_array(ogs_hash_t *ht, unsigned int max)
|
||||
{
|
||||
return ogs_calloc(1, sizeof(*ht->array) * (max + 1));
|
||||
return ogs_calloc_or_assert(1, sizeof(*ht->array) * (max + 1));
|
||||
}
|
||||
|
||||
ogs_hash_t *ogs_hash_make()
|
||||
|
@ -70,6 +70,7 @@ ogs_hash_t *ogs_hash_make()
|
|||
ogs_time_t now = ogs_get_monotonic_time();
|
||||
|
||||
ht = ogs_malloc(sizeof(ogs_hash_t));
|
||||
ogs_expect_or_return_val(ht, NULL);
|
||||
|
||||
ht->free = NULL;
|
||||
ht->count = 0;
|
||||
|
@ -85,6 +86,7 @@ ogs_hash_t *ogs_hash_make()
|
|||
ogs_hash_t *ogs_hash_make_custom(ogs_hashfunc_t hash_func)
|
||||
{
|
||||
ogs_hash_t *ht = ogs_hash_make();
|
||||
ogs_expect_or_return_val(ht, NULL);
|
||||
ht->hash_func = hash_func;
|
||||
return ht;
|
||||
}
|
||||
|
@ -283,7 +285,7 @@ static ogs_hash_entry_t **find_entry(ogs_hash_t *ht,
|
|||
if ((he = ht->free) != NULL)
|
||||
ht->free = he->next;
|
||||
else
|
||||
he = ogs_malloc_debug(sizeof(*he), file_line);
|
||||
he = ogs_malloc_debug(sizeof(*he), file_line, true);
|
||||
he->next = NULL;
|
||||
he->hash = hash;
|
||||
he->key = key;
|
||||
|
|
|
@ -68,6 +68,7 @@ static void kqueue_init(ogs_pollset_t *pollset)
|
|||
|
||||
context->change_list = ogs_calloc(
|
||||
pollset->capacity, sizeof(struct kevent));
|
||||
ogs_assert(context->change_list);
|
||||
context->event_list = ogs_calloc(
|
||||
pollset->capacity, sizeof(struct kevent));
|
||||
ogs_assert(context->change_list);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#undef OGS_LOG_DOMAIN
|
||||
#define OGS_LOG_DOMAIN __ogs_mem_domain
|
||||
|
||||
void *ogs_malloc_debug(size_t size, const char *file_line)
|
||||
void *ogs_malloc_debug(size_t size, const char *file_line, bool abort)
|
||||
{
|
||||
size_t headroom = 0;
|
||||
ogs_pkbuf_t *pkbuf = NULL;
|
||||
|
@ -31,7 +31,12 @@ void *ogs_malloc_debug(size_t size, const char *file_line)
|
|||
|
||||
headroom = sizeof(ogs_pkbuf_t *);
|
||||
pkbuf = ogs_pkbuf_alloc_debug(NULL, headroom + size, file_line);
|
||||
|
||||
if (abort == true)
|
||||
ogs_assert(pkbuf);
|
||||
else
|
||||
ogs_expect_or_return_val(pkbuf, NULL);
|
||||
|
||||
ogs_pkbuf_reserve(pkbuf, headroom);
|
||||
memcpy(pkbuf->head, &pkbuf, headroom);
|
||||
ogs_pkbuf_put(pkbuf, size);
|
||||
|
@ -54,18 +59,23 @@ void ogs_free(void *ptr)
|
|||
ogs_pkbuf_free(pkbuf);
|
||||
}
|
||||
|
||||
void *ogs_calloc_debug(size_t nmemb, size_t size, const char *file_line)
|
||||
void *ogs_calloc_debug(
|
||||
size_t nmemb, size_t size, const char *file_line, bool abort)
|
||||
{
|
||||
void *ptr = NULL;
|
||||
|
||||
ptr = ogs_malloc_debug(nmemb * size, file_line);
|
||||
ptr = ogs_malloc_debug(nmemb * size, file_line, abort);
|
||||
if (abort == true)
|
||||
ogs_assert(ptr);
|
||||
else
|
||||
ogs_expect_or_return_val(ptr, NULL);
|
||||
|
||||
memset(ptr, 0, nmemb * size);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void *ogs_realloc_debug(void *ptr, size_t size, const char *file_line)
|
||||
void *ogs_realloc_debug(
|
||||
void *ptr, size_t size, const char *file_line, bool abort)
|
||||
{
|
||||
size_t headroom = 0;
|
||||
ogs_pkbuf_t *pkbuf = NULL;
|
||||
|
@ -77,9 +87,17 @@ void *ogs_realloc_debug(void *ptr, size_t size, const char *file_line)
|
|||
headroom = sizeof(ogs_pkbuf_t *);
|
||||
|
||||
memcpy(&pkbuf, (unsigned char*)ptr - headroom, headroom);
|
||||
|
||||
if (abort == true)
|
||||
ogs_assert(pkbuf);
|
||||
else
|
||||
ogs_expect_or_return_val(pkbuf, NULL);
|
||||
|
||||
cluster = pkbuf->cluster;
|
||||
if (abort == true)
|
||||
ogs_assert(cluster);
|
||||
else
|
||||
ogs_expect_or_return_val(cluster, NULL);
|
||||
|
||||
if (!size) {
|
||||
ogs_pkbuf_free(pkbuf);
|
||||
|
@ -89,8 +107,13 @@ void *ogs_realloc_debug(void *ptr, size_t size, const char *file_line)
|
|||
if (size > (cluster->size - headroom)) {
|
||||
void *new = NULL;
|
||||
|
||||
new = ogs_malloc_debug(size, file_line);
|
||||
new = ogs_malloc_debug(size, file_line, abort);
|
||||
|
||||
if (abort == true)
|
||||
ogs_assert(new);
|
||||
else
|
||||
ogs_expect_or_return_val(new, NULL);
|
||||
|
||||
memcpy(new, ptr, pkbuf->len);
|
||||
|
||||
ogs_pkbuf_free(pkbuf);
|
||||
|
|
|
@ -44,13 +44,23 @@ extern "C" {
|
|||
memcpy((__dST), (__sRC), sizeof(*(__sRC))*sizeof(uint8_t)); \
|
||||
} while(0)
|
||||
|
||||
#define ogs_malloc(size) ogs_malloc_debug(size, OGS_FILE_LINE)
|
||||
void *ogs_malloc_debug(size_t size, const char *file_line);
|
||||
#define ogs_malloc(size) ogs_malloc_debug(size, OGS_FILE_LINE, false)
|
||||
#define ogs_malloc_or_assert(size) \
|
||||
ogs_malloc_debug(size, OGS_FILE_LINE, true)
|
||||
void *ogs_malloc_debug(size_t size, const char *file_line, bool abort);
|
||||
void ogs_free(void *ptr);
|
||||
#define ogs_calloc(nmemb, size) ogs_calloc_debug(nmemb, size, OGS_FILE_LINE)
|
||||
void *ogs_calloc_debug(size_t nmemb, size_t size, const char *file_line);
|
||||
#define ogs_realloc(ptr, size) ogs_realloc_debug(ptr, size, OGS_FILE_LINE)
|
||||
void *ogs_realloc_debug(void *ptr, size_t size, const char *file_line);
|
||||
#define ogs_calloc(nmemb, size) \
|
||||
ogs_calloc_debug(nmemb, size, OGS_FILE_LINE, false)
|
||||
#define ogs_calloc_or_assert(nmemb, size) \
|
||||
ogs_calloc_debug(nmemb, size, OGS_FILE_LINE, true)
|
||||
void *ogs_calloc_debug(
|
||||
size_t nmemb, size_t size, const char *file_line, bool abort);
|
||||
#define ogs_realloc(ptr, size) \
|
||||
ogs_realloc_debug(ptr, size, OGS_FILE_LINE, false)
|
||||
#define ogs_realloc_or_assert(ptr, size) \
|
||||
ogs_realloc_debug(ptr, size, OGS_FILE_LINE, true)
|
||||
void *ogs_realloc_debug(
|
||||
void *ptr, size_t size, const char *file_line, bool abort);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -199,10 +199,13 @@ ogs_pkbuf_t *ogs_pkbuf_alloc_debug(
|
|||
ogs_thread_mutex_unlock(&pool->mutex);
|
||||
return NULL;
|
||||
}
|
||||
ogs_assert(cluster);
|
||||
|
||||
ogs_pool_alloc(&pool->pkbuf, &pkbuf);
|
||||
ogs_assert(pkbuf);
|
||||
if (!pkbuf) {
|
||||
ogs_error("ogs_pkbuf_alloc() failed [size=%d]", size);
|
||||
ogs_thread_mutex_unlock(&pool->mutex);
|
||||
return NULL;
|
||||
}
|
||||
memset(pkbuf, 0, sizeof(*pkbuf));
|
||||
|
||||
cluster->ref++;
|
||||
|
@ -248,7 +251,7 @@ void ogs_pkbuf_free(ogs_pkbuf_t *pkbuf)
|
|||
ogs_thread_mutex_unlock(&pool->mutex);
|
||||
}
|
||||
|
||||
ogs_pkbuf_t *ogs_pkbuf_copy(ogs_pkbuf_t *pkbuf)
|
||||
ogs_pkbuf_t *ogs_pkbuf_copy_debug(ogs_pkbuf_t *pkbuf, const char *file_line)
|
||||
{
|
||||
ogs_pkbuf_pool_t *pool = NULL;
|
||||
ogs_pkbuf_t *newbuf = NULL;
|
||||
|
@ -288,51 +291,31 @@ static ogs_cluster_t *cluster_alloc(
|
|||
|
||||
if (size <= OGS_CLUSTER_128_SIZE) {
|
||||
ogs_pool_alloc(&pool->cluster_128, (ogs_cluster_128_t**)&buffer);
|
||||
if (!buffer) {
|
||||
ogs_fatal("No OGS_CLUSTER_128_SIZE");
|
||||
return NULL;
|
||||
}
|
||||
ogs_expect_or_return_val(buffer, NULL);
|
||||
cluster->size = OGS_CLUSTER_128_SIZE;
|
||||
} else if (size <= OGS_CLUSTER_256_SIZE) {
|
||||
ogs_pool_alloc(&pool->cluster_256, (ogs_cluster_256_t**)&buffer);
|
||||
if (!buffer) {
|
||||
ogs_fatal("No OGS_CLUSTER_256_SIZE");
|
||||
return NULL;
|
||||
}
|
||||
ogs_expect_or_return_val(buffer, NULL);
|
||||
cluster->size = OGS_CLUSTER_256_SIZE;
|
||||
} else if (size <= OGS_CLUSTER_512_SIZE) {
|
||||
ogs_pool_alloc(&pool->cluster_512, (ogs_cluster_512_t**)&buffer);
|
||||
if (!buffer) {
|
||||
ogs_fatal("No OGS_CLUSTER_512_SIZE");
|
||||
return NULL;
|
||||
}
|
||||
ogs_expect_or_return_val(buffer, NULL);
|
||||
cluster->size = OGS_CLUSTER_512_SIZE;
|
||||
} else if (size <= OGS_CLUSTER_1024_SIZE) {
|
||||
ogs_pool_alloc(&pool->cluster_1024, (ogs_cluster_1024_t**)&buffer);
|
||||
if (!buffer) {
|
||||
ogs_fatal("No OGS_CLUSTER_1024_SIZE");
|
||||
return NULL;
|
||||
}
|
||||
ogs_expect_or_return_val(buffer, NULL);
|
||||
cluster->size = OGS_CLUSTER_1024_SIZE;
|
||||
} else if (size <= OGS_CLUSTER_2048_SIZE) {
|
||||
ogs_pool_alloc(&pool->cluster_2048, (ogs_cluster_2048_t**)&buffer);
|
||||
if (!buffer) {
|
||||
ogs_fatal("No OGS_CLUSTER_2048_SIZE");
|
||||
return NULL;
|
||||
}
|
||||
ogs_expect_or_return_val(buffer, NULL);
|
||||
cluster->size = OGS_CLUSTER_2048_SIZE;
|
||||
} else if (size <= OGS_CLUSTER_8192_SIZE) {
|
||||
ogs_pool_alloc(&pool->cluster_8192, (ogs_cluster_8192_t**)&buffer);
|
||||
if (!buffer) {
|
||||
ogs_fatal("No OGS_CLUSTER_8192_SIZE");
|
||||
return NULL;
|
||||
}
|
||||
ogs_expect_or_return_val(buffer, NULL);
|
||||
cluster->size = OGS_CLUSTER_8192_SIZE;
|
||||
} else if (size <= OGS_CLUSTER_BIG_SIZE) {
|
||||
ogs_pool_alloc(&pool->cluster_big, (ogs_cluster_big_t**)&buffer);
|
||||
if (!buffer) {
|
||||
ogs_fatal("No OGS_CLUSTER_BIG_SIZE");
|
||||
}
|
||||
ogs_expect_or_return_val(buffer, NULL);
|
||||
cluster->size = OGS_CLUSTER_BIG_SIZE;
|
||||
} else {
|
||||
ogs_fatal("invalid size = %d", size);
|
||||
|
|
|
@ -84,7 +84,9 @@ void ogs_pkbuf_free(ogs_pkbuf_t *pkbuf);
|
|||
|
||||
void *ogs_pkbuf_put_data(
|
||||
ogs_pkbuf_t *pkbuf, const void *data, unsigned int len);
|
||||
ogs_pkbuf_t *ogs_pkbuf_copy(ogs_pkbuf_t *pkbuf);
|
||||
#define ogs_pkbuf_copy(pkbuf) \
|
||||
ogs_pkbuf_copy_debug(pkbuf, OGS_FILE_LINE)
|
||||
ogs_pkbuf_t *ogs_pkbuf_copy_debug(ogs_pkbuf_t *pkbuf, const char *file_line);
|
||||
|
||||
static ogs_inline int ogs_pkbuf_tailroom(const ogs_pkbuf_t *pkbuf)
|
||||
{
|
||||
|
|
|
@ -35,7 +35,7 @@ bool ogs_pollset_actions_initialized = false;
|
|||
ogs_pollset_t *ogs_pollset_create(unsigned int capacity)
|
||||
{
|
||||
ogs_pollset_t *pollset = ogs_calloc(1, sizeof *pollset);
|
||||
ogs_assert(pollset);
|
||||
ogs_expect_or_return_val(pollset, NULL);
|
||||
|
||||
pollset->capacity = capacity;
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ typedef struct ogs_queue_s {
|
|||
ogs_queue_t *ogs_queue_create(unsigned int capacity)
|
||||
{
|
||||
ogs_queue_t *queue = ogs_calloc(1, sizeof *queue);
|
||||
ogs_expect_or_return_val(queue, NULL);
|
||||
ogs_assert(queue);
|
||||
|
||||
ogs_thread_mutex_init(&queue->one_big_mutex);
|
||||
|
@ -77,6 +78,7 @@ ogs_queue_t *ogs_queue_create(unsigned int capacity)
|
|||
ogs_thread_cond_init(&queue->not_full);
|
||||
|
||||
queue->data = ogs_calloc(1, capacity * sizeof(void*));
|
||||
ogs_expect_or_return_val(queue->data, NULL);
|
||||
queue->bounds = capacity;
|
||||
queue->nelts = 0;
|
||||
queue->in = 0;
|
||||
|
|
|
@ -130,6 +130,7 @@ int ogs_addaddrinfo(ogs_sockaddr_t **sa_list,
|
|||
continue;
|
||||
|
||||
new = ogs_calloc(1, sizeof(ogs_sockaddr_t));
|
||||
ogs_expect_or_return_val(new, OGS_ERROR);
|
||||
memcpy(&new->sa, ai->ai_addr, ai->ai_addrlen);
|
||||
new->ogs_sin_port = htobe16(port);
|
||||
|
||||
|
@ -203,12 +204,15 @@ int ogs_copyaddrinfo(ogs_sockaddr_t **dst, const ogs_sockaddr_t *src)
|
|||
for (*dst = d = NULL, s = src; s; s = s->next) {
|
||||
if (!d) {
|
||||
*dst = d = ogs_memdup(s, sizeof *s);
|
||||
ogs_expect_or_return_val(*dst, OGS_ERROR);
|
||||
} else {
|
||||
d = d->next = ogs_memdup(s, sizeof *s);
|
||||
ogs_expect_or_return_val(d, OGS_ERROR);
|
||||
}
|
||||
if (s->hostname) {
|
||||
if (s == src || s->hostname != src->hostname) {
|
||||
d->hostname = ogs_strdup(s->hostname);
|
||||
ogs_expect_or_return_val(d->hostname, OGS_ERROR);
|
||||
} else {
|
||||
d->hostname = (*dst)->hostname;
|
||||
}
|
||||
|
@ -279,6 +283,7 @@ ogs_sockaddr_t *ogs_link_local_addr_by_dev(const char *dev)
|
|||
continue;
|
||||
|
||||
addr = ogs_calloc(1, sizeof(ogs_sockaddr_t));
|
||||
ogs_expect_or_return_val(addr, NULL);
|
||||
ogs_assert(addr);
|
||||
memcpy(&addr->sa, cur->ifa_addr, ogs_sockaddr_len(cur->ifa_addr));
|
||||
|
||||
|
@ -288,6 +293,7 @@ ogs_sockaddr_t *ogs_link_local_addr_by_dev(const char *dev)
|
|||
|
||||
freeifaddrs(iflist);
|
||||
#endif
|
||||
ogs_error("ogs_link_local_addr_by_dev() failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ ogs_sock_t *ogs_sock_create(void)
|
|||
ogs_sock_t *sock = NULL;
|
||||
|
||||
sock = ogs_calloc(1, sizeof(*sock));
|
||||
ogs_assert(sock);
|
||||
ogs_expect_or_return_val(sock, NULL);
|
||||
|
||||
sock->fd = INVALID_SOCKET;
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ ogs_socknode_t *ogs_socknode_new(ogs_sockaddr_t *addr)
|
|||
ogs_assert(addr);
|
||||
|
||||
node = ogs_calloc(1, sizeof(ogs_socknode_t));
|
||||
ogs_assert(node);
|
||||
ogs_expect_or_return_val(node, NULL);
|
||||
|
||||
node->addr = addr;
|
||||
|
||||
|
@ -71,12 +71,13 @@ ogs_socknode_t *ogs_socknode_add(
|
|||
ogs_assert(list);
|
||||
ogs_assert(addr);
|
||||
|
||||
ogs_copyaddrinfo(&dup, addr);
|
||||
ogs_assert(OGS_OK == ogs_copyaddrinfo(&dup, addr));
|
||||
if (family != AF_UNSPEC)
|
||||
ogs_filteraddrinfo(&dup, family);
|
||||
|
||||
if (dup) {
|
||||
node = ogs_socknode_new(dup);
|
||||
ogs_assert(node);
|
||||
ogs_list_add(list, node);
|
||||
}
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ char *ogs_slprintf(char *str, char *last, const char *format, ...)
|
|||
return r;
|
||||
}
|
||||
|
||||
char *ogs_strdup_debug(const char *s, const char *file_line)
|
||||
char *ogs_strdup_debug(const char *s, const char *file_line, bool abort)
|
||||
{
|
||||
char *res;
|
||||
size_t len;
|
||||
|
@ -129,11 +129,13 @@ char *ogs_strdup_debug(const char *s, const char *file_line)
|
|||
return NULL;
|
||||
|
||||
len = strlen(s) + 1;
|
||||
res = ogs_memdup_debug(s, len, file_line);
|
||||
res = ogs_memdup_debug(s, len, file_line, abort);
|
||||
ogs_expect_or_return_val(res, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
char *ogs_strndup_debug(const char *s, size_t n, const char *file_line)
|
||||
char *ogs_strndup_debug(
|
||||
const char *s, size_t n, const char *file_line, bool abort)
|
||||
{
|
||||
char *res;
|
||||
const char *end;
|
||||
|
@ -144,20 +146,23 @@ char *ogs_strndup_debug(const char *s, size_t n, const char *file_line)
|
|||
end = memchr(s, '\0', n);
|
||||
if (end != NULL)
|
||||
n = end - s;
|
||||
res = ogs_malloc_debug(n + 1, file_line);
|
||||
res = ogs_malloc_debug(n + 1, file_line, abort);
|
||||
ogs_expect_or_return_val(res, res);
|
||||
memcpy(res, s, n);
|
||||
res[n] = '\0';
|
||||
return res;
|
||||
}
|
||||
|
||||
void *ogs_memdup_debug(const void *m, size_t n, const char *file_line)
|
||||
void *ogs_memdup_debug(
|
||||
const void *m, size_t n, const char *file_line, bool abort)
|
||||
{
|
||||
void *res;
|
||||
|
||||
if (m == NULL)
|
||||
return NULL;
|
||||
|
||||
res = ogs_malloc_debug(n, file_line);
|
||||
res = ogs_malloc_debug(n, file_line, abort);
|
||||
ogs_expect_or_return_val(res, res);
|
||||
memcpy(res, m, n);
|
||||
return res;
|
||||
}
|
||||
|
@ -195,7 +200,8 @@ char *ogs_cpystrn(char *dst, const char *src, size_t dst_size)
|
|||
*
|
||||
* https://github.com/babelouest/orcania.git
|
||||
*/
|
||||
char *ogs_msprintf_debug(const char *file_line, const char *message, ...)
|
||||
char *ogs_msprintf_debug(
|
||||
const char *file_line, bool abort, const char *message, ...)
|
||||
{
|
||||
va_list argp, argp_cpy;
|
||||
size_t out_len = 0;
|
||||
|
@ -206,7 +212,7 @@ char *ogs_msprintf_debug(const char *file_line, const char *message, ...)
|
|||
in some architectures,
|
||||
vsnprintf can modify argp */
|
||||
out_len = vsnprintf(NULL, 0, message, argp);
|
||||
out = ogs_malloc_debug(out_len + sizeof(char), file_line);
|
||||
out = ogs_malloc_debug(out_len + sizeof(char), file_line, abort);
|
||||
if (out == NULL) {
|
||||
va_end(argp);
|
||||
va_end(argp_cpy);
|
||||
|
@ -220,7 +226,8 @@ char *ogs_msprintf_debug(const char *file_line, const char *message, ...)
|
|||
}
|
||||
|
||||
char *ogs_mstrcatf_debug(
|
||||
char *source, const char *file_line, const char *message, ...)
|
||||
char *source, const char *file_line, bool abort,
|
||||
const char *message, ...)
|
||||
{
|
||||
va_list argp, argp_cpy;
|
||||
char *out = NULL, *message_formatted = NULL;
|
||||
|
@ -238,7 +245,7 @@ char *ogs_mstrcatf_debug(
|
|||
vsnprintf(message_formatted,
|
||||
(message_formatted_len+sizeof(char)), message, argp_cpy);
|
||||
out = ogs_msprintf_debug(
|
||||
file_line, "%s%s", source, message_formatted);
|
||||
file_line, abort, "%s%s", source, message_formatted);
|
||||
ogs_free(message_formatted);
|
||||
ogs_free(source);
|
||||
}
|
||||
|
@ -250,7 +257,7 @@ char *ogs_mstrcatf_debug(
|
|||
in some architectures,
|
||||
vsnprintf can modify argp */
|
||||
out_len = vsnprintf(NULL, 0, message, argp);
|
||||
out = ogs_malloc_debug(out_len+sizeof(char), file_line);
|
||||
out = ogs_malloc_debug(out_len+sizeof(char), file_line, abort);
|
||||
if (out != NULL) {
|
||||
vsnprintf(out, (out_len+sizeof(char)), message, argp_cpy);
|
||||
}
|
||||
|
|
|
@ -75,12 +75,17 @@ char *ogs_vslprintf(char *str, char *last, const char *format, va_list ap)
|
|||
char *ogs_slprintf(char *str, char *last, const char *format, ...)
|
||||
OGS_GNUC_PRINTF(3, 4);
|
||||
|
||||
#define ogs_strdup(s) ogs_strdup_debug(s, OGS_FILE_LINE)
|
||||
char *ogs_strdup_debug(const char *s, const char *file_line);
|
||||
#define ogs_strndup(s, n) ogs_strndup_debug(s, n, OGS_FILE_LINE)
|
||||
char *ogs_strndup_debug(const char *s, size_t n, const char *file_line);
|
||||
#define ogs_memdup(m, n) ogs_memdup_debug(m, n, OGS_FILE_LINE)
|
||||
void *ogs_memdup_debug(const void *m, size_t n, const char *file_line);
|
||||
#define ogs_strdup(s) ogs_strdup_debug(s, OGS_FILE_LINE, false)
|
||||
#define ogs_strdup_or_assert(s) ogs_strdup_debug(s, OGS_FILE_LINE, true)
|
||||
char *ogs_strdup_debug(const char *s, const char *file_line, bool abort);
|
||||
#define ogs_strndup(s, n) ogs_strndup_debug(s, n, OGS_FILE_LINE, false)
|
||||
#define ogs_strndup_or_assert(s, n) ogs_strndup_debug(s, n, OGS_FILE_LINE, true)
|
||||
char *ogs_strndup_debug
|
||||
(const char *s, size_t n, const char *file_line, bool abort);
|
||||
#define ogs_memdup(m, n) ogs_memdup_debug(m, n, OGS_FILE_LINE, false)
|
||||
#define ogs_memdup_or_assert(m, n) ogs_memdup_debug(m, n, OGS_FILE_LINE, true)
|
||||
void *ogs_memdup_debug
|
||||
(const void *m, size_t n, const char *file_line, bool abort);
|
||||
|
||||
char *ogs_cpystrn(char *dst, const char *src, size_t dst_size);
|
||||
|
||||
|
@ -94,14 +99,20 @@ char *ogs_cpystrn(char *dst, const char *src, size_t dst_size);
|
|||
*
|
||||
* https://github.com/babelouest/orcania.git
|
||||
*/
|
||||
#define ogs_msprintf(...) ogs_msprintf_debug(OGS_FILE_LINE, __VA_ARGS__)
|
||||
char *ogs_msprintf_debug(const char *file_line, const char *message, ...)
|
||||
OGS_GNUC_PRINTF(2, 3);
|
||||
#define ogs_mstrcatf(source, ...) \
|
||||
ogs_mstrcatf_debug(source, OGS_FILE_LINE, __VA_ARGS__)
|
||||
char *ogs_mstrcatf_debug(
|
||||
char *source, const char *file_line, const char *message, ...)
|
||||
#define ogs_msprintf(...) ogs_msprintf_debug(OGS_FILE_LINE, false, __VA_ARGS__)
|
||||
#define ogs_msprintf_or_assert(...) \
|
||||
ogs_msprintf_debug(OGS_FILE_LINE, true, __VA_ARGS__)
|
||||
char *ogs_msprintf_debug
|
||||
(const char *file_line, bool abort, const char *message, ...)
|
||||
OGS_GNUC_PRINTF(3, 4);
|
||||
#define ogs_mstrcatf(source, ...) \
|
||||
ogs_mstrcatf_debug(source, OGS_FILE_LINE, false, __VA_ARGS__)
|
||||
#define ogs_mstrcatf_or_assert(source, ...) \
|
||||
ogs_mstrcatf_debug(source, OGS_FILE_LINE, true, __VA_ARGS__)
|
||||
char *ogs_mstrcatf_debug(
|
||||
char *source, const char *file_line, bool abort,
|
||||
const char *message, ...)
|
||||
OGS_GNUC_PRINTF(4, 5);
|
||||
|
||||
char *ogs_trimwhitespace(char *str);
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ static void *thread_worker(void *arg)
|
|||
ogs_thread_t *ogs_thread_create(void (*func)(void *), void *data)
|
||||
{
|
||||
ogs_thread_t *thread = ogs_calloc(1, sizeof *thread);
|
||||
ogs_assert(thread);
|
||||
ogs_expect_or_return_val(thread, NULL);
|
||||
|
||||
ogs_thread_mutex_init(&thread->mutex);
|
||||
ogs_thread_cond_init(&thread->cond);
|
||||
|
|
|
@ -55,7 +55,7 @@ static void add_timer_node(
|
|||
ogs_timer_mgr_t *ogs_timer_mgr_create(unsigned int capacity)
|
||||
{
|
||||
ogs_timer_mgr_t *manager = ogs_calloc(1, sizeof *manager);
|
||||
ogs_assert(manager);
|
||||
ogs_expect_or_return_val(manager, NULL);
|
||||
|
||||
ogs_pool_init(&manager->pool, capacity);
|
||||
|
||||
|
|
|
@ -141,6 +141,7 @@ typedef struct ogs_tlv_int32_s {
|
|||
(__dST)->presence = (__sRC)->presence; \
|
||||
(__dST)->len = (__sRC)->len; \
|
||||
(__dST)->data = ogs_calloc((__dST)->len, sizeof(uint8_t)); \
|
||||
ogs_assert((__dST)->data); \
|
||||
memcpy((__dST)->data, (__sRC)->data, (__dST)->len); \
|
||||
} while(0)
|
||||
typedef struct ogs_tlv_octet_s {
|
||||
|
|
|
@ -413,7 +413,7 @@ void snow_3g_f8(u8 *key, u32 count, u32 bearer, u32 dir, u8 *data, u32 length)
|
|||
|
||||
/* Run SNOW 3G algorithm to generate sequence of key stream bits KS*/
|
||||
snow_3g_initialize(K,IV);
|
||||
KS = (u32 *)ogs_malloc(4*n);
|
||||
KS = (u32 *)ogs_malloc_or_assert(4*n);
|
||||
snow_3g_generate_key_stream(n,(u32*)KS);
|
||||
|
||||
/* Exclusive-OR the input data with keystream to generate the output bit
|
||||
|
|
|
@ -296,7 +296,7 @@ void zuc_eea3(u8* CK, u32 COUNT, u32 BEARER, u32 DIRECTION,
|
|||
u32 lastbits = (8-(LENGTH%8))%8;
|
||||
|
||||
L = (LENGTH+31)/32;
|
||||
z = (u32 *) ogs_malloc(L*sizeof(u32));
|
||||
z = (u32 *) ogs_malloc_or_assert(L*sizeof(u32));
|
||||
|
||||
L8 = (LENGTH+7)/8;
|
||||
|
||||
|
@ -387,7 +387,7 @@ void zuc_eia3(u8* IK, u32 COUNT, u32 BEARER, u32 DIRECTION,
|
|||
|
||||
N = LENGTH + 64;
|
||||
L = (N + 31) / 32;
|
||||
z = (u32 *) ogs_malloc(L*sizeof(u32));
|
||||
z = (u32 *) ogs_malloc_or_assert(L*sizeof(u32));
|
||||
ZUC(IK, IV, z, L);
|
||||
|
||||
T = 0;
|
||||
|
|
|
@ -57,6 +57,7 @@ static char *masked_db_uri(const char *db_uri)
|
|||
ogs_assert(db_uri);
|
||||
|
||||
tmp = ogs_strdup(db_uri);
|
||||
ogs_assert(tmp);
|
||||
|
||||
memset(array, 0, sizeof(array));
|
||||
array[0] = strtok_r(tmp, "@", &saveptr);
|
||||
|
|
|
@ -452,6 +452,7 @@ done:
|
|||
utf8 = bson_iter_utf8(
|
||||
&child8_iter, &length);
|
||||
flow->description = ogs_malloc(length+1);
|
||||
ogs_assert(flow->description);
|
||||
ogs_cpystrn((char*)flow->description,
|
||||
utf8, length+1);
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ ogs_pkbuf_t *ogs_gtp_build_error_indication(
|
|||
|
||||
pkbuf = ogs_pkbuf_alloc(
|
||||
NULL, 100 /* enough for Error Indiciation; use smaller buffer */);
|
||||
ogs_assert(pkbuf);
|
||||
ogs_expect_or_return_val(pkbuf, NULL);
|
||||
ogs_pkbuf_reserve(pkbuf, OGS_GTPV1U_5GC_HEADER_LEN);
|
||||
|
||||
/*
|
||||
|
|
|
@ -502,7 +502,7 @@ ogs_gtp_node_t *ogs_gtp_node_new(ogs_sockaddr_t *sa_list)
|
|||
ogs_assert(sa_list);
|
||||
|
||||
ogs_pool_alloc(&pool, &node);
|
||||
ogs_assert(node);
|
||||
ogs_expect_or_return_val(node, NULL);
|
||||
memset(node, 0, sizeof(ogs_gtp_node_t));
|
||||
|
||||
node->sa_list = sa_list;
|
||||
|
@ -538,7 +538,7 @@ ogs_gtp_node_t *ogs_gtp_node_add_by_f_teid(
|
|||
ogs_assert(port);
|
||||
|
||||
rv = ogs_gtp_f_teid_to_sockaddr(f_teid, port, &addr);
|
||||
ogs_assert(rv == OGS_OK);
|
||||
ogs_expect_or_return_val(rv == OGS_OK, NULL);
|
||||
|
||||
rv = ogs_filter_ip_version(
|
||||
&addr,
|
||||
|
@ -554,7 +554,7 @@ ogs_gtp_node_t *ogs_gtp_node_add_by_f_teid(
|
|||
ogs_assert(node);
|
||||
|
||||
rv = ogs_gtp_f_teid_to_ip(f_teid, &node->ip);
|
||||
ogs_assert(rv == OGS_OK);
|
||||
ogs_expect_or_return_val(rv == OGS_OK, NULL);
|
||||
|
||||
ogs_list_add(list, node);
|
||||
|
||||
|
@ -569,7 +569,7 @@ ogs_gtp_node_t *ogs_gtp_node_add_by_addr(ogs_list_t *list, ogs_sockaddr_t *addr)
|
|||
ogs_assert(list);
|
||||
ogs_assert(addr);
|
||||
|
||||
ogs_copyaddrinfo(&new, addr);
|
||||
ogs_assert(OGS_OK == ogs_copyaddrinfo(&new, addr));
|
||||
gnode = ogs_gtp_node_new(new);
|
||||
|
||||
ogs_assert(gnode);
|
||||
|
@ -646,20 +646,20 @@ ogs_gtp_node_t *ogs_gtp_node_add_by_ip(
|
|||
ogs_assert(port);
|
||||
|
||||
rv = ogs_ip_to_sockaddr(ip, port, &addr);
|
||||
ogs_assert(rv == OGS_OK);
|
||||
ogs_expect_or_return_val(rv == OGS_OK, NULL);
|
||||
|
||||
rv = ogs_filter_ip_version(
|
||||
&addr,
|
||||
ogs_app()->parameter.no_ipv4,
|
||||
ogs_app()->parameter.no_ipv6,
|
||||
ogs_app()->parameter.prefer_ipv4);
|
||||
ogs_assert(addr);
|
||||
ogs_expect_or_return_val(addr, NULL);
|
||||
|
||||
rv = ogs_socknode_fill_scope_id_in_local(addr);
|
||||
ogs_assert(rv == OGS_OK);
|
||||
ogs_expect_or_return_val(rv == OGS_OK, NULL);
|
||||
|
||||
node = ogs_gtp_node_new(addr);
|
||||
ogs_assert(node);
|
||||
ogs_expect_or_return_val(node, NULL);
|
||||
|
||||
memcpy(&node->ip, ip, sizeof(*ip));
|
||||
|
||||
|
|
|
@ -28,12 +28,12 @@ int ogs_gtp_f_teid_to_sockaddr(
|
|||
ogs_assert(list);
|
||||
|
||||
addr = ogs_calloc(1, sizeof(ogs_sockaddr_t));
|
||||
ogs_assert(addr);
|
||||
ogs_expect_or_return_val(addr, OGS_ERROR);
|
||||
addr->ogs_sa_family = AF_INET;
|
||||
addr->ogs_sin_port = htobe16(port);
|
||||
|
||||
addr6 = ogs_calloc(1, sizeof(ogs_sockaddr_t));
|
||||
ogs_assert(addr6);
|
||||
ogs_expect_or_return_val(addr6, OGS_ERROR);
|
||||
addr6->ogs_sa_family = AF_INET6;
|
||||
addr6->ogs_sin_port = htobe16(port);
|
||||
|
||||
|
@ -57,7 +57,8 @@ int ogs_gtp_f_teid_to_sockaddr(
|
|||
} else {
|
||||
ogs_free(addr);
|
||||
ogs_free(addr6);
|
||||
ogs_assert_if_reached();
|
||||
ogs_error("No IPv4 or IPv6");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
return OGS_OK;
|
||||
|
@ -84,8 +85,10 @@ int ogs_gtp_sockaddr_to_f_teid(ogs_sockaddr_t *addr, ogs_sockaddr_t *addr6,
|
|||
f_teid->ipv6 = 1;
|
||||
memcpy(f_teid->addr6, addr6->sin6.sin6_addr.s6_addr, OGS_IPV6_LEN);
|
||||
*len = OGS_GTP_F_TEID_IPV6_LEN;
|
||||
} else
|
||||
ogs_assert_if_reached();
|
||||
} else {
|
||||
ogs_error("No IPv4 or IPv6");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
@ -110,8 +113,10 @@ int ogs_gtp_f_teid_to_ip(ogs_gtp_f_teid_t *f_teid, ogs_ip_t *ip)
|
|||
} else if (ip->ipv6) {
|
||||
memcpy(ip->addr6, f_teid->addr6, OGS_IPV6_LEN);
|
||||
ip->len = OGS_IPV6_LEN;
|
||||
} else
|
||||
} else {
|
||||
ogs_error("No IPv4 or IPv6");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
@ -134,8 +139,10 @@ int ogs_gtp_ip_to_f_teid(ogs_ip_t *ip, ogs_gtp_f_teid_t *f_teid, int *len)
|
|||
} else if (f_teid->ipv6) {
|
||||
memcpy(f_teid->addr6, ip->addr6, OGS_IPV6_LEN);
|
||||
*len = OGS_GTP_F_TEID_IPV6_LEN;
|
||||
} else
|
||||
ogs_assert_if_reached();
|
||||
} else {
|
||||
ogs_error("No IPv4 or IPv6");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
@ -160,8 +167,10 @@ int ogs_gtp_paa_to_ip(ogs_paa_t *paa, ogs_ip_t *ip)
|
|||
ip->ipv4 = 0;
|
||||
ip->ipv6 = 1;
|
||||
memcpy(ip->addr6, paa->addr6, OGS_IPV6_LEN);
|
||||
} else
|
||||
ogs_assert_if_reached();
|
||||
} else {
|
||||
ogs_error("No IPv4 or IPv6");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
|
|
@ -253,7 +253,7 @@ ogs_pkbuf_t *ogs_gtp_handle_echo_req(ogs_pkbuf_t *pkb)
|
|||
|
||||
pkb_resp = ogs_pkbuf_alloc(NULL,
|
||||
100 /* enough for ECHO_RSP; use smaller buffer */);
|
||||
ogs_assert(pkb_resp);
|
||||
ogs_expect_or_return_val(pkb_resp, NULL);
|
||||
ogs_pkbuf_put(pkb_resp, 100);
|
||||
gtph_resp = (ogs_gtp_header_t *)pkb_resp->data;
|
||||
|
||||
|
|
|
@ -66,23 +66,23 @@ char *ogs_nas_5gs_suci_from_mobile_identity(
|
|||
(ogs_nas_5gs_mobile_identity_suci_t *)mobile_identity->buffer;
|
||||
ogs_assert(mobile_identity_suci);
|
||||
|
||||
ogs_assert(mobile_identity_suci->h.supi_format ==
|
||||
OGS_NAS_5GS_SUPI_FORMAT_IMSI);
|
||||
ogs_assert(mobile_identity_suci->protection_scheme_id ==
|
||||
OGS_NAS_5GS_NULL_SCHEME);
|
||||
ogs_expect_or_return_val(mobile_identity_suci->h.supi_format ==
|
||||
OGS_NAS_5GS_SUPI_FORMAT_IMSI, NULL);
|
||||
ogs_expect_or_return_val(mobile_identity_suci->protection_scheme_id ==
|
||||
OGS_NAS_5GS_NULL_SCHEME, NULL);
|
||||
|
||||
suci = ogs_msprintf("suci-%d-", mobile_identity_suci->h.supi_format);
|
||||
ogs_assert(suci);
|
||||
ogs_expect_or_return_val(suci, NULL);
|
||||
|
||||
ogs_nas_to_plmn_id(&plmn_id, &mobile_identity_suci->nas_plmn_id);
|
||||
if (ogs_plmn_id_mnc_len(&plmn_id) == 2) {
|
||||
suci = ogs_mstrcatf(suci, "%03d-%02d-",
|
||||
ogs_plmn_id_mcc(&plmn_id), ogs_plmn_id_mnc(&plmn_id));
|
||||
ogs_assert(suci);
|
||||
ogs_expect_or_return_val(suci, NULL);
|
||||
} else {
|
||||
suci = ogs_mstrcatf(suci, "%03d-%03d-",
|
||||
ogs_plmn_id_mcc(&plmn_id), ogs_plmn_id_mnc(&plmn_id));
|
||||
ogs_assert(suci);
|
||||
ogs_expect_or_return_val(suci, NULL);
|
||||
}
|
||||
|
||||
memset(routing_indicator, 0, sizeof(routing_indicator));
|
||||
|
@ -102,7 +102,7 @@ char *ogs_nas_5gs_suci_from_mobile_identity(
|
|||
}
|
||||
}
|
||||
|
||||
ogs_assert(mobile_identity->length > 8);
|
||||
ogs_expect_or_return_val(mobile_identity->length > 8, NULL);
|
||||
ogs_buffer_to_bcd(mobile_identity_suci->scheme_output,
|
||||
mobile_identity->length - 8, tmp);
|
||||
|
||||
|
@ -111,6 +111,7 @@ char *ogs_nas_5gs_suci_from_mobile_identity(
|
|||
mobile_identity_suci->protection_scheme_id,
|
||||
mobile_identity_suci->home_network_pki_value,
|
||||
tmp);
|
||||
ogs_expect(suci);
|
||||
|
||||
return suci;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
/*******************************************************************************
|
||||
* This file had been created by nas-message.py script v0.2.0
|
||||
* Please do not modify this file but regenerate it via script.
|
||||
* Created on: 2021-05-07 23:02:37.438427 by acetcom
|
||||
* Created on: 2021-05-30 21:57:39.474183 by acetcom
|
||||
* from 24501-g41.docx
|
||||
******************************************************************************/
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
/*******************************************************************************
|
||||
* This file had been created by nas-message.py script v0.2.0
|
||||
* Please do not modify this file but regenerate it via script.
|
||||
* Created on: 2021-05-07 23:02:37.448758 by acetcom
|
||||
* Created on: 2021-05-30 21:57:39.484594 by acetcom
|
||||
* from 24501-g41.docx
|
||||
******************************************************************************/
|
||||
|
||||
|
@ -2817,7 +2817,7 @@ ogs_pkbuf_t *ogs_nas_5gmm_encode(ogs_nas_5gs_message_t *message)
|
|||
/* The Packet Buffer(ogs_pkbuf_t) for NAS message MUST make a HEADROOM.
|
||||
* When calculating AES_CMAC, we need to use the headroom of the packet. */
|
||||
pkbuf = ogs_pkbuf_alloc(NULL, OGS_MAX_SDU_LEN);
|
||||
ogs_assert(pkbuf);
|
||||
ogs_expect_or_return_val(pkbuf, NULL);
|
||||
ogs_pkbuf_reserve(pkbuf, OGS_NAS_HEADROOM);
|
||||
ogs_pkbuf_put(pkbuf, OGS_MAX_SDU_LEN-OGS_NAS_HEADROOM);
|
||||
|
||||
|
@ -2977,7 +2977,7 @@ ogs_pkbuf_t *ogs_nas_5gsm_encode(ogs_nas_5gs_message_t *message)
|
|||
/* The Packet Buffer(ogs_pkbuf_t) for NAS message MUST make a HEADROOM.
|
||||
* When calculating AES_CMAC, we need to use the headroom of the packet. */
|
||||
pkbuf = ogs_pkbuf_alloc(NULL, OGS_MAX_SDU_LEN);
|
||||
ogs_assert(pkbuf);
|
||||
ogs_expect_or_return_val(pkbuf, NULL);
|
||||
ogs_pkbuf_reserve(pkbuf, OGS_NAS_HEADROOM);
|
||||
ogs_pkbuf_put(pkbuf, OGS_MAX_SDU_LEN-OGS_NAS_HEADROOM);
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
/*******************************************************************************
|
||||
* This file had been created by nas-message.py script v0.2.0
|
||||
* Please do not modify this file but regenerate it via script.
|
||||
* Created on: 2021-05-07 23:02:37.421878 by acetcom
|
||||
* Created on: 2021-05-30 21:57:39.457575 by acetcom
|
||||
* from 24501-g41.docx
|
||||
******************************************************************************/
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
/*******************************************************************************
|
||||
* This file had been created by nas-message.py script v0.2.0
|
||||
* Please do not modify this file but regenerate it via script.
|
||||
* Created on: 2021-05-07 23:02:37.419237 by acetcom
|
||||
* Created on: 2021-05-30 21:57:39.454963 by acetcom
|
||||
* from 24501-g41.docx
|
||||
******************************************************************************/
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
/*******************************************************************************
|
||||
* This file had been created by nas-message.py script v0.2.0
|
||||
* Please do not modify this file but regenerate it via script.
|
||||
* Created on: 2021-05-07 23:02:37.431012 by acetcom
|
||||
* Created on: 2021-05-30 21:57:39.466799 by acetcom
|
||||
* from 24501-g41.docx
|
||||
******************************************************************************/
|
||||
|
||||
|
|
|
@ -854,7 +854,7 @@ f.write("""ogs_pkbuf_t *ogs_nas_5gmm_encode(ogs_nas_5gs_message_t *message)
|
|||
/* The Packet Buffer(ogs_pkbuf_t) for NAS message MUST make a HEADROOM.
|
||||
* When calculating AES_CMAC, we need to use the headroom of the packet. */
|
||||
pkbuf = ogs_pkbuf_alloc(NULL, OGS_MAX_SDU_LEN);
|
||||
ogs_assert(pkbuf);
|
||||
ogs_expect_or_return_val(pkbuf, NULL);
|
||||
ogs_pkbuf_reserve(pkbuf, OGS_NAS_HEADROOM);
|
||||
ogs_pkbuf_put(pkbuf, OGS_MAX_SDU_LEN-OGS_NAS_HEADROOM);
|
||||
|
||||
|
@ -905,7 +905,7 @@ f.write("""ogs_pkbuf_t *ogs_nas_5gsm_encode(ogs_nas_5gs_message_t *message)
|
|||
/* The Packet Buffer(ogs_pkbuf_t) for NAS message MUST make a HEADROOM.
|
||||
* When calculating AES_CMAC, we need to use the headroom of the packet. */
|
||||
pkbuf = ogs_pkbuf_alloc(NULL, OGS_MAX_SDU_LEN);
|
||||
ogs_assert(pkbuf);
|
||||
ogs_expect_or_return_val(pkbuf, NULL);
|
||||
ogs_pkbuf_reserve(pkbuf, OGS_NAS_HEADROOM);
|
||||
ogs_pkbuf_put(pkbuf, OGS_MAX_SDU_LEN-OGS_NAS_HEADROOM);
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "ogs-nas-5gs.h"
|
||||
|
||||
void ogs_nas_5gs_tai_list_build(
|
||||
int ogs_nas_5gs_tai_list_build(
|
||||
ogs_nas_5gs_tracking_area_identity_list_t *target,
|
||||
ogs_5gs_tai0_list_t *source0, ogs_5gs_tai2_list_t *source2)
|
||||
{
|
||||
|
@ -54,9 +54,9 @@ void ogs_nas_5gs_tai_list_build(
|
|||
|
||||
size = (1 + 3 + 3 * source0->tai[i].num);
|
||||
if ((target->length + size) > OGS_NAS_5GS_MAX_TAI_LIST_LEN) {
|
||||
ogs_warn("Overflow: Ignore remained TAI LIST(length:%d, size:%d)",
|
||||
ogs_error("Overflow: Ignore remained TAI LIST(length:%d, size:%d)",
|
||||
target->length, size);
|
||||
return;
|
||||
return OGS_ERROR;
|
||||
}
|
||||
memcpy(target->buffer + target->length, &target0.tai[i], size);
|
||||
target->length += size;
|
||||
|
@ -75,9 +75,9 @@ void ogs_nas_5gs_tai_list_build(
|
|||
|
||||
size = (1 + (3 + 3) * source2->num);
|
||||
if ((target->length + size) > OGS_NAS_5GS_MAX_TAI_LIST_LEN) {
|
||||
ogs_warn("Overflow: Ignore remained TAI LIST(length:%d, size:%d)",
|
||||
ogs_error("Overflow: Ignore remained TAI LIST(length:%d, size:%d)",
|
||||
target->length, size);
|
||||
return;
|
||||
return OGS_ERROR;
|
||||
}
|
||||
for (i = 0; i < source2->num; i++) {
|
||||
memcpy(&target2.tai[i].plmn_id,
|
||||
|
@ -89,6 +89,8 @@ void ogs_nas_5gs_tai_list_build(
|
|||
memcpy(target->buffer + target->length, &target2, size);
|
||||
target->length += size;
|
||||
}
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
||||
void ogs_nas_build_s_nssai(
|
||||
|
@ -329,7 +331,7 @@ int ogs_nas_parse_rejected_nssai(
|
|||
if (!rejected_nssai->length) {
|
||||
ogs_error("No NSSAI [%p:%d]",
|
||||
rejected_nssai->buffer, rejected_nssai->length);
|
||||
return OGS_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
|
@ -366,7 +368,7 @@ int ogs_nas_parse_rejected_nssai(
|
|||
return i;
|
||||
}
|
||||
|
||||
void ogs_nas_build_qos_flow_descriptions(
|
||||
int ogs_nas_build_qos_flow_descriptions(
|
||||
ogs_nas_qos_flow_descriptions_t *flow_descriptions,
|
||||
ogs_nas_qos_flow_description_t *flow_description,
|
||||
int num_of_flow_description)
|
||||
|
@ -381,7 +383,7 @@ void ogs_nas_build_qos_flow_descriptions(
|
|||
ogs_assert(num_of_flow_description);
|
||||
|
||||
buffer = ogs_calloc(1, OGS_NAS_MAX_QOS_FLOW_DESCRIPTIONS_LEN);
|
||||
ogs_assert(buffer);
|
||||
ogs_expect_or_return_val(buffer, OGS_ERROR);
|
||||
length = 0;
|
||||
|
||||
for (i = 0; i < num_of_flow_description; i++) {
|
||||
|
@ -438,9 +440,11 @@ void ogs_nas_build_qos_flow_descriptions(
|
|||
|
||||
flow_descriptions->buffer = buffer;
|
||||
flow_descriptions->length = length;
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
||||
void ogs_nas_build_qos_rules(ogs_nas_qos_rules_t *rules,
|
||||
int ogs_nas_build_qos_rules(ogs_nas_qos_rules_t *rules,
|
||||
ogs_nas_qos_rule_t *rule, int num_of_rule)
|
||||
{
|
||||
int i, j, k;
|
||||
|
@ -453,6 +457,7 @@ void ogs_nas_build_qos_rules(ogs_nas_qos_rules_t *rules,
|
|||
ogs_assert(num_of_rule);
|
||||
|
||||
buffer = ogs_calloc(1, OGS_NAS_MAX_QOS_RULES_LEN);
|
||||
ogs_expect_or_return_val(buffer, OGS_ERROR);
|
||||
ogs_assert(buffer);
|
||||
length = 0;
|
||||
|
||||
|
@ -636,4 +641,6 @@ void ogs_nas_build_qos_rules(ogs_nas_qos_rules_t *rules,
|
|||
|
||||
rules->buffer = buffer;
|
||||
rules->length = length;
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
|
|
@ -303,7 +303,7 @@ typedef struct ogs_nas_5gs_tracking_area_identity_list_s {
|
|||
uint8_t buffer[OGS_NAS_5GS_MAX_TAI_LIST_LEN];
|
||||
} __attribute__ ((packed)) ogs_nas_5gs_tracking_area_identity_list_t;
|
||||
|
||||
void ogs_nas_5gs_tai_list_build(
|
||||
int ogs_nas_5gs_tai_list_build(
|
||||
ogs_nas_5gs_tracking_area_identity_list_t *target,
|
||||
ogs_5gs_tai0_list_t *source0, ogs_5gs_tai2_list_t *source2);
|
||||
|
||||
|
@ -798,7 +798,7 @@ typedef struct ogs_nas_qos_flow_descriptions_s {
|
|||
void *buffer;
|
||||
} ogs_nas_qos_flow_descriptions_t;
|
||||
|
||||
void ogs_nas_build_qos_flow_descriptions(
|
||||
int ogs_nas_build_qos_flow_descriptions(
|
||||
ogs_nas_qos_flow_descriptions_t *flow_descriptions,
|
||||
ogs_nas_qos_flow_description_t *flow_description,
|
||||
int num_of_flow_description);
|
||||
|
@ -856,7 +856,7 @@ typedef struct ogs_nas_qos_rules_s {
|
|||
void *buffer;
|
||||
} __attribute__ ((packed)) ogs_nas_qos_rules_t;
|
||||
|
||||
void ogs_nas_build_qos_rules(ogs_nas_qos_rules_t *rules,
|
||||
int ogs_nas_build_qos_rules(ogs_nas_qos_rules_t *rules,
|
||||
ogs_nas_qos_rule_t *rule, int num_of_rule);
|
||||
|
||||
/* 9.11.4.15 SM PDU DN request container
|
||||
|
|
|
@ -61,6 +61,7 @@ extern "C" {
|
|||
OGS_NAS_CLEAR_DATA(__dST); \
|
||||
(__dST)->length = (__sRC)->length; \
|
||||
(__dST)->buffer = ogs_calloc((__dST)->length, sizeof(uint8_t)); \
|
||||
ogs_assert((__dST)->buffer); \
|
||||
memcpy((__dST)->buffer, (__sRC)->buffer, (__dST)->length); \
|
||||
} while(0)
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
/*******************************************************************************
|
||||
* This file had been created by nas-message.py script v0.1.0
|
||||
* Please do not modify this file but regenerate it via script.
|
||||
* Created on: 2021-05-07 23:02:21.680106 by acetcom
|
||||
* Created on: 2021-05-30 21:57:00.074257 by acetcom
|
||||
* from 24301-g40.docx
|
||||
******************************************************************************/
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
/*******************************************************************************
|
||||
* This file had been created by nas-message.py script v0.1.0
|
||||
* Please do not modify this file but regenerate it via script.
|
||||
* Created on: 2021-05-07 23:02:21.691492 by acetcom
|
||||
* Created on: 2021-05-30 21:57:00.085478 by acetcom
|
||||
* from 24301-g40.docx
|
||||
******************************************************************************/
|
||||
|
||||
|
@ -3243,7 +3243,7 @@ ogs_pkbuf_t *ogs_nas_emm_encode(ogs_nas_eps_message_t *message)
|
|||
/* The Packet Buffer(ogs_pkbuf_t) for NAS message MUST make a HEADROOM.
|
||||
* When calculating AES_CMAC, we need to use the headroom of the packet. */
|
||||
pkbuf = ogs_pkbuf_alloc(NULL, OGS_MAX_SDU_LEN);
|
||||
ogs_assert(pkbuf);
|
||||
ogs_expect_or_return_val(pkbuf, NULL);
|
||||
ogs_pkbuf_reserve(pkbuf, OGS_NAS_HEADROOM);
|
||||
ogs_pkbuf_put(pkbuf, OGS_MAX_SDU_LEN-OGS_NAS_HEADROOM);
|
||||
|
||||
|
@ -3429,7 +3429,7 @@ ogs_pkbuf_t *ogs_nas_esm_encode(ogs_nas_eps_message_t *message)
|
|||
/* The Packet Buffer(ogs_pkbuf_t) for NAS message MUST make a HEADROOM.
|
||||
* When calculating AES_CMAC, we need to use the headroom of the packet. */
|
||||
pkbuf = ogs_pkbuf_alloc(NULL, OGS_MAX_SDU_LEN);
|
||||
ogs_assert(pkbuf);
|
||||
ogs_expect_or_return_val(pkbuf, NULL);
|
||||
ogs_pkbuf_reserve(pkbuf, OGS_NAS_HEADROOM);
|
||||
ogs_pkbuf_put(pkbuf, OGS_MAX_SDU_LEN-OGS_NAS_HEADROOM);
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
/*******************************************************************************
|
||||
* This file had been created by nas-message.py script v0.1.0
|
||||
* Please do not modify this file but regenerate it via script.
|
||||
* Created on: 2021-05-07 23:02:21.664083 by acetcom
|
||||
* Created on: 2021-05-30 21:57:00.058358 by acetcom
|
||||
* from 24301-g40.docx
|
||||
******************************************************************************/
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
/*******************************************************************************
|
||||
* This file had been created by nas-message.py script v0.1.0
|
||||
* Please do not modify this file but regenerate it via script.
|
||||
* Created on: 2021-05-07 23:02:21.661736 by acetcom
|
||||
* Created on: 2021-05-30 21:57:00.055906 by acetcom
|
||||
* from 24301-g40.docx
|
||||
******************************************************************************/
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
/*******************************************************************************
|
||||
* This file had been created by nas-message.py script v0.1.0
|
||||
* Please do not modify this file but regenerate it via script.
|
||||
* Created on: 2021-05-07 23:02:21.671298 by acetcom
|
||||
* Created on: 2021-05-30 21:57:00.065569 by acetcom
|
||||
* from 24301-g40.docx
|
||||
******************************************************************************/
|
||||
|
||||
|
|
|
@ -880,7 +880,7 @@ f.write("""ogs_pkbuf_t *ogs_nas_emm_encode(ogs_nas_eps_message_t *message)
|
|||
/* The Packet Buffer(ogs_pkbuf_t) for NAS message MUST make a HEADROOM.
|
||||
* When calculating AES_CMAC, we need to use the headroom of the packet. */
|
||||
pkbuf = ogs_pkbuf_alloc(NULL, OGS_MAX_SDU_LEN);
|
||||
ogs_assert(pkbuf);
|
||||
ogs_expect_or_return_val(pkbuf, NULL);
|
||||
ogs_pkbuf_reserve(pkbuf, OGS_NAS_HEADROOM);
|
||||
ogs_pkbuf_put(pkbuf, OGS_MAX_SDU_LEN-OGS_NAS_HEADROOM);
|
||||
|
||||
|
@ -943,7 +943,7 @@ f.write("""ogs_pkbuf_t *ogs_nas_esm_encode(ogs_nas_eps_message_t *message)
|
|||
/* The Packet Buffer(ogs_pkbuf_t) for NAS message MUST make a HEADROOM.
|
||||
* When calculating AES_CMAC, we need to use the headroom of the packet. */
|
||||
pkbuf = ogs_pkbuf_alloc(NULL, OGS_MAX_SDU_LEN);
|
||||
ogs_assert(pkbuf);
|
||||
ogs_expect_or_return_val(pkbuf, NULL);
|
||||
ogs_pkbuf_reserve(pkbuf, OGS_NAS_HEADROOM);
|
||||
ogs_pkbuf_put(pkbuf, OGS_MAX_SDU_LEN-OGS_NAS_HEADROOM);
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "ogs-nas-eps.h"
|
||||
|
||||
void ogs_nas_tai_list_build(ogs_nas_tracking_area_identity_list_t *target,
|
||||
int ogs_nas_tai_list_build(ogs_nas_tracking_area_identity_list_t *target,
|
||||
ogs_eps_tai0_list_t *source0, ogs_eps_tai2_list_t *source2)
|
||||
{
|
||||
int i = 0, j = 0, size = 0;
|
||||
|
@ -53,9 +53,9 @@ void ogs_nas_tai_list_build(ogs_nas_tracking_area_identity_list_t *target,
|
|||
|
||||
size = (1 + 3 + 2 * source0->tai[i].num);
|
||||
if ((target->length + size) > OGS_NAS_EPS_MAX_TAI_LIST_LEN) {
|
||||
ogs_warn("Overflow: Ignore remained TAI LIST(length:%d, size:%d)",
|
||||
ogs_error("Overflow: Ignore remained TAI LIST(length:%d, size:%d)",
|
||||
target->length, size);
|
||||
return;
|
||||
return OGS_ERROR;
|
||||
}
|
||||
memcpy(target->buffer + target->length, &target0.tai[i], size);
|
||||
target->length += size;
|
||||
|
@ -74,9 +74,9 @@ void ogs_nas_tai_list_build(ogs_nas_tracking_area_identity_list_t *target,
|
|||
|
||||
size = (1 + (3 + 2) * source2->num);
|
||||
if ((target->length + size) > OGS_NAS_EPS_MAX_TAI_LIST_LEN) {
|
||||
ogs_warn("Overflow: Ignore remained TAI LIST(length:%d, size:%d)",
|
||||
ogs_error("Overflow: Ignore remained TAI LIST(length:%d, size:%d)",
|
||||
target->length, size);
|
||||
return;
|
||||
return OGS_ERROR;
|
||||
}
|
||||
for (i = 0; i < source2->num; i++) {
|
||||
memcpy(&target2.tai[i].plmn_id,
|
||||
|
@ -88,4 +88,6 @@ void ogs_nas_tai_list_build(ogs_nas_tracking_area_identity_list_t *target,
|
|||
memcpy(target->buffer + target->length, &target2, size);
|
||||
target->length += size;
|
||||
}
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
|
|
@ -552,7 +552,7 @@ typedef struct ogs_nas_tracking_area_identity_list_s {
|
|||
uint8_t buffer[OGS_NAS_EPS_MAX_TAI_LIST_LEN];
|
||||
} __attribute__ ((packed)) ogs_nas_tracking_area_identity_list_t;
|
||||
|
||||
void ogs_nas_tai_list_build(ogs_nas_tracking_area_identity_list_t *target,
|
||||
int ogs_nas_tai_list_build(ogs_nas_tracking_area_identity_list_t *target,
|
||||
ogs_eps_tai0_list_t *source0, ogs_eps_tai2_list_t *source2);
|
||||
|
||||
|
||||
|
|
|
@ -31,10 +31,7 @@ ogs_pkbuf_t *ogs_ngap_encode(ogs_ngap_message_t *message)
|
|||
asn_fprint(stdout, &asn_DEF_NGAP_NGAP_PDU, message);
|
||||
|
||||
pkbuf = ogs_asn_encode(&asn_DEF_NGAP_NGAP_PDU, message);
|
||||
if (pkbuf == NULL) {
|
||||
ogs_error("Failed to encode NGAP-PDU");
|
||||
return NULL;
|
||||
}
|
||||
ogs_expect_or_return_val(pkbuf, NULL);
|
||||
|
||||
return pkbuf;
|
||||
}
|
||||
|
|
|
@ -59,17 +59,18 @@ ogs_pkbuf_t *ogs_pfcp_cp_build_association_setup_request(uint8_t type)
|
|||
ogs_pfcp_association_setup_request_t *req = NULL;
|
||||
|
||||
ogs_pfcp_node_id_t node_id;
|
||||
int node_id_len = 0;
|
||||
int node_id_len = 0, rv;
|
||||
|
||||
ogs_debug("Association Setup Request");
|
||||
|
||||
req = &pfcp_message.pfcp_association_setup_request;
|
||||
memset(&pfcp_message, 0, sizeof(ogs_pfcp_message_t));
|
||||
|
||||
ogs_pfcp_sockaddr_to_node_id(
|
||||
rv = ogs_pfcp_sockaddr_to_node_id(
|
||||
ogs_pfcp_self()->pfcp_addr, ogs_pfcp_self()->pfcp_addr6,
|
||||
ogs_app()->parameter.prefer_ipv4,
|
||||
&node_id, &node_id_len);
|
||||
ogs_expect_or_return_val(rv == OGS_OK, NULL);
|
||||
req->node_id.presence = 1;
|
||||
req->node_id.data = &node_id;
|
||||
req->node_id.len = node_id_len;
|
||||
|
@ -91,17 +92,18 @@ ogs_pkbuf_t *ogs_pfcp_cp_build_association_setup_response(uint8_t type,
|
|||
ogs_pfcp_association_setup_response_t *rsp = NULL;
|
||||
|
||||
ogs_pfcp_node_id_t node_id;
|
||||
int node_id_len = 0;
|
||||
int node_id_len = 0, rv;
|
||||
|
||||
ogs_debug("Association Setup Response");
|
||||
|
||||
rsp = &pfcp_message.pfcp_association_setup_response;
|
||||
memset(&pfcp_message, 0, sizeof(ogs_pfcp_message_t));
|
||||
|
||||
ogs_pfcp_sockaddr_to_node_id(
|
||||
rv = ogs_pfcp_sockaddr_to_node_id(
|
||||
ogs_pfcp_self()->pfcp_addr, ogs_pfcp_self()->pfcp_addr6,
|
||||
ogs_app()->parameter.prefer_ipv4,
|
||||
&node_id, &node_id_len);
|
||||
ogs_expect_or_return_val(rv == OGS_OK, NULL);
|
||||
rsp->node_id.presence = 1;
|
||||
rsp->node_id.data = &node_id;
|
||||
rsp->node_id.len = node_id_len;
|
||||
|
@ -130,17 +132,18 @@ ogs_pkbuf_t *ogs_pfcp_up_build_association_setup_request(uint8_t type)
|
|||
ogs_gtpu_resource_t *resource = NULL;
|
||||
char infobuf[OGS_MAX_NUM_OF_GTPU_RESOURCE]
|
||||
[OGS_MAX_USER_PLANE_IP_RESOURCE_INFO_LEN];
|
||||
int i = 0;
|
||||
int i = 0, rv;
|
||||
|
||||
ogs_debug("Association Setup Request");
|
||||
|
||||
req = &pfcp_message.pfcp_association_setup_request;
|
||||
memset(&pfcp_message, 0, sizeof(ogs_pfcp_message_t));
|
||||
|
||||
ogs_pfcp_sockaddr_to_node_id(
|
||||
rv = ogs_pfcp_sockaddr_to_node_id(
|
||||
ogs_pfcp_self()->pfcp_addr, ogs_pfcp_self()->pfcp_addr6,
|
||||
ogs_app()->parameter.prefer_ipv4,
|
||||
&node_id, &node_id_len);
|
||||
ogs_expect_or_return_val(rv == OGS_OK, NULL);
|
||||
req->node_id.presence = 1;
|
||||
req->node_id.data = &node_id;
|
||||
req->node_id.len = node_id_len;
|
||||
|
@ -185,17 +188,18 @@ ogs_pkbuf_t *ogs_pfcp_up_build_association_setup_response(uint8_t type,
|
|||
ogs_gtpu_resource_t *resource = NULL;
|
||||
char infobuf[OGS_MAX_NUM_OF_GTPU_RESOURCE]
|
||||
[OGS_MAX_USER_PLANE_IP_RESOURCE_INFO_LEN];
|
||||
int i = 0;
|
||||
int i = 0, rv;
|
||||
|
||||
ogs_debug("Association Setup Response");
|
||||
|
||||
rsp = &pfcp_message.pfcp_association_setup_response;
|
||||
memset(&pfcp_message, 0, sizeof(ogs_pfcp_message_t));
|
||||
|
||||
ogs_pfcp_sockaddr_to_node_id(
|
||||
rv = ogs_pfcp_sockaddr_to_node_id(
|
||||
ogs_pfcp_self()->pfcp_addr, ogs_pfcp_self()->pfcp_addr6,
|
||||
ogs_app()->parameter.prefer_ipv4,
|
||||
&node_id, &node_id_len);
|
||||
ogs_expect_or_return_val(rv == OGS_OK, NULL);
|
||||
rsp->node_id.presence = 1;
|
||||
rsp->node_id.data = &node_id;
|
||||
rsp->node_id.len = node_id_len;
|
||||
|
@ -299,6 +303,7 @@ void ogs_pfcp_build_create_pdr(
|
|||
|
||||
message->pdi.sdf_filter[j].presence = 1;
|
||||
pdrbuf[i].sdf_filter[j] = ogs_calloc(1, len);
|
||||
ogs_assert(pdrbuf[i].sdf_filter[j]);
|
||||
ogs_pfcp_build_sdf_filter(&message->pdi.sdf_filter[j],
|
||||
&pfcp_sdf_filter[j], pdrbuf[i].sdf_filter[j], len);
|
||||
}
|
||||
|
@ -404,6 +409,7 @@ void ogs_pfcp_build_update_pdr(
|
|||
|
||||
message->pdi.sdf_filter[j].presence = 1;
|
||||
pdrbuf[i].sdf_filter[j] = ogs_calloc(1, len);
|
||||
ogs_assert(pdrbuf[i].sdf_filter[j]);
|
||||
ogs_pfcp_build_sdf_filter(&message->pdi.sdf_filter[j],
|
||||
&pfcp_sdf_filter[j], pdrbuf[i].sdf_filter[j], len);
|
||||
}
|
||||
|
|
|
@ -85,8 +85,11 @@ void ogs_pfcp_context_init(void)
|
|||
ogs_pool_init(&ogs_pfcp_subnet_pool, OGS_MAX_NUM_OF_SUBNET);
|
||||
|
||||
self.object_teid_hash = ogs_hash_make();
|
||||
ogs_assert(self.object_teid_hash);
|
||||
self.far_f_teid_hash = ogs_hash_make();
|
||||
ogs_assert(self.far_f_teid_hash);
|
||||
self.far_teid_hash = ogs_hash_make();
|
||||
ogs_assert(self.far_teid_hash);
|
||||
|
||||
context_initialized = 1;
|
||||
}
|
||||
|
@ -676,7 +679,7 @@ ogs_pfcp_node_t *ogs_pfcp_node_add(
|
|||
ogs_assert(list);
|
||||
ogs_assert(addr);
|
||||
|
||||
ogs_copyaddrinfo(&new, addr);
|
||||
ogs_assert(OGS_OK == ogs_copyaddrinfo(&new, addr));
|
||||
node = ogs_pfcp_node_new(new);
|
||||
|
||||
ogs_assert(node);
|
||||
|
@ -752,7 +755,7 @@ ogs_gtpu_resource_t *ogs_pfcp_find_gtpu_resource(ogs_list_t *list,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void ogs_pfcp_setup_far_gtpu_node(ogs_pfcp_far_t *far)
|
||||
int ogs_pfcp_setup_far_gtpu_node(ogs_pfcp_far_t *far)
|
||||
{
|
||||
int rv;
|
||||
ogs_ip_t ip;
|
||||
|
@ -763,23 +766,25 @@ void ogs_pfcp_setup_far_gtpu_node(ogs_pfcp_far_t *far)
|
|||
ogs_pfcp_outer_header_creation_to_ip(&far->outer_header_creation, &ip);
|
||||
|
||||
/* No Outer Header Creation */
|
||||
if (ip.len == 0) return;
|
||||
if (ip.len == 0) return OGS_DONE;
|
||||
|
||||
gnode = ogs_gtp_node_find_by_ip(&ogs_gtp_self()->gtpu_peer_list, &ip);
|
||||
if (!gnode) {
|
||||
gnode = ogs_gtp_node_add_by_ip(
|
||||
&ogs_gtp_self()->gtpu_peer_list, &ip, ogs_gtp_self()->gtpu_port);
|
||||
ogs_assert(gnode);
|
||||
ogs_expect_or_return_val(gnode, OGS_ERROR);
|
||||
|
||||
rv = ogs_gtp_connect(
|
||||
ogs_gtp_self()->gtpu_sock, ogs_gtp_self()->gtpu_sock6, gnode);
|
||||
ogs_assert(rv == OGS_OK);
|
||||
ogs_expect_or_return_val(rv == OGS_OK, rv);
|
||||
}
|
||||
|
||||
OGS_SETUP_GTP_NODE(far, gnode);
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
||||
void ogs_pfcp_setup_pdr_gtpu_node(ogs_pfcp_pdr_t *pdr)
|
||||
int ogs_pfcp_setup_pdr_gtpu_node(ogs_pfcp_pdr_t *pdr)
|
||||
{
|
||||
int rv;
|
||||
ogs_ip_t ip;
|
||||
|
@ -788,22 +793,25 @@ void ogs_pfcp_setup_pdr_gtpu_node(ogs_pfcp_pdr_t *pdr)
|
|||
ogs_assert(pdr);
|
||||
|
||||
/* No F-TEID */
|
||||
if (pdr->f_teid_len == 0) return;
|
||||
if (pdr->f_teid_len == 0) return OGS_DONE;
|
||||
|
||||
ogs_pfcp_f_teid_to_ip(&pdr->f_teid, &ip);
|
||||
rv = ogs_pfcp_f_teid_to_ip(&pdr->f_teid, &ip);
|
||||
ogs_expect_or_return_val(rv == OGS_OK, rv);
|
||||
|
||||
gnode = ogs_gtp_node_find_by_ip(&ogs_gtp_self()->gtpu_peer_list, &ip);
|
||||
if (!gnode) {
|
||||
gnode = ogs_gtp_node_add_by_ip(
|
||||
&ogs_gtp_self()->gtpu_peer_list, &ip, ogs_gtp_self()->gtpu_port);
|
||||
ogs_assert(gnode);
|
||||
ogs_expect_or_return_val(gnode, OGS_ERROR);
|
||||
|
||||
rv = ogs_gtp_connect(
|
||||
ogs_gtp_self()->gtpu_sock, ogs_gtp_self()->gtpu_sock6, gnode);
|
||||
ogs_assert(rv == OGS_OK);
|
||||
ogs_expect_or_return_val(rv == OGS_OK, rv);
|
||||
}
|
||||
|
||||
OGS_SETUP_GTP_NODE(pdr, gnode);
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
||||
void ogs_pfcp_sess_clear(ogs_pfcp_sess_t *sess)
|
||||
|
@ -1577,8 +1585,8 @@ ogs_pfcp_ue_ip_t *ogs_pfcp_ue_ip_alloc(
|
|||
} else if (family == AF_INET6) {
|
||||
maxbytes = 16;
|
||||
} else {
|
||||
ogs_fatal("Invalid family[%d]", family);
|
||||
ogs_assert_if_reached();
|
||||
ogs_error("Invalid family[%d]", family);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (dnn)
|
||||
|
@ -1596,22 +1604,22 @@ ogs_pfcp_ue_ip_t *ogs_pfcp_ue_ip_alloc(
|
|||
else if (family == AF_INET6)
|
||||
ogs_error(" - addr: 2001:230:cafe::1/48");
|
||||
|
||||
ogs_assert_if_reached();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* if assigning a static IP, do so. If not, assign dynamically! */
|
||||
if (memcmp(addr, zero, maxbytes) != 0) {
|
||||
ue_ip = ogs_calloc(1, sizeof(ogs_pfcp_ue_ip_t));
|
||||
ogs_expect_or_return_val(ue_ip, NULL);
|
||||
|
||||
ue_ip->subnet = subnet;
|
||||
ue_ip->static_ip = true;
|
||||
memcpy(ue_ip->addr, addr, maxbytes);
|
||||
} else {
|
||||
ogs_pool_alloc(&subnet->pool, &ue_ip);
|
||||
ogs_expect(ue_ip);
|
||||
}
|
||||
|
||||
ogs_assert(ue_ip);
|
||||
return ue_ip;
|
||||
}
|
||||
|
||||
|
|
|
@ -353,8 +353,8 @@ void ogs_pfcp_node_remove_all(ogs_list_t *list);
|
|||
|
||||
ogs_gtpu_resource_t *ogs_pfcp_find_gtpu_resource(ogs_list_t *list,
|
||||
char *dnn, ogs_pfcp_interface_t source_interface);
|
||||
void ogs_pfcp_setup_far_gtpu_node(ogs_pfcp_far_t *far);
|
||||
void ogs_pfcp_setup_pdr_gtpu_node(ogs_pfcp_pdr_t *pdr);
|
||||
int ogs_pfcp_setup_far_gtpu_node(ogs_pfcp_far_t *far);
|
||||
int ogs_pfcp_setup_pdr_gtpu_node(ogs_pfcp_pdr_t *pdr);
|
||||
|
||||
void ogs_pfcp_sess_clear(ogs_pfcp_sess_t *sess);
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ int ogs_pfcp_sockaddr_to_node_id(
|
|||
node_id->addr = addr->sin.sin_addr.s_addr;
|
||||
*len = OGS_IPV4_LEN + hdr_len;
|
||||
} else {
|
||||
ogs_assert_if_reached();
|
||||
ogs_error("No IPv4 or IPv6");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
|
@ -81,12 +81,12 @@ int ogs_pfcp_f_seid_to_sockaddr(
|
|||
ogs_assert(list);
|
||||
|
||||
addr = ogs_calloc(1, sizeof(ogs_sockaddr_t));
|
||||
ogs_assert(addr);
|
||||
ogs_expect_or_return_val(addr, OGS_ERROR);
|
||||
addr->ogs_sa_family = AF_INET;
|
||||
addr->ogs_sin_port = htobe16(port);
|
||||
|
||||
addr6 = ogs_calloc(1, sizeof(ogs_sockaddr_t));
|
||||
ogs_assert(addr6);
|
||||
ogs_expect_or_return_val(addr6, OGS_ERROR);
|
||||
addr6->ogs_sa_family = AF_INET6;
|
||||
addr6->ogs_sin_port = htobe16(port);
|
||||
|
||||
|
@ -110,7 +110,8 @@ int ogs_pfcp_f_seid_to_sockaddr(
|
|||
} else {
|
||||
ogs_free(addr);
|
||||
ogs_free(addr6);
|
||||
ogs_assert_if_reached();
|
||||
ogs_error("No IPv4 or IPv6");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
return OGS_OK;
|
||||
|
@ -142,8 +143,10 @@ int ogs_pfcp_sockaddr_to_f_seid(
|
|||
f_seid->ipv6 = 1;
|
||||
memcpy(f_seid->addr6, addr6->sin6.sin6_addr.s6_addr, OGS_IPV6_LEN);
|
||||
*len = OGS_IPV6_LEN + hdr_len;
|
||||
} else
|
||||
ogs_assert_if_reached();
|
||||
} else {
|
||||
ogs_error("No IPv4 or IPv6");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
@ -168,8 +171,10 @@ int ogs_pfcp_f_seid_to_ip(ogs_pfcp_f_seid_t *f_seid, ogs_ip_t *ip)
|
|||
} else if (ip->ipv6) {
|
||||
memcpy(ip->addr6, f_seid->addr6, OGS_IPV6_LEN);
|
||||
ip->len = OGS_IPV6_LEN;
|
||||
} else
|
||||
ogs_assert_if_reached();
|
||||
} else {
|
||||
ogs_error("No IPv4 or IPv6");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
@ -200,8 +205,10 @@ int ogs_pfcp_sockaddr_to_f_teid(
|
|||
f_teid->ipv6 = 1;
|
||||
memcpy(f_teid->addr6, addr6->sin6.sin6_addr.s6_addr, OGS_IPV6_LEN);
|
||||
*len = OGS_IPV6_LEN + hdr_len;
|
||||
} else
|
||||
ogs_expect_or_return_val(0, OGS_ERROR);
|
||||
} else {
|
||||
ogs_error("No IPv4 or IPv6");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
@ -219,25 +226,28 @@ int ogs_pfcp_f_teid_to_sockaddr(
|
|||
|
||||
if (f_teid->ipv4 && f_teid->ipv6) {
|
||||
*addr = ogs_calloc(1, sizeof(**addr));
|
||||
ogs_assert(*addr);
|
||||
ogs_expect_or_return_val(*addr, OGS_ERROR);
|
||||
(*addr)->sin.sin_addr.s_addr = f_teid->both.addr;
|
||||
(*addr)->ogs_sa_family = AF_INET;
|
||||
|
||||
*addr6 = ogs_calloc(1, sizeof(**addr6));
|
||||
ogs_assert(*addr6);
|
||||
ogs_expect_or_return_val(*addr6, OGS_ERROR);
|
||||
memcpy((*addr6)->sin6.sin6_addr.s6_addr,
|
||||
f_teid->both.addr6, OGS_IPV6_LEN);
|
||||
(*addr6)->ogs_sa_family = AF_INET6;
|
||||
} else if (f_teid->ipv4) {
|
||||
*addr = ogs_calloc(1, sizeof(**addr));
|
||||
ogs_assert(*addr);
|
||||
ogs_expect_or_return_val(*addr, OGS_ERROR);
|
||||
(*addr)->sin.sin_addr.s_addr = f_teid->addr;
|
||||
(*addr)->ogs_sa_family = AF_INET;
|
||||
} else if (f_teid->ipv6) {
|
||||
*addr6 = ogs_calloc(1, sizeof(**addr6));
|
||||
ogs_assert(*addr6);
|
||||
ogs_expect_or_return_val(*addr6, OGS_ERROR);
|
||||
memcpy((*addr6)->sin6.sin6_addr.s6_addr, f_teid->addr6, OGS_IPV6_LEN);
|
||||
(*addr6)->ogs_sa_family = AF_INET6;
|
||||
} else {
|
||||
ogs_error("No IPv4 or IPv6");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
return OGS_OK;
|
||||
|
@ -263,8 +273,10 @@ int ogs_pfcp_f_teid_to_ip(ogs_pfcp_f_teid_t *f_teid, ogs_ip_t *ip)
|
|||
} else if (ip->ipv6) {
|
||||
memcpy(ip->addr6, f_teid->addr6, OGS_IPV6_LEN);
|
||||
ip->len = OGS_IPV6_LEN;
|
||||
} else
|
||||
ogs_assert_if_reached();
|
||||
} else {
|
||||
ogs_error("No IPv4 or IPv6");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
@ -295,8 +307,10 @@ int ogs_pfcp_user_plane_ip_resource_info_to_f_teid(
|
|||
f_teid->ipv6 = 1;
|
||||
memcpy(f_teid->addr6, info->addr6, OGS_IPV6_LEN);
|
||||
*len = OGS_IPV6_LEN + hdr_len;
|
||||
} else
|
||||
ogs_assert_if_reached();
|
||||
} else {
|
||||
ogs_error("No IPv4 or IPv6");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
@ -327,8 +341,10 @@ int ogs_pfcp_paa_to_ue_ip_addr(
|
|||
addr->ipv6 = 1;
|
||||
memcpy(addr->addr6, paa->addr6, OGS_IPV6_LEN);
|
||||
*len = OGS_IPV6_LEN + hdr_len;
|
||||
} else
|
||||
ogs_assert_if_reached();
|
||||
} else {
|
||||
ogs_error("No IPv4 or IPv6");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
@ -358,13 +374,15 @@ int ogs_pfcp_ip_to_outer_header_creation(ogs_ip_t *ip,
|
|||
outer_header_creation->gtpu6 = 1;
|
||||
memcpy(outer_header_creation->addr6, ip->addr6, OGS_IPV6_LEN);
|
||||
*len = OGS_IPV6_LEN + hdr_len;
|
||||
} else
|
||||
ogs_assert_if_reached();
|
||||
} else {
|
||||
ogs_error("No IPv4 or IPv6");
|
||||
return OGS_ERROR;
|
||||
}
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
||||
int ogs_pfcp_outer_header_creation_to_ip(
|
||||
void ogs_pfcp_outer_header_creation_to_ip(
|
||||
ogs_pfcp_outer_header_creation_t *outer_header_creation, ogs_ip_t *ip)
|
||||
{
|
||||
ogs_assert(outer_header_creation);
|
||||
|
@ -393,8 +411,5 @@ int ogs_pfcp_outer_header_creation_to_ip(
|
|||
ip->ipv6 = 1;
|
||||
ip->len = OGS_IPV6_LEN;
|
||||
memcpy(ip->addr6, outer_header_creation->addr6, OGS_IPV6_LEN);
|
||||
} else
|
||||
return OGS_ERROR;
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ int ogs_pfcp_paa_to_ue_ip_addr(
|
|||
|
||||
int ogs_pfcp_ip_to_outer_header_creation(ogs_ip_t *ip,
|
||||
ogs_pfcp_outer_header_creation_t *outer_header_creation, int *len);
|
||||
int ogs_pfcp_outer_header_creation_to_ip(
|
||||
void ogs_pfcp_outer_header_creation_to_ip(
|
||||
ogs_pfcp_outer_header_creation_t *outer_header_creation, ogs_ip_t *ip);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -19,15 +19,20 @@
|
|||
|
||||
#include "ogs-pfcp.h"
|
||||
|
||||
void ogs_pfcp_handle_heartbeat_request(
|
||||
bool ogs_pfcp_handle_heartbeat_request(
|
||||
ogs_pfcp_node_t *node, ogs_pfcp_xact_t *xact,
|
||||
ogs_pfcp_heartbeat_request_t *req)
|
||||
{
|
||||
int rv;
|
||||
ogs_assert(xact);
|
||||
ogs_pfcp_send_heartbeat_response(xact);
|
||||
|
||||
rv = ogs_pfcp_send_heartbeat_response(xact);
|
||||
ogs_expect_or_return_val(rv == OGS_OK, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ogs_pfcp_handle_heartbeat_response(
|
||||
bool ogs_pfcp_handle_heartbeat_response(
|
||||
ogs_pfcp_node_t *node, ogs_pfcp_xact_t *xact,
|
||||
ogs_pfcp_heartbeat_response_t *rsp)
|
||||
{
|
||||
|
@ -36,9 +41,11 @@ void ogs_pfcp_handle_heartbeat_response(
|
|||
|
||||
ogs_timer_start(node->t_no_heartbeat,
|
||||
ogs_app()->time.message.pfcp.no_heartbeat_duration);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ogs_pfcp_cp_handle_association_setup_request(
|
||||
bool ogs_pfcp_cp_handle_association_setup_request(
|
||||
ogs_pfcp_node_t *node, ogs_pfcp_xact_t *xact,
|
||||
ogs_pfcp_association_setup_request_t *req)
|
||||
{
|
||||
|
@ -81,9 +88,11 @@ void ogs_pfcp_cp_handle_association_setup_request(
|
|||
ogs_error("F-TEID allocation/release not supported with peer [%s]:%d",
|
||||
OGS_ADDR(addr, buf), OGS_PORT(addr));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ogs_pfcp_cp_handle_association_setup_response(
|
||||
bool ogs_pfcp_cp_handle_association_setup_response(
|
||||
ogs_pfcp_node_t *node, ogs_pfcp_xact_t *xact,
|
||||
ogs_pfcp_association_setup_response_t *rsp)
|
||||
{
|
||||
|
@ -125,9 +134,11 @@ void ogs_pfcp_cp_handle_association_setup_response(
|
|||
ogs_error("F-TEID allocation/release not supported with peer [%s]:%d",
|
||||
OGS_ADDR(addr, buf), OGS_PORT(addr));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ogs_pfcp_up_handle_association_setup_request(
|
||||
bool ogs_pfcp_up_handle_association_setup_request(
|
||||
ogs_pfcp_node_t *node, ogs_pfcp_xact_t *xact,
|
||||
ogs_pfcp_association_setup_request_t *req)
|
||||
{
|
||||
|
@ -139,9 +150,11 @@ void ogs_pfcp_up_handle_association_setup_request(
|
|||
ogs_pfcp_self()->cp_function_features.octet5 =
|
||||
req->cp_function_features.u8;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ogs_pfcp_up_handle_association_setup_response(
|
||||
bool ogs_pfcp_up_handle_association_setup_response(
|
||||
ogs_pfcp_node_t *node, ogs_pfcp_xact_t *xact,
|
||||
ogs_pfcp_association_setup_response_t *rsp)
|
||||
{
|
||||
|
@ -152,9 +165,11 @@ void ogs_pfcp_up_handle_association_setup_response(
|
|||
ogs_pfcp_self()->cp_function_features.octet5 =
|
||||
rsp->cp_function_features.u8;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ogs_pfcp_up_handle_pdr(
|
||||
bool ogs_pfcp_up_handle_pdr(
|
||||
ogs_pfcp_pdr_t *pdr, ogs_pkbuf_t *recvbuf,
|
||||
ogs_pfcp_user_plane_report_t *report)
|
||||
{
|
||||
|
@ -172,12 +187,7 @@ void ogs_pfcp_up_handle_pdr(
|
|||
memset(report, 0, sizeof(*report));
|
||||
|
||||
sendbuf = ogs_pkbuf_copy(recvbuf);
|
||||
if (!sendbuf) {
|
||||
ogs_fatal("Not enough packet buffer");
|
||||
ogs_assert_if_reached();
|
||||
|
||||
return;
|
||||
}
|
||||
ogs_expect_or_return_val(sendbuf, false);
|
||||
|
||||
buffering = false;
|
||||
|
||||
|
@ -214,9 +224,11 @@ void ogs_pfcp_up_handle_pdr(
|
|||
ogs_pkbuf_free(sendbuf);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ogs_pfcp_up_handle_error_indication(
|
||||
bool ogs_pfcp_up_handle_error_indication(
|
||||
ogs_pfcp_far_t *far, ogs_pfcp_user_plane_report_t *report)
|
||||
{
|
||||
uint16_t len;
|
||||
|
@ -244,10 +256,12 @@ void ogs_pfcp_up_handle_error_indication(
|
|||
far->hash.f_teid.key.addr, len);
|
||||
} else {
|
||||
ogs_error("Invalid Length [%d]", len);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
report->type.error_indication_report = 1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ogs_pfcp_pdr_t *ogs_pfcp_handle_create_pdr(ogs_pfcp_sess_t *sess,
|
||||
|
@ -350,6 +364,7 @@ ogs_pfcp_pdr_t *ogs_pfcp_handle_create_pdr(ogs_pfcp_sess_t *sess,
|
|||
|
||||
flow_description = ogs_malloc(
|
||||
sdf_filter.flow_description_len+1);
|
||||
ogs_assert(flow_description);
|
||||
ogs_cpystrn(flow_description,
|
||||
sdf_filter.flow_description,
|
||||
sdf_filter.flow_description_len+1);
|
||||
|
@ -408,6 +423,7 @@ ogs_pfcp_pdr_t *ogs_pfcp_handle_create_pdr(ogs_pfcp_sess_t *sess,
|
|||
message->pdi.network_instance.len);
|
||||
|
||||
pdr->dnn = ogs_strdup(dnn);
|
||||
ogs_assert(pdr->dnn);
|
||||
}
|
||||
|
||||
pdr->chid = false;
|
||||
|
@ -593,6 +609,7 @@ ogs_pfcp_pdr_t *ogs_pfcp_handle_update_pdr(ogs_pfcp_sess_t *sess,
|
|||
|
||||
flow_description = ogs_malloc(
|
||||
sdf_filter.flow_description_len+1);
|
||||
ogs_assert(flow_description);
|
||||
ogs_cpystrn(flow_description,
|
||||
sdf_filter.flow_description,
|
||||
sdf_filter.flow_description_len+1);
|
||||
|
@ -648,6 +665,7 @@ ogs_pfcp_pdr_t *ogs_pfcp_handle_update_pdr(ogs_pfcp_sess_t *sess,
|
|||
if (pdr->dnn)
|
||||
ogs_free(pdr->dnn);
|
||||
pdr->dnn = ogs_strdup(dnn);
|
||||
ogs_assert(pdr->dnn);
|
||||
}
|
||||
|
||||
if (message->pdi.local_f_teid.presence) {
|
||||
|
|
|
@ -24,31 +24,31 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
void ogs_pfcp_handle_heartbeat_request(
|
||||
bool ogs_pfcp_handle_heartbeat_request(
|
||||
ogs_pfcp_node_t *node, ogs_pfcp_xact_t *xact,
|
||||
ogs_pfcp_heartbeat_request_t *req);
|
||||
void ogs_pfcp_handle_heartbeat_response(
|
||||
bool ogs_pfcp_handle_heartbeat_response(
|
||||
ogs_pfcp_node_t *node, ogs_pfcp_xact_t *xact,
|
||||
ogs_pfcp_heartbeat_response_t *req);
|
||||
|
||||
void ogs_pfcp_cp_handle_association_setup_request(
|
||||
bool ogs_pfcp_cp_handle_association_setup_request(
|
||||
ogs_pfcp_node_t *node, ogs_pfcp_xact_t *xact,
|
||||
ogs_pfcp_association_setup_request_t *req);
|
||||
void ogs_pfcp_cp_handle_association_setup_response(
|
||||
bool ogs_pfcp_cp_handle_association_setup_response(
|
||||
ogs_pfcp_node_t *node, ogs_pfcp_xact_t *xact,
|
||||
ogs_pfcp_association_setup_response_t *req);
|
||||
|
||||
void ogs_pfcp_up_handle_association_setup_request(
|
||||
bool ogs_pfcp_up_handle_association_setup_request(
|
||||
ogs_pfcp_node_t *node, ogs_pfcp_xact_t *xact,
|
||||
ogs_pfcp_association_setup_request_t *req);
|
||||
void ogs_pfcp_up_handle_association_setup_response(
|
||||
bool ogs_pfcp_up_handle_association_setup_response(
|
||||
ogs_pfcp_node_t *node, ogs_pfcp_xact_t *xact,
|
||||
ogs_pfcp_association_setup_response_t *req);
|
||||
|
||||
void ogs_pfcp_up_handle_pdr(
|
||||
bool ogs_pfcp_up_handle_pdr(
|
||||
ogs_pfcp_pdr_t *pdr, ogs_pkbuf_t *recvbuf,
|
||||
ogs_pfcp_user_plane_report_t *report);
|
||||
void ogs_pfcp_up_handle_error_indication(
|
||||
bool ogs_pfcp_up_handle_error_indication(
|
||||
ogs_pfcp_far_t *far, ogs_pfcp_user_plane_report_t *report);
|
||||
|
||||
ogs_pfcp_pdr_t *ogs_pfcp_handle_create_pdr(ogs_pfcp_sess_t *sess,
|
||||
|
|
|
@ -120,7 +120,7 @@ int ogs_pfcp_sendto(ogs_pfcp_node_t *node, ogs_pkbuf_t *pkbuf)
|
|||
return OGS_OK;
|
||||
}
|
||||
|
||||
void ogs_pfcp_send_heartbeat_request(ogs_pfcp_node_t *node,
|
||||
int ogs_pfcp_send_heartbeat_request(ogs_pfcp_node_t *node,
|
||||
void (*cb)(ogs_pfcp_xact_t *xact, void *data))
|
||||
{
|
||||
int rv;
|
||||
|
@ -135,16 +135,18 @@ void ogs_pfcp_send_heartbeat_request(ogs_pfcp_node_t *node,
|
|||
h.seid = 0;
|
||||
|
||||
pkbuf = ogs_pfcp_build_heartbeat_request(h.type);
|
||||
ogs_expect_or_return(pkbuf);
|
||||
ogs_expect_or_return_val(pkbuf, OGS_ERROR);
|
||||
|
||||
xact = ogs_pfcp_xact_local_create(node, &h, pkbuf, cb, node);
|
||||
ogs_expect_or_return(xact);
|
||||
ogs_expect_or_return_val(xact, OGS_ERROR);
|
||||
|
||||
rv = ogs_pfcp_xact_commit(xact);
|
||||
ogs_expect(rv == OGS_OK);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void ogs_pfcp_send_heartbeat_response(ogs_pfcp_xact_t *xact)
|
||||
int ogs_pfcp_send_heartbeat_response(ogs_pfcp_xact_t *xact)
|
||||
{
|
||||
int rv;
|
||||
ogs_pkbuf_t *pkbuf = NULL;
|
||||
|
@ -157,16 +159,18 @@ void ogs_pfcp_send_heartbeat_response(ogs_pfcp_xact_t *xact)
|
|||
h.seid = 0;
|
||||
|
||||
pkbuf = ogs_pfcp_build_heartbeat_response(h.type);
|
||||
ogs_expect_or_return(pkbuf);
|
||||
ogs_expect_or_return_val(pkbuf, OGS_ERROR);
|
||||
|
||||
rv = ogs_pfcp_xact_update_tx(xact, &h, pkbuf);
|
||||
ogs_expect_or_return(rv == OGS_OK);
|
||||
ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR);
|
||||
|
||||
rv = ogs_pfcp_xact_commit(xact);
|
||||
ogs_expect(rv == OGS_OK);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void ogs_pfcp_cp_send_association_setup_request(ogs_pfcp_node_t *node,
|
||||
int ogs_pfcp_cp_send_association_setup_request(ogs_pfcp_node_t *node,
|
||||
void (*cb)(ogs_pfcp_xact_t *xact, void *data))
|
||||
{
|
||||
int rv;
|
||||
|
@ -181,16 +185,18 @@ void ogs_pfcp_cp_send_association_setup_request(ogs_pfcp_node_t *node,
|
|||
h.seid = 0;
|
||||
|
||||
pkbuf = ogs_pfcp_cp_build_association_setup_request(h.type);
|
||||
ogs_expect_or_return(pkbuf);
|
||||
ogs_expect_or_return_val(pkbuf, OGS_ERROR);
|
||||
|
||||
xact = ogs_pfcp_xact_local_create(node, &h, pkbuf, cb, node);
|
||||
ogs_expect_or_return(xact);
|
||||
ogs_expect_or_return_val(xact, OGS_ERROR);
|
||||
|
||||
rv = ogs_pfcp_xact_commit(xact);
|
||||
ogs_expect(rv == OGS_OK);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void ogs_pfcp_cp_send_association_setup_response(ogs_pfcp_xact_t *xact,
|
||||
int ogs_pfcp_cp_send_association_setup_response(ogs_pfcp_xact_t *xact,
|
||||
uint8_t cause)
|
||||
{
|
||||
int rv;
|
||||
|
@ -204,16 +210,18 @@ void ogs_pfcp_cp_send_association_setup_response(ogs_pfcp_xact_t *xact,
|
|||
h.seid = 0;
|
||||
|
||||
pkbuf = ogs_pfcp_cp_build_association_setup_response(h.type, cause);
|
||||
ogs_expect_or_return(pkbuf);
|
||||
ogs_expect_or_return_val(pkbuf, OGS_ERROR);
|
||||
|
||||
rv = ogs_pfcp_xact_update_tx(xact, &h, pkbuf);
|
||||
ogs_expect_or_return(rv == OGS_OK);
|
||||
ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR);
|
||||
|
||||
rv = ogs_pfcp_xact_commit(xact);
|
||||
ogs_expect(rv == OGS_OK);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void ogs_pfcp_up_send_association_setup_request(ogs_pfcp_node_t *node,
|
||||
int ogs_pfcp_up_send_association_setup_request(ogs_pfcp_node_t *node,
|
||||
void (*cb)(ogs_pfcp_xact_t *xact, void *data))
|
||||
{
|
||||
int rv;
|
||||
|
@ -228,16 +236,18 @@ void ogs_pfcp_up_send_association_setup_request(ogs_pfcp_node_t *node,
|
|||
h.seid = 0;
|
||||
|
||||
pkbuf = ogs_pfcp_up_build_association_setup_request(h.type);
|
||||
ogs_expect_or_return(pkbuf);
|
||||
ogs_expect_or_return_val(pkbuf, OGS_ERROR);
|
||||
|
||||
xact = ogs_pfcp_xact_local_create(node, &h, pkbuf, cb, node);
|
||||
ogs_expect_or_return(xact);
|
||||
ogs_expect_or_return_val(xact, OGS_ERROR);
|
||||
|
||||
rv = ogs_pfcp_xact_commit(xact);
|
||||
ogs_expect(rv == OGS_OK);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void ogs_pfcp_up_send_association_setup_response(ogs_pfcp_xact_t *xact,
|
||||
int ogs_pfcp_up_send_association_setup_response(ogs_pfcp_xact_t *xact,
|
||||
uint8_t cause)
|
||||
{
|
||||
int rv;
|
||||
|
@ -251,13 +261,15 @@ void ogs_pfcp_up_send_association_setup_response(ogs_pfcp_xact_t *xact,
|
|||
h.seid = 0;
|
||||
|
||||
pkbuf = ogs_pfcp_up_build_association_setup_response(h.type, cause);
|
||||
ogs_expect_or_return(pkbuf);
|
||||
ogs_expect_or_return_val(pkbuf, OGS_ERROR);
|
||||
|
||||
rv = ogs_pfcp_xact_update_tx(xact, &h, pkbuf);
|
||||
ogs_expect_or_return(rv == OGS_OK);
|
||||
ogs_expect_or_return_val(rv == OGS_OK, OGS_ERROR);
|
||||
|
||||
rv = ogs_pfcp_xact_commit(xact);
|
||||
ogs_expect(rv == OGS_OK);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void ogs_pfcp_send_g_pdu(ogs_pfcp_pdr_t *pdr, ogs_pkbuf_t *sendbuf)
|
||||
|
@ -299,7 +311,7 @@ void ogs_pfcp_send_g_pdu(ogs_pfcp_pdr_t *pdr, ogs_pkbuf_t *sendbuf)
|
|||
ogs_gtp_send_user_plane(gnode, >p_hdesc, &ext_hdesc, sendbuf);
|
||||
}
|
||||
|
||||
void ogs_pfcp_send_end_marker(ogs_pfcp_pdr_t *pdr)
|
||||
int ogs_pfcp_send_end_marker(ogs_pfcp_pdr_t *pdr)
|
||||
{
|
||||
ogs_gtp_node_t *gnode = NULL;
|
||||
ogs_pfcp_far_t *far = NULL;
|
||||
|
@ -316,15 +328,15 @@ void ogs_pfcp_send_end_marker(ogs_pfcp_pdr_t *pdr)
|
|||
gnode = far->gnode;
|
||||
if (!gnode) {
|
||||
ogs_error("No GTP Node Setup");
|
||||
return;
|
||||
return OGS_DONE;
|
||||
}
|
||||
if (!gnode->sock) {
|
||||
ogs_error("No GTP Socket Setup");
|
||||
return;
|
||||
return OGS_DONE;
|
||||
}
|
||||
|
||||
sendbuf = ogs_pkbuf_alloc(NULL, OGS_GTPV1U_5GC_HEADER_LEN);
|
||||
ogs_assert(sendbuf);
|
||||
ogs_expect_or_return_val(sendbuf, OGS_ERROR);
|
||||
ogs_pkbuf_reserve(sendbuf, OGS_GTPV1U_5GC_HEADER_LEN);
|
||||
|
||||
memset(>p_hdesc, 0, sizeof(gtp_hdesc));
|
||||
|
@ -336,6 +348,8 @@ void ogs_pfcp_send_end_marker(ogs_pfcp_pdr_t *pdr)
|
|||
ext_hdesc.qos_flow_identifier = pdr->qer->qfi;
|
||||
|
||||
ogs_gtp_send_user_plane(gnode, >p_hdesc, &ext_hdesc, sendbuf);
|
||||
|
||||
return OGS_OK;
|
||||
}
|
||||
|
||||
void ogs_pfcp_send_buffered_packet(ogs_pfcp_pdr_t *pdr)
|
||||
|
|
|
@ -64,22 +64,22 @@ int ogs_pfcp_sendto(ogs_pfcp_node_t *node, ogs_pkbuf_t *pkbuf);
|
|||
|
||||
ogs_pkbuf_t *ogs_pfcp_handle_echo_req(ogs_pkbuf_t *pkt);
|
||||
|
||||
void ogs_pfcp_send_heartbeat_request(ogs_pfcp_node_t *node,
|
||||
int ogs_pfcp_send_heartbeat_request(ogs_pfcp_node_t *node,
|
||||
void (*cb)(ogs_pfcp_xact_t *xact, void *data));
|
||||
void ogs_pfcp_send_heartbeat_response(ogs_pfcp_xact_t *xact);
|
||||
int ogs_pfcp_send_heartbeat_response(ogs_pfcp_xact_t *xact);
|
||||
|
||||
void ogs_pfcp_cp_send_association_setup_request(ogs_pfcp_node_t *node,
|
||||
int ogs_pfcp_cp_send_association_setup_request(ogs_pfcp_node_t *node,
|
||||
void (*cb)(ogs_pfcp_xact_t *xact, void *data));
|
||||
void ogs_pfcp_cp_send_association_setup_response(ogs_pfcp_xact_t *xact,
|
||||
int ogs_pfcp_cp_send_association_setup_response(ogs_pfcp_xact_t *xact,
|
||||
uint8_t cause);
|
||||
|
||||
void ogs_pfcp_up_send_association_setup_request(ogs_pfcp_node_t *node,
|
||||
int ogs_pfcp_up_send_association_setup_request(ogs_pfcp_node_t *node,
|
||||
void (*cb)(ogs_pfcp_xact_t *xact, void *data));
|
||||
void ogs_pfcp_up_send_association_setup_response(ogs_pfcp_xact_t *xact,
|
||||
int ogs_pfcp_up_send_association_setup_response(ogs_pfcp_xact_t *xact,
|
||||
uint8_t cause);
|
||||
|
||||
void ogs_pfcp_send_g_pdu(ogs_pfcp_pdr_t *pdr, ogs_pkbuf_t *sendbuf);
|
||||
void ogs_pfcp_send_end_marker(ogs_pfcp_pdr_t *pdr);
|
||||
int ogs_pfcp_send_end_marker(ogs_pfcp_pdr_t *pdr);
|
||||
|
||||
void ogs_pfcp_send_buffered_packet(ogs_pfcp_pdr_t *pdr);
|
||||
|
||||
|
|
|
@ -31,10 +31,7 @@ ogs_pkbuf_t *ogs_s1ap_encode(ogs_s1ap_message_t *message)
|
|||
asn_fprint(stdout, &asn_DEF_S1AP_S1AP_PDU, message);
|
||||
|
||||
pkbuf = ogs_asn_encode(&asn_DEF_S1AP_S1AP_PDU, message);
|
||||
if (pkbuf == NULL) {
|
||||
ogs_error("Failed to encode S1AP-PDU");
|
||||
return NULL;
|
||||
}
|
||||
ogs_expect_or_return_val(pkbuf, NULL);
|
||||
|
||||
return pkbuf;
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ ogs_sbi_client_t *ogs_sbi_client_add(ogs_sockaddr_t *addr)
|
|||
|
||||
ogs_trace("ogs_sbi_client_add()");
|
||||
|
||||
ogs_copyaddrinfo(&client->node.addr, addr);
|
||||
ogs_assert(OGS_OK == ogs_copyaddrinfo(&client->node.addr, addr));
|
||||
|
||||
ogs_list_init(&client->connection_list);
|
||||
|
||||
|
@ -220,9 +220,11 @@ static char *add_params_to_uri(CURL *easy, char *uri, ogs_hash_t *params)
|
|||
|
||||
if (!has_params) {
|
||||
uri = ogs_mstrcatf(uri, "%s%s=%s", fp, key_esc, val_esc);
|
||||
ogs_expect(uri);
|
||||
has_params = 1;
|
||||
} else {
|
||||
uri = ogs_mstrcatf(uri, "%s%s=%s", np, key_esc, val_esc);
|
||||
ogs_expect(uri);
|
||||
}
|
||||
|
||||
curl_free(val_esc);
|
||||
|
@ -247,7 +249,7 @@ static connection_t *connection_add(
|
|||
ogs_assert(request->h.method);
|
||||
|
||||
ogs_pool_alloc(&connection_pool, &conn);
|
||||
ogs_assert(conn);
|
||||
ogs_expect_or_return_val(conn, NULL);
|
||||
memset(conn, 0, sizeof(connection_t));
|
||||
|
||||
conn->client = client;
|
||||
|
@ -255,18 +257,19 @@ static connection_t *connection_add(
|
|||
conn->data = data;
|
||||
|
||||
conn->method = ogs_strdup(request->h.method);
|
||||
ogs_expect_or_return_val(conn->method, NULL);
|
||||
|
||||
conn->num_of_header = ogs_hash_count(request->http.headers);
|
||||
if (conn->num_of_header) {
|
||||
conn->headers = ogs_calloc(conn->num_of_header, sizeof(char *));
|
||||
ogs_assert(conn->headers);
|
||||
ogs_expect_or_return_val(conn->headers, NULL);
|
||||
for (hi = ogs_hash_first(request->http.headers), i = 0;
|
||||
hi && i < conn->num_of_header; hi = ogs_hash_next(hi), i++) {
|
||||
const char *key = ogs_hash_this_key(hi);
|
||||
char *val = ogs_hash_this_val(hi);
|
||||
|
||||
conn->headers[i] = ogs_msprintf("%s: %s", key, val);
|
||||
ogs_assert(conn->headers[i]);
|
||||
ogs_expect_or_return_val(conn->headers[i], NULL);
|
||||
conn->header_list = curl_slist_append(
|
||||
conn->header_list, conn->headers[i]);
|
||||
}
|
||||
|
@ -274,7 +277,7 @@ static connection_t *connection_add(
|
|||
|
||||
conn->timer = ogs_timer_add(
|
||||
ogs_app()->timer_mgr, connection_timer_expired, conn);
|
||||
ogs_assert(conn->timer);
|
||||
ogs_expect_or_return_val(conn->timer, NULL);
|
||||
|
||||
ogs_list_add(&client->connection_list, conn);
|
||||
|
||||
|
@ -321,6 +324,7 @@ static connection_t *connection_add(
|
|||
if (ogs_hash_count(request->http.params)) {
|
||||
request->h.uri = add_params_to_uri(conn->easy,
|
||||
request->h.uri, request->http.params);
|
||||
ogs_expect_or_return_val(request->h.uri, NULL);
|
||||
}
|
||||
|
||||
curl_easy_setopt(conn->easy, CURLOPT_URL, request->h.uri);
|
||||
|
@ -438,15 +442,22 @@ static void check_multi_info(ogs_sbi_client_t *client)
|
|||
|
||||
ogs_assert(conn->method);
|
||||
response->h.method = ogs_strdup(conn->method);
|
||||
ogs_assert(response->h.method);
|
||||
|
||||
/* remove https://localhost:8000 */
|
||||
response->h.uri = ogs_strdup(url);
|
||||
ogs_assert(response->h.uri);
|
||||
|
||||
ogs_debug("[%d:%s] %s",
|
||||
response->status, response->h.method, response->h.uri);
|
||||
|
||||
response->http.content = ogs_memdup(conn->memory, conn->size);
|
||||
if (conn->memory) {
|
||||
response->http.content =
|
||||
ogs_memdup(conn->memory, conn->size);
|
||||
ogs_assert(response->http.content);
|
||||
response->http.content_length = conn->size;
|
||||
ogs_assert(response->http.content_length);
|
||||
}
|
||||
|
||||
ogs_debug("RECEIVED[%d]", (int)response->http.content_length);
|
||||
if (response->http.content_length && response->http.content)
|
||||
|
@ -473,7 +484,7 @@ static void check_multi_info(ogs_sbi_client_t *client)
|
|||
}
|
||||
}
|
||||
|
||||
void ogs_sbi_client_send_request(
|
||||
bool ogs_sbi_client_send_request(
|
||||
ogs_sbi_client_t *client, ogs_sbi_client_cb_f client_cb,
|
||||
ogs_sbi_request_t *request, void *data)
|
||||
{
|
||||
|
@ -488,9 +499,11 @@ void ogs_sbi_client_send_request(
|
|||
ogs_debug("[%s] %s", request->h.method, request->h.uri);
|
||||
|
||||
conn = connection_add(client, client_cb, request, data);
|
||||
ogs_assert(conn);
|
||||
ogs_expect_or_return_val(conn, false);
|
||||
|
||||
ogs_sbi_request_free(request);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static size_t write_cb(void *contents, size_t size, size_t nmemb, void *data)
|
||||
|
@ -503,7 +516,7 @@ static size_t write_cb(void *contents, size_t size, size_t nmemb, void *data)
|
|||
ogs_assert(conn);
|
||||
|
||||
realsize = size * nmemb;
|
||||
ptr = ogs_realloc(conn->memory, conn->size + realsize + 1);
|
||||
ptr = ogs_realloc_or_assert(conn->memory, conn->size + realsize + 1);
|
||||
if(!ptr) {
|
||||
ogs_fatal("not enough memory (realloc returned NULL)");
|
||||
return 0;
|
||||
|
@ -532,6 +545,7 @@ static size_t header_cb(void *ptr, size_t size, size_t nmemb, void *data)
|
|||
/* Only copy http://xxx/xxx/xxx" from 'ptr' string */
|
||||
conn->location = ogs_memdup(
|
||||
(char *)ptr + strlen(OGS_SBI_LOCATION) + 2, len+1);
|
||||
ogs_assert(conn->location);
|
||||
conn->location[len] = 0;
|
||||
}
|
||||
}
|
||||
|
@ -585,6 +599,7 @@ static void sock_set(sockinfo_t *sockinfo, curl_socket_t s,
|
|||
|
||||
sockinfo->poll = ogs_pollset_add(
|
||||
ogs_app()->pollset, kind, s, event_cb, sockinfo);
|
||||
ogs_assert(sockinfo->poll);
|
||||
}
|
||||
|
||||
/* Initialize a new sockinfo_t structure */
|
||||
|
|
|
@ -68,7 +68,7 @@ ogs_sbi_client_t *ogs_sbi_client_add(ogs_sockaddr_t *addr);
|
|||
void ogs_sbi_client_remove(ogs_sbi_client_t *client);
|
||||
ogs_sbi_client_t *ogs_sbi_client_find(ogs_sockaddr_t *addr);
|
||||
|
||||
void ogs_sbi_client_send_request(
|
||||
bool ogs_sbi_client_send_request(
|
||||
ogs_sbi_client_t *client, ogs_sbi_client_cb_f client_cb,
|
||||
ogs_sbi_request_t *request, void *data);
|
||||
|
||||
|
|
|
@ -638,11 +638,17 @@ void ogs_sbi_nf_service_add_version(ogs_sbi_nf_service_t *nf_service,
|
|||
if (nf_service->num_of_version < OGS_SBI_MAX_NUM_OF_SERVICE_VERSION) {
|
||||
nf_service->versions[nf_service->num_of_version].in_uri =
|
||||
ogs_strdup(in_uri);
|
||||
ogs_assert(nf_service->versions[nf_service->num_of_version].in_uri);
|
||||
nf_service->versions[nf_service->num_of_version].full =
|
||||
ogs_strdup(full);
|
||||
if (expiry)
|
||||
ogs_assert(nf_service->versions[nf_service->num_of_version].full);
|
||||
if (expiry) {
|
||||
nf_service->versions[nf_service->num_of_version].expiry =
|
||||
ogs_strdup(expiry);
|
||||
ogs_assert(
|
||||
nf_service->versions[nf_service->num_of_version].expiry);
|
||||
|
||||
}
|
||||
nf_service->num_of_version++;
|
||||
}
|
||||
}
|
||||
|
@ -839,7 +845,7 @@ void ogs_sbi_nf_instance_build_default(
|
|||
|
||||
if (nf_instance->num_of_ipv4 < OGS_SBI_MAX_NUM_OF_IP_ADDRESS) {
|
||||
ogs_sockaddr_t *addr = NULL;
|
||||
ogs_copyaddrinfo(&addr, advertise);
|
||||
ogs_assert(OGS_OK == ogs_copyaddrinfo(&addr, advertise));
|
||||
ogs_assert(addr);
|
||||
|
||||
if (addr->ogs_sa_family == AF_INET) {
|
||||
|
@ -904,7 +910,7 @@ ogs_sbi_nf_service_t *ogs_sbi_nf_service_build_default(
|
|||
if (nf_service->num_of_addr < OGS_SBI_MAX_NUM_OF_IP_ADDRESS) {
|
||||
int port = 0;
|
||||
ogs_sockaddr_t *addr = NULL;
|
||||
ogs_copyaddrinfo(&addr, advertise);
|
||||
ogs_assert(OGS_OK == ogs_copyaddrinfo(&addr, advertise));
|
||||
ogs_assert(addr);
|
||||
|
||||
port = OGS_PORT(addr);
|
||||
|
@ -1132,18 +1138,27 @@ ogs_sbi_xact_t *ogs_sbi_xact_add(
|
|||
ogs_assert(sbi_object);
|
||||
|
||||
ogs_pool_alloc(&xact_pool, &xact);
|
||||
if (!xact) return NULL;
|
||||
ogs_expect_or_return_val(xact, NULL);
|
||||
memset(xact, 0, sizeof(ogs_sbi_xact_t));
|
||||
|
||||
xact->target_nf_type = target_nf_type;
|
||||
xact->sbi_object = sbi_object;
|
||||
|
||||
xact->request = (*build)(context, data);
|
||||
ogs_assert(xact->request);
|
||||
if (!xact->request) {
|
||||
ogs_error("SBI build failed");
|
||||
ogs_pool_free(&xact_pool, xact);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
xact->t_response = ogs_timer_add(
|
||||
ogs_app()->timer_mgr, timer_cb, xact);
|
||||
ogs_assert(xact->t_response);
|
||||
if (!xact->t_response) {
|
||||
ogs_error("ogs_timer_add() failed");
|
||||
ogs_sbi_request_free(xact->request);
|
||||
ogs_pool_free(&xact_pool, xact);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ogs_timer_start(xact->t_response,
|
||||
ogs_app()->time.message.sbi.client_wait_duration);
|
||||
|
|
|
@ -112,7 +112,7 @@ static char *url_decode(const char *str)
|
|||
{
|
||||
if (str != NULL) {
|
||||
char *pstr = (char*)str;
|
||||
char *buf = ogs_malloc(strlen(str) + 1);
|
||||
char *buf = ogs_malloc_or_assert(strlen(str) + 1);
|
||||
char *pbuf = buf;
|
||||
while (*pstr) {
|
||||
if (*pstr == '%') {
|
||||
|
@ -404,11 +404,11 @@ char *ogs_sbi_s_nssai_to_string(ogs_s_nssai_t *s_nssai)
|
|||
sNSSAI.sd = ogs_s_nssai_sd_to_string(s_nssai->sd);
|
||||
|
||||
item = OpenAPI_snssai_convertToJSON(&sNSSAI);
|
||||
ogs_assert(item);
|
||||
ogs_expect_or_return_val(item, NULL);
|
||||
if (sNSSAI.sd) ogs_free(sNSSAI.sd);
|
||||
|
||||
v = cJSON_Print(item);
|
||||
ogs_assert(v);
|
||||
ogs_expect(v);
|
||||
cJSON_Delete(item);
|
||||
|
||||
return v;
|
||||
|
@ -446,12 +446,12 @@ OpenAPI_plmn_id_t *ogs_sbi_build_plmn_id(ogs_plmn_id_t *plmn_id)
|
|||
ogs_assert(plmn_id);
|
||||
|
||||
PlmnId = ogs_calloc(1, sizeof(*PlmnId));
|
||||
ogs_assert(PlmnId);
|
||||
ogs_expect_or_return_val(PlmnId, NULL);
|
||||
|
||||
PlmnId->mcc = ogs_plmn_id_mcc_string(plmn_id);
|
||||
ogs_assert(PlmnId->mcc);
|
||||
ogs_expect_or_return_val(PlmnId->mcc, NULL);
|
||||
PlmnId->mnc = ogs_plmn_id_mnc_string(plmn_id);
|
||||
ogs_assert(PlmnId->mnc);
|
||||
ogs_expect_or_return_val(PlmnId->mnc, NULL);
|
||||
|
||||
return PlmnId;
|
||||
}
|
||||
|
@ -489,12 +489,12 @@ OpenAPI_plmn_id_nid_t *ogs_sbi_build_plmn_id_nid(ogs_plmn_id_t *plmn_id)
|
|||
ogs_assert(plmn_id);
|
||||
|
||||
PlmnIdNid = ogs_calloc(1, sizeof(*PlmnIdNid));
|
||||
ogs_assert(PlmnIdNid);
|
||||
ogs_expect_or_return_val(PlmnIdNid, NULL);
|
||||
|
||||
PlmnIdNid->mcc = ogs_plmn_id_mcc_string(plmn_id);
|
||||
ogs_assert(PlmnIdNid->mcc);
|
||||
ogs_expect_or_return_val(PlmnIdNid->mcc, NULL);
|
||||
PlmnIdNid->mnc = ogs_plmn_id_mnc_string(plmn_id);
|
||||
ogs_assert(PlmnIdNid->mnc);
|
||||
ogs_expect_or_return_val(PlmnIdNid->mnc, NULL);
|
||||
|
||||
return PlmnIdNid;
|
||||
}
|
||||
|
@ -537,9 +537,9 @@ OpenAPI_guami_t *ogs_sbi_build_guami(ogs_guami_t *guami)
|
|||
ogs_assert(Guami);
|
||||
|
||||
Guami->plmn_id = ogs_sbi_build_plmn_id_nid(&guami->plmn_id);
|
||||
ogs_assert(Guami->plmn_id);
|
||||
ogs_expect_or_return_val(Guami->plmn_id, NULL);
|
||||
Guami->amf_id = ogs_amf_id_to_string(&guami->amf_id);
|
||||
ogs_assert(Guami->amf_id);
|
||||
ogs_expect_or_return_val(Guami->amf_id, NULL);
|
||||
|
||||
return Guami;
|
||||
}
|
||||
|
@ -579,17 +579,21 @@ OpenAPI_nr_location_t *ogs_sbi_build_nr_location(
|
|||
ogs_assert(nr_cgi);
|
||||
|
||||
Tai = ogs_calloc(1, sizeof(*Tai));
|
||||
ogs_assert(Tai);
|
||||
ogs_expect_or_return_val(Tai, NULL);
|
||||
Tai->plmn_id = ogs_sbi_build_plmn_id(&tai->plmn_id);
|
||||
ogs_expect_or_return_val(Tai->plmn_id, NULL);
|
||||
Tai->tac = ogs_uint24_to_0string(tai->tac);
|
||||
ogs_expect_or_return_val(Tai->tac, NULL);
|
||||
|
||||
Ncgi = ogs_calloc(1, sizeof(*Ncgi));
|
||||
ogs_assert(Ncgi);
|
||||
ogs_expect_or_return_val(Ncgi, NULL);
|
||||
Ncgi->plmn_id = ogs_sbi_build_plmn_id(&nr_cgi->plmn_id);
|
||||
ogs_expect_or_return_val(Ncgi->plmn_id, NULL);
|
||||
Ncgi->nr_cell_id = ogs_uint36_to_0string(nr_cgi->cell_id);
|
||||
ogs_expect_or_return_val(Ncgi->nr_cell_id, NULL);
|
||||
|
||||
NrLocation = ogs_calloc(1, sizeof(*NrLocation));
|
||||
ogs_assert(NrLocation);
|
||||
ogs_expect_or_return_val(NrLocation, NULL);
|
||||
NrLocation->tai = Tai;
|
||||
NrLocation->ncgi = Ncgi;
|
||||
|
||||
|
|
|
@ -30,12 +30,12 @@ static char *build_json(ogs_sbi_message_t *message);
|
|||
static int parse_json(ogs_sbi_message_t *message,
|
||||
char *content_type, char *json);
|
||||
|
||||
static void build_content(
|
||||
static bool build_content(
|
||||
ogs_sbi_http_message_t *http, ogs_sbi_message_t *message);
|
||||
static int parse_content(
|
||||
ogs_sbi_message_t *message, ogs_sbi_http_message_t *http);
|
||||
|
||||
static void build_multipart(
|
||||
static bool build_multipart(
|
||||
ogs_sbi_http_message_t *http, ogs_sbi_message_t *message);
|
||||
static int parse_multipart(
|
||||
ogs_sbi_message_t *sbi_message, ogs_sbi_http_message_t *http);
|
||||
|
@ -173,11 +173,13 @@ ogs_sbi_request_t *ogs_sbi_request_new(void)
|
|||
ogs_sbi_request_t *request = NULL;
|
||||
|
||||
ogs_pool_alloc(&request_pool, &request);
|
||||
if (!request) return NULL;
|
||||
ogs_expect_or_return_val(request, NULL);
|
||||
memset(request, 0, sizeof(ogs_sbi_request_t));
|
||||
|
||||
request->http.params = ogs_hash_make();
|
||||
ogs_expect_or_return_val(request->http.params, NULL);
|
||||
request->http.headers = ogs_hash_make();
|
||||
ogs_expect_or_return_val(request->http.headers, NULL);
|
||||
|
||||
return request;
|
||||
}
|
||||
|
@ -187,11 +189,13 @@ ogs_sbi_response_t *ogs_sbi_response_new(void)
|
|||
ogs_sbi_response_t *response = NULL;
|
||||
|
||||
ogs_pool_alloc(&response_pool, &response);
|
||||
ogs_assert(response);
|
||||
ogs_expect_or_return_val(response, NULL);
|
||||
memset(response, 0, sizeof(ogs_sbi_response_t));
|
||||
|
||||
response->http.params = ogs_hash_make();
|
||||
ogs_expect_or_return_val(response->http.params, NULL);
|
||||
response->http.headers = ogs_hash_make();
|
||||
ogs_expect_or_return_val(response->http.headers, NULL);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
@ -229,21 +233,24 @@ ogs_sbi_request_t *ogs_sbi_build_request(ogs_sbi_message_t *message)
|
|||
ogs_assert(message);
|
||||
|
||||
request = ogs_sbi_request_new();
|
||||
if (!request) return NULL;
|
||||
ogs_expect_or_return_val(request, NULL);
|
||||
|
||||
ogs_assert(message->h.method);
|
||||
ogs_expect_or_return_val(message->h.method, NULL);
|
||||
request->h.method = ogs_strdup(message->h.method);
|
||||
if (message->h.uri) {
|
||||
ogs_expect_or_return_val(message->h.uri, NULL);
|
||||
request->h.uri = ogs_strdup(message->h.uri);
|
||||
ogs_expect_or_return_val(request->h.uri, NULL);
|
||||
} else {
|
||||
int i;
|
||||
|
||||
ogs_assert(message->h.service.name);
|
||||
ogs_expect_or_return_val(message->h.service.name, NULL);
|
||||
request->h.service.name = ogs_strdup(message->h.service.name);
|
||||
ogs_assert(message->h.api.version);
|
||||
ogs_expect_or_return_val(message->h.api.version, NULL);
|
||||
request->h.api.version = ogs_strdup(message->h.api.version);
|
||||
ogs_expect_or_return_val(request->h.api.version, NULL);
|
||||
|
||||
ogs_assert(message->h.resource.component[0]);
|
||||
ogs_expect_or_return_val(message->h.resource.component[0], NULL);
|
||||
for (i = 0; i < OGS_SBI_MAX_NUM_OF_RESOURCE_COMPONENT &&
|
||||
message->h.resource.component[i]; i++)
|
||||
request->h.resource.component[i] = ogs_strdup(
|
||||
|
@ -257,24 +264,24 @@ ogs_sbi_request_t *ogs_sbi_build_request(ogs_sbi_message_t *message)
|
|||
}
|
||||
if (message->param.nf_type) {
|
||||
char *v = OpenAPI_nf_type_ToString(message->param.nf_type);
|
||||
ogs_assert(v);
|
||||
ogs_expect_or_return_val(v, NULL);
|
||||
ogs_sbi_header_set(request->http.params, OGS_SBI_PARAM_NF_TYPE, v);
|
||||
}
|
||||
if (message->param.requester_nf_type) {
|
||||
char *v = OpenAPI_nf_type_ToString(message->param.requester_nf_type);
|
||||
ogs_assert(v);
|
||||
ogs_expect_or_return_val(v, NULL);
|
||||
ogs_sbi_header_set(request->http.params,
|
||||
OGS_SBI_PARAM_REQUESTER_NF_TYPE, v);
|
||||
}
|
||||
if (message->param.target_nf_type) {
|
||||
char *v = OpenAPI_nf_type_ToString(message->param.target_nf_type);
|
||||
ogs_assert(v);
|
||||
ogs_expect_or_return_val(v, NULL);
|
||||
ogs_sbi_header_set(request->http.params,
|
||||
OGS_SBI_PARAM_TARGET_NF_TYPE, v);
|
||||
}
|
||||
if (message->param.limit) {
|
||||
char *v = ogs_msprintf("%d", message->param.limit);
|
||||
ogs_assert(v);
|
||||
ogs_expect_or_return_val(v, NULL);
|
||||
ogs_sbi_header_set(request->http.params, OGS_SBI_PARAM_LIMIT, v);
|
||||
ogs_free(v);
|
||||
}
|
||||
|
@ -293,12 +300,12 @@ ogs_sbi_request_t *ogs_sbi_build_request(ogs_sbi_message_t *message)
|
|||
cJSON *item = NULL;
|
||||
|
||||
item = OpenAPI_plmn_id_convertToJSON(&plmn_id);
|
||||
ogs_assert(item);
|
||||
ogs_expect_or_return_val(item, NULL);
|
||||
if (plmn_id.mnc) ogs_free(plmn_id.mnc);
|
||||
if (plmn_id.mcc) ogs_free(plmn_id.mcc);
|
||||
|
||||
v = cJSON_Print(item);
|
||||
ogs_assert(v);
|
||||
ogs_expect_or_return_val(v, NULL);
|
||||
cJSON_Delete(item);
|
||||
|
||||
ogs_sbi_header_set(request->http.params, OGS_SBI_PARAM_PLMN_ID, v);
|
||||
|
@ -307,11 +314,13 @@ ogs_sbi_request_t *ogs_sbi_build_request(ogs_sbi_message_t *message)
|
|||
}
|
||||
if (message->param.single_nssai_presence) {
|
||||
char *v = ogs_sbi_s_nssai_to_string(&message->param.s_nssai);
|
||||
ogs_expect_or_return_val(v, NULL);
|
||||
ogs_sbi_header_set(request->http.params, OGS_SBI_PARAM_SINGLE_NSSAI, v);
|
||||
ogs_free(v);
|
||||
}
|
||||
if (message->param.snssai_presence) {
|
||||
char *v = ogs_sbi_s_nssai_to_string(&message->param.s_nssai);
|
||||
ogs_expect_or_return_val(v, NULL);
|
||||
ogs_sbi_header_set(request->http.params, OGS_SBI_PARAM_SNSSAI, v);
|
||||
ogs_free(v);
|
||||
}
|
||||
|
@ -326,12 +335,12 @@ ogs_sbi_request_t *ogs_sbi_build_request(ogs_sbi_message_t *message)
|
|||
cJSON *item = NULL;
|
||||
|
||||
item = OpenAPI_plmn_id_convertToJSON(&plmn_id);
|
||||
ogs_assert(item);
|
||||
ogs_expect_or_return_val(item, NULL);
|
||||
if (plmn_id.mnc) ogs_free(plmn_id.mnc);
|
||||
if (plmn_id.mcc) ogs_free(plmn_id.mcc);
|
||||
|
||||
v = cJSON_Print(item);
|
||||
ogs_assert(v);
|
||||
ogs_expect_or_return_val(v, NULL);
|
||||
cJSON_Delete(item);
|
||||
|
||||
ogs_sbi_header_set(request->http.params, OGS_SBI_PARAM_PLMN_ID, v);
|
||||
|
@ -345,8 +354,8 @@ ogs_sbi_request_t *ogs_sbi_build_request(ogs_sbi_message_t *message)
|
|||
char *v = NULL;
|
||||
cJSON *item = NULL;
|
||||
|
||||
ogs_assert(message->param.s_nssai.sst);
|
||||
ogs_assert(message->param.roaming_indication);
|
||||
ogs_expect_or_return_val(message->param.s_nssai.sst, NULL);
|
||||
ogs_expect_or_return_val(message->param.roaming_indication, NULL);
|
||||
|
||||
memset(&sNSSAI, 0, sizeof(sNSSAI));
|
||||
sNSSAI.sst = message->param.s_nssai.sst;
|
||||
|
@ -360,10 +369,10 @@ ogs_sbi_request_t *ogs_sbi_build_request(ogs_sbi_message_t *message)
|
|||
|
||||
item = OpenAPI_slice_info_for_pdu_session_convertToJSON(
|
||||
&SliceInfoForPDUSession);
|
||||
ogs_assert(item);
|
||||
ogs_expect_or_return_val(item, NULL);
|
||||
|
||||
v = cJSON_Print(item);
|
||||
ogs_assert(v);
|
||||
ogs_expect_or_return_val(v, NULL);
|
||||
cJSON_Delete(item);
|
||||
|
||||
ogs_sbi_header_set(request->http.params,
|
||||
|
@ -382,7 +391,8 @@ ogs_sbi_request_t *ogs_sbi_build_request(ogs_sbi_message_t *message)
|
|||
OGS_SBI_PARAM_IPV6PREFIX, message->param.ipv6prefix);
|
||||
}
|
||||
|
||||
build_content(&request->http, message);
|
||||
ogs_expect_or_return_val(true ==
|
||||
build_content(&request->http, message), NULL);
|
||||
|
||||
if (message->http.accept) {
|
||||
ogs_sbi_header_set(request->http.headers, OGS_SBI_ACCEPT,
|
||||
|
@ -415,12 +425,13 @@ ogs_sbi_response_t *ogs_sbi_build_response(
|
|||
ogs_assert(message);
|
||||
|
||||
response = ogs_sbi_response_new();
|
||||
ogs_assert(response);
|
||||
ogs_expect_or_return_val(response, NULL);
|
||||
|
||||
response->status = status;
|
||||
|
||||
if (response->status != OGS_SBI_HTTP_STATUS_NO_CONTENT) {
|
||||
build_content(&response->http, message);
|
||||
ogs_expect_or_return_val(true ==
|
||||
build_content(&response->http, message), NULL);
|
||||
}
|
||||
|
||||
if (message->http.location) {
|
||||
|
@ -1699,14 +1710,15 @@ static int parse_content(
|
|||
}
|
||||
}
|
||||
|
||||
static void build_content(
|
||||
static bool build_content(
|
||||
ogs_sbi_http_message_t *http, ogs_sbi_message_t *message)
|
||||
{
|
||||
ogs_assert(message);
|
||||
ogs_assert(http);
|
||||
|
||||
if (message->num_of_part) {
|
||||
build_multipart(http, message);
|
||||
ogs_expect_or_return_val(true ==
|
||||
build_multipart(http, message), false);
|
||||
} else {
|
||||
http->content = build_json(message);
|
||||
if (http->content) {
|
||||
|
@ -1720,6 +1732,8 @@ static void build_content(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
typedef struct multipart_parser_data_s {
|
||||
|
@ -1747,6 +1761,7 @@ static int on_header_field(
|
|||
if (data->header_field)
|
||||
ogs_free(data->header_field);
|
||||
data->header_field = ogs_strndup(at, length);
|
||||
ogs_assert(data->header_field);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1767,12 +1782,14 @@ static int on_header_value(
|
|||
ogs_free(data->part[data->num_of_part].content_type);
|
||||
data->part[data->num_of_part].content_type =
|
||||
ogs_strndup(at, length);
|
||||
ogs_assert(data->part[data->num_of_part].content_type);
|
||||
break;
|
||||
CASE(OGS_SBI_CONTENT_ID)
|
||||
if (data->part[data->num_of_part].content_id)
|
||||
ogs_free(data->part[data->num_of_part].content_id);
|
||||
data->part[data->num_of_part].content_id =
|
||||
ogs_strndup(at, length);
|
||||
ogs_assert(data->part[data->num_of_part].content_id);
|
||||
break;
|
||||
|
||||
DEFAULT
|
||||
|
@ -1915,7 +1932,8 @@ static int parse_multipart(
|
|||
data.part[i].content_type;
|
||||
http->part[http->num_of_part].pkbuf =
|
||||
ogs_pkbuf_alloc(NULL, data.part[i].content_length);
|
||||
ogs_assert(http->part[http->num_of_part].pkbuf);
|
||||
ogs_expect_or_return_val(
|
||||
http->part[http->num_of_part].pkbuf, OGS_ERROR);
|
||||
ogs_pkbuf_put_data(http->part[http->num_of_part].pkbuf,
|
||||
data.part[i].content, data.part[i].content_length);
|
||||
|
||||
|
@ -1925,7 +1943,8 @@ static int parse_multipart(
|
|||
http->part[http->num_of_part].content_type;
|
||||
message->part[message->num_of_part].pkbuf =
|
||||
ogs_pkbuf_copy(http->part[http->num_of_part].pkbuf);
|
||||
ogs_assert(message->part[message->num_of_part].pkbuf);
|
||||
ogs_expect_or_return_val(
|
||||
message->part[message->num_of_part].pkbuf, OGS_ERROR);
|
||||
|
||||
http->num_of_part++;
|
||||
message->num_of_part++;
|
||||
|
@ -1950,7 +1969,7 @@ static int parse_multipart(
|
|||
return OGS_OK;
|
||||
}
|
||||
|
||||
static void build_multipart(
|
||||
static bool build_multipart(
|
||||
ogs_sbi_http_message_t *http, ogs_sbi_message_t *message)
|
||||
{
|
||||
int i;
|
||||
|
@ -1970,7 +1989,7 @@ static void build_multipart(
|
|||
ogs_base64_encode_binary(boundary + 2, digest, 16);
|
||||
|
||||
p = http->content = ogs_calloc(1, OGS_HUGE_LEN);
|
||||
ogs_assert(p);
|
||||
ogs_expect_or_return_val(p, false);
|
||||
last = p + OGS_HUGE_LEN;
|
||||
|
||||
/* First boundary */
|
||||
|
@ -1978,7 +1997,7 @@ static void build_multipart(
|
|||
|
||||
/* Encapsulated multipart part (application/json) */
|
||||
json = build_json(message);
|
||||
ogs_assert(json);
|
||||
ogs_expect_or_return_val(json, false);
|
||||
|
||||
p = ogs_slprintf(p, last, "%s\r\n\r\n%s",
|
||||
OGS_SBI_CONTENT_TYPE ": " OGS_SBI_CONTENT_JSON_TYPE, json);
|
||||
|
@ -2003,11 +2022,13 @@ static void build_multipart(
|
|||
|
||||
content_type = ogs_msprintf("%s; boundary=\"%s\"",
|
||||
OGS_SBI_CONTENT_MULTIPART_TYPE, boundary);
|
||||
ogs_assert(content_type);
|
||||
ogs_expect_or_return_val(content_type, false);
|
||||
|
||||
ogs_sbi_header_set(http->headers, OGS_SBI_CONTENT_TYPE, content_type);
|
||||
|
||||
ogs_free(content_type);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void http_message_free(ogs_sbi_http_message_t *http)
|
||||
|
|
|
@ -35,7 +35,7 @@ static int server_start(ogs_sbi_server_t *server,
|
|||
int (*cb)(ogs_sbi_request_t *request, void *data));
|
||||
static void server_stop(ogs_sbi_server_t *server);
|
||||
|
||||
static void server_send_response(
|
||||
static bool server_send_response(
|
||||
ogs_sbi_stream_t *stream, ogs_sbi_response_t *response);
|
||||
|
||||
static ogs_sbi_server_t *server_from_stream(ogs_sbi_stream_t *stream);
|
||||
|
@ -289,7 +289,7 @@ static void server_stop(ogs_sbi_server_t *server)
|
|||
}
|
||||
}
|
||||
|
||||
static void server_send_response(
|
||||
static bool server_send_response(
|
||||
ogs_sbi_stream_t *stream, ogs_sbi_response_t *response)
|
||||
{
|
||||
int ret;
|
||||
|
@ -355,10 +355,12 @@ static void server_send_response(
|
|||
|
||||
ret = MHD_queue_response(connection, status, mhd_response);
|
||||
if (ret != MHD_YES) {
|
||||
ogs_fatal("MHD_queue_response_error [%d]", ret);
|
||||
ogs_assert_if_reached();
|
||||
ogs_error("MHD_queue_response_error [%d]", ret);
|
||||
return false;
|
||||
}
|
||||
MHD_destroy_response(mhd_response);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void run(short when, ogs_socket_t fd, void *data)
|
||||
|
@ -460,7 +462,9 @@ static _MHD_Result access_handler(
|
|||
(MHD_KeyValueIterator)get_values, request->http.headers);
|
||||
|
||||
request->h.method = ogs_strdup(method);
|
||||
ogs_assert(request->h.method);
|
||||
request->h.uri = ogs_strdup(url);
|
||||
ogs_assert(request->h.uri);
|
||||
|
||||
if (ogs_sbi_header_get(request->http.headers, "Content-Length") ||
|
||||
ogs_sbi_header_get(request->http.headers, "Transfer-Encoding")) {
|
||||
|
@ -514,9 +518,10 @@ suspend:
|
|||
if (server->cb) {
|
||||
if (server->cb(request, sbi_sess) != OGS_OK) {
|
||||
ogs_warn("server callback error");
|
||||
ogs_assert(true ==
|
||||
ogs_sbi_server_send_error((ogs_sbi_stream_t *)sbi_sess,
|
||||
OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR, NULL,
|
||||
"server callback error", NULL);
|
||||
"server callback error", NULL));
|
||||
|
||||
return MHD_YES;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ static int server_start(ogs_sbi_server_t *server,
|
|||
int (*cb)(ogs_sbi_request_t *request, void *data));
|
||||
static void server_stop(ogs_sbi_server_t *server);
|
||||
|
||||
static void server_send_response(
|
||||
static bool server_send_response(
|
||||
ogs_sbi_stream_t *stream, ogs_sbi_response_t *response);
|
||||
|
||||
static ogs_sbi_server_t *server_from_stream(ogs_sbi_stream_t *data);
|
||||
|
@ -282,7 +282,7 @@ static ssize_t response_read_callback(nghttp2_session *session,
|
|||
return response->http.content_length;
|
||||
}
|
||||
|
||||
static void server_send_response(
|
||||
static bool server_send_response(
|
||||
ogs_sbi_stream_t *stream, ogs_sbi_response_t *response)
|
||||
{
|
||||
ogs_sbi_session_t *sbi_sess = NULL;
|
||||
|
@ -318,11 +318,11 @@ static void server_send_response(
|
|||
nvlen++;
|
||||
|
||||
nva = ogs_calloc(nvlen, sizeof(nghttp2_nv));
|
||||
ogs_assert(nva);
|
||||
ogs_expect_or_return_val(nva, false);
|
||||
|
||||
i = 0;
|
||||
|
||||
ogs_assert(response->status < 600);
|
||||
ogs_expect_or_return_val(response->status < 600, false);
|
||||
ogs_assert(strlen(status_string[response->status]) == 3);
|
||||
add_header(&nva[i++], ":status", status_string[response->status]);
|
||||
|
||||
|
@ -375,6 +375,8 @@ static void server_send_response(
|
|||
|
||||
ogs_sbi_response_free(response);
|
||||
ogs_free(nva);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static ogs_sbi_server_t *server_from_stream(ogs_sbi_stream_t *stream)
|
||||
|
@ -397,11 +399,11 @@ static ogs_sbi_stream_t *stream_add(
|
|||
ogs_assert(sbi_sess);
|
||||
|
||||
ogs_pool_alloc(&stream_pool, &stream);
|
||||
ogs_assert(stream);
|
||||
ogs_expect_or_return_val(stream, NULL);
|
||||
memset(stream, 0, sizeof(ogs_sbi_stream_t));
|
||||
|
||||
stream->request = ogs_sbi_request_new();
|
||||
ogs_assert(stream->request);
|
||||
ogs_expect_or_return_val(stream->request, NULL);
|
||||
|
||||
stream->stream_id = stream_id;
|
||||
sbi_sess->last_stream_id = stream_id;
|
||||
|
@ -446,14 +448,14 @@ static ogs_sbi_session_t *session_add(
|
|||
ogs_assert(sock);
|
||||
|
||||
ogs_pool_alloc(&session_pool, &sbi_sess);
|
||||
ogs_assert(sbi_sess);
|
||||
ogs_expect_or_return_val(sbi_sess, NULL);
|
||||
memset(sbi_sess, 0, sizeof(ogs_sbi_session_t));
|
||||
|
||||
sbi_sess->server = server;
|
||||
sbi_sess->sock = sock;
|
||||
|
||||
sbi_sess->addr = ogs_calloc(1, sizeof(ogs_sockaddr_t));
|
||||
ogs_assert(sbi_sess->addr);
|
||||
ogs_expect_or_return_val(sbi_sess->addr, NULL);
|
||||
memcpy(sbi_sess->addr, &sock->remote_addr, sizeof(ogs_sockaddr_t));
|
||||
|
||||
ogs_list_add(&server->session_list, sbi_sess);
|
||||
|
@ -770,9 +772,10 @@ static int on_frame_recv(nghttp2_session *session,
|
|||
|
||||
if (server->cb(request, stream) != OGS_OK) {
|
||||
ogs_warn("server callback error");
|
||||
ogs_assert(true ==
|
||||
ogs_sbi_server_send_error(stream,
|
||||
OGS_SBI_HTTP_STATUS_INTERNAL_SERVER_ERROR, NULL,
|
||||
"server callback error", NULL);
|
||||
"server callback error", NULL));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -896,6 +899,7 @@ static int on_header(nghttp2_session *session, const nghttp2_frame *frame,
|
|||
|
||||
ogs_assert(request->h.method == NULL);
|
||||
request->h.method = ogs_strdup(valuestr);
|
||||
ogs_assert(request->h.method);
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -1263,7 +1267,9 @@ static void session_write_to_buffer(
|
|||
|
||||
ogs_list_add(&sbi_sess->write_queue, pkbuf);
|
||||
|
||||
if (!sbi_sess->poll.write)
|
||||
if (!sbi_sess->poll.write) {
|
||||
sbi_sess->poll.write = ogs_pollset_add(ogs_app()->pollset,
|
||||
OGS_POLLOUT, fd, session_write_callback, sbi_sess);
|
||||
ogs_assert(sbi_sess->poll.write);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,10 +34,12 @@ OpenAPI_nf_profile_t *ogs_nnrf_nfm_build_nf_profile(
|
|||
int fqdn_len;
|
||||
char fqdn[OGS_MAX_FQDN_LEN];
|
||||
|
||||
char *ipstr = NULL;
|
||||
|
||||
ogs_assert(nf_instance);
|
||||
|
||||
NFProfile = ogs_calloc(1, sizeof(*NFProfile));
|
||||
ogs_assert(NFProfile);
|
||||
ogs_expect_or_return_val(NFProfile, NULL);
|
||||
|
||||
NFProfile->nf_instance_id = nf_instance->id;
|
||||
NFProfile->nf_type = nf_instance->nf_type;
|
||||
|
@ -58,6 +60,7 @@ OpenAPI_nf_profile_t *ogs_nnrf_nfm_build_nf_profile(
|
|||
fqdn_len = ogs_fqdn_build(fqdn,
|
||||
nf_instance->fqdn, strlen(nf_instance->fqdn));
|
||||
NFProfile->fqdn = ogs_memdup(fqdn, fqdn_len);
|
||||
ogs_expect_or_return_val(NFProfile->fqdn, NULL);
|
||||
|
||||
ogs_trace("FQDN[%s]", nf_instance->fqdn);
|
||||
}
|
||||
|
@ -74,7 +77,9 @@ OpenAPI_nf_profile_t *ogs_nnrf_nfm_build_nf_profile(
|
|||
htobe32(nf_instance->ipv4[i]->sin.sin_addr.s_addr),
|
||||
nf_instance->ipv4[i]->ogs_sin_port);
|
||||
ogs_assert(nf_instance->ipv4[i]->ogs_sa_family == AF_INET);
|
||||
OpenAPI_list_add(Ipv4AddrList, ogs_ipstrdup(nf_instance->ipv4[i]));
|
||||
ipstr = ogs_ipstrdup(nf_instance->ipv4[i]);
|
||||
ogs_expect_or_return_val(ipstr, NULL);
|
||||
OpenAPI_list_add(Ipv4AddrList, ipstr);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < nf_instance->num_of_ipv6; i++) {
|
||||
|
@ -83,7 +88,9 @@ OpenAPI_nf_profile_t *ogs_nnrf_nfm_build_nf_profile(
|
|||
nf_instance->ipv6[i]->ogs_sa_family,
|
||||
nf_instance->ipv6[i]->ogs_sin_port);
|
||||
ogs_assert(nf_instance->ipv6[i]->ogs_sa_family == AF_INET6);
|
||||
OpenAPI_list_add(Ipv6AddrList, ogs_ipstrdup(nf_instance->ipv6[i]));
|
||||
ipstr = ogs_ipstrdup(nf_instance->ipv6[i]);
|
||||
ogs_expect_or_return_val(ipstr, NULL);
|
||||
OpenAPI_list_add(Ipv6AddrList, ipstr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,9 +112,11 @@ OpenAPI_nf_profile_t *ogs_nnrf_nfm_build_nf_profile(
|
|||
OpenAPI_list_t *IpEndPointList = NULL;
|
||||
|
||||
NFService = ogs_calloc(1, sizeof(*NFService));
|
||||
ogs_assert(NFService);
|
||||
ogs_expect_or_return_val(NFService, NULL);
|
||||
NFService->service_instance_id = ogs_strdup(nf_service->id);
|
||||
ogs_expect_or_return_val(NFService->service_instance_id, NULL);
|
||||
NFService->service_name = ogs_strdup(nf_service->name);
|
||||
ogs_expect_or_return_val(NFService->service_name, NULL);
|
||||
|
||||
VersionList = OpenAPI_list_create();
|
||||
ogs_assert(VersionList);
|
||||
|
@ -116,16 +125,25 @@ OpenAPI_nf_profile_t *ogs_nnrf_nfm_build_nf_profile(
|
|||
OpenAPI_nf_service_version_t *NFServiceVersion = NULL;
|
||||
|
||||
NFServiceVersion = ogs_calloc(1, sizeof(*NFServiceVersion));
|
||||
ogs_assert(NFServiceVersion);
|
||||
if (nf_service->versions[i].in_uri)
|
||||
ogs_expect_or_return_val(NFServiceVersion, NULL);
|
||||
if (nf_service->versions[i].in_uri) {
|
||||
NFServiceVersion->api_version_in_uri =
|
||||
ogs_strdup(nf_service->versions[i].in_uri);
|
||||
if (nf_service->versions[i].full)
|
||||
ogs_expect_or_return_val(
|
||||
NFServiceVersion->api_version_in_uri, NULL);
|
||||
}
|
||||
if (nf_service->versions[i].full) {
|
||||
NFServiceVersion->api_full_version =
|
||||
ogs_strdup(nf_service->versions[i].full);
|
||||
if (nf_service->versions[i].expiry)
|
||||
ogs_expect_or_return_val(
|
||||
NFServiceVersion->api_full_version, NULL);
|
||||
}
|
||||
if (nf_service->versions[i].expiry) {
|
||||
NFServiceVersion->expiry =
|
||||
ogs_strdup(nf_service->versions[i].expiry);
|
||||
ogs_expect_or_return_val(
|
||||
NFServiceVersion->expiry, NULL);
|
||||
}
|
||||
|
||||
OpenAPI_list_add(VersionList, NFServiceVersion);
|
||||
}
|
||||
|
@ -141,6 +159,7 @@ OpenAPI_nf_profile_t *ogs_nnrf_nfm_build_nf_profile(
|
|||
fqdn_len = ogs_fqdn_build(fqdn,
|
||||
nf_service->fqdn, strlen(nf_service->fqdn));
|
||||
NFService->fqdn = ogs_memdup(fqdn, fqdn_len);
|
||||
ogs_expect_or_return_val(NFService->fqdn, NULL);
|
||||
}
|
||||
|
||||
IpEndPointList = OpenAPI_list_create();
|
||||
|
@ -157,9 +176,15 @@ OpenAPI_nf_profile_t *ogs_nnrf_nfm_build_nf_profile(
|
|||
|
||||
if (ipv4 || ipv6) {
|
||||
IpEndPoint = ogs_calloc(1, sizeof(*IpEndPoint));
|
||||
ogs_assert(IpEndPoint);
|
||||
if (ipv4) IpEndPoint->ipv4_address = ogs_ipstrdup(ipv4);
|
||||
if (ipv6) IpEndPoint->ipv6_address = ogs_ipstrdup(ipv6);
|
||||
ogs_expect_or_return_val(IpEndPoint, NULL);
|
||||
if (ipv4) {
|
||||
IpEndPoint->ipv4_address = ogs_ipstrdup(ipv4);
|
||||
ogs_expect_or_return_val(IpEndPoint->ipv4_address, NULL);
|
||||
}
|
||||
if (ipv6) {
|
||||
IpEndPoint->ipv6_address = ogs_ipstrdup(ipv6);
|
||||
ogs_expect_or_return_val(IpEndPoint->ipv6_address, NULL);
|
||||
}
|
||||
IpEndPoint->port = nf_service->addr[i].port;
|
||||
OpenAPI_list_add(IpEndPointList, IpEndPoint);
|
||||
}
|
||||
|
@ -318,10 +343,10 @@ ogs_sbi_request_t *ogs_nnrf_nfm_build_status_subscribe(
|
|||
(char *)OGS_SBI_RESOURCE_NAME_SUBSCRIPTIONS;
|
||||
|
||||
SubscriptionData = ogs_calloc(1, sizeof(*SubscriptionData));
|
||||
ogs_assert(SubscriptionData);
|
||||
ogs_expect_or_return_val(SubscriptionData, NULL);
|
||||
|
||||
server = ogs_list_first(&ogs_sbi_self()->server_list);
|
||||
ogs_assert(server);
|
||||
ogs_expect_or_return_val(server, NULL);
|
||||
|
||||
memset(&header, 0, sizeof(header));
|
||||
header.service.name = (char *)OGS_SBI_SERVICE_NAME_NNRF_NFM;
|
||||
|
@ -330,7 +355,8 @@ ogs_sbi_request_t *ogs_nnrf_nfm_build_status_subscribe(
|
|||
(char *)OGS_SBI_RESOURCE_NAME_NF_STATUS_NOTIFY;
|
||||
SubscriptionData->nf_status_notification_uri =
|
||||
ogs_sbi_server_uri(server, &header);
|
||||
ogs_assert(SubscriptionData->nf_status_notification_uri);
|
||||
ogs_expect_or_return_val(
|
||||
SubscriptionData->nf_status_notification_uri, NULL);
|
||||
|
||||
SubscriptionData->req_nf_type = subscription->req_nf_type;
|
||||
SubscriptionData->req_nf_instance_id = subscription->req_nf_instance_id;
|
||||
|
|
|
@ -63,6 +63,9 @@ static void handle_smf_info(
|
|||
ogs_assert(dnn_index < OGS_MAX_NUM_OF_DNN);
|
||||
nf_info->smf.slice[nf_info->smf.num_of_slice].
|
||||
dnn[dnn_index] = ogs_strdup(DnnSmfInfoItem->dnn);
|
||||
ogs_assert(
|
||||
nf_info->smf.slice[nf_info->smf.num_of_slice].
|
||||
dnn[dnn_index]);
|
||||
nf_info->smf.slice[nf_info->smf.num_of_slice].
|
||||
num_of_dnn++;
|
||||
}
|
||||
|
@ -165,32 +168,40 @@ bool ogs_sbi_nnrf_handle_nf_profile(ogs_sbi_nf_instance_t *nf_instance,
|
|||
if (!NFProfile) {
|
||||
ogs_error("No NFProfile");
|
||||
if (stream)
|
||||
ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST,
|
||||
message, "No NFProfile", NULL);
|
||||
ogs_assert(true ==
|
||||
ogs_sbi_server_send_error(
|
||||
stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST,
|
||||
message, "No NFProfile", NULL));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!NFProfile->nf_instance_id) {
|
||||
ogs_error("No NFProfile.NFInstanceId");
|
||||
if (stream)
|
||||
ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST,
|
||||
message, "NFProfile", "No NFInstanceId");
|
||||
ogs_assert(true ==
|
||||
ogs_sbi_server_send_error(
|
||||
stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST,
|
||||
message, "NFProfile", "No NFInstanceId"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!NFProfile->nf_type) {
|
||||
ogs_error("No NFProfile.NFType");
|
||||
if (stream)
|
||||
ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST,
|
||||
message, "NFProfile", "No NFType");
|
||||
ogs_assert(true ==
|
||||
ogs_sbi_server_send_error(
|
||||
stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST,
|
||||
message, "NFProfile", "No NFType"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!NFProfile->nf_status) {
|
||||
ogs_error("No NFProfile.NFStatus");
|
||||
if (stream)
|
||||
ogs_sbi_server_send_error(stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST,
|
||||
message, "NFProfile", "No NFStatus");
|
||||
ogs_assert(true ==
|
||||
ogs_sbi_server_send_error(
|
||||
stream, OGS_SBI_HTTP_STATUS_BAD_REQUEST,
|
||||
message, "NFProfile", "No NFStatus"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
OpenAPI_map_t *OpenAPI_map_create(char *key, void *value)
|
||||
{
|
||||
OpenAPI_map_t *OpenAPI_map = ogs_malloc(sizeof(OpenAPI_map_t));
|
||||
ogs_assert(OpenAPI_map);
|
||||
OpenAPI_map->key = key;
|
||||
OpenAPI_map->value = value;
|
||||
return OpenAPI_map;
|
||||
|
@ -13,6 +14,7 @@ OpenAPI_map_t *OpenAPI_map_create(char *key, void *value)
|
|||
OpenAPI_map_t *OpenAPI_map_create_allocate(char *key, double value)
|
||||
{
|
||||
double* boolpointer = ogs_malloc(sizeof(value));
|
||||
ogs_assert(boolpointer);
|
||||
memcpy(boolpointer, &value, sizeof(value));
|
||||
return OpenAPI_map_create(key, boolpointer);
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ static void *internal_realloc(void *pointer, size_t size)
|
|||
#include "ogs-core.h"
|
||||
static void *internal_malloc(size_t size)
|
||||
{
|
||||
return ogs_malloc(size);
|
||||
return ogs_malloc_or_assert(size);
|
||||
}
|
||||
static void internal_free(void *pointer)
|
||||
{
|
||||
|
@ -156,7 +156,7 @@ static void internal_free(void *pointer)
|
|||
}
|
||||
static void *internal_realloc(void *pointer, size_t size)
|
||||
{
|
||||
return ogs_realloc(pointer, size);
|
||||
return ogs_realloc_or_assert(pointer, size);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
static OpenAPI_lnode_t *listEntry_create(void *data)
|
||||
{
|
||||
OpenAPI_lnode_t *created = ogs_malloc(sizeof(OpenAPI_lnode_t));
|
||||
ogs_assert(created);
|
||||
|
||||
if (created == NULL) {
|
||||
// TODO Malloc Failure
|
||||
|
@ -29,6 +30,7 @@ void OpenAPI_lnode_print(OpenAPI_lnode_t *listEntry, void *additionalData)
|
|||
OpenAPI_list_t *OpenAPI_list_create(void)
|
||||
{
|
||||
OpenAPI_list_t *createdList = ogs_malloc(sizeof(OpenAPI_list_t));
|
||||
ogs_assert(createdList);
|
||||
|
||||
if (createdList == NULL) {
|
||||
// TODO Malloc Failure
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define OpenAPI_malloc(__sIZE) __sIZE == 0 ? NULL : ogs_malloc(__sIZE)
|
||||
#define OpenAPI_malloc(__sIZE) __sIZE == 0 ? NULL : ogs_malloc_or_assert(__sIZE)
|
||||
|
||||
typedef struct OpenAPI_list_s OpenAPI_list_t;
|
||||
|
||||
|
|
|
@ -594,7 +594,7 @@ OpenAPI_{{classname}}_t *OpenAPI_{{classname}}_parseFromJSON(cJSON *{{classname}
|
|||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add({{{name}}}List , ogs_strdup({{{name}}}_local->valuestring));
|
||||
OpenAPI_list_add({{{name}}}List , ogs_strdup_or_assert({{{name}}}_local->valuestring));
|
||||
{{/isString}}
|
||||
{{#isNumeric}}
|
||||
if (!cJSON_IsNumber({{{name}}}_local)) {
|
||||
|
@ -676,21 +676,21 @@ OpenAPI_{{classname}}_t *OpenAPI_{{classname}}_parseFromJSON(cJSON *{{classname}
|
|||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
localMapKeyPair = OpenAPI_map_create(ogs_strdup(localMapObject->string),ogs_strdup(localMapObject->valuestring));
|
||||
localMapKeyPair = OpenAPI_map_create(ogs_strdup_or_assert(localMapObject->string),ogs_strdup_or_assert(localMapObject->valuestring));
|
||||
{{/isString}}
|
||||
{{#isBoolean}}
|
||||
if (!cJSON_IsBool(localMapObject)) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
localMapKeyPair = OpenAPI_map_create(ogs_strdup(localMapObject->string), &localMapObject->valueint);
|
||||
localMapKeyPair = OpenAPI_map_create(ogs_strdup_or_assert(localMapObject->string), &localMapObject->valueint);
|
||||
{{/isBoolean}}
|
||||
{{#isNumeric}}
|
||||
if (!cJSON_IsNumber(localMapObject)) {
|
||||
ogs_error("OpenAPI_{{classname}}_parseFromJSON() failed [{{{name}}}]");
|
||||
goto end;
|
||||
}
|
||||
localMapKeyPair = OpenAPI_map_create(ogs_strdup(localMapObject->string),&localMapObject->valuedouble );
|
||||
localMapKeyPair = OpenAPI_map_create(ogs_strdup_or_assert(localMapObject->string),&localMapObject->valuedouble );
|
||||
{{/isNumeric}}
|
||||
{{/isPrimitiveType}}
|
||||
{{^isPrimitiveType}}
|
||||
|
@ -722,10 +722,10 @@ OpenAPI_{{classname}}_t *OpenAPI_{{classname}}_parseFromJSON(cJSON *{{classname}
|
|||
{{^required}}{{{name}}} ? {{/required}}{{{name}}}_local_nonprim{{^required}} : NULL{{/required}}{{#hasMore}},{{/hasMore}}
|
||||
{{/isModel}}
|
||||
{{#isUuid}}
|
||||
{{^required}}{{{name}}} ? {{/required}}ogs_strdup({{{name}}}->valuestring){{^required}} : NULL{{/required}}{{#hasMore}},{{/hasMore}}
|
||||
{{^required}}{{{name}}} ? {{/required}}ogs_strdup_or_assert({{{name}}}->valuestring){{^required}} : NULL{{/required}}{{#hasMore}},{{/hasMore}}
|
||||
{{/isUuid}}
|
||||
{{#isEmail}}
|
||||
{{^required}}{{{name}}} ? {{/required}}ogs_strdup({{{name}}}->valuestring){{^required}} : NULL{{/required}}{{#hasMore}},{{/hasMore}}
|
||||
{{^required}}{{{name}}} ? {{/required}}ogs_strdup_or_assert({{{name}}}->valuestring){{^required}} : NULL{{/required}}{{#hasMore}},{{/hasMore}}
|
||||
{{/isEmail}}
|
||||
{{#isFreeFormObject}}
|
||||
{{^required}}{{{name}}} ? {{/required}}{{{name}}}_local_object{{^required}} : NULL{{/required}}{{#hasMore}},{{/hasMore}}
|
||||
|
@ -744,7 +744,7 @@ OpenAPI_{{classname}}_t *OpenAPI_{{classname}}_parseFromJSON(cJSON *{{classname}
|
|||
{{^required}}{{{name}}} ? {{/required}}{{{name}}}->valueint{{^required}} : 0{{/required}}{{#hasMore}},{{/hasMore}}
|
||||
{{/isBoolean}}
|
||||
{{#isString}}
|
||||
{{^required}}{{{name}}} ? {{/required}}ogs_strdup({{{name}}}->valuestring){{^required}} : NULL{{/required}}{{#hasMore}},{{/hasMore}}
|
||||
{{^required}}{{{name}}} ? {{/required}}ogs_strdup_or_assert({{{name}}}->valuestring){{^required}} : NULL{{/required}}{{#hasMore}},{{/hasMore}}
|
||||
{{/isString}}
|
||||
{{/isEnum}}
|
||||
{{#isByteArray}}
|
||||
|
@ -754,10 +754,10 @@ OpenAPI_{{classname}}_t *OpenAPI_{{classname}}_parseFromJSON(cJSON *{{classname}
|
|||
{{^required}}{{{name}}} ? {{/required}}decoded_str_{{{name}}}{{^required}} : NULL{{/required}}{{#hasMore}},{{/hasMore}}
|
||||
{{/isBinary}}
|
||||
{{#isDate}}
|
||||
{{^required}}{{{name}}} ? {{/required}}ogs_strdup({{{name}}}->valuestring){{^required}} : NULL{{/required}}{{#hasMore}},{{/hasMore}}
|
||||
{{^required}}{{{name}}} ? {{/required}}ogs_strdup_or_assert({{{name}}}->valuestring){{^required}} : NULL{{/required}}{{#hasMore}},{{/hasMore}}
|
||||
{{/isDate}}
|
||||
{{#isDateTime}}
|
||||
{{^required}}{{{name}}} ? {{/required}}ogs_strdup({{{name}}}->valuestring){{^required}} : NULL{{/required}}{{#hasMore}},{{/hasMore}}
|
||||
{{^required}}{{{name}}} ? {{/required}}ogs_strdup_or_assert({{{name}}}->valuestring){{^required}} : NULL{{/required}}{{#hasMore}},{{/hasMore}}
|
||||
{{/isDateTime}}
|
||||
{{/isPrimitiveType}}
|
||||
{{/isContainer}}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
OpenAPI_object_t *OpenAPI_object_create(void)
|
||||
{
|
||||
OpenAPI_object_t *object = ogs_malloc(sizeof(OpenAPI_object_t));
|
||||
ogs_assert(object);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ static void *internal_realloc(void *pointer, size_t size)
|
|||
#include "ogs-core.h"
|
||||
static void *internal_malloc(size_t size)
|
||||
{
|
||||
return ogs_malloc(size);
|
||||
return ogs_malloc_or_assert(size);
|
||||
}
|
||||
static void internal_free(void *pointer)
|
||||
{
|
||||
|
@ -156,7 +156,7 @@ static void internal_free(void *pointer)
|
|||
}
|
||||
static void *internal_realloc(void *pointer, size_t size)
|
||||
{
|
||||
return ogs_realloc(pointer, size);
|
||||
return ogs_realloc_or_assert(pointer, size);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define OpenAPI_malloc(__sIZE) __sIZE == 0 ? NULL : ogs_malloc(__sIZE)
|
||||
#define OpenAPI_malloc(__sIZE) __sIZE == 0 ? NULL : ogs_malloc_or_assert(__sIZE)
|
||||
|
||||
typedef struct OpenAPI_list_s OpenAPI_list_t;
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ OpenAPI_acc_net_ch_id_t *OpenAPI_acc_net_ch_id_parseFromJSON(cJSON *acc_net_ch_i
|
|||
ogs_error("OpenAPI_acc_net_ch_id_parseFromJSON() failed [ref_pcc_rule_ids]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(ref_pcc_rule_idsList, ogs_strdup(ref_pcc_rule_ids_local->valuestring));
|
||||
OpenAPI_list_add(ref_pcc_rule_idsList, ogs_strdup_or_assert(ref_pcc_rule_ids_local->valuestring));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,8 +80,8 @@ OpenAPI_acc_net_charging_address_t *OpenAPI_acc_net_charging_address_parseFromJS
|
|||
}
|
||||
|
||||
acc_net_charging_address_local_var = OpenAPI_acc_net_charging_address_create (
|
||||
an_charg_ipv4_addr ? ogs_strdup(an_charg_ipv4_addr->valuestring) : NULL,
|
||||
an_charg_ipv6_addr ? ogs_strdup(an_charg_ipv6_addr->valuestring) : NULL
|
||||
an_charg_ipv4_addr ? ogs_strdup_or_assert(an_charg_ipv4_addr->valuestring) : NULL,
|
||||
an_charg_ipv6_addr ? ogs_strdup_or_assert(an_charg_ipv6_addr->valuestring) : NULL
|
||||
);
|
||||
|
||||
return acc_net_charging_address_local_var;
|
||||
|
|
|
@ -133,8 +133,8 @@ OpenAPI_acceptable_service_info_t *OpenAPI_acceptable_service_info_parseFromJSON
|
|||
|
||||
acceptable_service_info_local_var = OpenAPI_acceptable_service_info_create (
|
||||
acc_bw_med_comps ? acc_bw_med_compsList : NULL,
|
||||
mar_bw_ul ? ogs_strdup(mar_bw_ul->valuestring) : NULL,
|
||||
mar_bw_dl ? ogs_strdup(mar_bw_dl->valuestring) : NULL
|
||||
mar_bw_ul ? ogs_strdup_or_assert(mar_bw_ul->valuestring) : NULL,
|
||||
mar_bw_dl ? ogs_strdup_or_assert(mar_bw_dl->valuestring) : NULL
|
||||
);
|
||||
|
||||
return acceptable_service_info_local_var;
|
||||
|
|
|
@ -498,24 +498,24 @@ OpenAPI_access_and_mobility_data_t *OpenAPI_access_and_mobility_data_parseFromJS
|
|||
|
||||
access_and_mobility_data_local_var = OpenAPI_access_and_mobility_data_create (
|
||||
location ? location_local_nonprim : NULL,
|
||||
location_ts ? ogs_strdup(location_ts->valuestring) : NULL,
|
||||
time_zone ? ogs_strdup(time_zone->valuestring) : NULL,
|
||||
time_zone_ts ? ogs_strdup(time_zone_ts->valuestring) : NULL,
|
||||
location_ts ? ogs_strdup_or_assert(location_ts->valuestring) : NULL,
|
||||
time_zone ? ogs_strdup_or_assert(time_zone->valuestring) : NULL,
|
||||
time_zone_ts ? ogs_strdup_or_assert(time_zone_ts->valuestring) : NULL,
|
||||
access_type ? access_typeVariable : 0,
|
||||
reg_states ? reg_statesList : NULL,
|
||||
reg_states_ts ? ogs_strdup(reg_states_ts->valuestring) : NULL,
|
||||
reg_states_ts ? ogs_strdup_or_assert(reg_states_ts->valuestring) : NULL,
|
||||
conn_states ? conn_statesList : NULL,
|
||||
conn_states_ts ? ogs_strdup(conn_states_ts->valuestring) : NULL,
|
||||
conn_states_ts ? ogs_strdup_or_assert(conn_states_ts->valuestring) : NULL,
|
||||
reachability_status ? reachability_status_local_nonprim : NULL,
|
||||
reachability_status_ts ? ogs_strdup(reachability_status_ts->valuestring) : NULL,
|
||||
reachability_status_ts ? ogs_strdup_or_assert(reachability_status_ts->valuestring) : NULL,
|
||||
sms_over_nas_status ? sms_over_nas_statusVariable : 0,
|
||||
sms_over_nas_status_ts ? ogs_strdup(sms_over_nas_status_ts->valuestring) : NULL,
|
||||
sms_over_nas_status_ts ? ogs_strdup_or_assert(sms_over_nas_status_ts->valuestring) : NULL,
|
||||
roaming_status ? roaming_status->valueint : 0,
|
||||
roaming_status_ts ? ogs_strdup(roaming_status_ts->valuestring) : NULL,
|
||||
roaming_status_ts ? ogs_strdup_or_assert(roaming_status_ts->valuestring) : NULL,
|
||||
current_plmn ? current_plmn_local_nonprim : NULL,
|
||||
current_plmn_ts ? ogs_strdup(current_plmn_ts->valuestring) : NULL,
|
||||
current_plmn_ts ? ogs_strdup_or_assert(current_plmn_ts->valuestring) : NULL,
|
||||
rat_type ? rat_typeList : NULL,
|
||||
rat_types_ts ? ogs_strdup(rat_types_ts->valuestring) : NULL
|
||||
rat_types_ts ? ogs_strdup_or_assert(rat_types_ts->valuestring) : NULL
|
||||
);
|
||||
|
||||
return access_and_mobility_data_local_var;
|
||||
|
|
|
@ -730,7 +730,7 @@ OpenAPI_access_and_mobility_subscription_data_t *OpenAPI_access_and_mobility_sub
|
|||
ogs_error("OpenAPI_access_and_mobility_subscription_data_parseFromJSON() failed [gpsis]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(gpsisList, ogs_strdup(gpsis_local->valuestring));
|
||||
OpenAPI_list_add(gpsisList, ogs_strdup_or_assert(gpsis_local->valuestring));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -750,7 +750,7 @@ OpenAPI_access_and_mobility_subscription_data_t *OpenAPI_access_and_mobility_sub
|
|||
ogs_error("OpenAPI_access_and_mobility_subscription_data_parseFromJSON() failed [internal_group_ids]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(internal_group_idsList, ogs_strdup(internal_group_ids_local->valuestring));
|
||||
OpenAPI_list_add(internal_group_idsList, ogs_strdup_or_assert(internal_group_ids_local->valuestring));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -992,7 +992,7 @@ OpenAPI_access_and_mobility_subscription_data_t *OpenAPI_access_and_mobility_sub
|
|||
ogs_error("OpenAPI_access_and_mobility_subscription_data_parseFromJSON() failed [shared_am_data_ids]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(shared_am_data_idsList, ogs_strdup(shared_am_data_ids_local->valuestring));
|
||||
OpenAPI_list_add(shared_am_data_idsList, ogs_strdup_or_assert(shared_am_data_ids_local->valuestring));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1023,7 +1023,7 @@ OpenAPI_access_and_mobility_subscription_data_t *OpenAPI_access_and_mobility_sub
|
|||
ogs_error("OpenAPI_access_and_mobility_subscription_data_parseFromJSON() failed [subscribed_dnn_list]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(subscribed_dnn_listList, ogs_strdup(subscribed_dnn_list_local->valuestring));
|
||||
OpenAPI_list_add(subscribed_dnn_listList, ogs_strdup_or_assert(subscribed_dnn_list_local->valuestring));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1266,7 +1266,7 @@ OpenAPI_access_and_mobility_subscription_data_t *OpenAPI_access_and_mobility_sub
|
|||
}
|
||||
|
||||
access_and_mobility_subscription_data_local_var = OpenAPI_access_and_mobility_subscription_data_create (
|
||||
supported_features ? ogs_strdup(supported_features->valuestring) : NULL,
|
||||
supported_features ? ogs_strdup_or_assert(supported_features->valuestring) : NULL,
|
||||
gpsis ? gpsisList : NULL,
|
||||
internal_group_ids ? internal_group_idsList : NULL,
|
||||
shared_vn_group_data_ids ? shared_vn_group_data_idsList : NULL,
|
||||
|
@ -1296,8 +1296,8 @@ OpenAPI_access_and_mobility_subscription_data_t *OpenAPI_access_and_mobility_sub
|
|||
mdt_configuration ? mdt_configuration_local_nonprim : NULL,
|
||||
trace_data ? trace_data_local_nonprim : NULL,
|
||||
cag_data ? cag_data_local_nonprim : NULL,
|
||||
stn_sr ? ogs_strdup(stn_sr->valuestring) : NULL,
|
||||
c_msisdn ? ogs_strdup(c_msisdn->valuestring) : NULL,
|
||||
stn_sr ? ogs_strdup_or_assert(stn_sr->valuestring) : NULL,
|
||||
c_msisdn ? ogs_strdup_or_assert(c_msisdn->valuestring) : NULL,
|
||||
nb_io_t_ue_priority ? nb_io_t_ue_priority->valuedouble : 0,
|
||||
nssai_inclusion_allowed ? nssai_inclusion_allowed->valueint : 0,
|
||||
rg_wireline_characteristics ? rg_wireline_characteristics->valueint : 0,
|
||||
|
|
|
@ -206,7 +206,7 @@ OpenAPI_accu_usage_report_t *OpenAPI_accu_usage_report_parseFromJSON(cJSON *accu
|
|||
}
|
||||
|
||||
accu_usage_report_local_var = OpenAPI_accu_usage_report_create (
|
||||
ogs_strdup(ref_um_ids->valuestring),
|
||||
ogs_strdup_or_assert(ref_um_ids->valuestring),
|
||||
vol_usage ? vol_usage->valuedouble : 0,
|
||||
vol_usage_uplink ? vol_usage_uplink->valuedouble : 0,
|
||||
vol_usage_downlink ? vol_usage_downlink->valuedouble : 0,
|
||||
|
|
|
@ -119,10 +119,10 @@ OpenAPI_acknowledge_info_t *OpenAPI_acknowledge_info_parseFromJSON(cJSON *acknow
|
|||
}
|
||||
|
||||
acknowledge_info_local_var = OpenAPI_acknowledge_info_create (
|
||||
sor_mac_iue ? ogs_strdup(sor_mac_iue->valuestring) : NULL,
|
||||
upu_mac_iue ? ogs_strdup(upu_mac_iue->valuestring) : NULL,
|
||||
secured_packet ? ogs_strdup(secured_packet->valuestring) : NULL,
|
||||
ogs_strdup(provisioning_time->valuestring)
|
||||
sor_mac_iue ? ogs_strdup_or_assert(sor_mac_iue->valuestring) : NULL,
|
||||
upu_mac_iue ? ogs_strdup_or_assert(upu_mac_iue->valuestring) : NULL,
|
||||
secured_packet ? ogs_strdup_or_assert(secured_packet->valuestring) : NULL,
|
||||
ogs_strdup_or_assert(provisioning_time->valuestring)
|
||||
);
|
||||
|
||||
return acknowledge_info_local_var;
|
||||
|
|
|
@ -99,9 +99,9 @@ OpenAPI_acs_info_t *OpenAPI_acs_info_parseFromJSON(cJSON *acs_infoJSON)
|
|||
}
|
||||
|
||||
acs_info_local_var = OpenAPI_acs_info_create (
|
||||
acs_url ? ogs_strdup(acs_url->valuestring) : NULL,
|
||||
acs_ipv4_addr ? ogs_strdup(acs_ipv4_addr->valuestring) : NULL,
|
||||
acs_ipv6_addr ? ogs_strdup(acs_ipv6_addr->valuestring) : NULL
|
||||
acs_url ? ogs_strdup_or_assert(acs_url->valuestring) : NULL,
|
||||
acs_ipv4_addr ? ogs_strdup_or_assert(acs_ipv4_addr->valuestring) : NULL,
|
||||
acs_ipv6_addr ? ogs_strdup_or_assert(acs_ipv6_addr->valuestring) : NULL
|
||||
);
|
||||
|
||||
return acs_info_local_var;
|
||||
|
|
|
@ -99,9 +99,9 @@ OpenAPI_acs_info_rm_t *OpenAPI_acs_info_rm_parseFromJSON(cJSON *acs_info_rmJSON)
|
|||
}
|
||||
|
||||
acs_info_rm_local_var = OpenAPI_acs_info_rm_create (
|
||||
acs_url ? ogs_strdup(acs_url->valuestring) : NULL,
|
||||
acs_ipv4_addr ? ogs_strdup(acs_ipv4_addr->valuestring) : NULL,
|
||||
acs_ipv6_addr ? ogs_strdup(acs_ipv6_addr->valuestring) : NULL
|
||||
acs_url ? ogs_strdup_or_assert(acs_url->valuestring) : NULL,
|
||||
acs_ipv4_addr ? ogs_strdup_or_assert(acs_ipv4_addr->valuestring) : NULL,
|
||||
acs_ipv6_addr ? ogs_strdup_or_assert(acs_ipv6_addr->valuestring) : NULL
|
||||
);
|
||||
|
||||
return acs_info_rm_local_var;
|
||||
|
|
|
@ -151,7 +151,7 @@ OpenAPI_af_event_exposure_data_t *OpenAPI_af_event_exposure_data_parseFromJSON(c
|
|||
ogs_error("OpenAPI_af_event_exposure_data_parseFromJSON() failed [af_ids]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(af_idsList, ogs_strdup(af_ids_local->valuestring));
|
||||
OpenAPI_list_add(af_idsList, ogs_strdup_or_assert(af_ids_local->valuestring));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ OpenAPI_af_event_exposure_data_t *OpenAPI_af_event_exposure_data_parseFromJSON(c
|
|||
ogs_error("OpenAPI_af_event_exposure_data_parseFromJSON() failed [app_ids]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(app_idsList, ogs_strdup(app_ids_local->valuestring));
|
||||
OpenAPI_list_add(app_idsList, ogs_strdup_or_assert(app_ids_local->valuestring));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ OpenAPI_af_external_t *OpenAPI_af_external_parseFromJSON(cJSON *af_externalJSON)
|
|||
}
|
||||
|
||||
af_external_local_var = OpenAPI_af_external_create (
|
||||
af_id ? ogs_strdup(af_id->valuestring) : NULL,
|
||||
af_id ? ogs_strdup_or_assert(af_id->valuestring) : NULL,
|
||||
allowed_geographic_area ? allowed_geographic_areaList : NULL,
|
||||
privacy_check_related_action ? privacy_check_related_actionVariable : 0,
|
||||
valid_time_period ? valid_time_period_local_nonprim : NULL
|
||||
|
|
|
@ -137,10 +137,10 @@ OpenAPI_alternative_qos_profile_t *OpenAPI_alternative_qos_profile_parseFromJSON
|
|||
|
||||
alternative_qos_profile_local_var = OpenAPI_alternative_qos_profile_create (
|
||||
index->valuedouble,
|
||||
gua_fbr_dl ? ogs_strdup(gua_fbr_dl->valuestring) : NULL,
|
||||
gua_fbr_ul ? ogs_strdup(gua_fbr_ul->valuestring) : NULL,
|
||||
gua_fbr_dl ? ogs_strdup_or_assert(gua_fbr_dl->valuestring) : NULL,
|
||||
gua_fbr_ul ? ogs_strdup_or_assert(gua_fbr_ul->valuestring) : NULL,
|
||||
packet_delay_budget ? packet_delay_budget->valuedouble : 0,
|
||||
packet_err_rate ? ogs_strdup(packet_err_rate->valuestring) : NULL
|
||||
packet_err_rate ? ogs_strdup_or_assert(packet_err_rate->valuestring) : NULL
|
||||
);
|
||||
|
||||
return alternative_qos_profile_local_var;
|
||||
|
|
|
@ -131,7 +131,7 @@ OpenAPI_am_policy_data_t *OpenAPI_am_policy_data_parseFromJSON(cJSON *am_policy_
|
|||
ogs_error("OpenAPI_am_policy_data_parseFromJSON() failed [subsc_cats]");
|
||||
goto end;
|
||||
}
|
||||
OpenAPI_list_add(subsc_catsList, ogs_strdup(subsc_cats_local->valuestring));
|
||||
OpenAPI_list_add(subsc_catsList, ogs_strdup_or_assert(subsc_cats_local->valuestring));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,8 +82,8 @@ OpenAPI_ambr_t *OpenAPI_ambr_parseFromJSON(cJSON *ambrJSON)
|
|||
}
|
||||
|
||||
ambr_local_var = OpenAPI_ambr_create (
|
||||
ogs_strdup(uplink->valuestring),
|
||||
ogs_strdup(downlink->valuestring)
|
||||
ogs_strdup_or_assert(uplink->valuestring),
|
||||
ogs_strdup_or_assert(downlink->valuestring)
|
||||
);
|
||||
|
||||
return ambr_local_var;
|
||||
|
|
|
@ -82,8 +82,8 @@ OpenAPI_ambr_rm_t *OpenAPI_ambr_rm_parseFromJSON(cJSON *ambr_rmJSON)
|
|||
}
|
||||
|
||||
ambr_rm_local_var = OpenAPI_ambr_rm_create (
|
||||
ogs_strdup(uplink->valuestring),
|
||||
ogs_strdup(downlink->valuestring)
|
||||
ogs_strdup_or_assert(uplink->valuestring),
|
||||
ogs_strdup_or_assert(downlink->valuestring)
|
||||
);
|
||||
|
||||
return ambr_rm_local_var;
|
||||
|
|
|
@ -506,25 +506,25 @@ OpenAPI_amf3_gpp_access_registration_t *OpenAPI_amf3_gpp_access_registration_par
|
|||
}
|
||||
|
||||
amf3_gpp_access_registration_local_var = OpenAPI_amf3_gpp_access_registration_create (
|
||||
ogs_strdup(amf_instance_id->valuestring),
|
||||
supported_features ? ogs_strdup(supported_features->valuestring) : NULL,
|
||||
ogs_strdup_or_assert(amf_instance_id->valuestring),
|
||||
supported_features ? ogs_strdup_or_assert(supported_features->valuestring) : NULL,
|
||||
purge_flag ? purge_flag->valueint : 0,
|
||||
pei ? ogs_strdup(pei->valuestring) : NULL,
|
||||
pei ? ogs_strdup_or_assert(pei->valuestring) : NULL,
|
||||
ims_vo_ps ? ims_vo_psVariable : 0,
|
||||
ogs_strdup(dereg_callback_uri->valuestring),
|
||||
amf_service_name_dereg ? ogs_strdup(amf_service_name_dereg->valuestring) : NULL,
|
||||
pcscf_restoration_callback_uri ? ogs_strdup(pcscf_restoration_callback_uri->valuestring) : NULL,
|
||||
amf_service_name_pcscf_rest ? ogs_strdup(amf_service_name_pcscf_rest->valuestring) : NULL,
|
||||
ogs_strdup_or_assert(dereg_callback_uri->valuestring),
|
||||
amf_service_name_dereg ? ogs_strdup_or_assert(amf_service_name_dereg->valuestring) : NULL,
|
||||
pcscf_restoration_callback_uri ? ogs_strdup_or_assert(pcscf_restoration_callback_uri->valuestring) : NULL,
|
||||
amf_service_name_pcscf_rest ? ogs_strdup_or_assert(amf_service_name_pcscf_rest->valuestring) : NULL,
|
||||
initial_registration_ind ? initial_registration_ind->valueint : 0,
|
||||
guami_local_nonprim,
|
||||
backup_amf_info ? backup_amf_infoList : NULL,
|
||||
dr_flag ? dr_flag->valueint : 0,
|
||||
rat_typeVariable,
|
||||
urrp_indicator ? urrp_indicator->valueint : 0,
|
||||
amf_ee_subscription_id ? ogs_strdup(amf_ee_subscription_id->valuestring) : NULL,
|
||||
amf_ee_subscription_id ? ogs_strdup_or_assert(amf_ee_subscription_id->valuestring) : NULL,
|
||||
eps_interworking_info ? eps_interworking_info_local_nonprim : NULL,
|
||||
ue_srvcc_capability ? ue_srvcc_capability->valueint : 0,
|
||||
registration_time ? ogs_strdup(registration_time->valuestring) : NULL,
|
||||
registration_time ? ogs_strdup_or_assert(registration_time->valuestring) : NULL,
|
||||
vgmlc_address ? vgmlc_address_local_nonprim : NULL,
|
||||
context_info ? context_info_local_nonprim : NULL,
|
||||
no_ee_subscription_ind ? no_ee_subscription_ind->valueint : 0
|
||||
|
|
|
@ -233,7 +233,7 @@ OpenAPI_amf3_gpp_access_registration_modification_t *OpenAPI_amf3_gpp_access_reg
|
|||
amf3_gpp_access_registration_modification_local_var = OpenAPI_amf3_gpp_access_registration_modification_create (
|
||||
guami_local_nonprim,
|
||||
purge_flag ? purge_flag->valueint : 0,
|
||||
pei ? ogs_strdup(pei->valuestring) : NULL,
|
||||
pei ? ogs_strdup_or_assert(pei->valuestring) : NULL,
|
||||
ims_vo_ps ? ims_vo_psVariable : 0,
|
||||
backup_amf_info ? backup_amf_infoList : NULL,
|
||||
eps_interworking_info ? eps_interworking_info_local_nonprim : NULL,
|
||||
|
|
|
@ -80,8 +80,8 @@ OpenAPI_amf_cond_t *OpenAPI_amf_cond_parseFromJSON(cJSON *amf_condJSON)
|
|||
}
|
||||
|
||||
amf_cond_local_var = OpenAPI_amf_cond_create (
|
||||
amf_set_id ? ogs_strdup(amf_set_id->valuestring) : NULL,
|
||||
amf_region_id ? ogs_strdup(amf_region_id->valuestring) : NULL
|
||||
amf_set_id ? ogs_strdup_or_assert(amf_set_id->valuestring) : NULL,
|
||||
amf_region_id ? ogs_strdup_or_assert(amf_region_id->valuestring) : NULL
|
||||
);
|
||||
|
||||
return amf_cond_local_var;
|
||||
|
|
|
@ -105,7 +105,7 @@ OpenAPI_amf_event_mode_t *OpenAPI_amf_event_mode_parseFromJSON(cJSON *amf_event_
|
|||
amf_event_mode_local_var = OpenAPI_amf_event_mode_create (
|
||||
trigger_local_nonprim,
|
||||
max_reports ? max_reports->valuedouble : 0,
|
||||
expiry ? ogs_strdup(expiry->valuestring) : NULL
|
||||
expiry ? ogs_strdup_or_assert(expiry->valuestring) : NULL
|
||||
);
|
||||
|
||||
return amf_event_mode_local_var;
|
||||
|
|
|
@ -308,15 +308,15 @@ OpenAPI_amf_event_subscription_t *OpenAPI_amf_event_subscription_parseFromJSON(c
|
|||
|
||||
amf_event_subscription_local_var = OpenAPI_amf_event_subscription_create (
|
||||
event_listList,
|
||||
ogs_strdup(event_notify_uri->valuestring),
|
||||
ogs_strdup(notify_correlation_id->valuestring),
|
||||
ogs_strdup(nf_id->valuestring),
|
||||
subs_change_notify_uri ? ogs_strdup(subs_change_notify_uri->valuestring) : NULL,
|
||||
subs_change_notify_correlation_id ? ogs_strdup(subs_change_notify_correlation_id->valuestring) : NULL,
|
||||
supi ? ogs_strdup(supi->valuestring) : NULL,
|
||||
group_id ? ogs_strdup(group_id->valuestring) : NULL,
|
||||
gpsi ? ogs_strdup(gpsi->valuestring) : NULL,
|
||||
pei ? ogs_strdup(pei->valuestring) : NULL,
|
||||
ogs_strdup_or_assert(event_notify_uri->valuestring),
|
||||
ogs_strdup_or_assert(notify_correlation_id->valuestring),
|
||||
ogs_strdup_or_assert(nf_id->valuestring),
|
||||
subs_change_notify_uri ? ogs_strdup_or_assert(subs_change_notify_uri->valuestring) : NULL,
|
||||
subs_change_notify_correlation_id ? ogs_strdup_or_assert(subs_change_notify_correlation_id->valuestring) : NULL,
|
||||
supi ? ogs_strdup_or_assert(supi->valuestring) : NULL,
|
||||
group_id ? ogs_strdup_or_assert(group_id->valuestring) : NULL,
|
||||
gpsi ? ogs_strdup_or_assert(gpsi->valuestring) : NULL,
|
||||
pei ? ogs_strdup_or_assert(pei->valuestring) : NULL,
|
||||
any_ue ? any_ue->valueint : 0,
|
||||
options ? options_local_nonprim : NULL
|
||||
);
|
||||
|
|
|
@ -351,8 +351,8 @@ OpenAPI_amf_info_t *OpenAPI_amf_info_parseFromJSON(cJSON *amf_infoJSON)
|
|||
}
|
||||
|
||||
amf_info_local_var = OpenAPI_amf_info_create (
|
||||
ogs_strdup(amf_set_id->valuestring),
|
||||
ogs_strdup(amf_region_id->valuestring),
|
||||
ogs_strdup_or_assert(amf_set_id->valuestring),
|
||||
ogs_strdup_or_assert(amf_region_id->valuestring),
|
||||
guami_listList,
|
||||
tai_list ? tai_listList : NULL,
|
||||
tai_range_list ? tai_range_listList : NULL,
|
||||
|
|
|
@ -412,21 +412,21 @@ OpenAPI_amf_non3_gpp_access_registration_t *OpenAPI_amf_non3_gpp_access_registra
|
|||
}
|
||||
|
||||
amf_non3_gpp_access_registration_local_var = OpenAPI_amf_non3_gpp_access_registration_create (
|
||||
ogs_strdup(amf_instance_id->valuestring),
|
||||
supported_features ? ogs_strdup(supported_features->valuestring) : NULL,
|
||||
ogs_strdup_or_assert(amf_instance_id->valuestring),
|
||||
supported_features ? ogs_strdup_or_assert(supported_features->valuestring) : NULL,
|
||||
purge_flag ? purge_flag->valueint : 0,
|
||||
pei ? ogs_strdup(pei->valuestring) : NULL,
|
||||
pei ? ogs_strdup_or_assert(pei->valuestring) : NULL,
|
||||
ims_vo_psVariable,
|
||||
ogs_strdup(dereg_callback_uri->valuestring),
|
||||
amf_service_name_dereg ? ogs_strdup(amf_service_name_dereg->valuestring) : NULL,
|
||||
pcscf_restoration_callback_uri ? ogs_strdup(pcscf_restoration_callback_uri->valuestring) : NULL,
|
||||
amf_service_name_pcscf_rest ? ogs_strdup(amf_service_name_pcscf_rest->valuestring) : NULL,
|
||||
ogs_strdup_or_assert(dereg_callback_uri->valuestring),
|
||||
amf_service_name_dereg ? ogs_strdup_or_assert(amf_service_name_dereg->valuestring) : NULL,
|
||||
pcscf_restoration_callback_uri ? ogs_strdup_or_assert(pcscf_restoration_callback_uri->valuestring) : NULL,
|
||||
amf_service_name_pcscf_rest ? ogs_strdup_or_assert(amf_service_name_pcscf_rest->valuestring) : NULL,
|
||||
guami_local_nonprim,
|
||||
backup_amf_info ? backup_amf_infoList : NULL,
|
||||
rat_typeVariable,
|
||||
urrp_indicator ? urrp_indicator->valueint : 0,
|
||||
amf_ee_subscription_id ? ogs_strdup(amf_ee_subscription_id->valuestring) : NULL,
|
||||
registration_time ? ogs_strdup(registration_time->valuestring) : NULL,
|
||||
amf_ee_subscription_id ? ogs_strdup_or_assert(amf_ee_subscription_id->valuestring) : NULL,
|
||||
registration_time ? ogs_strdup_or_assert(registration_time->valuestring) : NULL,
|
||||
vgmlc_address ? vgmlc_address_local_nonprim : NULL,
|
||||
context_info ? context_info_local_nonprim : NULL
|
||||
);
|
||||
|
|
|
@ -174,7 +174,7 @@ OpenAPI_amf_non3_gpp_access_registration_modification_t *OpenAPI_amf_non3_gpp_ac
|
|||
amf_non3_gpp_access_registration_modification_local_var = OpenAPI_amf_non3_gpp_access_registration_modification_create (
|
||||
guami_local_nonprim,
|
||||
purge_flag ? purge_flag->valueint : 0,
|
||||
pei ? ogs_strdup(pei->valuestring) : NULL,
|
||||
pei ? ogs_strdup_or_assert(pei->valuestring) : NULL,
|
||||
ims_vo_ps ? ims_vo_psVariable : 0,
|
||||
backup_amf_info ? backup_amf_infoList : NULL
|
||||
);
|
||||
|
|
|
@ -111,7 +111,7 @@ OpenAPI_amf_status_change_subscription_data_t *OpenAPI_amf_status_change_subscri
|
|||
}
|
||||
|
||||
amf_status_change_subscription_data_local_var = OpenAPI_amf_status_change_subscription_data_create (
|
||||
ogs_strdup(amf_status_uri->valuestring),
|
||||
ogs_strdup_or_assert(amf_status_uri->valuestring),
|
||||
guami_list ? guami_listList : NULL
|
||||
);
|
||||
|
||||
|
|
|
@ -153,8 +153,8 @@ OpenAPI_amf_status_info_t *OpenAPI_amf_status_info_parseFromJSON(cJSON *amf_stat
|
|||
amf_status_info_local_var = OpenAPI_amf_status_info_create (
|
||||
guami_listList,
|
||||
status_changeVariable,
|
||||
target_amf_removal ? ogs_strdup(target_amf_removal->valuestring) : NULL,
|
||||
target_amf_failure ? ogs_strdup(target_amf_failure->valuestring) : NULL
|
||||
target_amf_removal ? ogs_strdup_or_assert(target_amf_removal->valuestring) : NULL,
|
||||
target_amf_failure ? ogs_strdup_or_assert(target_amf_failure->valuestring) : NULL
|
||||
);
|
||||
|
||||
return amf_status_info_local_var;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue