Refactor TLVEncoder
* deleted unused TLVEncoder.c * removed dependency from LOG module in TLVEncoder Macros
This commit is contained in:
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The OpenAirInterface Software Alliance licenses this file to You under
|
||||
* the OAI Public License, Version 1.1 (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.openairinterface.org/?page_id=698
|
||||
*
|
||||
* 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.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*-------------------------------------------------------------------------------
|
||||
* For more information about the OpenAirInterface (OAI) Software Alliance:
|
||||
* contact@openairinterface.org
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "TLVEncoder.h"
|
||||
|
||||
int errorCodeEncoder = 0;
|
||||
|
||||
const char *const errorCodeStringEncoder[] = {
|
||||
"No error",
|
||||
"Buffer NULL",
|
||||
"Buffer too short",
|
||||
"Octet string too long for IEI",
|
||||
"Wrong message type",
|
||||
"Protocol not supported",
|
||||
};
|
||||
|
||||
void tlv_encode_perror(void)
|
||||
{
|
||||
if (errorCodeEncoder >= 0)
|
||||
// No error or TLV_DECODE_ERR_OK
|
||||
return;
|
||||
|
||||
printf("error: (%d, %s)\n", errorCodeEncoder, errorCodeStringEncoder[errorCodeEncoder * -1]);
|
||||
}
|
||||
|
||||
@@ -84,32 +84,32 @@ typedef enum {
|
||||
* it cannot be further processed */
|
||||
#define TLV_ENCODE_FATAL_ERROR (TLV_ENCODE_VALUE_DOESNT_MATCH)
|
||||
|
||||
extern int errorCodeEncoder;
|
||||
#ifdef ENABLE_TESTS
|
||||
#define TLV_ENC_ERROR(...) fprintf(stderr, "TLV Encoder: " __VA_ARGS__)
|
||||
#else
|
||||
#define TLV_ENC_ERROR(...) // Do nothing
|
||||
#endif
|
||||
|
||||
void tlv_encode_perror(void);
|
||||
#define CHECK_PDU_POINTER_AND_LENGTH_ENCODER(bUFFER, mINIMUMlENGTH, lENGTH) \
|
||||
do { \
|
||||
if ((bUFFER) == NULL) { \
|
||||
TLV_ENC_ERROR("Got NULL pointer for the payload\n"); \
|
||||
return TLV_ENCODE_BUFFER_NULL; \
|
||||
} \
|
||||
if ((lENGTH) < (mINIMUMlENGTH)) { \
|
||||
TLV_ENC_ERROR("(%s:%d) Expecting at least %d bytes, got %u\n", __FILE__, __LINE__, (mINIMUMlENGTH), (lENGTH)); \
|
||||
return TLV_ENCODE_BUFFER_TOO_SHORT; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define CHECK_PDU_POINTER_AND_LENGTH_ENCODER(bUFFER, mINIMUMlENGTH, lENGTH) \
|
||||
if (bUFFER == NULL) \
|
||||
{ \
|
||||
printf("Got NULL pointer for the payload\n"); \
|
||||
errorCodeEncoder = TLV_ENCODE_BUFFER_NULL; \
|
||||
return TLV_ENCODE_BUFFER_NULL; \
|
||||
} \
|
||||
if (lENGTH < mINIMUMlENGTH) \
|
||||
{ \
|
||||
printf("(%s:%d) Expecting at least %d bytes, got %u\n", \
|
||||
__FILE__, __LINE__, mINIMUMlENGTH, lENGTH); \
|
||||
errorCodeEncoder = TLV_ENCODE_BUFFER_TOO_SHORT; \
|
||||
return TLV_ENCODE_BUFFER_TOO_SHORT; \
|
||||
}
|
||||
|
||||
#define CHECK_PDU_POINTER_ENCODER(bUFFER) \
|
||||
if (bUFFER == NULL) \
|
||||
{ \
|
||||
printf("Got NULL pointer for the payload\n"); \
|
||||
errorCodeEncoder = TLV_ENCODE_BUFFER_NULL; \
|
||||
return TLV_ENCODE_BUFFER_NULL; \
|
||||
}
|
||||
#define CHECK_PDU_POINTER_ENCODER(bUFFER) \
|
||||
do { \
|
||||
if ((bUFFER) == NULL) { \
|
||||
TLV_ENC_ERROR("Got NULL pointer for the payload\n"); \
|
||||
errorCodeEncoder = TLV_ENCODE_BUFFER_NULL; \
|
||||
return TLV_ENCODE_BUFFER_NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif /* define (TLV_ENCODER_H_) */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user