source: trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/Dispatcher/ProtocolInfo.h

Last change on this file was 22, checked in by rings, 14 years ago
  • Property svn:executable set to *
File size: 2.6 KB
RevLine 
[22]1#ifndef PROTOCOL_INFO_H
2#define PROTOCOL_INFO_H
3
4#include <list>
5#include <vector>
6
7#ifdef DISPATCH_DEBUG
8// TODO: For debugging only !!!
9namespace t3devlib
10{
11        typedef int ComponentId;
12}
13#else
14#include <t3devlib/t3devlib.h>
15#endif
16
17enum EProtocolType
18{
19        EProtocolType_None,
20        EProtocolType_Unknown,
21        EProtocolType_Ethernet,
22        EProtocolType_IPv4,
23        EProtocolType_Udp,
24        EProtocolType_Tcp,
25        EProtocolType_Sip,
26        EProtocolType_Dns
27};
28
29class ProtocolInfoElement
30{
31protected:
32        ProtocolInfoElement();
33public:
34        virtual ~ProtocolInfoElement();
35        virtual EProtocolType GetId() const = 0;
36        virtual bool Match(const ProtocolInfoElement & toCompare) const;
37        virtual ProtocolInfoElement * Clone() const = 0;
38};
39
40class ProtocolInfo : private std::vector<ProtocolInfoElement *>
41{
42public:
43        ProtocolInfo();
44        ~ProtocolInfo();
45        void AddItem(ProtocolInfoElement * info);
46        size_t Count();
47        const ProtocolInfoElement * operator[] ( int nIndex ) const;
48    bool Match(ProtocolInfo & info) const;
49};
50
51class IPv4Info : public ProtocolInfoElement
52{
53private:
54        unsigned int m_nSrcAddr, m_nDstAddr;
55public:
56        IPv4Info();
57        IPv4Info(const IPv4Info & src);
58        virtual ~IPv4Info();
59        virtual EProtocolType GetId() const { return EProtocolType_IPv4; }
60        virtual bool Match(const ProtocolInfoElement & toCompare) const;
61        unsigned int GetSourceAddress() const { return m_nSrcAddr; }
62        unsigned int GetDestinationAddress() const { return m_nDstAddr; }
63        void SetSourceAddress(unsigned int nAddr) { m_nSrcAddr = nAddr; }
64        void SetDestinationAddress(unsigned int nAddr) { m_nDstAddr = nAddr; }
65        virtual ProtocolInfoElement * Clone() const;
66 };
67
68class TransportLayerInfo : public ProtocolInfoElement
69{
70private:
71        unsigned short m_nSrcPort, m_nDstPort;
72protected:
73        TransportLayerInfo();
74        TransportLayerInfo(const TransportLayerInfo & src);
75public:         
76        virtual ~TransportLayerInfo();
77        virtual bool Match(const ProtocolInfoElement & toCompare) const;
78        unsigned short GetSourcePort() const { return m_nSrcPort; }
79        unsigned short GetDestinationPort() const { return m_nDstPort; }
80        void SetSourcePort(unsigned short nPort) { m_nSrcPort = nPort; }
81        void SetDestinationPort(unsigned short nPort) { m_nDstPort = nPort; }
82 };
83
84class TcpInfo : public TransportLayerInfo
85{
86public:
87        TcpInfo();
88        TcpInfo(const TcpInfo & src);
89        virtual ~TcpInfo();
90        virtual EProtocolType GetId() const { return EProtocolType_Tcp; }
91        virtual ProtocolInfoElement * Clone() const;
92};
93
94class UdpInfo : public TransportLayerInfo
95{
96public:
97        UdpInfo();
98        UdpInfo(const UdpInfo & src);
99        virtual ~UdpInfo();
100        virtual EProtocolType GetId() const { return EProtocolType_Udp; }
101        virtual ProtocolInfoElement * Clone() const;
102};
103
104#endif
Note: See TracBrowser for help on using the repository browser.