Line data Source code
1 : /* 2 : * Copyright (c) 2014 Juniper Networks, Inc. All rights reserved. 3 : * Copyright Contributors to the OpenSDN project 4 : */ 5 : #ifndef SRC_VNSW_AGENT_OPER_LOGICAL_PORT_H_ 6 : #define SRC_VNSW_AGENT_OPER_LOGICAL_PORT_H_ 7 : 8 : #include <cmn/agent_cmn.h> 9 : #include <cmn/agent.h> 10 : #include <string> 11 : 12 : class IFMapDependencyManager; 13 : 14 : class VmInterface; 15 : class SandeshLogicalInterface; 16 : 17 : struct LogicalInterfaceKey; 18 : struct LogicalInterfaceData; 19 : 20 : class LogicalInterface : public Interface { 21 : public: 22 : enum Type { 23 : VLAN 24 : }; 25 : 26 : explicit LogicalInterface(const boost::uuids::uuid &uuid, 27 : const std::string &name, 28 : const boost::uuids::uuid &logical_router_uuid); 29 : virtual ~LogicalInterface(); 30 : 31 : virtual bool CmpInterface(const DBEntry &rhs) const; 32 : virtual std::string ToString() const; 33 : virtual bool Delete(const DBRequest *req); 34 : virtual void GetOsParams(Agent *agent); 35 : virtual bool OnChange(const InterfaceTable *table, 36 : const LogicalInterfaceData *data); 37 : 38 : const std::string &display_name() const { return display_name_; } 39 0 : const std::string &phy_dev_display_name() const { return phy_dev_display_name_; } 40 0 : const std::string &phy_intf_display_name() const { return phy_intf_display_name_; } 41 : Interface *physical_interface() const; 42 : VmInterface *vm_interface() const; 43 : PhysicalDevice *physical_device() const; 44 : 45 : private: 46 : friend class InterfaceTable; 47 : std::string display_name_; 48 : InterfaceRef physical_interface_; 49 : InterfaceRef vm_interface_; 50 : boost::uuids::uuid vm_uuid_; 51 : PhysicalDeviceRef physical_device_; 52 : std::string phy_dev_display_name_; 53 : std::string phy_intf_display_name_; 54 : boost::uuids::uuid vn_uuid_; 55 : DISALLOW_COPY_AND_ASSIGN(LogicalInterface); 56 : }; 57 : 58 : struct LogicalInterfaceKey : public InterfaceKey { 59 : explicit LogicalInterfaceKey(const boost::uuids::uuid &uuid, 60 : const std::string &name); 61 : virtual ~LogicalInterfaceKey(); 62 : 63 : }; 64 : 65 : struct LogicalInterfaceData : public InterfaceData { 66 : LogicalInterfaceData(Agent *agent, IFMapNode *node, 67 : const std::string &display_name, 68 : const std::string &physical_interface, 69 : const boost::uuids::uuid &vif, 70 : const boost::uuids::uuid &device_uuid, 71 : const std::string &phy_dev_display_name, 72 : const std::string &phy_intf_display_name); 73 : virtual ~LogicalInterfaceData(); 74 : 75 : std::string display_name_; 76 : std::string physical_interface_; 77 : boost::uuids::uuid vm_interface_; 78 : boost::uuids::uuid device_uuid_; 79 : std::string phy_dev_display_name_; 80 : std::string phy_intf_display_name_; 81 : }; 82 : 83 : struct VlanLogicalInterfaceKey : public LogicalInterfaceKey { 84 : explicit VlanLogicalInterfaceKey(const boost::uuids::uuid &uuid, 85 : const std::string &name); 86 : virtual ~VlanLogicalInterfaceKey(); 87 : 88 : virtual LogicalInterface *AllocEntry(const InterfaceTable *table) const; 89 : virtual LogicalInterface *AllocEntry(const InterfaceTable *table, 90 : const InterfaceData *data) const; 91 : virtual InterfaceKey *Clone() const; 92 : }; 93 : 94 : struct VlanLogicalInterfaceData : public LogicalInterfaceData { 95 : VlanLogicalInterfaceData(Agent *agent, IFMapNode *node, 96 : const std::string &display_name, 97 : const std::string &physical_interface, 98 : const boost::uuids::uuid &vif, 99 : const boost::uuids::uuid &device_uuid, 100 : const std::string &phy_dev_display_name, 101 : const std::string &phy_intf_display_name, 102 : uint16_t vlan); 103 : virtual ~VlanLogicalInterfaceData(); 104 : 105 : uint16_t vlan_; 106 : }; 107 : 108 : class VlanLogicalInterface : public LogicalInterface { 109 : public: 110 : explicit VlanLogicalInterface(const boost::uuids::uuid &uuid, 111 : const std::string &name, uint16_t vlan, 112 : const boost::uuids::uuid &lr_uuid); 113 : virtual ~VlanLogicalInterface(); 114 : virtual DBEntryBase::KeyPtr GetDBRequestKey() const; 115 : 116 7 : uint16_t vlan() const { return vlan_; } 117 : 118 : private: 119 : // IMP: vlan_ cannot be changed 120 : uint16_t vlan_; 121 : DISALLOW_COPY_AND_ASSIGN(VlanLogicalInterface); 122 : }; 123 : 124 : #endif // SRC_VNSW_AGENT_OPER_LOGICAL_PORT_H_