Added custom error codes for p5

This commit is contained in:
MaheshK1995
2020-06-25 18:02:05 +05:30
parent e3a05b9af7
commit abefe1a095
11 changed files with 59 additions and 46 deletions
@@ -85,11 +85,6 @@ typedef struct {
nfapi_vendor_extension_tlv_t vendor_extension;
} nfapi_nr_param_request_t;
typedef enum {
NFAPI_NR_PARAM_MSG_OK = 0,
NFAPI_NR_PARAM_MSG_INVALID_STATE
} nfapi_nr_param_errors_e;
/*typedef struct {
nfapi_nr_param_errors_e error_code;
@@ -263,12 +258,6 @@ typedef struct
//-------------------------------------------//
//3.3.2 CONFIG
typedef enum {
NFAPI_NR_CONFIG_MSG_OK = 0,
NFAPI_NR_CONFIG_MSG_INVALID_CONFIG //The configuration provided has missing mandatory TLVs, or TLVs that are invalid or unsupported in this state.
} nfapi_nr_config_errors_e;
/*typedef struct {
nfapi_nr_config_errors_e error_code;
uint8_t number_of_invalid_tlvs_that_can_only_be_configured_in_idle;
@@ -448,6 +437,25 @@ typedef struct
} nfapi_nr_measurement_config_t;
// ERROR enums
typedef enum { // Table 2-22
NFAPI_NR_PARAM_MSG_OK = 0,
NFAPI_NR_PARAM_MSG_INVALID_STATE
} nfapi_nr_param_errors_e;
typedef enum { // Table 2-25
NFAPI_NR_CONFIG_MSG_OK = 0,
NFAPI_NR_CONFIG_MSG_INVALID_STATE, //The CONFIG.request was received when the PHY was not in the IDLE state or the CONFIGURED state.
NFAPI_NR_CONFIG_MSG_INVALID_CONFIG //The configuration provided has missing mandatory TLVs, or TLVs that are invalid or unsupported in this state.
} nfapi_nr_config_errors_e;
typedef enum { // Table 2-27
NFAPI_NR_START_MSG_OK = 0,
NFAPI_NR_START_MSG_INVALID_STATE
} nfapi_nr_start_errors_e;
/* PARAM.REQUEST */
typedef struct {
nfapi_p4_p5_message_header_t header;
@@ -479,7 +487,7 @@ typedef struct {
/* CONFIG.REQUEST */
typedef struct {
nfapi_p4_p5_message_header_t header;
nfapi_nr_param_errors_e error_code;
nfapi_nr_param_errors_e error_code; // TODO: check if needed
uint8_t num_tlv;
nfapi_vendor_extension_tlv_t vendor_extension;
@@ -497,10 +505,9 @@ typedef struct {
/* CONFIG.RESPONSE */
typedef struct {
// TODO: add here
nfapi_p4_p5_message_header_t header;
nfapi_nr_param_errors_e error_code;
uint8_t num_invalid_tlvs;
nfapi_nr_config_errors_e error_code;
//uint8_t num_invalid_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;
@@ -513,9 +520,11 @@ typedef struct {
nfapi_vendor_extension_tlv_t vendor_extension;
} nfapi_nr_start_request_scf_t;
typedef enum {
NFAPI_NR_START_MSG_INVALID_STATE
} nfapi_nr_start_errors_e;
typedef struct {
nfapi_p4_p5_message_header_t header;
nfapi_nr_start_errors_e error_code;
nfapi_vendor_extension_tlv_t vendor_extension;
} nfapi_nr_start_response_scf_t;
//3.3.4 STOP
@@ -524,6 +533,7 @@ typedef struct {
nfapi_vendor_extension_tlv_t vendor_extension;
} nfapi_nr_stop_request_t;
typedef struct {
nfapi_p4_p5_message_header_t header;
nfapi_vendor_extension_tlv_t vendor_extension;
+4 -4
View File
@@ -871,7 +871,7 @@ static uint8_t pack_start_request(void *msg, uint8_t **ppWritePackedMsg, uint8_t
static uint8_t pack_start_response(void *msg, uint8_t **ppWritePackedMsg, uint8_t *end, nfapi_p4_p5_codec_config_t* config)
{
nfapi_start_response_t *pNfapiMsg = (nfapi_start_response_t*)msg;
nfapi_nr_start_response_scf_t *pNfapiMsg = (nfapi_nr_start_response_scf_t*)msg;
return ( push32(pNfapiMsg->error_code, ppWritePackedMsg, end ) &&
pack_vendor_extension_tlv(pNfapiMsg->vendor_extension, ppWritePackedMsg, end, config) );
@@ -1809,7 +1809,7 @@ static uint8_t unpack_start_request(uint8_t **ppReadPackedMsg, uint8_t *end, voi
static uint8_t unpack_start_response(uint8_t **ppReadPackedMsg, uint8_t *end, void *msg, nfapi_p4_p5_codec_config_t* config)
{
nfapi_start_response_t *pNfapiMsg = (nfapi_start_response_t*)msg;
nfapi_nr_start_response_scf_t *pNfapiMsg = (nfapi_nr_start_response_scf_t*)msg;
unpack_tlv_t unpack_fns[] =
{
@@ -1957,8 +1957,8 @@ static int check_unpack_length(nfapi_message_id_e msgId, uint32_t unpackedBufLen
break;
case NFAPI_START_RESPONSE:
if (unpackedBufLen >= sizeof(nfapi_start_response_t))
retLen = sizeof(nfapi_start_response_t);
if (unpackedBufLen >= sizeof(nfapi_nr_start_response_scf_t))
retLen = sizeof(nfapi_nr_start_response_scf_t);
break;
case NFAPI_STOP_REQUEST:
@@ -421,7 +421,7 @@ int nfapi_pnf_config_resp(nfapi_pnf_config_t* config, nfapi_nr_config_response_s
* \return 0 for success, -1 for failure
*
*/
int nfapi_pnf_start_resp(nfapi_pnf_config_t* config, nfapi_start_response_t* resp);
int nfapi_pnf_start_resp(nfapi_pnf_config_t* config, nfapi_nr_start_response_scf_t* resp);
/*! Send the STOP.response
* \param config A pointer to a pnf configuraiton
+2 -2
View File
@@ -210,7 +210,7 @@ int nfapi_pnf_config_resp(nfapi_pnf_config_t* config, nfapi_nr_config_response_s
return pnf_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_nr_config_response_scf_t));
}
int nfapi_pnf_start_resp(nfapi_pnf_config_t* config, nfapi_start_response_t* resp)
int nfapi_pnf_start_resp(nfapi_pnf_config_t* config, nfapi_nr_start_response_scf_t* resp)
{
if (config == NULL || resp == NULL)
{
@@ -234,7 +234,7 @@ int nfapi_pnf_start_resp(nfapi_pnf_config_t* config, nfapi_start_response_t* res
return -1;
}
return pnf_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_start_response_t));
return pnf_pack_and_send_p5_message(_this, &(resp->header), sizeof(nfapi_nr_start_response_scf_t));
}
int nfapi_pnf_stop_resp(nfapi_pnf_config_t* config, nfapi_stop_response_t* resp)
@@ -286,7 +286,7 @@ typedef struct nfapi_vnf_config
* then the substructure pointers should be set to 0 and then the client should
* use the codec_config.deallocate function to release it at a future point
*/
int (*start_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_start_response_t* resp);
int (*start_resp)(nfapi_vnf_config_t* config, int p5_idx, nfapi_nr_start_response_scf_t* resp);
/*! A callback for the STOP.resp
* \param config A pointer to the vnf configuration
+15 -8
View File
@@ -302,6 +302,7 @@ void vnf_handle_param_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_
void vnf_handle_config_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_t* config, int p5_idx)
{
// ensure it's valid
if (pRecvMsg == NULL || config == NULL)
{
@@ -316,9 +317,13 @@ void vnf_handle_config_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config
// unpack the message
if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >=0 )
{
if(config->config_resp)
{
(config->config_resp)(config, p5_idx, &msg);
// check the error code:
if (msg.error_code == NFAPI_MSG_OK){
if(config->config_resp)
{
(config->config_resp)(config, p5_idx, &msg);
}
}
}
else
@@ -343,14 +348,16 @@ void vnf_handle_start_response(void *pRecvMsg, int recvMsgLen, nfapi_vnf_config_
{
NFAPI_TRACE(NFAPI_TRACE_INFO, "Received START_RESPONSE\n");
nfapi_start_response_t msg;
nfapi_nr_start_response_scf_t msg;
// unpack the message
if (nfapi_p5_message_unpack(pRecvMsg, recvMsgLen, &msg, sizeof(msg), &config->codec_config) >= 0)
{
if(config->start_resp)
{
(config->start_resp)(config, p5_idx, &msg);
{ // check the error code
if (msg.error_code == NFAPI_MSG_OK){
if(config->start_resp)
{
(config->start_resp)(config, p5_idx, &msg);
}
}
}
else