From 63b3a1500087e7a3c6771d27a357c1fafaf3b0f6 Mon Sep 17 00:00:00 2001 From: daniel_peintner Date: Tue, 19 Sep 2017 08:22:34 +0000 Subject: [PATCH] fix V2GTP header length from 16 to 32 bits as suggested in https://sourceforge.net/p/openv2g/tickets/10/ git-svn-id: https://svn.code.sf.net/p/openv2g/code/trunk@106 d9f2db14-54d0-4bde-b00c-16405c910529 --- src/test/main.c | 2 +- src/test/main.h | 2 +- src/test/main_databinder.c | 2 +- src/test/main_example.c | 8 ++++---- src/transport/v2gtp.c | 16 +++++----------- src/transport/v2gtp.h | 7 ++++--- 6 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/test/main.c b/src/test/main.c index 087c349..59c3f3e 100644 --- a/src/test/main.c +++ b/src/test/main.c @@ -20,7 +20,7 @@ * @author Daniel.Peintner.EXT@siemens.com * @author Sebastian.Kaebisch@siemens.com * @version 1.0.0alpha - * @contact Joerg.Heuer@siemens.com + * @contact Richard.Kuntschke@siemens.com * *

Switch for sample programs: EXI codec only or for entire V2G example

* diff --git a/src/test/main.h b/src/test/main.h index b5838ab..42a4c00 100644 --- a/src/test/main.h +++ b/src/test/main.h @@ -20,7 +20,7 @@ * @author Daniel.Peintner.EXT@siemens.com * @author Sebastian.Kaebisch@siemens.com * @version 1.0.0alpha - * @contact Joerg.Heuer@siemens.com + * @contact Richard.Kuntschke@siemens.com * * ********************************************************************/ diff --git a/src/test/main_databinder.c b/src/test/main_databinder.c index 835ca19..e16e2f3 100644 --- a/src/test/main_databinder.c +++ b/src/test/main_databinder.c @@ -19,7 +19,7 @@ * * @author Daniel.Peintner.EXT@siemens.com * @version 1.0.0alpha - * @contact Joerg.Heuer@siemens.com + * @contact Richard.Kuntschke@siemens.com * *

Code generated by EXIdizer

*

Schema: V2G_CI_MsgDef.xsd

diff --git a/src/test/main_example.c b/src/test/main_example.c index 52c934c..2985755 100644 --- a/src/test/main_example.c +++ b/src/test/main_example.c @@ -20,7 +20,7 @@ * @author Daniel.Peintner.EXT@siemens.com * @author Sebastian.Kaebisch@siemens.com * @version 1.0.0alpha - * @contact Joerg.Heuer@siemens.com + * @contact Richard.Kuntschke@siemens.com * * ********************************************************************/ @@ -140,7 +140,7 @@ static int serializeEXI2Stream(struct iso2EXIDocument* exiIn, bitstream_t* strea /* deserializes V2G TP header and decodes right away EXI stream */ static int deserializeStream2EXI(bitstream_t* streamIn, struct iso2EXIDocument* exi) { int errn; - uint16_t payloadLength; + uint32_t payloadLength; *streamIn->pos = 0; if ( (errn = read_v2gtpHeader(streamIn->data, &payloadLength)) == 0) { @@ -157,7 +157,7 @@ static int appHandshakeHandler(bitstream_t* iStream, bitstream_t* oStream) { int i; struct appHandEXIDocument exiDoc; int errn = 0; - uint16_t payloadLengthDec; + uint32_t payloadLengthDec; if ( (errn = read_v2gtpHeader(iStream->data, &payloadLengthDec)) == 0) { @@ -207,7 +207,7 @@ static int appHandshake() bitstream_t stream1; bitstream_t stream2; - uint16_t payloadLengthDec; + uint32_t payloadLengthDec; size_t pos1 = V2GTP_HEADER_LENGTH; /* v2gtp header */ size_t pos2 = 0; diff --git a/src/transport/v2gtp.c b/src/transport/v2gtp.c index 0dccd7c..e5c6d3f 100644 --- a/src/transport/v2gtp.c +++ b/src/transport/v2gtp.c @@ -21,7 +21,7 @@ * @author Sebastian.Kaebisch@siemens.com * @author Daniel.Peintner.EXT@siemens.com * @version 1.0.0alpha - * @contact Joerg.Heuer@siemens.com + * @contact Richard.Kuntschke@siemens.com * ********************************************************************/ @@ -40,7 +40,7 @@ #include "v2gtp.h" -int write_v2gtpHeader(uint8_t* outStream, uint16_t outStreamLength, uint16_t payloadType) +int write_v2gtpHeader(uint8_t* outStream, uint32_t outStreamLength, uint16_t payloadType) { /* write v2gtp version number 1=byte */ @@ -57,16 +57,13 @@ int write_v2gtpHeader(uint8_t* outStream, uint16_t outStreamLength, uint16_t pay /* write payload length */ outStream[7] = (uint8_t)(outStreamLength & 0xFF); outStream[6] = (uint8_t)(outStreamLength>>8 & 0xFF); - outStream[5] = (uint8_t) 0; /* uint16 only, no need for (outStreamLength>>16 & 0xFF); */ - outStream[4] = (uint8_t) 0; /* uint16 only, no need for (outStreamLength>>24 & 0xFF); */ - - /* here, the outStream length have to be resized by the v2gtp offset*/ - /**outStreamLength += V2GTP_HEADER_LENGTH;*/ + outStream[5] = (uint8_t)(outStreamLength>>16 & 0xFF); + outStream[4] = (uint8_t)(outStreamLength>>24 & 0xFF); return 0; } -int read_v2gtpHeader(uint8_t* inStream, uint16_t* payloadLength) +int read_v2gtpHeader(uint8_t* inStream, uint32_t* payloadLength) { uint16_t payloadType=0; @@ -90,9 +87,6 @@ int read_v2gtpHeader(uint8_t* inStream, uint16_t* payloadLength) *payloadLength = (*payloadLength << 8 | inStream[6]); *payloadLength = (*payloadLength << 8 | inStream[7]); - /* if((*payloadLength+V2GTP_HEADER_LENGTH)!=inStreamLength) - return -1; */ - return 0; } diff --git a/src/transport/v2gtp.h b/src/transport/v2gtp.h index 3e8a4bc..f883893 100644 --- a/src/transport/v2gtp.h +++ b/src/transport/v2gtp.h @@ -19,8 +19,9 @@ /******************************************************************* * * @author Sebastian.Kaebisch@siemens.com + * @author Daniel.Peintner.EXT@siemens.com * @version 1.0.0alpha - * @contact Joerg.Heuer@siemens.com + * @contact Richard.Kuntschke@siemens.com * ********************************************************************/ @@ -43,9 +44,9 @@ extern "C" { /* define V2GTP payload types*/ #define V2GTP_EXI_TYPE 0x8001 -int write_v2gtpHeader(uint8_t* outStream, uint16_t outStreamLength, uint16_t payloadType); +int write_v2gtpHeader(uint8_t* outStream, uint32_t outStreamLength, uint16_t payloadType); -int read_v2gtpHeader(uint8_t* inStream, uint16_t* payloadLength); +int read_v2gtpHeader(uint8_t* inStream, uint32_t* payloadLength); #endif /* V2GTP_H_ */