Commit 7d6f604e authored by Andrea Bulgarelli's avatar Andrea Bulgarelli
Browse files

from Packet::set to Packet::decode; PacketStream::getPacketType(string name);...

from Packet::set to Packet::decode; PacketStream::getPacketType(string name); from Packet::getOutputStream() to Packet::encode()
parent 095a1f8c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ public:
    /// Returns a pointer of the stream for output purpose. If there is problems return NULL
    /// \remarks In little endian architecture it is necessary to call endOutputStream()
    /// after the use of the byte* stream in output operations.
    byte* getOutputStream();
    byte* encode();

    // This method must be called after the output operation.
    void endOutputStream();
+46 −46
Original line number Diff line number Diff line
@@ -59,20 +59,20 @@ public:
	/// Sets the ByteStream.
    /// \param stream A pointer to the stream of byte, with prefix and packet
	/// \param checkPacketLenght if true check the packet lenght and set the packet stream, if false do not check the packet lenght
    virtual bool set(ByteStreamPtr stream, bool checkPacketLenght = false);
    virtual bool decode(ByteStreamPtr stream, bool checkPacketLenght = false);
	
	/// Sets the ByteStream.
    /// \param prefix A pointer to the stream of byte, with the prefix
	/// \param packet A pointer to the stream of byte, with the packet
	/// \param checkPacketLenght if true check the packet lenght and set the packet stream, if false do not check the packet lenght
    virtual bool set(ByteStreamPtr prefix, ByteStreamPtr packet, bool checkPacketLenght = false);
    virtual bool decode(ByteStreamPtr prefix, ByteStreamPtr packet, bool checkPacketLenght = false);
	
	/// Sets the ByteStream.
    /// \param prefix A pointer to the stream of byte, with the prefix
	/// \param packetHeader A pointer to the stream of byte, with the packet header
	/// \param packetHeader A pointer to the stream of byte, with the packet data field
	/// \param checkPacketLenght if true check the packet lenght and set the packet stream, if false do not check the packet lenght
    virtual bool set(ByteStreamPtr prefix, ByteStreamPtr packetHeader, ByteStreamPtr packetDataField, bool checkPacketLenght = false);
    virtual bool decode(ByteStreamPtr prefix, ByteStreamPtr packetHeader, ByteStreamPtr packetDataField, bool checkPacketLenght = false);
	
	///return true is the packet contained into the stream is recognized using identifiers.
	///\pre the ByteStream is set with one of set(ByteStream) methods
@@ -104,13 +104,13 @@ public:
	///Get the the source data field as a ByteStream
	ByteStreamPtr getBSSourceDataField();
		
	///Get the tail as a ByteStream
	ByteStreamPtr getBSTail();
	
	///Copy an array of bytes into the source data field. The size must be the same.
	///It is necessary to set the number of blocks of each rblocks before.
	void copyBSSourceDataField(byte* bytestream, dword size);

	///Get the tail as a ByteStream
	ByteStreamPtr getBSTail();
	
	///
	PacketHeader* getPacketHeader();
	
@@ -123,39 +123,6 @@ public:
	///
	PartOfPacket* getPacketTail();
	

    /// Prints to stdout the value of packet data field in a formatted mode.
    virtual void printPacketValue();

    /// Prints the hexadecimal dump of the prefix.
    virtual  char* printPrefixStream();

    /// Prints the header values.
    virtual  char** printHeaderValue();

    /// Prints the hexadecimal dump of the header.
    virtual  char* printHeaderStream();

    /// Prints the data field header values.
    virtual  char** printDataFieldHeaderValue();

    /// Prints the hexadecimal dump of the data field header.
    virtual  char* printDataFieldHeaderStream();
    
    /// Prints the source data field values.
    virtual  char** printSourceDataFieldValue();

    /// Prints the hexadecimal dump of the source data field.
    virtual  char* printSourceDataFieldStream();
    
    /// Prints the tail values
    virtual  char** printTailValue();

    /// Print he hexadecimal dump of the tail.
    virtual  char* printTailStream();

    virtual  char* printPacketOutputStream();

	/// Gets the dimension in byte of the current packet (header + datafield (data field header + sdf + tail)
    dword size();
	
@@ -171,14 +138,13 @@ public:
    /// Gets the max dimension in byte of the packet.
    dword sizeMax();
    
    
    /// Gets the ByteStream received as input
    ByteStreamPtr getInputStream();

    
    /// Gets the packet generated with the generateStream() method. The output
    /// Gets the encoded method. The output
    /// packet is generated during this call.
    ByteStreamPtr getOutputStream();
    ByteStreamPtr encode();

    
    /// Gets the name of packet.
@@ -217,6 +183,40 @@ public:
		return iscompressed;
	}
	
	
	
    /// Prints to stdout the value of packet data field in a formatted mode.
    virtual void printPacketValue();
	
    /// Prints the hexadecimal dump of the prefix.
    virtual  char* printPrefixStream();
	
    /// Prints the header values.
    virtual  char** printHeaderValue();
	
    /// Prints the hexadecimal dump of the header.
    virtual  char* printHeaderStream();
	
    /// Prints the data field header values.
    virtual  char** printDataFieldHeaderValue();
	
    /// Prints the hexadecimal dump of the data field header.
    virtual  char* printDataFieldHeaderStream();
    
    /// Prints the source data field values.
    virtual  char** printSourceDataFieldValue();
	
    /// Prints the hexadecimal dump of the source data field.
    virtual  char* printSourceDataFieldStream();
    
    /// Prints the tail values
    virtual  char** printTailValue();
	
    /// Print he hexadecimal dump of the tail.
    virtual  char* printTailStream();
	
    virtual  char* printPacketOutputStream();
	
protected:
	
	/// This is the ByteStream generated with generateStream().
+3 −0
Original line number Diff line number Diff line
@@ -73,6 +73,9 @@ public:
    /// Return a packet of index passed as parameters.
    Packet* getPacketType(int index);
	
	/// Return a packet of name passed as parameters.
	Packet* getPacketType(string name);

    static char* packetLibVersion()
    {
        return (char*) "PacketLib version: 3.4.0 - June 2012";
+17 −14
Original line number Diff line number Diff line
@@ -44,26 +44,12 @@ public:
    /// Virtual destructor
    virtual ~PartOfPacket();

    /// Prints the structure of this part of packet.
    virtual string* printStructure();

    /// Prints the value of each field of this part of packet.
    virtual char** printValue(const char* addString = "");

    virtual void printValueStdout();

    /// This method loads the field present into the InputText (passed with the
    /// parameter).
    /// The InputText must be open and the internal pointer of the file must
    /// be in the first line that describes the fields.
    virtual bool loadFields(InputText& fp) throw(PacketException*);

    /// This method loads the field present into the MemoryBuffer (passed with the
    /// parameter).
    virtual bool loadFields(MemoryBuffer* mb) throw(PacketException*);

    virtual MemoryBuffer* loadFieldsInBuffer(InputText & fp);

    /// Returns the dimension (in byte) of this part of packet.
    virtual  inline dword size()
    {
@@ -360,8 +346,25 @@ public:

    char* popName;
	
	/// Prints the structure of this part of packet.
    virtual string* printStructure();
	
    /// Prints the value of each field of this part of packet.
    virtual char** printValue(const char* addString = "");
	
    virtual void printValueStdout();


protected:
	
	
    /// This method loads the field present into the MemoryBuffer (passed with the
    /// parameter).
    virtual bool loadFields(MemoryBuffer* mb) throw(PacketException*);
	
    virtual MemoryBuffer* loadFieldsInBuffer(InputText & fp);


	bool decode();
	
	bool decoded;
+1 −1
Original line number Diff line number Diff line
@@ -226,7 +226,7 @@ byte* PacketLib::ByteStream::getStream()



byte* PacketLib::ByteStream::getOutputStream()
byte* PacketLib::ByteStream::encode()
{
    swapWordIfStreamIsLittleEndian();
    return stream;
Loading