-
Notifications
You must be signed in to change notification settings - Fork 390
/
inet_interface.h
107 lines (93 loc) · 3.95 KB
/
inet_interface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
* Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
*/
#ifndef vnsw_agent_inet_interface_hpp
#define vnsw_agent_inet_interface_hpp
struct InetInterfaceData;
/////////////////////////////////////////////////////////////////////////////
// Implementation of inet interfaces created in host-os.
//
// Example interfaces:
// vhost0 : A L3 interface between host-os and vrouter. Used in KVM mode
// xenbr : A L3 interface between host-os and vrouter. Used in XEN mode
// xapi0 : A L3 interface for link-local subnets. Used in XEN mode
// vgw : A un-numbered L3 interface for simple gateway
/////////////////////////////////////////////////////////////////////////////
class InetInterface : public Interface {
public:
enum SubType {
VHOST,
LINK_LOCAL,
SIMPLE_GATEWAY
};
InetInterface(const std::string &name);
InetInterface(const std::string &name, SubType sub_type, VrfEntry *vrf,
const Ip4Address &ip_addr, int plen, const Ip4Address &gw,
Interface *xconnect, const std::string &vn_name);
virtual ~InetInterface() { }
// DBTable virtual functions
KeyPtr GetDBRequestKey() const;
std::string ToString() const { return "INET <" + name() + ">"; }
// The interfaces are keyed by name. No UUID is allocated for them
virtual bool CmpInterface(const DBEntry &rhs) const;
SubType sub_type() const { return sub_type_; }
const Ip4Address &ip_addr() const { return ip_addr_; }
Interface *xconnect() const { return xconnect_.get(); }
void PostAdd();
bool OnChange(InetInterfaceData *data);
bool Delete(const DBRequest *req);
void Activate();
void DeActivate();
void ActivateSimpleGateway();
void DeActivateSimpleGateway();
void ActivateHostInterface();
void DeActivateHostInterface();
void AddHostMulticastRoutes();
void DelHostMulticastRoutes();
// Helper functions
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);
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);
static void Delete(InterfaceTable *table, const std::string &ifname);
static void DeleteReq(InterfaceTable *table, const std::string &ifname);
private:
SubType sub_type_;
Ip4Address ip_addr_;
int plen_;
Ip4Address gw_;
InterfaceRef xconnect_; // Physical interface for VHOST
std::string vn_name_;
DISALLOW_COPY_AND_ASSIGN(InetInterface);
};
struct InetInterfaceKey : public InterfaceKey {
InetInterfaceKey(const std::string &name);
virtual ~InetInterfaceKey() { }
Interface *AllocEntry(const InterfaceTable *table) const;
Interface *AllocEntry(const InterfaceTable *table,
const InterfaceData *data) const;
InterfaceKey *Clone() const;
};
struct InetInterfaceData : public InterfaceData {
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);
virtual ~InetInterfaceData() { }
InetInterface::SubType sub_type_;
Ip4Address ip_addr_;
int plen_;
Ip4Address gw_;
std::string xconnect_;
std::string vn_name_;
};
#endif // vnsw_agent_inet_interface_hpp