diff --git a/ChangeLog b/ChangeLog index 871d31d53615cb177e7d0d6ce1e248a4b4e36873..598eee743608bec225943ccfd1ac3b2e361e7b87 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2013-09-17 Andrea Bulgarelli + +* include/InputPacketStream.h (InputPacketStream): + ** dword getPacketDimension(byte* stream); + ** int detPacketType(byte* packet); +* include/Packet.h (Packet): bool verifyPacketValue(byte* stream); + + 2013-09-13 Andrea Bulgarelli TAG v2.0.7 * src/PartOfPacket.cpp (PartOfPacket::setByteStream): diff --git a/include/InputPacketStream.h b/include/InputPacketStream.h index af89c16b620f6ac436d68dca064850843eafbb9d..9e1dc324d3c90c38c3f05503bbe6e95ed2e32196 100644 --- a/include/InputPacketStream.h +++ b/include/InputPacketStream.h @@ -36,17 +36,26 @@ public: ~InputPacketStream(); - /// \return The index of packet type if it's recognized. 0 if packet isn't recogniezed. + /// \return The index of packet type if it's recognized. 0 if packet isn't recognized. /// \param prefix A ByteStream that contains the prefix of packet (if present). /// \param packetHeader A ByteStream that contains the packet header. /// \param packetDataField A ByteStream that contains the packet data field. int detPacketType(ByteStream* prefix, ByteStream* packetHeader, ByteStream* packetDataField); - /// \return The index of packet type if it's recognized. 0 if packet isn't recogniezed. + /// \return The index of packet type if it's recognized. 0 if packet isn't recognized. /// \param prefix A ByteStream that contains the prefix of packet (if present). /// \param packet A ByteStream that contains the packet. int detPacketType(ByteStream* prefix, ByteStream* packet); + ///It returns the index of the packet type contained in the stream. The stream* contains also the prefix (if present) + /// \return The index of packet type if it's recognized. 0 if packet isn't recognized. + /// \param packet A byte* that contains the packet. + int detPacketType(byte* packet); + + ///It returns the total dimension of the packet contained in the stream (without prefix). The stream* contains also the prefix (if present) + ///\param The stream with the prefix (if present) + dword getPacketDimension(byte* stream); + /// This method sets the generic input of the stream /// \param in An input. void setInput(Input* in); diff --git a/include/Packet.h b/include/Packet.h index 53efe149a1c1c45fd6fdb78b7fe7677f69950c30..e2b865cfd75041fb0331a934453f60dd70544df7 100644 --- a/include/Packet.h +++ b/include/Packet.h @@ -86,6 +86,10 @@ public: /// \return True if the ByteStream contains a packet bool verifyPacketValue(ByteStream* prefix, ByteStream* packet); + /// Verifies if within the byte* stream passed with arguments it's present a correct packet. The stream* contains also the prefix (if present) + /// \param stream A pointer to the stream of byte, with prefix and packet + bool verifyPacketValue(byte* stream); + /// Verifies if within the ByteStream passed with arguments it's present a correct packet. /// \pre The structure of the stream must be loaded. /// \param prefix This is the prefix of the packet. diff --git a/src/InputPacketStream.cpp b/src/InputPacketStream.cpp index 51b95fefad660f5aa72bf180c1fadc5812281634..db886e52c63de59a7adad321be615c856dcfe52f 100644 --- a/src/InputPacketStream.cpp +++ b/src/InputPacketStream.cpp @@ -69,6 +69,18 @@ int InputPacketStream::detPacketType(ByteStream* prefix, ByteStream* packet) } +int InputPacketStream::detPacketType(byte* packet) +{ + /// Iterate through list and output each element. + /// The packetType 0 is the packet not recognized + for (dword i = 1; iverifyPacketValue(packet)) + return i; + } + return 0; +} void InputPacketStream::setInput(Input* in) { @@ -145,3 +157,20 @@ Packet* InputPacketStream::readPacket() throw(PacketExceptionIO*) throw e; } } + +dword InputPacketStream::getPacketDimension(byte* stream) { + dword dimPre = 0; + if(prefix) + dimPre += dimPrefix; + //ByteStream* prefix = new ByteStream(stream, dimPre, bigendian); + + dword dim = 0; + dword dimHeader = headerReference->getDimension(); + dim += dimHeader; + ByteStream* tempHeader = new ByteStream(); + tempHeader->setStream(stream+dimPre, dimHeader, bigendian); + headerReference->setByteStream(tempHeader); + dim += headerReference->getPacketLength(); + delete tempHeader; + return dim; +} diff --git a/src/Packet.cpp b/src/Packet.cpp index 1fe9cd3de6ee4997babd4903468635ea2e396c07..33542caefba41df1b83741aa79bff399525324d7 100644 --- a/src/Packet.cpp +++ b/src/Packet.cpp @@ -835,3 +835,22 @@ char* Packet::printPacketOutputStream() char* c = b.printStreamInHexadecimal(); return c; } + +bool Packet::verifyPacketValue(byte* stream) { + + + dword dimPre = 0; + if(thereisprefix) + dimPre += dimPrefix; + ByteStream* prefix = new ByteStream(stream, dimPre, bigendian); + + dword dim = 0; + dword dimHeader = header->getDimension(); + dim += dimHeader; + tempHeader->setStream(stream+dimPre, dimHeader, bigendian); + header->setByteStream(tempHeader); + dim += header->getDimensionOfPacketLenght() + 1; + ByteStream* packet = new ByteStream(stream+dimPre, dim, bigendian); + + return verifyPacketValue(prefix, packet); +} diff --git a/version b/version index 8c3e788c8c7825c52b63d37a4805ecd24de17542..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/version +++ b/version @@ -1 +0,0 @@ -2.0.1