source: trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Dispatcher/IpDissector.h @ 32

Last change on this file since 32 was 22, checked in by rings, 14 years ago
  • Property svn:executable set to *
File size: 1.8 KB
Line 
1#ifndef IP_DISSECTOR_H
2#define IP_DISSECTOR_H
3
4#include "Dissector.h"
5#include <map>
6#include <list>
7#include <string>
8
9class IpDissector : public Dissector {
10
11 public:
12  IpDissector();
13  virtual ~IpDissector();
14  virtual IpDissector * Clone() const;
15  virtual bool Dissect(const unsigned char * pData, const ssize_t nDataLen);
16  virtual bool NeedReassembly() const;
17  virtual bool Reassemble(Dissector * pDissector, ProtocolInfo * pProtocolInfo);
18  virtual const EProtocolType GetUpperLayerType() const;
19
20 private:
21  struct IpHeader {
22#if BYTE_ORDER == LITTLE_ENDIAN
23    unsigned char headerLength:4,    // 4-bit header length (in 32-bit words)
24      version:4;                     // 4-bit IPv4 version
25#else
26#if BYTE_ORDER == BIG_ENDIAN
27    unsigned char version:4,         // 4-bit IPv4 version
28      headerLength:4;                // 4-bit header length (in 32-bit words)
29#endif
30#endif
31    unsigned char  tos;              // IP type of service
32    unsigned short totalLength;      // Total length
33    unsigned short id;               // Unique identifier
34   
35    unsigned char  fragOffset   :5;  // Fragment offset field
36   
37    unsigned char  moreFragment :1;
38    unsigned char  dontFragment :1;
39    unsigned char  reservedZero :1;
40   
41    unsigned char  fragOffset1;      // Fragment offset
42   
43    unsigned char  ttl;              // Time to live
44    unsigned char  protocol;         // Protocol(TCP,UDP etc)
45    unsigned short checksum;         // IP checksum
46    unsigned char  srcAddr[4];       // Source address
47    unsigned char  destAddr[4];      // Source address
48  };
49
50 private:
51  IpHeader * m_ipHdr;
52
53  // Reassembly
54  std::list<std::pair<unsigned short, unsigned short> > m_holes;
55  std::map<unsigned short, const unsigned char *> m_fragments;
56  std::map<unsigned short, ssize_t> m_fragmentSizes;
57 protected:
58  ProtocolInfoElement * CreateLayerInfo();
59};
60
61#endif
Note: See TracBrowser for help on using the repository browser.