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