123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- #ifndef __IPA_TESTS_IPV4_PACKET__H__
- #define __IPA_TESTS_IPV4_PACKET__H__
- namespace IPA
- {
- #define IPV4_FLAGS_BYTE_OFFSET 6
- class IPv4Packet
- {
- public:
- IPv4Packet(unsigned int size);
- virtual ~IPv4Packet(void);
- void FromByteStream(unsigned char *buffer, unsigned int length);
- void ToNetworkByteStream(unsigned char *addr);
- unsigned int GetSrcAddr(void);
- void SetSrcAddr(unsigned int addr);
- unsigned int GetDstAddr(void);
- void SetDstAddr(unsigned int addr);
- unsigned char GetProtocol(void);
- unsigned int GetSize(void)
- {
- return m_PacketSize;
- }
- virtual unsigned short GetSrcPort(void);
- virtual unsigned short GetDstPort(void);
- virtual void SetDstPort(unsigned short port);
- virtual void SetSrcPort(unsigned short port);
- void SetMF(bool bValue);
- protected:
- virtual void RecalculateTCPChecksum(void) {}
- virtual void RecalculateUDPChecksum(void) {}
- virtual void RecalculateICMPChecksum(void) {}
- unsigned char *m_Packet;
- private:
- unsigned int m_PacketSize;
- void RecalculateChecksum(void);
- void RecalculateIPChecksum(void);
- };
- class TCPPacket:public IPv4Packet
- {
- public:
- TCPPacket(void);
- virtual ~TCPPacket(void) {}
- protected:
- virtual void RecalculateTCPChecksum(void);
- };
- class UDPPacket:public IPv4Packet
- {
- public:
- UDPPacket(void);
- virtual ~UDPPacket(void) {}
- protected:
- virtual void RecalculateUDPChecksum(void);
- };
- class ICMPPacket:public IPv4Packet
- {
- public:
- ICMPPacket(void);
- virtual ~ICMPPacket(void) {}
- virtual unsigned short GetSrcPort(void);
- virtual unsigned short GetDstPort(void);
- virtual void SetDstPort(unsigned short port);
- virtual void SetSrcPort(unsigned short port);
- protected:
-
- virtual void RecalculateICMPChecksum(void)
- {
- return;
- }
- };
- }
- #endif
|