Fix packing/unpacking for (n)FAPI PARAM and CONFIG.request/response
- Fix 4G and 5G discrepancy in TLV padding requirements: 4G does not need padding, whereas 5G needs, so make separate set of function for padding for NR - Fix packing/unpacking for (n)FAPI PARAM and CONFIG.request/response messages - Handle message padding to next 32-bit boundary, as per SCF specification in packing and unpacking functions - Account for message header size upon receiving message in PNF and VNF
This commit is contained in:
committed by
Robert Schmidt
parent
e70213cdf7
commit
09d7487dc1
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* Copyright 2017 Cisco Systems, Inc.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _NFAPI_H_
|
||||
#define _NFAPI_H_
|
||||
|
||||
@@ -40,7 +39,6 @@ uint8_t pulls16(uint8_t **in, int16_t *out, uint8_t *end);
|
||||
uint8_t pull32(uint8_t **in, uint32_t *out, uint8_t *end);
|
||||
uint8_t pulls32(uint8_t **in, int32_t *out, uint8_t *end);
|
||||
|
||||
|
||||
uint32_t pullarray8(uint8_t **in, uint8_t out[], uint32_t max_len, uint32_t len, uint8_t *end);
|
||||
uint32_t pullarray16(uint8_t **in, uint16_t out[], uint32_t max_len, uint32_t len, uint8_t *end);
|
||||
uint32_t pullarrays16(uint8_t **in, int16_t out[], uint32_t max_len, uint32_t len, uint8_t *end);
|
||||
@@ -61,40 +59,79 @@ uint32_t pusharray32(const uint32_t *values_to_push,
|
||||
uint8_t *out_end);
|
||||
uint32_t pusharrays32(int32_t in[], uint32_t max_len, uint32_t len, uint8_t **out, uint8_t *end);
|
||||
|
||||
typedef uint8_t (*pack_array_elem_fn)(void* elem, uint8_t **ppWritePackedMsg, uint8_t *end);
|
||||
uint8_t packarray(void* array, uint16_t elem_size, uint16_t max_count, uint16_t count, uint8_t **ppWritePackedMsg, uint8_t *end, pack_array_elem_fn fn);
|
||||
typedef uint8_t (*pack_array_elem_fn)(void *elem, uint8_t **ppWritePackedMsg, uint8_t *end);
|
||||
uint8_t packarray(void *array,
|
||||
uint16_t elem_size,
|
||||
uint16_t max_count,
|
||||
uint16_t count,
|
||||
uint8_t **ppWritePackedMsg,
|
||||
uint8_t *end,
|
||||
pack_array_elem_fn fn);
|
||||
|
||||
typedef uint8_t (*unpack_array_elem_fn)(void* elem, uint8_t **ppReadPackedMsg, uint8_t *end);
|
||||
uint8_t unpackarray(uint8_t **ppReadPackedMsg, void* array, uint16_t elem_size, uint16_t max_count, uint16_t count, uint8_t *end, unpack_array_elem_fn fn);
|
||||
typedef uint8_t (*unpack_array_elem_fn)(void *elem, uint8_t **ppReadPackedMsg, uint8_t *end);
|
||||
uint8_t unpackarray(uint8_t **ppReadPackedMsg,
|
||||
void *array,
|
||||
uint16_t elem_size,
|
||||
uint16_t max_count,
|
||||
uint16_t count,
|
||||
uint8_t *end,
|
||||
unpack_array_elem_fn fn);
|
||||
|
||||
uint8_t pack_tl(nfapi_tl_t *tl, uint8_t **ppWritePackedMsg, uint8_t *end);
|
||||
uint8_t unpack_tl(uint8_t **ppReadPackedMsg, nfapi_tl_t *tl, uint8_t *end);
|
||||
|
||||
typedef uint8_t (*pack_tlv_fn)(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end);
|
||||
typedef uint8_t (*pack_tlv_fn)(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end);
|
||||
uint8_t pack_tlv(uint16_t tag, void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end, pack_tlv_fn fn);
|
||||
uint8_t pack_nr_tlv(uint16_t tag, void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end, pack_tlv_fn fn);
|
||||
|
||||
uint32_t pack_vendor_extension_tlv(nfapi_tl_t* ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config);
|
||||
int unpack_vendor_extension(nfapi_tl_t* tl, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config, nfapi_tl_t** ve_tlv);
|
||||
uint32_t pack_vendor_extension_tlv(nfapi_tl_t *ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config);
|
||||
int unpack_vendor_extension_tlv(nfapi_tl_t *tl,
|
||||
uint8_t **ppReadPackedMsg,
|
||||
uint8_t *end,
|
||||
nfapi_p4_p5_codec_config_t *config,
|
||||
nfapi_tl_t **ve_tlv);
|
||||
|
||||
typedef uint8_t (*unpack_tlv_fn)(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end);
|
||||
typedef struct
|
||||
{
|
||||
uint16_t tag;
|
||||
void* tlv;
|
||||
unpack_tlv_fn unpack_func;
|
||||
uint8_t get_tlv_padding(uint16_t tlv_length);
|
||||
|
||||
typedef uint8_t (*unpack_tlv_fn)(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end);
|
||||
typedef struct {
|
||||
uint16_t tag;
|
||||
void *tlv;
|
||||
unpack_tlv_fn unpack_func;
|
||||
} unpack_tlv_t;
|
||||
|
||||
int unpack_tlv_list(unpack_tlv_t unpack_fns[], uint16_t size, uint8_t **ppReadPackedMsg, uint8_t* packedMsgEnd, nfapi_p4_p5_codec_config_t* config, nfapi_tl_t** ve);
|
||||
int unpack_tlv_list(unpack_tlv_t unpack_fns[],
|
||||
uint16_t size,
|
||||
uint8_t **ppReadPackedMsg,
|
||||
uint8_t *packedMsgEnd,
|
||||
nfapi_p4_p5_codec_config_t *config,
|
||||
nfapi_tl_t **ve);
|
||||
int unpack_nr_tlv_list(unpack_tlv_t unpack_fns[],
|
||||
uint16_t size,
|
||||
uint8_t **ppReadPackedMsg,
|
||||
uint8_t *packedMsgEnd,
|
||||
nfapi_p4_p5_codec_config_t *config,
|
||||
nfapi_tl_t **ve);
|
||||
|
||||
uint32_t pack_p7_vendor_extension_tlv(nfapi_tl_t *ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t* config);
|
||||
typedef uint8_t (*unpack_p7_tlv_fn)(void* tlv, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t*);
|
||||
typedef struct
|
||||
{
|
||||
uint16_t tag;
|
||||
void* tlv;
|
||||
unpack_p7_tlv_fn unpack_func;
|
||||
uint32_t pack_p7_vendor_extension_tlv(nfapi_tl_t *ve, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config);
|
||||
typedef uint8_t (*unpack_p7_tlv_fn)(void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *);
|
||||
typedef struct {
|
||||
uint16_t tag;
|
||||
void *tlv;
|
||||
unpack_p7_tlv_fn unpack_func;
|
||||
} unpack_p7_tlv_t;
|
||||
int unpack_p7_tlv_list(unpack_p7_tlv_t unpack_fns[], uint16_t size, uint8_t **ppReadPackedMsg, uint8_t* packedMsgEnd, nfapi_p7_codec_config_t* config, nfapi_tl_t** ve);
|
||||
int unpack_p7_tlv_list(unpack_p7_tlv_t unpack_fns[],
|
||||
uint16_t size,
|
||||
uint8_t **ppReadPackedMsg,
|
||||
uint8_t *packedMsgEnd,
|
||||
nfapi_p7_codec_config_t *config,
|
||||
nfapi_tl_t **ve);
|
||||
int unpack_nr_p7_tlv_list(unpack_p7_tlv_t unpack_fns[],
|
||||
uint16_t size,
|
||||
uint8_t **ppReadPackedMsg,
|
||||
uint8_t *packedMsgEnd,
|
||||
nfapi_p7_codec_config_t *config,
|
||||
nfapi_tl_t **ve);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
||||
@@ -292,8 +292,8 @@ typedef enum {
|
||||
} nfapi_nr_ssb_and_cset_mux_pattern_type_e;
|
||||
|
||||
typedef enum {
|
||||
NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED=0,
|
||||
NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED=1
|
||||
NFAPI_NR_CCE_REG_MAPPING_INTERLEAVED=1,
|
||||
NFAPI_NR_CCE_REG_MAPPING_NON_INTERLEAVED=0
|
||||
} nfapi_nr_cce_reg_mapping_type_e;
|
||||
|
||||
typedef enum {
|
||||
|
||||
@@ -474,7 +474,8 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
uint32_t error_code;
|
||||
uint8_t error_code;
|
||||
uint8_t num_tlvs;
|
||||
nfapi_pnf_param_general_t pnf_param_general;
|
||||
nfapi_pnf_phy_t pnf_phy;
|
||||
nfapi_vendor_extension_tlv_t vendor_extension;
|
||||
@@ -489,7 +490,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
uint32_t error_code;
|
||||
uint8_t error_code;
|
||||
nfapi_vendor_extension_tlv_t vendor_extension;
|
||||
} nfapi_nr_pnf_config_response_t;
|
||||
|
||||
@@ -566,7 +567,10 @@ typedef struct {
|
||||
typedef struct {
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
uint8_t error_code;
|
||||
//uint8_t num_invalid_tlvs;
|
||||
uint8_t num_invalid_tlvs;
|
||||
uint8_t num_invalid_tlvs_configured_in_idle;
|
||||
uint8_t num_invalid_tlvs_configured_in_running;
|
||||
uint8_t num_missing_tlvs;
|
||||
// TODO: add list of invalid/unsupported TLVs (see Table 3.18)
|
||||
nfapi_vendor_extension_tlv_t vendor_extension;
|
||||
} nfapi_nr_config_response_scf_t;
|
||||
|
||||
@@ -567,9 +567,14 @@ uint32_t pack_vendor_extension_tlv(nfapi_tl_t *ve, uint8_t **ppWritePackedMsg, u
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32_t unpack_vendor_extension_tlv(nfapi_tl_t *tl, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t *config, nfapi_tl_t **ve_tlv) {
|
||||
if(ve_tlv != 0 && config != 0) {
|
||||
if(config->unpack_vendor_extension_tlv) {
|
||||
int unpack_vendor_extension_tlv(nfapi_tl_t *tl,
|
||||
uint8_t **ppReadPackedMsg,
|
||||
uint8_t *end,
|
||||
nfapi_p4_p5_codec_config_t *config,
|
||||
nfapi_tl_t **ve_tlv)
|
||||
{
|
||||
if (ve_tlv != 0 && config != 0) {
|
||||
if (config->unpack_vendor_extension_tlv) {
|
||||
return (config->unpack_vendor_extension_tlv)(tl, ppReadPackedMsg, end, (void **)ve_tlv, config);
|
||||
}
|
||||
}
|
||||
@@ -702,6 +707,104 @@ int unpack_tlv_list(unpack_tlv_t unpack_fns[], uint16_t size, uint8_t **ppReadPa
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int unpack_nr_tlv_list(unpack_tlv_t unpack_fns[],
|
||||
uint16_t size,
|
||||
uint8_t **ppReadPackedMsg,
|
||||
uint8_t *end,
|
||||
nfapi_p4_p5_codec_config_t *config,
|
||||
nfapi_tl_t **ve)
|
||||
{
|
||||
nfapi_tl_t generic_tl;
|
||||
uint8_t numBadTags = 0;
|
||||
uint16_t idx = 0;
|
||||
|
||||
while ((uint8_t *)(*ppReadPackedMsg) < end) {
|
||||
// unpack the tl and process the values accordingly
|
||||
if (unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0)
|
||||
return 0;
|
||||
|
||||
uint8_t tagMatch = 0;
|
||||
uint8_t *pStartOfValue = *ppReadPackedMsg;
|
||||
|
||||
for (idx = 0; idx < size; ++idx) {
|
||||
if (unpack_fns[idx].tag == generic_tl.tag) { // match the extracted tag value with all the tags in unpack_fn list
|
||||
tagMatch = 1;
|
||||
nfapi_tl_t *tl = (nfapi_tl_t *)(unpack_fns[idx].tlv);
|
||||
tl->tag = generic_tl.tag;
|
||||
tl->length = generic_tl.length;
|
||||
int result = (*unpack_fns[idx].unpack_func)(tl, ppReadPackedMsg, end);
|
||||
|
||||
if (result == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// check if the length was right;
|
||||
if (tl->length != (*ppReadPackedMsg - pStartOfValue)) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR,
|
||||
"Warning tlv tag 0x%x length %d not equal to unpack %ld\n",
|
||||
tl->tag,
|
||||
tl->length,
|
||||
(*ppReadPackedMsg - pStartOfValue));
|
||||
on_error();
|
||||
}
|
||||
// Remove padding that ensures multiple of 4 bytes (SCF 225 Section 2.3.2.1)
|
||||
int padding = get_tlv_padding(tl->length);
|
||||
if (padding != 0) {
|
||||
(*ppReadPackedMsg) += padding;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tagMatch == 0) {
|
||||
if (generic_tl.tag >= NFAPI_VENDOR_EXTENSION_MIN_TAG_VALUE && generic_tl.tag <= NFAPI_VENDOR_EXTENSION_MAX_TAG_VALUE) {
|
||||
int result = unpack_vendor_extension_tlv(&generic_tl, ppReadPackedMsg, end, config, ve);
|
||||
|
||||
if (result == 0) {
|
||||
// got tot the end.
|
||||
return 0;
|
||||
} else if (result < 0) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown VE TAG value: 0x%04x\n", generic_tl.tag);
|
||||
on_error();
|
||||
|
||||
if (++numBadTags > MAX_BAD_TAG) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n");
|
||||
on_error();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((end - *ppReadPackedMsg) >= generic_tl.length) {
|
||||
// Advance past the unknown TLV
|
||||
(*ppReadPackedMsg) += generic_tl.length + get_tlv_padding(generic_tl.length);
|
||||
} else {
|
||||
// go to the end
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown TAG value: 0x%04x\n", generic_tl.tag);
|
||||
on_error();
|
||||
|
||||
if (++numBadTags > MAX_BAD_TAG) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n");
|
||||
on_error();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((end - *ppReadPackedMsg) >= generic_tl.length) {
|
||||
// Advance past the unknown TLV
|
||||
(*ppReadPackedMsg) += generic_tl.length + get_tlv_padding(generic_tl.length);
|
||||
} else {
|
||||
// go to the end
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int unpack_p7_tlv_list(unpack_p7_tlv_t unpack_fns[], uint16_t size, uint8_t **ppReadPackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config, nfapi_tl_t **ve) {
|
||||
nfapi_tl_t generic_tl;
|
||||
uint8_t numBadTags = 0;
|
||||
@@ -785,6 +888,103 @@ int unpack_p7_tlv_list(unpack_p7_tlv_t unpack_fns[], uint16_t size, uint8_t **pp
|
||||
return 1;
|
||||
}
|
||||
|
||||
int unpack_nr_p7_tlv_list(unpack_p7_tlv_t unpack_fns[],
|
||||
uint16_t size,
|
||||
uint8_t **ppReadPackedMsg,
|
||||
uint8_t *end,
|
||||
nfapi_p7_codec_config_t *config,
|
||||
nfapi_tl_t **ve)
|
||||
{
|
||||
nfapi_tl_t generic_tl;
|
||||
uint8_t numBadTags = 0;
|
||||
uint16_t idx = 0;
|
||||
|
||||
while ((uint8_t *)(*ppReadPackedMsg) < end) {
|
||||
// unpack the tl and process the values accordingly
|
||||
if (unpack_tl(ppReadPackedMsg, &generic_tl, end) == 0)
|
||||
return 0;
|
||||
|
||||
uint8_t tagMatch = 0;
|
||||
uint8_t *pStartOfValue = *ppReadPackedMsg;
|
||||
|
||||
for (idx = 0; idx < size; ++idx) {
|
||||
if (unpack_fns[idx].tag == generic_tl.tag) {
|
||||
tagMatch = 1;
|
||||
nfapi_tl_t *tl = (nfapi_tl_t *)(unpack_fns[idx].tlv);
|
||||
tl->tag = generic_tl.tag;
|
||||
tl->length = generic_tl.length;
|
||||
int result = (*unpack_fns[idx].unpack_func)(tl, ppReadPackedMsg, end, config);
|
||||
|
||||
if (result == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// check if the length was right;
|
||||
if (tl->length != (*ppReadPackedMsg - pStartOfValue)) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR,
|
||||
"Warning tlv tag 0x%x length %d not equal to unpack %ld\n",
|
||||
tl->tag,
|
||||
tl->length,
|
||||
(*ppReadPackedMsg - pStartOfValue));
|
||||
on_error();
|
||||
}
|
||||
// Remove padding that ensures multiple of 4 bytes (SCF 225 Section 2.3.2.1)
|
||||
int padding = get_tlv_padding(tl->length);
|
||||
if (padding != 0) {
|
||||
(*ppReadPackedMsg) += padding;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tagMatch == 0) {
|
||||
if (generic_tl.tag >= NFAPI_VENDOR_EXTENSION_MIN_TAG_VALUE && generic_tl.tag <= NFAPI_VENDOR_EXTENSION_MAX_TAG_VALUE) {
|
||||
int result = unpack_p7_vendor_extension_tlv(&generic_tl, ppReadPackedMsg, end, config, ve);
|
||||
|
||||
if (result == 0) {
|
||||
// got to end
|
||||
return 0;
|
||||
} else if (result < 0) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown TAG value: 0x%04x\n", generic_tl.tag);
|
||||
on_error();
|
||||
|
||||
if (++numBadTags > MAX_BAD_TAG) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n");
|
||||
on_error();
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((end - *ppReadPackedMsg) >= generic_tl.length) {
|
||||
// Advance past the unknown TLV
|
||||
(*ppReadPackedMsg) += generic_tl.length + get_tlv_padding(generic_tl.length);
|
||||
} else {
|
||||
// got ot the dn
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Unknown TAG value: 0x%04x\n", generic_tl.tag);
|
||||
on_error();
|
||||
|
||||
if (++numBadTags > MAX_BAD_TAG) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Supplied message has had too many bad tags\n");
|
||||
on_error();
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((end - *ppReadPackedMsg) >= generic_tl.length) {
|
||||
// Advance past the unknown TLV
|
||||
(*ppReadPackedMsg) += generic_tl.length + get_tlv_padding(generic_tl.length);
|
||||
} else {
|
||||
// got ot the dn
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// This intermediate function deals with calculating the length of the value
|
||||
// and writing into the tlv header.
|
||||
uint8_t pack_tlv(uint16_t tag, void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end, pack_tlv_fn fn) {
|
||||
@@ -820,6 +1020,47 @@ uint8_t pack_tlv(uint16_t tag, void *tlv, uint8_t **ppWritePackedMsg, uint8_t *e
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t pack_nr_tlv(uint16_t tag, void *tlv, uint8_t **ppWritePackedMsg, uint8_t *end, pack_tlv_fn fn)
|
||||
{
|
||||
nfapi_tl_t *tl = (nfapi_tl_t *)tlv;
|
||||
|
||||
// If the tag is defined
|
||||
if (tl->tag == tag) {
|
||||
uint8_t *pStartOfTlv = *ppWritePackedMsg;
|
||||
|
||||
// write a dumy tlv header
|
||||
if (pack_tl(tl, ppWritePackedMsg, end) == 0)
|
||||
return 0;
|
||||
|
||||
// Record the start of the value
|
||||
uint8_t *pStartOfValue = *ppWritePackedMsg;
|
||||
|
||||
// pack the tlv value
|
||||
if (fn(tlv, ppWritePackedMsg, end) == 0)
|
||||
return 0;
|
||||
|
||||
// calculate the length of the value and rewrite the tl header
|
||||
tl->length = (*ppWritePackedMsg) - pStartOfValue;
|
||||
// rewrite the header with the correct length
|
||||
pack_tl(tl, &pStartOfTlv, end);
|
||||
// Add padding that ensures multiple of 4 bytes (SCF 225 Section 2.3.2.1)
|
||||
int padding = get_tlv_padding(tl->length);
|
||||
NFAPI_TRACE(NFAPI_TRACE_DEBUG, "TLV 0x%x with padding of %d bytes\n", tl->tag, padding);
|
||||
if (padding != 0) {
|
||||
memset(*ppWritePackedMsg, 0, padding);
|
||||
(*ppWritePackedMsg) += padding;
|
||||
}
|
||||
} else {
|
||||
if (tl->tag != 0) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_WARN, "Warning pack_tlv tag 0x%x does not match expected 0x%x\n", tl->tag, tag);
|
||||
} else {
|
||||
// NFAPI_TRACE(NFAPI_TRACE_ERROR, "Warning pack_tlv tag 0x%x ZERO does not match expected 0x%x\n", tl->tag, tag);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char *nfapi_error_code_to_str(nfapi_error_code_e value) {
|
||||
switch(value) {
|
||||
case NFAPI_MSG_OK:
|
||||
@@ -853,3 +1094,8 @@ const char *nfapi_error_code_to_str(nfapi_error_code_e value) {
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t get_tlv_padding(uint16_t tlv_length)
|
||||
{
|
||||
return (4 - (tlv_length % 4)) % 4;
|
||||
}
|
||||
|
||||
+2310
-731
File diff suppressed because it is too large
Load Diff
@@ -2025,6 +2025,18 @@ static uint8_t pack_ue_release_request(void *msg, uint8_t **ppWritePackedMsg, ui
|
||||
return x && y && z;
|
||||
}
|
||||
|
||||
static uint8_t pack_nr_ue_release_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config)
|
||||
{
|
||||
nfapi_ue_release_request_t *pNfapiMsg = (nfapi_ue_release_request_t *)msg;
|
||||
return push16(pNfapiMsg->sfn_sf, ppWritePackedMsg, end)
|
||||
&& pack_nr_tlv(NFAPI_UE_RELEASE_BODY_TAG,
|
||||
&pNfapiMsg->ue_release_request_body,
|
||||
ppWritePackedMsg,
|
||||
end,
|
||||
&pack_release_request_body_value)
|
||||
&& pack_p7_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config);
|
||||
}
|
||||
|
||||
static uint8_t pack_ue_release_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p7_codec_config_t *config) {
|
||||
nfapi_ue_release_response_t *pNfapiMsg = (nfapi_ue_release_response_t *)msg;
|
||||
int x = push32(pNfapiMsg->error_code, ppWritePackedMsg, end);
|
||||
@@ -3432,157 +3444,146 @@ return 1;
|
||||
|
||||
// Main pack function - public
|
||||
|
||||
int nfapi_nr_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen, nfapi_p7_codec_config_t* config)
|
||||
int nfapi_nr_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen, nfapi_p7_codec_config_t *config)
|
||||
{
|
||||
nfapi_p7_message_header_t *pMessageHeader = pMessageBuf;
|
||||
uint8_t *pWritePackedMessage = pPackedBuf;
|
||||
uint8_t *pPackedLengthField = &pWritePackedMessage[4];
|
||||
nfapi_p7_message_header_t *pMessageHeader = pMessageBuf;
|
||||
uint8_t *pWritePackedMessage = pPackedBuf;
|
||||
uint8_t *pPackedLengthField = &pWritePackedMessage[4];
|
||||
|
||||
if (pMessageBuf == NULL || pPackedBuf == NULL)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 Pack supplied pointers are null\n");
|
||||
return -1;
|
||||
}
|
||||
if (pMessageBuf == NULL || pPackedBuf == NULL) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 Pack supplied pointers are null\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint8_t *end = (uint8_t *)pPackedBuf + packedBufLen;
|
||||
uint8_t *end = (uint8_t *)pPackedBuf + packedBufLen;
|
||||
|
||||
// process the header
|
||||
if(!(push16(pMessageHeader->phy_id, &pWritePackedMessage, end) &&
|
||||
push16(pMessageHeader->message_id, &pWritePackedMessage, end) &&
|
||||
push16(0/*pMessageHeader->message_length*/, &pWritePackedMessage, end) &&
|
||||
push16(pMessageHeader->m_segment_sequence, &pWritePackedMessage, end) &&
|
||||
push32(0/*pMessageHeader->checksum*/, &pWritePackedMessage, end) &&
|
||||
push32(pMessageHeader->transmit_timestamp, &pWritePackedMessage, end)))
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 Pack header failed\n");
|
||||
return -1;
|
||||
}
|
||||
// process the header
|
||||
if (!(push16(pMessageHeader->phy_id, &pWritePackedMessage, end) && push16(pMessageHeader->message_id, &pWritePackedMessage, end)
|
||||
&& push16(0 /*pMessageHeader->message_length*/, &pWritePackedMessage, end)
|
||||
&& push16(pMessageHeader->m_segment_sequence, &pWritePackedMessage, end)
|
||||
&& push32(0 /*pMessageHeader->checksum*/, &pWritePackedMessage, end)
|
||||
&& push32(pMessageHeader->transmit_timestamp, &pWritePackedMessage, end))) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 Pack header failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pMessageHeader->message_id != NFAPI_TIMING_INFO)
|
||||
{
|
||||
//NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() message_id:0x%04x phy_id:%u m_segment_sequence:%u timestamp:%u\n", __FUNCTION__, pMessageHeader->message_id, pMessageHeader->phy_id, pMessageHeader->m_segment_sequence, pMessageHeader->transmit_timestamp);
|
||||
if (pMessageHeader->message_id != NFAPI_TIMING_INFO) {
|
||||
// NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() message_id:0x%04x phy_id:%u m_segment_sequence:%u timestamp:%u\n", __FUNCTION__,
|
||||
// pMessageHeader->message_id, pMessageHeader->phy_id, pMessageHeader->m_segment_sequence, pMessageHeader->transmit_timestamp);
|
||||
}
|
||||
// look for the specific message
|
||||
uint8_t result = 0;
|
||||
switch (pMessageHeader->message_id) {
|
||||
case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST:
|
||||
result = pack_dl_tti_request(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST:
|
||||
result = pack_ul_tti_request(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST:
|
||||
result = pack_tx_data_request(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST:
|
||||
result = pack_ul_dci_request(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
case NFAPI_UE_RELEASE_REQUEST:
|
||||
result = pack_nr_ue_release_request(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
|
||||
case NFAPI_UE_RELEASE_RESPONSE:
|
||||
result = pack_ue_release_response(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_SLOT_INDICATION:
|
||||
result = pack_nr_slot_indication(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION:
|
||||
result = pack_nr_rx_data_indication(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION:
|
||||
result = pack_nr_crc_indication(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION:
|
||||
result = pack_nr_uci_indication(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_SRS_INDICATION:
|
||||
result = pack_nr_srs_indication(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION:
|
||||
result = pack_nr_rach_indication(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC:
|
||||
result = pack_nr_dl_node_sync(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_UL_NODE_SYNC:
|
||||
result = pack_nr_ul_node_sync(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
|
||||
case NFAPI_TIMING_INFO:
|
||||
result = pack_nr_timing_info(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
|
||||
default: {
|
||||
if (pMessageHeader->message_id >= NFAPI_VENDOR_EXT_MSG_MIN && pMessageHeader->message_id <= NFAPI_VENDOR_EXT_MSG_MAX) {
|
||||
if (config && config->pack_p7_vendor_extension) {
|
||||
result = (config->pack_p7_vendor_extension)(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR,
|
||||
"%s VE NFAPI message ID %d. No ve ecoder provided\n",
|
||||
__FUNCTION__,
|
||||
pMessageHeader->message_id);
|
||||
}
|
||||
// look for the specific message
|
||||
uint8_t result = 0;
|
||||
switch (pMessageHeader->message_id)
|
||||
{
|
||||
case NFAPI_NR_PHY_MSG_TYPE_DL_TTI_REQUEST:
|
||||
result = pack_dl_tti_request(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s NFAPI Unknown message ID %d\n", __FUNCTION__, pMessageHeader->message_id);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_UL_TTI_REQUEST:
|
||||
result = pack_ul_tti_request(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
if (result == 0) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 Pack failed to pack message\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_TX_DATA_REQUEST:
|
||||
result = pack_tx_data_request(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
// check for a valid message length
|
||||
uintptr_t msgHead = (uintptr_t)pPackedBuf;
|
||||
uintptr_t msgEnd = (uintptr_t)pWritePackedMessage;
|
||||
uint32_t packedMsgLen = msgEnd - msgHead;
|
||||
uint16_t packedMsgLen16;
|
||||
if (packedMsgLen > 0xFFFF || packedMsgLen > packedBufLen) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Packed message length error %d, buffer supplied %d\n", packedMsgLen, packedBufLen);
|
||||
return -1;
|
||||
} else {
|
||||
packedMsgLen16 = (uint16_t)packedMsgLen;
|
||||
}
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_UL_DCI_REQUEST:
|
||||
result = pack_ul_dci_request(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
case NFAPI_UE_RELEASE_REQUEST:
|
||||
result =pack_ue_release_request(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
// Update the message length in the header
|
||||
pMessageHeader->message_length = packedMsgLen16;
|
||||
|
||||
case NFAPI_UE_RELEASE_RESPONSE:
|
||||
result =pack_ue_release_response(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
if (!push16(packedMsgLen16, &pPackedLengthField, end))
|
||||
return -1;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_SLOT_INDICATION:
|
||||
result = pack_nr_slot_indication(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
if (1) {
|
||||
// quick test
|
||||
if (pMessageHeader->message_length != packedMsgLen) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR,
|
||||
"nfapi packedMsgLen(%d) != message_length(%d) id %d\n",
|
||||
packedMsgLen,
|
||||
pMessageHeader->message_length,
|
||||
pMessageHeader->message_id);
|
||||
}
|
||||
}
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_RX_DATA_INDICATION:
|
||||
result = pack_nr_rx_data_indication(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION:
|
||||
result = pack_nr_crc_indication(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION:
|
||||
result = pack_nr_uci_indication(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_SRS_INDICATION:
|
||||
result = pack_nr_srs_indication(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION:
|
||||
result = pack_nr_rach_indication(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC:
|
||||
result = pack_nr_dl_node_sync(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
|
||||
case NFAPI_NR_PHY_MSG_TYPE_UL_NODE_SYNC:
|
||||
result = pack_nr_ul_node_sync(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
|
||||
case NFAPI_TIMING_INFO:
|
||||
result = pack_nr_timing_info(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
if(pMessageHeader->message_id >= NFAPI_VENDOR_EXT_MSG_MIN &&
|
||||
pMessageHeader->message_id <= NFAPI_VENDOR_EXT_MSG_MAX)
|
||||
{
|
||||
if(config && config->pack_p7_vendor_extension)
|
||||
{
|
||||
result = (config->pack_p7_vendor_extension)(pMessageHeader, &pWritePackedMessage, end, config);
|
||||
}
|
||||
else
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s VE NFAPI message ID %d. No ve ecoder provided\n", __FUNCTION__, pMessageHeader->message_id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "%s NFAPI Unknown message ID %d\n", __FUNCTION__, pMessageHeader->message_id);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(result == 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "P7 Pack failed to pack message\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// check for a valid message length
|
||||
uintptr_t msgHead = (uintptr_t)pPackedBuf;
|
||||
uintptr_t msgEnd = (uintptr_t)pWritePackedMessage;
|
||||
uint32_t packedMsgLen = msgEnd - msgHead;
|
||||
uint16_t packedMsgLen16;
|
||||
if (packedMsgLen > 0xFFFF || packedMsgLen > packedBufLen)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "Packed message length error %d, buffer supplied %d\n", packedMsgLen, packedBufLen);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
packedMsgLen16 = (uint16_t)packedMsgLen;
|
||||
}
|
||||
|
||||
// Update the message length in the header
|
||||
pMessageHeader->message_length = packedMsgLen16;
|
||||
|
||||
if(!push16(packedMsgLen16, &pPackedLengthField, end))
|
||||
return -1;
|
||||
|
||||
if(1)
|
||||
{
|
||||
//quick test
|
||||
if(pMessageHeader->message_length != packedMsgLen)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_ERROR, "nfapi packedMsgLen(%d) != message_length(%d) id %d\n", packedMsgLen, pMessageHeader->message_length, pMessageHeader->message_id);
|
||||
}
|
||||
}
|
||||
|
||||
return (packedMsgLen);
|
||||
return (packedMsgLen);
|
||||
}
|
||||
|
||||
int nfapi_p7_message_pack(void *pMessageBuf, void *pPackedBuf, uint32_t packedBufLen, nfapi_p7_codec_config_t *config) {
|
||||
@@ -4624,8 +4625,8 @@ static uint8_t unpack_ul_tti_request_pusch_pdu(void *tlv, uint8_t **ppReadPacked
|
||||
return(
|
||||
pull8(ppReadPackedMsg, &pusch_pdu->pusch_ptrs.num_ptrs_ports, end) &&
|
||||
pull8(ppReadPackedMsg, &pusch_pdu->pusch_ptrs.ptrs_ports_list->ptrs_dmrs_port, end) &&
|
||||
+ pull16(ppReadPackedMsg, &pusch_pdu->pusch_ptrs.ptrs_ports_list->ptrs_port_index, end) &&
|
||||
+ pull8(ppReadPackedMsg, &pusch_pdu->pusch_ptrs.ptrs_ports_list->ptrs_re_offset, end) &&
|
||||
pull16(ppReadPackedMsg, &pusch_pdu->pusch_ptrs.ptrs_ports_list->ptrs_port_index, end) &&
|
||||
pull8(ppReadPackedMsg, &pusch_pdu->pusch_ptrs.ptrs_ports_list->ptrs_re_offset, end) &&
|
||||
pull8(ppReadPackedMsg, &pusch_pdu->pusch_ptrs.ptrs_time_density, end) &&
|
||||
pull8(ppReadPackedMsg, &pusch_pdu->pusch_ptrs.ptrs_freq_density, end) &&
|
||||
pull8(ppReadPackedMsg, &pusch_pdu->pusch_ptrs.ul_ptrs_power, end)
|
||||
@@ -7492,11 +7493,11 @@ static uint8_t unpack_nrach_indication(uint8_t **ppReadPackedMsg, uint8_t *end,
|
||||
unpack_p7_tlv_list(unpack_fns, sizeof(unpack_fns)/sizeof(unpack_tlv_t), ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension));
|
||||
}
|
||||
|
||||
static uint8_t unpack_nr_dl_node_sync(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t *config) {
|
||||
static uint8_t unpack_nr_dl_node_sync(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t *config)
|
||||
{
|
||||
nfapi_nr_dl_node_sync_t *pNfapiMsg = (nfapi_nr_dl_node_sync_t *)msg;
|
||||
return (pull32(ppReadPackedMsg, &pNfapiMsg->t1, end) &&
|
||||
pulls32(ppReadPackedMsg, &pNfapiMsg->delta_sfn_slot, end) &&
|
||||
unpack_p7_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension));
|
||||
return (pull32(ppReadPackedMsg, &pNfapiMsg->t1, end) && pulls32(ppReadPackedMsg, &pNfapiMsg->delta_sfn_slot, end)
|
||||
&& unpack_nr_p7_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension));
|
||||
}
|
||||
|
||||
static uint8_t unpack_dl_node_sync(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t *config) {
|
||||
@@ -7506,16 +7507,14 @@ static uint8_t unpack_dl_node_sync(uint8_t **ppReadPackedMsg, uint8_t *end, void
|
||||
unpack_p7_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension));
|
||||
}
|
||||
|
||||
|
||||
static uint8_t unpack_nr_ul_node_sync(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t *config) {
|
||||
static uint8_t unpack_nr_ul_node_sync(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t *config)
|
||||
{
|
||||
nfapi_nr_ul_node_sync_t *pNfapiMsg = (nfapi_nr_ul_node_sync_t *)msg;
|
||||
return (pull32(ppReadPackedMsg, &pNfapiMsg->t1, end) &&
|
||||
pull32(ppReadPackedMsg, &pNfapiMsg->t2, end) &&
|
||||
pull32(ppReadPackedMsg, &pNfapiMsg->t3, end) &&
|
||||
unpack_p7_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension));
|
||||
return (pull32(ppReadPackedMsg, &pNfapiMsg->t1, end) && pull32(ppReadPackedMsg, &pNfapiMsg->t2, end)
|
||||
&& pull32(ppReadPackedMsg, &pNfapiMsg->t3, end)
|
||||
&& unpack_nr_p7_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension));
|
||||
}
|
||||
|
||||
|
||||
static uint8_t unpack_ul_node_sync(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t *config) {
|
||||
nfapi_ul_node_sync_t *pNfapiMsg = (nfapi_ul_node_sync_t *)msg;
|
||||
return (pull32(ppReadPackedMsg, &pNfapiMsg->t1, end) &&
|
||||
@@ -7543,29 +7542,25 @@ static uint8_t unpack_timing_info(uint8_t **ppReadPackedMsg, uint8_t *end, void
|
||||
unpack_p7_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension));
|
||||
}
|
||||
|
||||
|
||||
static uint8_t unpack_nr_timing_info(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t *config) {
|
||||
static uint8_t unpack_nr_timing_info(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p7_codec_config_t *config)
|
||||
{
|
||||
nfapi_nr_timing_info_t *pNfapiMsg = (nfapi_nr_timing_info_t *)msg;
|
||||
return (pull32(ppReadPackedMsg, &pNfapiMsg->last_sfn, end) &&
|
||||
pull32(ppReadPackedMsg, &pNfapiMsg->last_slot, end) &&
|
||||
pull32(ppReadPackedMsg, &pNfapiMsg->time_since_last_timing_info, end) &&
|
||||
pull32(ppReadPackedMsg, &pNfapiMsg->dl_tti_jitter, end) &&
|
||||
pull32(ppReadPackedMsg, &pNfapiMsg->tx_data_request_jitter, end) &&
|
||||
pull32(ppReadPackedMsg, &pNfapiMsg->ul_tti_jitter, end) &&
|
||||
pull32(ppReadPackedMsg, &pNfapiMsg->ul_dci_jitter, end) &&
|
||||
pulls32(ppReadPackedMsg, &pNfapiMsg->dl_tti_latest_delay, end) &&
|
||||
pulls32(ppReadPackedMsg, &pNfapiMsg->tx_data_request_latest_delay, end) &&
|
||||
pulls32(ppReadPackedMsg, &pNfapiMsg->ul_tti_latest_delay, end) &&
|
||||
pulls32(ppReadPackedMsg, &pNfapiMsg->ul_dci_latest_delay, end) &&
|
||||
pulls32(ppReadPackedMsg, &pNfapiMsg->dl_tti_earliest_arrival, end) &&
|
||||
pulls32(ppReadPackedMsg, &pNfapiMsg->tx_data_request_earliest_arrival, end) &&
|
||||
pulls32(ppReadPackedMsg, &pNfapiMsg->ul_tti_earliest_arrival, end) &&
|
||||
pulls32(ppReadPackedMsg, &pNfapiMsg->ul_dci_earliest_arrival, end) &&
|
||||
unpack_p7_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension));
|
||||
return (pull32(ppReadPackedMsg, &pNfapiMsg->last_sfn, end) && pull32(ppReadPackedMsg, &pNfapiMsg->last_slot, end)
|
||||
&& pull32(ppReadPackedMsg, &pNfapiMsg->time_since_last_timing_info, end)
|
||||
&& pull32(ppReadPackedMsg, &pNfapiMsg->dl_tti_jitter, end)
|
||||
&& pull32(ppReadPackedMsg, &pNfapiMsg->tx_data_request_jitter, end)
|
||||
&& pull32(ppReadPackedMsg, &pNfapiMsg->ul_tti_jitter, end) && pull32(ppReadPackedMsg, &pNfapiMsg->ul_dci_jitter, end)
|
||||
&& pulls32(ppReadPackedMsg, &pNfapiMsg->dl_tti_latest_delay, end)
|
||||
&& pulls32(ppReadPackedMsg, &pNfapiMsg->tx_data_request_latest_delay, end)
|
||||
&& pulls32(ppReadPackedMsg, &pNfapiMsg->ul_tti_latest_delay, end)
|
||||
&& pulls32(ppReadPackedMsg, &pNfapiMsg->ul_dci_latest_delay, end)
|
||||
&& pulls32(ppReadPackedMsg, &pNfapiMsg->dl_tti_earliest_arrival, end)
|
||||
&& pulls32(ppReadPackedMsg, &pNfapiMsg->tx_data_request_earliest_arrival, end)
|
||||
&& pulls32(ppReadPackedMsg, &pNfapiMsg->ul_tti_earliest_arrival, end)
|
||||
&& pulls32(ppReadPackedMsg, &pNfapiMsg->ul_dci_earliest_arrival, end)
|
||||
&& unpack_nr_p7_tlv_list(NULL, 0, ppReadPackedMsg, end, config, &pNfapiMsg->vendor_extension));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// unpack length check
|
||||
|
||||
static int check_unpack_length(nfapi_message_id_e msgId, uint32_t unpackedBufLen) {
|
||||
|
||||
@@ -2131,77 +2131,77 @@ int pnf_read_dispatch_message(pnf_t* pnf)
|
||||
|
||||
int pnf_nr_read_dispatch_message(pnf_t* pnf)
|
||||
{
|
||||
int socket_connected = 1;
|
||||
int socket_connected = 1;
|
||||
|
||||
// 1. Peek the message header
|
||||
// 2. If the message is larger than the stack buffer then create a dynamic buffer
|
||||
// 3. Read the buffer
|
||||
// 4. Handle the p5 message
|
||||
// 1. Peek the message header
|
||||
// 2. If the message is larger than the stack buffer then create a dynamic buffer
|
||||
// 3. Read the buffer
|
||||
// 4. Handle the p5 message
|
||||
|
||||
uint32_t header_buffer_size = NFAPI_HEADER_LENGTH;
|
||||
uint8_t header_buffer[header_buffer_size];
|
||||
uint32_t header_buffer_size = NFAPI_HEADER_LENGTH;
|
||||
uint8_t header_buffer[header_buffer_size];
|
||||
|
||||
uint32_t stack_buffer_size = 32; //should it be the size of then sctp_notificatoin structure
|
||||
uint8_t stack_buffer[stack_buffer_size];
|
||||
uint32_t stack_buffer_size = 32; // should it be the size of then sctp_notificatoin structure
|
||||
uint8_t stack_buffer[stack_buffer_size];
|
||||
|
||||
uint8_t* dynamic_buffer = 0;
|
||||
uint8_t* dynamic_buffer = 0;
|
||||
|
||||
uint8_t* read_buffer = &stack_buffer[0];
|
||||
uint32_t message_size = 0;
|
||||
uint8_t* read_buffer = &stack_buffer[0];
|
||||
uint32_t message_size = 0;
|
||||
|
||||
struct sockaddr_in addr;
|
||||
socklen_t addr_len = sizeof(addr);
|
||||
struct sockaddr_in addr;
|
||||
socklen_t addr_len = sizeof(addr);
|
||||
|
||||
struct sctp_sndrcvinfo sndrcvinfo;
|
||||
(void)memset(&sndrcvinfo, 0, sizeof(struct sctp_sndrcvinfo));
|
||||
struct sctp_sndrcvinfo sndrcvinfo;
|
||||
(void)memset(&sndrcvinfo, 0, sizeof(struct sctp_sndrcvinfo));
|
||||
|
||||
{
|
||||
int flags = MSG_PEEK;
|
||||
message_size = sctp_recvmsg(pnf->p5_sock, header_buffer, header_buffer_size, /*(struct sockaddr*)&addr, &addr_len*/ 0, 0, &sndrcvinfo, &flags);
|
||||
{
|
||||
int flags = MSG_PEEK;
|
||||
message_size = sctp_recvmsg(pnf->p5_sock,
|
||||
header_buffer,
|
||||
header_buffer_size,
|
||||
/*(struct sockaddr*)&addr, &addr_len*/ 0,
|
||||
0,
|
||||
&sndrcvinfo,
|
||||
&flags);
|
||||
|
||||
if(message_size == -1)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF Failed to peek sctp message size errno:%d\n", errno);
|
||||
return 0;
|
||||
}
|
||||
if (message_size == -1) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF Failed to peek sctp message size errno:%d\n", errno);
|
||||
return 0;
|
||||
}
|
||||
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
int unpack_result = nfapi_p5_message_header_unpack(header_buffer, header_buffer_size, &header, sizeof(header), 0);
|
||||
if(unpack_result < 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF Failed to unpack p5 message header\n");
|
||||
return 0;
|
||||
}
|
||||
message_size = header.message_length;
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
int unpack_result = nfapi_p5_message_header_unpack(header_buffer, header_buffer_size, &header, sizeof(header), 0);
|
||||
if (unpack_result < 0) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF Failed to unpack p5 message header\n");
|
||||
return 0;
|
||||
}
|
||||
message_size = header.message_length + header_buffer_size;
|
||||
|
||||
// now have the size of the mesage
|
||||
}
|
||||
// now have the size of the mesage
|
||||
}
|
||||
|
||||
if(message_size > stack_buffer_size)
|
||||
{
|
||||
dynamic_buffer = (uint8_t*)malloc(message_size);
|
||||
if (message_size > stack_buffer_size) {
|
||||
dynamic_buffer = (uint8_t*)malloc(message_size);
|
||||
|
||||
if(dynamic_buffer == NULL)
|
||||
{
|
||||
// todo : add error mesage
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF Failed to allocate dynamic buffer for sctp_recvmsg size:%d\n", message_size);
|
||||
return -1;
|
||||
}
|
||||
if (dynamic_buffer == NULL) {
|
||||
// todo : add error mesage
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "PNF Failed to allocate dynamic buffer for sctp_recvmsg size:%d\n", message_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
read_buffer = dynamic_buffer;
|
||||
}
|
||||
read_buffer = dynamic_buffer;
|
||||
}
|
||||
|
||||
{
|
||||
int flags = 0;
|
||||
(void)memset(&sndrcvinfo, 0, sizeof(struct sctp_sndrcvinfo));
|
||||
{
|
||||
int flags = 0;
|
||||
(void)memset(&sndrcvinfo, 0, sizeof(struct sctp_sndrcvinfo));
|
||||
|
||||
int recvmsg_result = sctp_recvmsg(pnf->p5_sock, read_buffer, message_size, (struct sockaddr*)&addr, &addr_len, &sndrcvinfo, &flags);
|
||||
if(recvmsg_result == -1)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "Failed to read sctp message size errno:%d\n", errno);
|
||||
}
|
||||
else
|
||||
{
|
||||
int recvmsg_result =
|
||||
sctp_recvmsg(pnf->p5_sock, read_buffer, message_size, (struct sockaddr*)&addr, &addr_len, &sndrcvinfo, &flags);
|
||||
if (recvmsg_result == -1) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "Failed to read sctp message size errno:%d\n", errno);
|
||||
} else {
|
||||
#if 0
|
||||
// print the received message
|
||||
printf("\n MESSAGE RECEIVED: \n");
|
||||
@@ -2211,56 +2211,44 @@ int pnf_nr_read_dispatch_message(pnf_t* pnf)
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
if (flags & MSG_NOTIFICATION)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "Notification received from %s:%u\n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));
|
||||
if (flags & MSG_NOTIFICATION) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "Notification received from %s:%u\n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));
|
||||
|
||||
// todo - handle the events
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "Received message fd:%d from %s:%u assoc:%d on stream %d, PPID %d, length %d, flags 0x%x\n",
|
||||
pnf->p5_sock,
|
||||
inet_ntoa(addr.sin_addr),
|
||||
ntohs(addr.sin_port),
|
||||
sndrcvinfo.sinfo_assoc_id,
|
||||
sndrcvinfo.sinfo_stream,
|
||||
ntohl(sndrcvinfo.sinfo_ppid),
|
||||
message_size,
|
||||
flags);
|
||||
*/
|
||||
// todo - handle the events
|
||||
} else {
|
||||
/*
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "Received message fd:%d from %s:%u assoc:%d on stream %d, PPID %d, length %d, flags 0x%x\n",
|
||||
pnf->p5_sock,
|
||||
inet_ntoa(addr.sin_addr),
|
||||
ntohs(addr.sin_port),
|
||||
sndrcvinfo.sinfo_assoc_id,
|
||||
sndrcvinfo.sinfo_stream,
|
||||
ntohl(sndrcvinfo.sinfo_ppid),
|
||||
message_size,
|
||||
flags);
|
||||
*/
|
||||
|
||||
// handle now if complete message in one or more segments
|
||||
if ((flags & 0x80) == 0x80)
|
||||
{
|
||||
pnf_nr_handle_p5_message(pnf, read_buffer, message_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_WARN, "sctp_recvmsg: unhandled mode with flags 0x%x\n", flags);
|
||||
// handle now if complete message in one or more segments
|
||||
if ((flags & 0x80) == 0x80) {
|
||||
pnf_nr_handle_p5_message(pnf, read_buffer, message_size);
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_WARN, "sctp_recvmsg: unhandled mode with flags 0x%x\n", flags);
|
||||
|
||||
// assume socket disconnected
|
||||
NFAPI_TRACE(NFAPI_TRACE_WARN, "Disconnected socket\n");
|
||||
socket_connected = 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(dynamic_buffer)
|
||||
{
|
||||
free(dynamic_buffer);
|
||||
}
|
||||
|
||||
return socket_connected;
|
||||
// assume socket disconnected
|
||||
NFAPI_TRACE(NFAPI_TRACE_WARN, "Disconnected socket\n");
|
||||
socket_connected = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dynamic_buffer) {
|
||||
free(dynamic_buffer);
|
||||
}
|
||||
|
||||
return socket_connected;
|
||||
}
|
||||
|
||||
|
||||
int pnf_message_pump(pnf_t* pnf)
|
||||
{
|
||||
uint8_t socketConnected = 1;
|
||||
|
||||
+88
-104
@@ -1240,134 +1240,118 @@ void vnf_handle_p4_p5_message(void *pRecvMsg, int recvMsgLen, int p5_idx, nfapi_
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int vnf_nr_read_dispatch_message(nfapi_vnf_config_t* config, nfapi_vnf_pnf_info_t* pnf)
|
||||
{
|
||||
if(1)
|
||||
{
|
||||
int socket_connected = 1;
|
||||
if (1) {
|
||||
int socket_connected = 1;
|
||||
|
||||
// 1. Peek the message header
|
||||
// 2. If the message is larger than the stack buffer then create a dynamic buffer
|
||||
// 3. Read the buffer
|
||||
// 4. Handle the p5 message
|
||||
|
||||
uint32_t header_buffer_size = NFAPI_HEADER_LENGTH;
|
||||
uint8_t header_buffer[header_buffer_size];
|
||||
// 1. Peek the message header
|
||||
// 2. If the message is larger than the stack buffer then create a dynamic buffer
|
||||
// 3. Read the buffer
|
||||
// 4. Handle the p5 message
|
||||
|
||||
uint32_t stack_buffer_size = 32; //should it be the size of then sctp_notificatoin structure
|
||||
uint8_t stack_buffer[stack_buffer_size];
|
||||
uint32_t header_buffer_size = NFAPI_HEADER_LENGTH;
|
||||
uint8_t header_buffer[header_buffer_size];
|
||||
|
||||
uint8_t* dynamic_buffer = 0;
|
||||
uint32_t stack_buffer_size = 32; // should it be the size of then sctp_notificatoin structure
|
||||
uint8_t stack_buffer[stack_buffer_size];
|
||||
|
||||
uint8_t* read_buffer = &stack_buffer[0];
|
||||
uint32_t message_size = 0;
|
||||
uint8_t* dynamic_buffer = 0;
|
||||
|
||||
struct sockaddr_in addr;
|
||||
socklen_t addr_len = sizeof(addr);
|
||||
uint8_t* read_buffer = &stack_buffer[0];
|
||||
uint32_t message_size = 0;
|
||||
|
||||
struct sctp_sndrcvinfo sndrcvinfo;
|
||||
(void)memset(&sndrcvinfo, 0, sizeof(struct sctp_sndrcvinfo));
|
||||
struct sockaddr_in addr;
|
||||
socklen_t addr_len = sizeof(addr);
|
||||
|
||||
{
|
||||
int flags = MSG_PEEK;
|
||||
message_size = sctp_recvmsg(pnf->p5_sock, header_buffer, header_buffer_size, (struct sockaddr*)&addr, &addr_len, &sndrcvinfo, &flags);
|
||||
struct sctp_sndrcvinfo sndrcvinfo;
|
||||
(void)memset(&sndrcvinfo, 0, sizeof(struct sctp_sndrcvinfo));
|
||||
|
||||
if(message_size == -1)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF Failed to peek sctp message size errno:%d\n", errno);
|
||||
return 0;
|
||||
}
|
||||
{
|
||||
int flags = MSG_PEEK;
|
||||
message_size =
|
||||
sctp_recvmsg(pnf->p5_sock, header_buffer, header_buffer_size, (struct sockaddr*)&addr, &addr_len, &sndrcvinfo, &flags);
|
||||
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
int unpack_result = nfapi_p5_message_header_unpack(header_buffer, header_buffer_size, &header, sizeof(header), 0);
|
||||
if(unpack_result < 0)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF Failed to decode message header %d\n", unpack_result);
|
||||
return 0;
|
||||
}
|
||||
message_size = header.message_length;
|
||||
if (message_size == -1) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF Failed to peek sctp message size errno:%d\n", errno);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// now have the size of the mesage
|
||||
}
|
||||
nfapi_p4_p5_message_header_t header;
|
||||
int unpack_result = nfapi_p5_message_header_unpack(header_buffer, header_buffer_size, &header, sizeof(header), 0);
|
||||
if (unpack_result < 0) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF Failed to decode message header %d\n", unpack_result);
|
||||
return 0;
|
||||
}
|
||||
message_size = header.message_length + header_buffer_size;
|
||||
|
||||
if(message_size > stack_buffer_size)
|
||||
{
|
||||
dynamic_buffer = (uint8_t*)malloc(message_size);
|
||||
// now have the size of the mesage
|
||||
}
|
||||
|
||||
if(dynamic_buffer == NULL)
|
||||
{
|
||||
// todo : add error mesage
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF Failed to allocate dynamic buffer for sctp_recvmsg size:%d\n", message_size);
|
||||
return -1;
|
||||
}
|
||||
if (message_size > stack_buffer_size) {
|
||||
dynamic_buffer = (uint8_t*)malloc(message_size);
|
||||
|
||||
read_buffer = dynamic_buffer;
|
||||
}
|
||||
if (dynamic_buffer == NULL) {
|
||||
// todo : add error mesage
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "VNF Failed to allocate dynamic buffer for sctp_recvmsg size:%d\n", message_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
{
|
||||
int flags = 0;
|
||||
(void)memset(&sndrcvinfo, 0, sizeof(struct sctp_sndrcvinfo));
|
||||
read_buffer = dynamic_buffer;
|
||||
}
|
||||
|
||||
int recvmsg_result = sctp_recvmsg(pnf->p5_sock, read_buffer, message_size, (struct sockaddr*)&addr, &addr_len, &sndrcvinfo, &flags);
|
||||
if(recvmsg_result == -1)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "Failed to read sctp message size errno:%d\n", errno);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (flags & MSG_NOTIFICATION)
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "Notification received from %s:%u\n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));
|
||||
{
|
||||
int flags = 0;
|
||||
(void)memset(&sndrcvinfo, 0, sizeof(struct sctp_sndrcvinfo));
|
||||
|
||||
// todo - handle the events
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "Received message fd:%d from %s:%u assoc:%d on stream %d, PPID %d, length %d, flags 0x%x\n",
|
||||
pnf->p5_sock,
|
||||
inet_ntoa(addr.sin_addr),
|
||||
ntohs(addr.sin_port),
|
||||
sndrcvinfo.sinfo_assoc_id,
|
||||
sndrcvinfo.sinfo_stream,
|
||||
ntohl(sndrcvinfo.sinfo_ppid),
|
||||
message_size,
|
||||
flags);
|
||||
*/
|
||||
int recvmsg_result =
|
||||
sctp_recvmsg(pnf->p5_sock, read_buffer, message_size, (struct sockaddr*)&addr, &addr_len, &sndrcvinfo, &flags);
|
||||
if (recvmsg_result == -1) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "Failed to read sctp message size errno:%d\n", errno);
|
||||
} else {
|
||||
if (flags & MSG_NOTIFICATION) {
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "Notification received from %s:%u\n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port));
|
||||
|
||||
// handle now if complete message in one or more segments
|
||||
if ((flags & 0x80) == 0x80)
|
||||
{
|
||||
// printf("\nVNF RECEIVES:\n");
|
||||
// for(int i=0; i<message_size; i++){
|
||||
// printf("%d", read_buffer[i]);
|
||||
// }
|
||||
// printf("\n");
|
||||
// todo - handle the events
|
||||
} else {
|
||||
/*
|
||||
NFAPI_TRACE(NFAPI_TRACE_INFO, "Received message fd:%d from %s:%u assoc:%d on stream %d, PPID %d, length %d, flags 0x%x\n",
|
||||
pnf->p5_sock,
|
||||
inet_ntoa(addr.sin_addr),
|
||||
ntohs(addr.sin_port),
|
||||
sndrcvinfo.sinfo_assoc_id,
|
||||
sndrcvinfo.sinfo_stream,
|
||||
ntohl(sndrcvinfo.sinfo_ppid),
|
||||
message_size,
|
||||
flags);
|
||||
*/
|
||||
|
||||
vnf_nr_handle_p4_p5_message(read_buffer, message_size, pnf->p5_idx, config);
|
||||
}
|
||||
else
|
||||
{
|
||||
NFAPI_TRACE(NFAPI_TRACE_WARN, "sctp_recvmsg: unhandled mode with flags 0x%x\n", flags);
|
||||
// handle now if complete message in one or more segments
|
||||
if ((flags & 0x80) == 0x80) {
|
||||
// printf("\nVNF RECEIVES:\n");
|
||||
// for(int i=0; i<message_size; i++){
|
||||
// printf("%d", read_buffer[i]);
|
||||
// }
|
||||
// printf("\n");
|
||||
|
||||
// assume socket disconnected
|
||||
NFAPI_TRACE(NFAPI_TRACE_WARN, "Disconnected socket\n");
|
||||
socket_connected = 0;
|
||||
}
|
||||
vnf_nr_handle_p4_p5_message(read_buffer, message_size, pnf->p5_idx, config);
|
||||
} else {
|
||||
NFAPI_TRACE(NFAPI_TRACE_WARN, "sctp_recvmsg: unhandled mode with flags 0x%x\n", flags);
|
||||
|
||||
// assume socket disconnected
|
||||
NFAPI_TRACE(NFAPI_TRACE_WARN, "Disconnected socket\n");
|
||||
socket_connected = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dynamic_buffer) {
|
||||
free(dynamic_buffer);
|
||||
}
|
||||
|
||||
if(dynamic_buffer)
|
||||
{
|
||||
free(dynamic_buffer);
|
||||
}
|
||||
|
||||
return socket_connected;
|
||||
}
|
||||
return socket_connected;
|
||||
}
|
||||
}
|
||||
|
||||
int vnf_read_dispatch_message(nfapi_vnf_config_t* config, nfapi_vnf_pnf_info_t* pnf)
|
||||
|
||||
Reference in New Issue
Block a user