OpenSDN source code
arp_handler.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_handler_hpp
6 #define vnsw_agent_arp_handler_hpp
7 
8 #include <atomic>
9 #include "pkt/proto_handler.h"
10 
11 #define GRATUITOUS_ARP 0x0100 // keep this different from standard ARP commands
12 
13 struct ArpKey;
14 class ArpEntry;
16 
17 class ArpHandler : public ProtoHandler {
18 public:
19  static const uint16_t kMaxArpProbes = 256;
20  ArpHandler(Agent *agent, boost::shared_ptr<PktInfo> info,
21  boost::asio::io_context &io);
22  virtual ~ArpHandler();
23 
24  bool Run();
25  void SendArp(uint16_t op, const MacAddress &smac, in_addr_t sip,
26  const MacAddress &tmac, const MacAddress &dmac,
27  in_addr_t tip, uint32_t itf, uint32_t vrf);
28  void SendArpRequestByPlen(const VmInterface *vm_interface,
29  const MacAddress &smac,
30  const ArpPathPreferenceState *data,
31  const Ip4Address &tpa);
32  friend void intrusive_ptr_add_ref(const ArpHandler *p);
33  friend void intrusive_ptr_release(const ArpHandler *p);
34 
35 private:
36  uint32_t MaxArpProbeAddresses() const;
37  bool HandlePacket();
38  bool HandleMessage();
39  void EntryDelete(ArpKey &key);
40  uint16_t ArpHdr(const MacAddress &smac, in_addr_t sip,
41  const MacAddress &tmac, in_addr_t tip, uint16_t op);
42 
43  ether_arp *arp_;
44  in_addr_t arp_tpa_;
45  mutable std::atomic<uint32_t> refcount_;
47 };
48 
49 #endif // vnsw_agent_arp_handler_hpp
boost::asio::ip::address_v4 Ip4Address
Definition: address.h:14
Definition: agent.h:360
void SendArpRequestByPlen(const VmInterface *vm_interface, const MacAddress &smac, const ArpPathPreferenceState *data, const Ip4Address &tpa)
Definition: arp_handler.cc:392
ArpHandler(Agent *agent, boost::shared_ptr< PktInfo > info, boost::asio::io_context &io)
Definition: arp_handler.cc:18
in_addr_t arp_tpa_
Definition: arp_handler.h:44
uint32_t MaxArpProbeAddresses() const
Definition: arp_handler.cc:452
virtual ~ArpHandler()
Definition: arp_handler.cc:24
bool HandleMessage()
Definition: arp_handler.cc:254
bool HandlePacket()
Definition: arp_handler.cc:50
void EntryDelete(ArpKey &key)
Definition: arp_handler.cc:344
uint16_t ArpHdr(const MacAddress &smac, in_addr_t sip, const MacAddress &tmac, in_addr_t tip, uint16_t op)
Definition: arp_handler.cc:353
static const uint16_t kMaxArpProbes
Definition: arp_handler.h:19
std::atomic< uint32_t > refcount_
Definition: arp_handler.h:45
friend void intrusive_ptr_add_ref(const ArpHandler *p)
Definition: arp_handler.cc:458
DISALLOW_COPY_AND_ASSIGN(ArpHandler)
bool Run()
Definition: arp_handler.cc:27
ether_arp * arp_
Definition: arp_handler.h:43
void SendArp(uint16_t op, const MacAddress &smac, in_addr_t sip, const MacAddress &tmac, const MacAddress &dmac, in_addr_t tip, uint32_t itf, uint32_t vrf)
Definition: arp_handler.cc:369
friend void intrusive_ptr_release(const ArpHandler *p)
Definition: arp_handler.cc:462
Agent * agent() const
Definition: proto_handler.h:80
Definition: io_utils.cc:11