OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
inet_interface.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_inet_interface_hpp
6 #define vnsw_agent_inet_interface_hpp
7 
8 struct InetInterfaceData;
9 
11 // Implementation of inet interfaces created in host-os.
12 //
13 // Example interfaces:
14 // vhost0 : A L3 interface between host-os and vrouter. Used in KVM mode
15 // xenbr : A L3 interface between host-os and vrouter. Used in XEN mode
16 // xapi0 : A L3 interface for link-local subnets. Used in XEN mode
17 // vgw : A un-numbered L3 interface for simple gateway
19 class InetInterface : public Interface {
20 public:
21  enum SubType {
25  };
26 
27  InetInterface(const std::string &name);
28  InetInterface(const std::string &name, SubType sub_type, VrfEntry *vrf,
29  const Ip4Address &ip_addr, int plen, const Ip4Address &gw,
30  Interface *xconnect, const std::string &vn_name);
31  virtual ~InetInterface() { }
32 
33  // DBTable virtual functions
34  KeyPtr GetDBRequestKey() const;
35  std::string ToString() const { return "INET <" + name() + ">"; }
36 
37  // The interfaces are keyed by name. No UUID is allocated for them
38  virtual bool CmpInterface(const DBEntry &rhs) const;
39  SubType sub_type() const { return sub_type_; }
40  const Ip4Address &ip_addr() const { return ip_addr_; }
41  Interface *xconnect() const { return xconnect_.get(); }
42 
43  void PostAdd();
44  bool OnChange(InetInterfaceData *data);
45  bool Delete(const DBRequest *req);
46  void Activate();
47  void DeActivate();
48 
49  void ActivateSimpleGateway();
51  void ActivateHostInterface();
55 
56  // Helper functions
57  static void Create(InterfaceTable *table, const std::string &ifname,
58  SubType sub_type, const std::string &vrf_name,
59  const Ip4Address &addr, int plen,
60  const Ip4Address &gw, const std::string &xconnect,
61  const std::string &vn_name,
63  static void CreateReq(InterfaceTable *table, const std::string &ifname,
64  SubType sub_type, const std::string &vrf_name,
65  const Ip4Address &addr, int plen,
66  const Ip4Address &gw, const std::string &xconnect,
67  const std::string &vn_name,
69  static void Delete(InterfaceTable *table, const std::string &ifname);
70  static void DeleteReq(InterfaceTable *table, const std::string &ifname);
71 private:
74  int plen_;
76  InterfaceRef xconnect_; // Physical interface for VHOST
77  std::string vn_name_;
79 };
80 
81 struct InetInterfaceKey : public InterfaceKey {
82  InetInterfaceKey(const std::string &name);
83  virtual ~InetInterfaceKey() { }
84 
85  Interface *AllocEntry(const InterfaceTable *table) const;
86  Interface *AllocEntry(const InterfaceTable *table,
87  const InterfaceData *data) const;
88  InterfaceKey *Clone() const;
89 };
90 
93  const std::string &vrf_name, const Ip4Address &addr,
94  int plen, const Ip4Address &gw,
95  const std::string &xconnect, const std::string vn_name,
96  Interface::Transport transport);
97  virtual ~InetInterfaceData() { }
98 
101  int plen_;
103  std::string xconnect_;
104  std::string vn_name_;
105 };
106 
107 #endif // vnsw_agent_inet_interface_hpp
Interface * xconnect() const
std::string vn_name_
void DelHostMulticastRoutes()
uint8_t sub_type
Definition: load_balance.h:110
Definition: vrf.h:86
virtual ~InetInterfaceData()
void DeActivateSimpleGateway()
void ActivateSimpleGateway()
Interface::Transport transport() const
Definition: interface.h:138
void DeActivateHostInterface()
static void CreateReq(InterfaceTable *table, const std::string &ifname, SubType sub_type, const std::string &vrf_name, const Ip4Address &addr, int plen, const Ip4Address &gw, const std::string &xconnect, const std::string &vn_name, Interface::Transport transport)
VrfEntry * vrf() const
Definition: interface.h:115
std::unique_ptr< DBRequestKey > KeyPtr
Definition: db_entry.h:25
InetInterface::SubType sub_type_
KeyPtr GetDBRequestKey() const
InterfaceRef xconnect_
virtual ~InetInterfaceKey()
InetInterfaceKey(const std::string &name)
static void Create(InterfaceTable *table, const std::string &ifname, SubType sub_type, const std::string &vrf_name, const Ip4Address &addr, int plen, const Ip4Address &gw, const std::string &xconnect, const std::string &vn_name, Interface::Transport transport)
std::string ToString() const
bool OnChange(InetInterfaceData *data)
SubType sub_type_
void ActivateHostInterface()
boost::asio::ip::address_v4 Ip4Address
Definition: address.h:14
Interface * AllocEntry(const InterfaceTable *table) const
void AddHostMulticastRoutes()
void Delete()
Definition: db_entry.cc:131
InetInterface(const std::string &name)
Ip4Address ip_addr_
DISALLOW_COPY_AND_ASSIGN(InetInterface)
InetInterfaceData(InetInterface::SubType sub_type, const std::string &vrf_name, const Ip4Address &addr, int plen, const Ip4Address &gw, const std::string &xconnect, const std::string vn_name, Interface::Transport transport)
const std::string & name() const
Definition: interface.h:114
virtual ~InetInterface()
static void DeleteReq(InterfaceTable *table, const std::string &ifname)
boost::intrusive_ptr< Interface > InterfaceRef
Definition: agent.h:49
const Ip4Address & ip_addr() const
std::string xconnect_
std::string vn_name_
SubType sub_type() const
Ip4Address gw_
InterfaceKey * Clone() const
virtual bool CmpInterface(const DBEntry &rhs) const