OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
interface_ksync.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_interface_ksync_h
6 #define vnsw_agent_interface_ksync_h
7 
8 #include <net/ethernet.h>
9 
10 #include <boost/asio.hpp>
11 #include <boost/bind.hpp>
12 
13 #include <db/db_entry.h>
14 #include <db/db_table.h>
15 #include <db/db_table_partition.h>
16 #include <ksync/ksync_entry.h>
17 #include <ksync/ksync_object.h>
18 #include <ksync/ksync_netlink.h>
19 #include "oper/interface_common.h"
20 #include "vrouter/ksync/agent_ksync_types.h"
21 #include "vr_types.h"
22 
23 void KSyncInterfaceCreate(Interface::Type type, const char *if_name,
24  uint32_t vrf_id, uint32_t &ifindex, uint32_t &fd,
25  MacAddress &mac);
26 void KSyncInterfaceDelete(Interface::Type type, const char *if_name,
27  uint32_t vrf_id, uint32_t ifindex, uint32_t fd);
28 void GetPhyMac(const char *ifname, char *mac);
29 
30 class Timer;
32 
34 public:
35  static const int kDefaultInterfaceMsgSize = 2048;
36 
38  const InterfaceKSyncEntry *entry, uint32_t index);
40  virtual ~InterfaceKSyncEntry();
41 
42  const MacAddress &mac() const {
43  if (parent_.get() == NULL) {
44  return mac_;
45  } else {
46  const InterfaceKSyncEntry *parent =
47  static_cast<const InterfaceKSyncEntry *>(parent_.get());
48  return parent->mac();
49  }
50  }
51  const MacAddress &smac() const {return smac_;}
52 
53  uint32_t interface_id() const {return interface_id_;}
54  const string &interface_name() const {return interface_name_;}
55  bool has_service_vlan() const {return has_service_vlan_;}
56  bool no_arp() const { return no_arp_; }
58 
59  KSyncDBObject *GetObject() const;
60  virtual bool Sync(DBEntry *e);
61  virtual bool IsLess(const KSyncEntry &rhs) const;
62  virtual std::string ToString() const;
63  virtual int AddMsg(char *buf, int buf_len);
64  virtual int ChangeMsg(char *buf, int buf_len);
65  virtual int DeleteMsg(char *buf, int buf_len);
67  void FillObjectLog(sandesh_op::type op, KSyncIntfInfo &info) const;
68  bool drop_new_flows() const {return drop_new_flows_;}
69  bool dhcp_enable() const {return dhcp_enable_;}
70  bool dhcp_enable_v6() const {return dhcp_enable_v6_;}
71  bool layer3_forwarding() const {return layer3_forwarding_;}
72  bool bridging() const {return bridging_;}
73  bool pbb_interface() const {return pbb_interface_;}
74  const MacAddress &pbb_mac() const { return pbb_mac_; }
75 
76  int MsgLen() { return kDefaultInterfaceMsgSize; }
77  bool KSyncEntrySandesh(Sandesh *resp);
78 
79 private:
80  friend class InterfaceKSyncObject;
81  int Encode(sandesh_op::type op, char *buf, int buf_len);
82  void SetKsyncItfSandeshData(KSyncItfSandeshData *data) const;
83 
88  uint32_t fd_; // FD opened for this
89  uint32_t flow_key_nh_id_;
91  uint32_t interface_id_;
92  string interface_name_; // Key
93  uint32_t ip_;
95  bool hc_active_;
99  bool l2_active_;
102  bool bridging_;
108  size_t os_index_;
116  uint16_t rx_vlan_id_;
117  uint16_t tx_vlan_id_;
118  uint32_t vrf_id_;
123  bool no_arp_;
125  std::string display_name_;
130  std::set<MacAddress> aap_mac_list_;
133  uint32_t isid_;
134  uint32_t pbb_cmac_vrf_;
141  boost::optional<InterfaceOsParams::IfGuid> os_guid_;
142  std::vector<KSyncEntryPtr> xconnect_list_;
144 };
145 
147 public:
148  InterfaceKSyncObject(KSync *parent);
149  virtual ~InterfaceKSyncObject();
150 
151  KSync *ksync() const { return ksync_; }
152 
153  void Init();
154  void InitTest();
155  virtual KSyncEntry *Alloc(const KSyncEntry *entry, uint32_t index);
156  virtual KSyncEntry *DBToKSyncEntry(const DBEntry *e);
157  void RegisterDBClients();
158  DBFilterResp DBEntryFilter(const DBEntry *e, const KSyncDBEntry *k);
159 
160 private:
163 };
164 
165 #endif // vnsw_agent_interface_ksync_h
bool layer3_forwarding() const
PhysicalInterface::EncapType encap_type_
static const int kDefaultInterfaceMsgSize
InetInterface::SubType sub_type_
VmInterface::DeviceType vmi_device_type_
bool dhcp_enable_v6() const
DISALLOW_COPY_AND_ASSIGN(InterfaceKSyncEntry)
VmInterface::FatFlowList fat_flow_list_
InterfaceKSyncObject(KSync *parent)
KSync * ksync() const
VmInterface::ProxyArpMode proxy_arp_mode_
void KSyncInterfaceCreate(Interface::Type type, const char *if_name, uint32_t vrf_id, uint32_t &ifindex, uint32_t &fd, MacAddress &mac)
virtual KSyncEntry * UnresolvedReference()
bool KSyncEntrySandesh(Sandesh *resp)
bool has_service_vlan() const
boost::optional< InterfaceOsParams::IfGuid > os_guid_
virtual bool IsLess(const KSyncEntry &rhs) const
KSyncDBObject * GetObject() const
void GetPhyMac(const char *ifname, char *mac)
virtual KSyncEntry * Alloc(const KSyncEntry *entry, uint32_t index)
int Encode(sandesh_op::type op, char *buf, int buf_len)
void KSyncInterfaceDelete(Interface::Type type, const char *if_name, uint32_t vrf_id, uint32_t ifindex, uint32_t fd)
const MacAddress & mac() const
virtual KSyncEntry * DBToKSyncEntry(const DBEntry *e)
const MacAddress & smac() const
std::vector< KSyncEntryPtr > xconnect_list_
DISALLOW_COPY_AND_ASSIGN(InterfaceKSyncObject)
uint8_t type
Definition: load_balance.h:109
KSyncEntryPtr qos_config_
InterfaceKSyncObject * ksync_obj_
boost::asio::ip::address_v6 Ip6Address
Definition: address.h:15
boost::intrusive_ptr< KSyncEntry > KSyncEntryPtr
Definition: ksync_entry.h:68
VmInterface::FatFlowExcludeList fat_flow_exclude_list_
const MacAddress & pbb_mac() const
bool dhcp_enable() const
bool pbb_interface() const
KSyncEntryPtr xconnect_
virtual std::string ToString() const
std::string display_name_
PhysicalInterface::SubType subtype_
virtual ~InterfaceKSyncEntry()
VmInterface::HbsIntfType hbs_intf_type_
virtual int DeleteMsg(char *buf, int buf_len)
InterfaceKSyncEntry(InterfaceKSyncObject *obj, const InterfaceKSyncEntry *entry, uint32_t index)
virtual bool Sync(DBEntry *e)
PhysicalInterface::EncapType encap_type() const
bool drop_new_flows() const
DBFilterResp DBEntryFilter(const DBEntry *e, const KSyncDBEntry *k)
virtual int ChangeMsg(char *buf, int buf_len)
bool no_arp() const
std::set< MacAddress > aap_mac_list_
KSyncEntryPtr parent_
bool bridging() const
Interface::MirrorDirection mirror_direction_
const string & interface_name() const
VmInterface::VmiType vmi_type_
Definition: timer.h:54
void SetKsyncItfSandeshData(KSyncItfSandeshData *data) const
MirrorDirection
Definition: interface.h:55
uint32_t interface_id() const
void FillObjectLog(sandesh_op::type op, KSyncIntfInfo &info) const
virtual int AddMsg(char *buf, int buf_len)
Interface::Type type_
Interface::Transport transport_