| 1 | #include "ProtocolInfo.h" |
|---|
| 2 | |
|---|
| 3 | ProtocolInfoElement::ProtocolInfoElement() |
|---|
| 4 | { |
|---|
| 5 | } |
|---|
| 6 | ProtocolInfoElement::~ProtocolInfoElement() |
|---|
| 7 | { |
|---|
| 8 | } |
|---|
| 9 | bool ProtocolInfoElement::Match (const ProtocolInfoElement & toCompare) const |
|---|
| 10 | { |
|---|
| 11 | return GetId() == toCompare.GetId(); |
|---|
| 12 | } |
|---|
| 13 | |
|---|
| 14 | ProtocolInfo::ProtocolInfo() |
|---|
| 15 | { |
|---|
| 16 | } |
|---|
| 17 | |
|---|
| 18 | ProtocolInfo::~ProtocolInfo() |
|---|
| 19 | { |
|---|
| 20 | int nLen = size(); |
|---|
| 21 | for (int i = 0; i < nLen; ++i) |
|---|
| 22 | delete (*this)[i]; |
|---|
| 23 | } |
|---|
| 24 | void ProtocolInfo::AddItem(ProtocolInfoElement * info) |
|---|
| 25 | { |
|---|
| 26 | push_back(info); |
|---|
| 27 | } |
|---|
| 28 | |
|---|
| 29 | bool ProtocolInfo::Match(ProtocolInfo & info) const |
|---|
| 30 | { |
|---|
| 31 | size_t nLen = size(); |
|---|
| 32 | if (nLen != info.size()) |
|---|
| 33 | return false; |
|---|
| 34 | for (unsigned int i = 0; i < nLen; ++i) |
|---|
| 35 | if (!(*this)[i]->Match(*info[i])) |
|---|
| 36 | return false; |
|---|
| 37 | return true; |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | size_t ProtocolInfo::Count() |
|---|
| 41 | { |
|---|
| 42 | return size(); |
|---|
| 43 | } |
|---|
| 44 | const ProtocolInfoElement * ProtocolInfo::operator[] ( int nIndex ) const |
|---|
| 45 | { |
|---|
| 46 | return std::vector<ProtocolInfoElement *>::operator[](nIndex); |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | IPv4Info::IPv4Info() : |
|---|
| 51 | m_nSrcAddr(0), |
|---|
| 52 | m_nDstAddr(0) |
|---|
| 53 | { |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | IPv4Info::IPv4Info(const IPv4Info & src) : |
|---|
| 57 | m_nSrcAddr(src.m_nSrcAddr), |
|---|
| 58 | m_nDstAddr(src.m_nDstAddr) |
|---|
| 59 | { |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | IPv4Info::~IPv4Info() |
|---|
| 63 | { |
|---|
| 64 | } |
|---|
| 65 | bool IPv4Info::Match (const ProtocolInfoElement & toCompare) const |
|---|
| 66 | { |
|---|
| 67 | if (!ProtocolInfoElement::Match(toCompare)) |
|---|
| 68 | return false; |
|---|
| 69 | const IPv4Info & tmp = dynamic_cast<const IPv4Info &>(toCompare); |
|---|
| 70 | return m_nSrcAddr == tmp.m_nSrcAddr && m_nDstAddr == tmp.m_nDstAddr; |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | ProtocolInfoElement * IPv4Info::Clone() const |
|---|
| 74 | { |
|---|
| 75 | return new IPv4Info(*this); |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | TransportLayerInfo::TransportLayerInfo() : |
|---|
| 79 | m_nSrcPort(0), |
|---|
| 80 | m_nDstPort(0) |
|---|
| 81 | { |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | TransportLayerInfo::TransportLayerInfo(const TransportLayerInfo & src) : |
|---|
| 85 | m_nSrcPort(src.m_nSrcPort), |
|---|
| 86 | m_nDstPort(src.m_nDstPort) |
|---|
| 87 | { |
|---|
| 88 | } |
|---|
| 89 | |
|---|
| 90 | TransportLayerInfo::~TransportLayerInfo() |
|---|
| 91 | { |
|---|
| 92 | } |
|---|
| 93 | bool TransportLayerInfo::Match (const ProtocolInfoElement & toCompare) const |
|---|
| 94 | { |
|---|
| 95 | if (!ProtocolInfoElement::Match(toCompare)) |
|---|
| 96 | return false; |
|---|
| 97 | const TransportLayerInfo & tmp = dynamic_cast<const TransportLayerInfo &>(toCompare); |
|---|
| 98 | return m_nSrcPort == tmp.m_nSrcPort && m_nDstPort == tmp.m_nDstPort; |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | TcpInfo::TcpInfo() |
|---|
| 102 | { |
|---|
| 103 | } |
|---|
| 104 | |
|---|
| 105 | TcpInfo::TcpInfo(const TcpInfo & src) : |
|---|
| 106 | TransportLayerInfo(src) |
|---|
| 107 | { |
|---|
| 108 | } |
|---|
| 109 | |
|---|
| 110 | TcpInfo::~TcpInfo() |
|---|
| 111 | { |
|---|
| 112 | } |
|---|
| 113 | |
|---|
| 114 | ProtocolInfoElement * TcpInfo::Clone() const |
|---|
| 115 | { |
|---|
| 116 | return new TcpInfo(*this); |
|---|
| 117 | } |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | UdpInfo::UdpInfo() |
|---|
| 121 | { |
|---|
| 122 | } |
|---|
| 123 | |
|---|
| 124 | UdpInfo::UdpInfo(const UdpInfo & src) : |
|---|
| 125 | TransportLayerInfo(src) |
|---|
| 126 | { |
|---|
| 127 | } |
|---|
| 128 | |
|---|
| 129 | UdpInfo::~UdpInfo() |
|---|
| 130 | { |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | ProtocolInfoElement * UdpInfo::Clone() const |
|---|
| 134 | { |
|---|
| 135 | return new UdpInfo(*this); |
|---|
| 136 | } |
|---|
| 137 | |
|---|