From 8a514ea8f10f91d7b30dd10017480b5bf20a5868 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Wed, 9 Jan 2019 16:28:06 +0100 Subject: [PATCH] REM: remove unused files --- armsrc/tlv.c | 94 ---------------------------------------------------- armsrc/tlv.h | 38 --------------------- 2 files changed, 132 deletions(-) delete mode 100644 armsrc/tlv.c delete mode 100644 armsrc/tlv.h diff --git a/armsrc/tlv.c b/armsrc/tlv.c deleted file mode 100644 index 839b34d66..000000000 --- a/armsrc/tlv.c +++ /dev/null @@ -1,94 +0,0 @@ -#include - -int decode_ber_tlv_item(uint8_t* data, tlvtag* returnedtag) -{ - uint8_t tag[TAG_LENGTH] = {0x00, 0x00, 0x00, 0x00}; - uint16_t length = 0; - //uint8_t value[VALUE_LENGTH]; - uint8_t lenlen = 0; - int i = 0; - int z = 0; - //decode tag - tag[0] = data[0]; - if ((tag[0] & TLV_TAG_NUMBER_MASK) == TLV_TAG_NUMBER_MASK) { //see subsequent bytes - i++; - - tag[i] = data[i]; - - while((data[i] & TLV_TAG_MASK) == TLV_TAG_MASK){ - i++; - tag[i] = data[i]; - } - - } - i++; - //decode length - if ((data[i] & TLV_LENGTH_MASK) == TLV_LENGTH_MASK) { - lenlen = data[i] ^ TLV_LENGTH_MASK; - i++; - length = (uint16_t)data[i]; - z = 1; - while (z < lenlen) { - i++; - z++; - length <<= 8; - length += (uint16_t)data[i]; - } - i++; - } else { - length = (uint16_t)data[i]; - i++; - } - // copy results into the structure and return - memcpy(returnedtag->tag, tag, TAG_LENGTH); - - // return length of tag value - (*returnedtag).valuelength = length; - - // return length of total field - (*returnedtag).fieldlength = length + i + 1; - - memcpy(returnedtag->value, &(data[i]), length); - return 0; -} - -//generate a TLV tag off input data -int encode_ber_tlv_item(uint8_t* tag, uint8_t taglen, uint8_t* data, uint32_t datalen, uint8_t* outputtag, uint32_t* outputtaglen) -{ - if (!tag || !data || !outputtag || !outputtaglen) - return 0; - - // field length of the tag - uint8_t datafieldlen = (datalen / 128) + 1; - - // total length of the tag - uint8_t tlvtotallen = taglen + datafieldlen + datalen; - - // buffer for the returned tag - uint8_t returnedtag[tlvtotallen]; - - uint8_t counter = 0; - - // copy tag into buffer - memcpy(returnedtag, tag, taglen); - counter += taglen; - - // 1 byte length value - if (datalen < 128){ - returnedtag[counter++] = datalen; - } else { - - // high bit set and number of length bytes - returnedtag[counter++] = datafieldlen | 0x80; - - for (uint8_t i = datafieldlen; i !=0; i--) { - // get current byte - returnedtag[counter++] = (datalen >> (i * 8)) & 0xFF; - } - } - memcpy(&returnedtag[counter], data, datalen); - *outputtaglen = tlvtotallen; - memcpy(outputtag, returnedtag, tlvtotallen); - return 0; -} - diff --git a/armsrc/tlv.h b/armsrc/tlv.h deleted file mode 100644 index de8180cab..000000000 --- a/armsrc/tlv.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef __TLV_H -#define __TLV_H - -#include -#include -#include - -//structure buffer definitions -#ifndef TAG_LENGTH -# define TAG_LENGTH 4 -#endif - -#ifndef VALUE_LENGTH -# define VALUE_LENGTH 1024 -#endif - -//masks -//if TLV_TAG_NUMBER_MASK bits are set, refer to the next byte for the tag number -//otherwise its located in bits 1-5 -#define TLV_TAG_NUMBER_MASK 0x1f -//if TLV_DATA_MASK set then its a 'constructed data object' -//otherwise a 'primitive data object' -#define TLV_DATA_MASK 0x20 -#define TLV_TAG_MASK 0x80 -#define TLV_LENGTH_MASK 0x80 - -//tlv tag structure, tag can be max of 4 bytes, length up to 0xFFFFFFFF and value 1024 bytes long -typedef struct { - uint8_t tag[TAG_LENGTH]; - uint16_t fieldlength; - uint16_t valuelength; - uint8_t value[VALUE_LENGTH]; -} tlvtag; - -//decode a BER TLV -extern int decode_ber_tlv_item(uint8_t* data, tlvtag* returnedtag); -extern int encode_ber_tlv_item(uint8_t* tag, uint8_t taglen, uint8_t*data, uint32_t datalen, uint8_t* outputtag, uint32_t* outputtaglen); -#endif //__TLV_H