OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
arp_entry.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef vnsw_agent_arp_entry_hpp
6 #define vnsw_agent_arp_entry_hpp
7 
8 struct ArpKey {
9  ArpKey(in_addr_t addr, const VrfEntry *ventry) : ip(addr), vrf(ventry) {};
10  ArpKey(const ArpKey &key) : ip(key.ip), vrf(key.vrf) {};
11  bool operator <(const ArpKey &rhs) const {
12  if (vrf != rhs.vrf)
13  return vrf < rhs.vrf;
14  return (ip < rhs.ip);
15  }
16 
17  in_addr_t ip;
18  const VrfEntry *vrf;
19 };
20 
21 // Represents each Arp entry maintained by the ARP module
22 class ArpEntry {
23 public:
24  enum State {
25  INITING = 0x01,
26  RESOLVING = 0x02,
27  ACTIVE = 0x04,
28  RERESOLVING = 0x08,
29  };
30 
31  ArpEntry(boost::asio::io_context &io, ArpHandler *handler,
32  ArpKey &key, const VrfEntry *vrf, State state,
33  const Interface *itf);
34  virtual ~ArpEntry();
35 
36  const ArpKey &key() const { return key_; }
37  State state() const { return state_; }
38  const MacAddress &mac_address() const { return mac_address_; }
39  const Interface *get_interface() const { return interface_.get(); }
40 
41  bool HandleArpRequest();
42  void HandleArpReply(const MacAddress &);
43  bool RetryExpiry();
44  bool AgingExpiry();
45  void SendGratuitousArp();
46  bool DeleteArpRoute();
47  bool IsResolved();
48  void Resync(bool policy, const VnListType &vnlist,
49  const SecurityGroupList &sg,
50  const TagList &tag);
51  int retry_count() const { return retry_count_; }
53 private:
54  void StartTimer(uint32_t timeout, uint32_t mtype);
55  void SendArpRequest();
56  void AddArpRoute(bool resolved);
58  bool IsDerived();
59 
60  boost::asio::io_context &io_;
62  const VrfEntry *nh_vrf_;
66  boost::intrusive_ptr<ArpHandler> handler_;
70 };
71 
72 #endif // vnsw_agent_arp_entry_hpp
void HandleArpReply(const MacAddress &)
Definition: arp_entry.cc:68
void StartTimer(uint32_t timeout, uint32_t mtype)
Definition: arp_entry.cc:189
Definition: vrf.h:86
const ArpKey & key() const
Definition: arp_entry.h:36
int retry_count() const
Definition: arp_entry.h:51
void Resync(bool policy, const VnListType &vnlist, const SecurityGroupList &sg, const TagList &tag)
Definition: arp_entry.cc:341
bool operator<(const ArpKey &rhs) const
Definition: arp_entry.h:11
int retry_count_
Definition: arp_entry.h:65
State state() const
Definition: arp_entry.h:37
ArpKey key_
Definition: arp_entry.h:61
bool AgingExpiry()
Definition: arp_entry.cc:122
std::vector< int > SecurityGroupList
Definition: agent.h:201
ArpKey(const ArpKey &key)
Definition: arp_entry.h:10
DISALLOW_COPY_AND_ASSIGN(ArpEntry)
boost::asio::io_context & io_
Definition: arp_entry.h:60
bool RetryExpiry()
Definition: arp_entry.cc:90
void SendArpRequest()
Definition: arp_entry.cc:196
void AddArpRoute(bool resolved)
Definition: arp_entry.cc:239
ArpEntry(boost::asio::io_context &io, ArpHandler *handler, ArpKey &key, const VrfEntry *vrf, State state, const Interface *itf)
Definition: arp_entry.cc:11
virtual ~ArpEntry()
Definition: arp_entry.cc:23
const VrfEntry * nh_vrf_
Definition: arp_entry.h:62
MacAddress mac_address_
Definition: arp_entry.h:63
State state_
Definition: arp_entry.h:64
boost::intrusive_ptr< ArpHandler > handler_
Definition: arp_entry.h:66
void SetState(State state)
Definition: arp_entry.h:52
boost::intrusive_ptr< const Interface > InterfaceConstRef
Definition: agent.h:51
bool IsDerived()
Definition: arp_entry.cc:182
const Interface * get_interface() const
Definition: arp_entry.h:39
std::set< std::string > VnListType
Definition: agent.h:212
bool DeleteArpRoute()
Definition: arp_entry.cc:312
bool HandleArpRequest()
Definition: arp_entry.cc:51
void SendGratuitousArp()
Definition: arp_entry.cc:137
void HandleDerivedArpRequest()
Definition: arp_entry.cc:31
const VrfEntry * vrf
Definition: arp_entry.h:18
Definition: timer.h:54
const MacAddress & mac_address() const
Definition: arp_entry.h:38
bool IsResolved()
Definition: arp_entry.cc:178
ArpKey(in_addr_t addr, const VrfEntry *ventry)
Definition: arp_entry.h:9
Timer * arp_timer_
Definition: arp_entry.h:67
std::vector< int > TagList
Definition: agent.h:202
InterfaceConstRef interface_
Definition: arp_entry.h:68
in_addr_t ip
Definition: arp_entry.h:17