OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
physical_interface.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 #ifndef src_vnsw_agent_oper_physical_interface_hpp
5 #define src_vnsw_agent_oper_physical_interface_hpp
6 
9 
11 // Implementation of Physical Ports local to the device
12 // Does not have reference to physical-device since they are local devices
13 // Can be Ethernet Ports or LAG Ports
14 // Name of port is used as key
16 class PhysicalInterface : public Interface {
17 public:
18  enum SubType {
19  FABRIC, // Physical port connecting to fabric network
20  VMWARE, // For vmware, port connecting to contrail-vm-portgroup
21  CONFIG, // Interface created from config
23  };
24 
25  enum EncapType {
26  ETHERNET, // Ethernet with ARP
27  RAW_IP // No L2 header. Packets sent as raw-ip
28  };
29 
30  struct Bond_ChildIntf {
31  string intf_name;
32  string intf_drv_name;
34  };
35 
36  typedef std::map<const std::string, Bond_ChildIntf> BondChildIntfMap;
37  typedef BondChildIntfMap::const_iterator BondChildIntfMapIterator;
38 
39 
40  PhysicalInterface(const std::string &name,
42  virtual ~PhysicalInterface();
43 
44  virtual bool CmpInterface(const DBEntry &rhs) const;
45  virtual std::string ToString() const;
46  virtual KeyPtr GetDBRequestKey() const;
47 
48  virtual void PostAdd();
49  virtual bool Delete(const DBRequest *req);
50  virtual bool OnChange(const InterfaceTable *table,
51  const PhysicalInterfaceData *data);
52  SubType subtype() const { return subtype_; }
54  const std::string& display_name() const {
55  return display_name_;
56  }
57 
58  // Lets kernel know if physical interface is to be kept after agent exits or
59  // dies. If its true keep the interface, else remove it.
60  // Currently only vnware physical interface is persistent.
61  // By default every physical interface is non-persistent.
62  bool persistent() const {return persistent_;}
63  EncapType encap_type() const { return encap_type_; }
64  bool no_arp() const { return no_arp_; }
65  Ip4Address ip_addr() const { return ip_;}
66 
67  // Helper functions
68  static void CreateReq(InterfaceTable *table, const std::string &ifname,
69  const std::string &vrf_name, SubType subtype,
70  EncapType encap, bool no_arp,
71  const boost::uuids::uuid &device_uuid,
72  const Ip4Address &ip,
74  static void Create(InterfaceTable *table, const std::string &ifname,
75  const std::string &vrf_name, SubType subtype,
76  EncapType encap, bool no_arp,
77  const boost::uuids::uuid &device_uuid,
78  const Ip4Address &ip,
80  static void DeleteReq(InterfaceTable *table, const std::string &ifname);
81  static void Delete(InterfaceTable *table, const std::string &ifname);
82  bool OnChange(PhysicalInterfaceData *data);
83  virtual void ObtainOsSpecificParams(const std::string &name, Agent *agent);
84  friend struct PhysicalInterfaceKey;
86  friend class TestVnswIf;
87 
89  return bond_childIntf_map_;
90  }
91  void setBondChildIntfMap(const BondChildIntfMap bondChildIntfMap) {
92  bond_childIntf_map_ = bondChildIntfMap;
93  }
94 
95 private:
96  std::string GetPhysicalInterfaceName() const;
97 
101  bool no_arp_;
103  std::string display_name_;
107 };
108 
111  const std::string &vrf_name,
114  bool no_arp,
115  const boost::uuids::uuid &device_uuid,
116  const std::string &display_name,
117  const Ip4Address &ip,
118  Interface::Transport transport);
122  bool no_arp_;
124  std::string display_name_;
126 };
127 
129  PhysicalInterfaceKey(const std::string &name);
130  virtual ~PhysicalInterfaceKey();
131 
132  Interface *AllocEntry(const InterfaceTable *table) const;
133  Interface *AllocEntry(const InterfaceTable *table,
134  const InterfaceData *data) const;
135  InterfaceKey *Clone() const;
136 };
137 
142  };
143 
145  std::string intf_name, std::string intf_drv_name, bool status):
147  PhysicalInterface::ETHERNET, false, boost::uuids::nil_uuid(),
148  "", Ip4Address(0), Interface::TRANSPORT_INVALID),
149  type_(type_), intf_name(intf_name), intf_drv_name(intf_drv_name),
150  oper_state_(status) { }
152  virtual bool OnResync(PhysicalInterface *phy_intf) const;
153 
154  unsigned short int type_;
155  string intf_name;
158 };
159 
160 #endif // src_vnsw_agent_oper_physical_interface_hpp
friend class TestVnswIf
PhysicalInterface::SubType subtype_
PhysicalInterface(const std::string &name, const boost::uuids::uuid &logical_router_uuid)
std::string GetPhysicalInterfaceName() const
Transport transport_
Definition: interface.h:186
SubType subtype() const
Interface::Transport transport() const
Definition: interface.h:138
virtual bool OnResync(PhysicalInterface *phy_intf) const
bool persistent() const
boost::uuids::uuid uuid
PhysicalInterfaceOsOperStateData(unsigned short int type_, std::string intf_name, std::string intf_drv_name, bool status)
Ip4Address ip_addr() const
const boost::uuids::uuid & logical_router_uuid() const
Definition: interface.h:146
std::unique_ptr< DBRequestKey > KeyPtr
Definition: db_entry.h:25
virtual bool OnChange(const InterfaceTable *table, const PhysicalInterfaceData *data)
bool no_arp() const
DISALLOW_COPY_AND_ASSIGN(PhysicalInterface)
Definition: agent.h:358
boost::uuids::uuid device_uuid_
const BondChildIntfMap & getBondChildIntfMap() const
PhysicalDeviceRef physical_device_
static void Create(InterfaceTable *table, const std::string &ifname, const std::string &vrf_name, SubType subtype, EncapType encap, bool no_arp, const boost::uuids::uuid &device_uuid, const Ip4Address &ip, Interface::Transport transport_)
virtual KeyPtr GetDBRequestKey() const
virtual void PostAdd()
BondChildIntfMap::const_iterator BondChildIntfMapIterator
boost::asio::ip::address_v4 Ip4Address
Definition: address.h:14
EncapType encap_type() const
void Delete()
Definition: db_entry.cc:131
PhysicalInterfaceKey(const std::string &name)
PhysicalInterface::EncapType encap_type_
Interface * AllocEntry(const InterfaceTable *table) const
InterfaceKey * Clone() const
const Agent * agent() const
Definition: oper_db.h:65
virtual bool CmpInterface(const DBEntry &rhs) const
void setBondChildIntfMap(const BondChildIntfMap bondChildIntfMap)
virtual void ObtainOsSpecificParams(const std::string &name, Agent *agent)
static void DeleteReq(InterfaceTable *table, const std::string &ifname)
const std::string & name() const
Definition: interface.h:114
PhysicalDevice * physical_device() const
virtual std::string ToString() const
boost::intrusive_ptr< PhysicalDevice > PhysicalDeviceRef
Definition: agent.h:153
std::map< const std::string, Bond_ChildIntf > BondChildIntfMap
const std::string & display_name() const
BondChildIntfMap bond_childIntf_map_
PhysicalInterfaceData(Agent *agent, IFMapNode *node, const std::string &vrf_name, PhysicalInterface::SubType subtype, PhysicalInterface::EncapType encap, bool no_arp, const boost::uuids::uuid &device_uuid, const std::string &display_name, const Ip4Address &ip, Interface::Transport transport)
static void CreateReq(InterfaceTable *table, const std::string &ifname, const std::string &vrf_name, SubType subtype, EncapType encap, bool no_arp, const boost::uuids::uuid &device_uuid, const Ip4Address &ip, Interface::Transport transport)