/
arp_entry.h
70 lines (61 loc) · 1.93 KB
/
arp_entry.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
*/
#ifndef vnsw_agent_arp_entry_hpp
#define vnsw_agent_arp_entry_hpp
struct ArpKey {
ArpKey(in_addr_t addr, const VrfEntry *ventry) : ip(addr), vrf(ventry) {};
ArpKey(const ArpKey &key) : ip(key.ip), vrf(key.vrf) {};
bool operator <(const ArpKey &rhs) const {
if (vrf != rhs.vrf)
return vrf < rhs.vrf;
return (ip < rhs.ip);
}
in_addr_t ip;
const VrfEntry *vrf;
};
// Represents each Arp entry maintained by the ARP module
class ArpEntry {
public:
enum State {
INITING = 0x01,
RESOLVING = 0x02,
ACTIVE = 0x04,
RERESOLVING = 0x08,
};
ArpEntry(boost::asio::io_service &io, ArpHandler *handler,
ArpKey &key, const VrfEntry *vrf, State state,
const Interface *itf);
virtual ~ArpEntry();
const ArpKey &key() const { return key_; }
State state() const { return state_; }
const MacAddress &mac_address() const { return mac_address_; }
const Interface *interface() const { return interface_; }
bool HandleArpRequest();
void HandleArpReply(const MacAddress &);
bool RetryExpiry();
bool AgingExpiry();
void SendGratuitousArp();
bool DeleteArpRoute();
bool IsResolved();
void Resync(bool policy, const VnListType &vnlist,
const SecurityGroupList &sg);
int retry_count() const { return retry_count_; }
private:
void StartTimer(uint32_t timeout, uint32_t mtype);
void SendArpRequest();
void AddArpRoute(bool resolved);
void HandleDerivedArpRequest();
bool IsDerived();
boost::asio::io_service &io_;
ArpKey key_;
const VrfEntry *nh_vrf_;
MacAddress mac_address_;
State state_;
int retry_count_;
boost::intrusive_ptr<ArpHandler> handler_;
Timer *arp_timer_;
const Interface *interface_;
DISALLOW_COPY_AND_ASSIGN(ArpEntry);
};
#endif // vnsw_agent_arp_entry_hpp