Skip to content

Commit

Permalink
Adding big int support (#18)
Browse files Browse the repository at this point in the history
* Adding big int support

Signed-off-by: Sebastian Lukas <[email protected]>

* Update cbexigen generator hash and branch

Signed-off-by: Kai-Uwe Hermann <[email protected]>

* Bump version to 0.2.1

Signed-off-by: Kai-Uwe Hermann <[email protected]>

---------

Signed-off-by: Sebastian Lukas <[email protected]>
Signed-off-by: Kai-Uwe Hermann <[email protected]>
Co-authored-by: Kai-Uwe Hermann <[email protected]>
  • Loading branch information
SebaLukas and hikinggrass authored Oct 25, 2024
1 parent ee578a0 commit 0966194
Show file tree
Hide file tree
Showing 31 changed files with 24,482 additions and 24,226 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.14)

project(cb_v2g
VERSION 0.1
VERSION 0.2.1
DESCRIPTION "V2GTP EXI library"
HOMEPAGE_URL "https://github.com/Everest/libcbv2g"
LANGUAGES C CXX
Expand All @@ -16,7 +16,7 @@ option(CB_V2G_INSTALL "Install the library (shared data might be installed anywa

add_subdirectory(lib)

message(STATUS "library code based on cbexigen generator version: 90c70d0")
message(STATUS "library code based on cbexigen generator version: 98e3fd3 @ feature/use_big_int_for_integer_fixup")

# tests
if (CB_V2G_BUILD_TESTS)
Expand Down
23 changes: 20 additions & 3 deletions include/cbv2g/common/exi_basetypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ extern "C" {
#define EXI_STRING_MAX_LEN 64
#define EXI_BYTE_ARRAY_MAX_LEN 350

#define EXI_BASETYPES_MAX_OCTETS_SUPPORTED 10
// To support EXI integer 8/7 coding, this needs to be 8/7 of the desired
// size of 25 for EXI representation
#define EXI_BASETYPES_MAX_OCTETS_SUPPORTED 29

#define EXI_BASETYPES_OCTET_SEQ_FLAG_MASK 0x80
#define EXI_BASETYPES_OCTET_SEQ_VALUE_MASK 0x7F
Expand All @@ -66,13 +68,28 @@ typedef struct
size_t octets_count;
} exi_unsigned_t;

typedef struct exi_signed_t
{
exi_unsigned_t data;
uint8_t is_negative : 1;
} exi_signed_t;

typedef char exi_character_t;

int exi_basetypes_convert_to_unsigned(exi_unsigned_t* exi_unsigned, uint32_t value, size_t max_octets);
int exi_basetypes_convert_64_to_unsigned(exi_unsigned_t* exi_unsigned, uint64_t value);

int exi_basetypes_convert_from_unsigned(exi_unsigned_t* exi_unsigned, uint32_t* value, size_t max_octets);
int exi_basetypes_convert_64_from_unsigned(exi_unsigned_t* exi_unsigned, uint64_t* value);
int exi_basetypes_convert_from_unsigned(const exi_unsigned_t* exi_unsigned, uint32_t* value, size_t max_octets);
int exi_basetypes_convert_64_from_unsigned(const exi_unsigned_t* exi_unsigned, uint64_t* value);

int exi_basetypes_convert_to_signed(exi_signed_t* exi_signed, int32_t value, size_t max_octets);
int exi_basetypes_convert_64_to_signed(exi_signed_t* exi_signed, int64_t value);

int exi_basetypes_convert_from_signed(const exi_signed_t* exi_unsigned, int32_t* value, size_t max_octets);
int exi_basetypes_convert_64_from_signed(const exi_signed_t* exi_unsigned, int64_t* value);

int exi_basetypes_convert_bytes_from_unsigned(const exi_unsigned_t* exi_unsigned, uint8_t* data, size_t* data_len, size_t data_size);
int exi_basetypes_convert_bytes_to_unsigned(exi_unsigned_t* exi_unsigned, const uint8_t* data, size_t data_len);


#ifdef __cplusplus
Expand Down
2 changes: 2 additions & 0 deletions include/cbv2g/common/exi_basetypes_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ int exi_basetypes_decoder_uint_8(exi_bitstream_t* stream, uint8_t* value);
int exi_basetypes_decoder_uint_16(exi_bitstream_t* stream, uint16_t* value);
int exi_basetypes_decoder_uint_32(exi_bitstream_t* stream, uint32_t* value);
int exi_basetypes_decoder_uint_64(exi_bitstream_t* stream, uint64_t* value);
int exi_basetypes_decoder_unsigned(exi_bitstream_t* stream, exi_unsigned_t* value);

/**
* \brief decoder for type integer
Expand All @@ -105,6 +106,7 @@ int exi_basetypes_decoder_integer_8(exi_bitstream_t* stream, int8_t* value);
int exi_basetypes_decoder_integer_16(exi_bitstream_t* stream, int16_t* value);
int exi_basetypes_decoder_integer_32(exi_bitstream_t* stream, int32_t* value);
int exi_basetypes_decoder_integer_64(exi_bitstream_t* stream, int64_t* value);
int exi_basetypes_decoder_signed(exi_bitstream_t* stream, exi_signed_t* value);

/**
* \brief decoder for type character array
Expand Down
2 changes: 2 additions & 0 deletions include/cbv2g/common/exi_basetypes_encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ int exi_basetypes_encoder_uint_8(exi_bitstream_t* stream, uint8_t value);
int exi_basetypes_encoder_uint_16(exi_bitstream_t* stream, uint16_t value);
int exi_basetypes_encoder_uint_32(exi_bitstream_t* stream, uint32_t value);
int exi_basetypes_encoder_uint_64(exi_bitstream_t* stream, uint64_t value);
int exi_basetypes_encoder_unsigned(exi_bitstream_t* stream, const exi_unsigned_t* value);

/**
* \brief encoder for type integer
Expand All @@ -105,6 +106,7 @@ int exi_basetypes_encoder_integer_8(exi_bitstream_t* stream, int8_t value);
int exi_basetypes_encoder_integer_16(exi_bitstream_t* stream, int16_t value);
int exi_basetypes_encoder_integer_32(exi_bitstream_t* stream, int32_t value);
int exi_basetypes_encoder_integer_64(exi_bitstream_t* stream, int64_t value);
int exi_basetypes_encoder_signed(exi_bitstream_t* stream, const exi_signed_t* value);

/**
* \brief encoder for type exi_character array
Expand Down
1 change: 1 addition & 0 deletions include/cbv2g/common/exi_error_codes.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ extern "C" {
#define EXI_ERROR__ARRAY_OUT_OF_BOUNDS -110
#define EXI_ERROR__CHARACTER_BUFFER_TOO_SMALL -111
#define EXI_ERROR__BYTE_BUFFER_TOO_SMALL -112
#define EXI_ERROR__ENCODED_INTEGER_SIZE_LARGER_THAN_DESTINATION -113

// grammar errors -130 to -149
#define EXI_ERROR__UNKNOWN_GRAMMAR_ID -130
Expand Down
Loading

0 comments on commit 0966194

Please sign in to comment.