Refactor TLVEncoder
* deleted unused TLVEncoder.c * removed dependency from LOG module in TLVEncoder Macros
This commit is contained in:
@@ -1678,7 +1678,6 @@ set (libnas_utils_OBJS
|
|||||||
${NAS_SRC}COMMON/UTIL/nas_timer.c
|
${NAS_SRC}COMMON/UTIL/nas_timer.c
|
||||||
${NAS_SRC}COMMON/UTIL/socket.c
|
${NAS_SRC}COMMON/UTIL/socket.c
|
||||||
${NAS_SRC}COMMON/UTIL/stty.c
|
${NAS_SRC}COMMON/UTIL/stty.c
|
||||||
${NAS_SRC}COMMON/UTIL/TLVEncoder.c
|
|
||||||
${NAS_SRC}COMMON/UTIL/TLVDecoder.c
|
${NAS_SRC}COMMON/UTIL/TLVDecoder.c
|
||||||
${NAS_SRC}COMMON/UTIL/OctetString.c
|
${NAS_SRC}COMMON/UTIL/OctetString.c
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -145,7 +145,6 @@ set(util_SRC
|
|||||||
${OPENAIR_NAS_DIR}/COMMON/UTIL/OctetString.c
|
${OPENAIR_NAS_DIR}/COMMON/UTIL/OctetString.c
|
||||||
${OPENAIR_NAS_DIR}/COMMON/UTIL/parser.c
|
${OPENAIR_NAS_DIR}/COMMON/UTIL/parser.c
|
||||||
${OPENAIR_NAS_DIR}/COMMON/UTIL/TLVDecoder.c
|
${OPENAIR_NAS_DIR}/COMMON/UTIL/TLVDecoder.c
|
||||||
${OPENAIR_NAS_DIR}/COMMON/UTIL/TLVEncoder.c
|
|
||||||
${OPENAIR_NAS_DIR}/COMMON/UTIL/socket.c
|
${OPENAIR_NAS_DIR}/COMMON/UTIL/socket.c
|
||||||
${OPENAIR_NAS_DIR}/COMMON/UTIL/stty.c
|
${OPENAIR_NAS_DIR}/COMMON/UTIL/stty.c
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ set(CONF2UEDATA_LIB_SRC
|
|||||||
${OPENAIR_DIR}/openair3/NAS/UE/API/USIM/aka_functions.c
|
${OPENAIR_DIR}/openair3/NAS/UE/API/USIM/aka_functions.c
|
||||||
${OPENAIR_DIR}/common/utils/mem/memory.c
|
${OPENAIR_DIR}/common/utils/mem/memory.c
|
||||||
${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/OctetString.c
|
${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/OctetString.c
|
||||||
${OPENAIR_DIR}/openair3/NAS/COMMON/UTIL/TLVEncoder.c
|
|
||||||
${OPENAIR_DIR}/common/utils/utils.c
|
${OPENAIR_DIR}/common/utils/utils.c
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1332,7 +1332,6 @@ INPUT = \
|
|||||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/UTIL/parser.h \
|
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/UTIL/parser.h \
|
||||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/UTIL/device.h \
|
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/UTIL/device.h \
|
||||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/UTIL/device.c \
|
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/UTIL/device.c \
|
||||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/UTIL/TLVEncoder.c \
|
|
||||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/UTIL/OctetString.h \
|
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/UTIL/OctetString.h \
|
||||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/UTIL/nas_timer.c \
|
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/UTIL/nas_timer.c \
|
||||||
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/UTIL/TLVDecoder.c \
|
@CMAKE_CURRENT_SOURCE_DIR@/../openair3/NAS/COMMON/UTIL/TLVDecoder.c \
|
||||||
|
|||||||
@@ -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 */
|
* it cannot be further processed */
|
||||||
#define TLV_ENCODE_FATAL_ERROR (TLV_ENCODE_VALUE_DOESNT_MATCH)
|
#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) \
|
#define CHECK_PDU_POINTER_ENCODER(bUFFER) \
|
||||||
if (bUFFER == NULL) \
|
do { \
|
||||||
{ \
|
if ((bUFFER) == NULL) { \
|
||||||
printf("Got NULL pointer for the payload\n"); \
|
TLV_ENC_ERROR("Got NULL pointer for the payload\n"); \
|
||||||
errorCodeEncoder = TLV_ENCODE_BUFFER_NULL; \
|
errorCodeEncoder = TLV_ENCODE_BUFFER_NULL; \
|
||||||
return TLV_ENCODE_BUFFER_NULL; \
|
return TLV_ENCODE_BUFFER_NULL; \
|
||||||
} \
|
} \
|
||||||
if (lENGTH < mINIMUMlENGTH) \
|
} while (0)
|
||||||
{ \
|
|
||||||
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; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* define (TLV_ENCODER_H_) */
|
#endif /* define (TLV_ENCODER_H_) */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user