diff options
author | 2016-11-30 15:04:59 +0200 | |
---|---|---|
committer | 2016-11-30 15:04:59 +0200 | |
commit | b812770167d37125b3f3e1b0673517d8f83393ac (patch) | |
tree | b99f73265f7f713995ed9ccdf5016e01c45b9ca9 /src/pre_test.cpp | |
parent | 5b4fcd558793cf7222cc260d8d5aead03cf1cb86 (diff) | |
parent | 3beb07058c3781d9f3ce888be636b6484f750c96 (diff) |
merging with latest master
Signed-off-by: imarom <imarom@cisco.com>
Conflicts:
src/main_dpdk.cpp
Diffstat (limited to 'src/pre_test.cpp')
-rw-r--r-- | src/pre_test.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/pre_test.cpp b/src/pre_test.cpp index 583427eb..7127645d 100644 --- a/src/pre_test.cpp +++ b/src/pre_test.cpp @@ -35,6 +35,15 @@ CPretestOnePortInfo::CPretestOnePortInfo() { m_stats.clear(); } +CPretestOnePortInfo::~CPretestOnePortInfo() { + for (std::vector<COneIPInfo *>::iterator it = m_src_info.begin(); it != m_src_info.end(); ++it) { + delete *it; + } + for (std::vector<COneIPInfo *>::iterator it = m_dst_info.begin(); it != m_dst_info.end(); ++it) { + delete *it; + } +} + void CPretestOnePortInfo::add_src(uint32_t ip, uint16_t vlan, MacAddress mac) { COneIPv4Info *one_ip = new COneIPv4Info(ip, vlan, mac); assert(one_ip); @@ -121,6 +130,8 @@ COneIPv6Info *CPretestOnePortInfo::find_ipv6(uint16_t ip[8], uint16_t vlan) { } bool CPretestOnePortInfo::get_mac(COneIPInfo *ip, uint8_t *mac) { + MacAddress defaultmac; + for (std::vector<COneIPInfo *>::iterator it = m_dst_info.begin(); it != m_dst_info.end(); ++it) { if (ip->ip_ver() != (*it)->ip_ver()) continue; @@ -139,7 +150,11 @@ bool CPretestOnePortInfo::get_mac(COneIPInfo *ip, uint8_t *mac) { } (*it)->get_mac(mac); - return true; + if (! memcmp(mac, defaultmac.GetConstBuffer(), ETHER_ADDR_LEN)) { + return false; + } else { + return true; + } } return false; @@ -361,7 +376,7 @@ bool CPretest::is_arp(const uint8_t *p, uint16_t pkt_size, ArpHdr *&arp, uint16_ EthernetHeader *m_ether = (EthernetHeader *)p; vlan_tag = 0; - if ((pkt_size < 60) || + if ((pkt_size < sizeof(EthernetHeader)) || ((m_ether->getNextProtocol() != EthernetHeader::Protocol::ARP) && (m_ether->getNextProtocol() != EthernetHeader::Protocol::VLAN))) return false; @@ -497,6 +512,7 @@ void CPretest::get_results(CManyIPInfo &resolved_ips) { for (std::vector<COneIPInfo *>::iterator it = m_port_info[port].m_dst_info.begin() ; it != m_port_info[port].m_dst_info.end(); ++it) { uint8_t ip_type = (*it)->ip_ver(); + (*it)->set_port(port); switch(ip_type) { case COneIPInfo::IP4_VER: resolved_ips.insert(*(COneIPv4Info *)(*it)); |