aboutsummaryrefslogtreecommitdiffstats
path: root/src/include/VppUplink.hpp
blob: 7c8b738954418154a44e61812ced8b13c438fca8 (plain)
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/* -*- C++ -*-; c-basic-offset: 4; indent-tabs-mode: nil */
/*
 * Copyright (c) 2017-2018 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */

#ifndef __VPP_UPLINK_H__
#define __VPP_UPLINK_H__

#include <unordered_set>

#include "opflexagent/Agent.h"

#include <vom/dhcp_client.hpp>
#include <vom/tap_interface.hpp>
#include <vom/vxlan_tunnel.hpp>

//#include "VppSpineProxy.hpp"

using namespace VOM;

namespace VPP
{
class SpineProxy;
/**
 * A description of the uplink interface.
 *  Can be one of VLAN< VXLAN or iVXLAN
 */
class Uplink : public dhcp_client::event_listener
{
  public:
    /**
     * The uplink interface's encapsulation type for data traffic.
     */
    enum uplink_type_t
    {
        /**
         * VXLAN encap
         */
        VXLAN,
        /**
         * VLAN encap
         */
        VLAN,
    };

    /**
     * Default Constructor
     */
    Uplink(opflexagent::Agent &agent);

    /**
     * Given the VNID, create an interface of the appropriate type
     */
    std::shared_ptr<interface> mk_interface(const std::string &uuid,
                                            uint32_t vnid);

    /**
     * Set the uplink paramenters for vxlan
     */
    void set(const std::string &uplink,
             uint16_t vlan,
             const std::string &name,
             const boost::asio::ip::address &ip,
             uint16_t port);

    /**
     * Set the uplink paramenters for vlan
     */
    void set(const std::string &uplink, uint16_t vlan, const std::string &name);

    /**
     * make the control channel/interfaces
     *
     * @param fqdn Fully Qualifed Domain name
     */
    void configure(const std::string &fqdn);

    /**
     * insert the new slave interface in the slave_ifaces
     */
    void insert_slave_ifaces(std::string name);

    /**
     * insert the dhcp options
     */
    void insert_dhcp_options(std::string name);

    const boost::asio::ip::address &local_address() const;
    const std::shared_ptr<interface> local_interface() const;
    const std::string uplink_l2_address() const;
    /**
     * Handle notifications about DHCP complete
     */
    void handle_dhcp_event(std::shared_ptr<dhcp_client::lease_t> lease);

    std::shared_ptr<SpineProxy> spine_proxy();
    const std::string &system_name() const;

  private:
    void handle_dhcp_event_i(std::shared_ptr<dhcp_client::lease_t> lease);

    /**
     * Configure the tap interface
     */
    void configure_tap(const route::prefix_t &pfx);

    /**
     * VXLAN uplink encap, if used
     */
    vxlan_tunnel::endpoint_t m_vxlan;

    /**
     * A reference to the uplink physical insterface
     */
    std::shared_ptr<interface> m_uplink;

    /**
     * A reference to the uplink vlan insterface
     */
    std::shared_ptr<interface> m_subitf;

    /**
     * the encap type on the uplinnk
     */
    uplink_type_t m_type;

    /**
     * The VLAN used for control traffic
     */
    uint16_t m_vlan;

    /**
     * The name of the uplink interface
     */
    std::string m_iface;

    /**
     * The system name
     */
    std::string m_system_name;

    /**
     * The name of the slave interfaces (in case of Bond)
     */
    std::unordered_set<std::string> slave_ifaces;

    /**
     * The dhcp options for uplink interface
     */
    std::unordered_set<std::string> dhcp_options;

    /**
     * the uber agent
     */
    opflexagent::Agent &m_agent;

    route::prefix_t m_pfx;
};
};

/*
 * Local Variables:
 * eval: (c-set-style "llvm.org")
 * End:
 */

#endif