aboutsummaryrefslogtreecommitdiffstats
path: root/src/include/VppEndPointGroupManager.hpp
blob: 23bc2862cb0e43ff769f42aa99d7e87941413b38 (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
/* -*- C++ -*-; c-basic-offset: 4; indent-tabs-mode: nil */
/*
 * Copyright (c) 2017 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
 */

#include <boost/optional.hpp>

#include <opflexagent/Agent.h>

#include "VppRuntime.hpp"

namespace VOM
{
class gbp_endpoint_group;
class gbp_bridge_domain;
class gbp_route_domain;
class bridge_domain;
class route_domain;
class vxlan_tunnel;
};

namespace VPP
{
class EndPointGroupManager
{
  public:
    struct ForwardInfo
    {
        ForwardInfo();
        ~ForwardInfo() = default;

        uint16_t sclass;
        uint32_t vnid;
        uint32_t rdId;
        uint32_t bdId;
        boost::optional<opflex::modb::URI> rdURI;
        boost::optional<opflex::modb::URI> bdURI;
    };
    struct NoFowardInfoException
    {
        NoFowardInfoException(std::string s)
            : reason(s)
        {
        }

        std::string reason;
    };

    EndPointGroupManager(Runtime &runtime);

    static ForwardInfo
    get_fwd_info(Runtime &r,
                 const opflex::modb::URI &uri) throw(NoFowardInfoException);
    static ForwardInfo get_fwd_info_ext_itf(
        Runtime &r, const opflex::modb::URI &uri) throw(NoFowardInfoException);

    void handle_update(const opflex::modb::URI &epgURI);

    static std::shared_ptr<VOM::gbp_endpoint_group>
    mk_group(Runtime &r,
             const std::string &key,
             const opflex::modb::URI &uri,
             bool is_ext = false);

    static std::shared_ptr<VOM::gbp_route_domain>
    mk_gbp_rd(Runtime &r,
              const std::string &key,
              const VOM::route_domain &rd,
              uint32_t vnid);

    static std::shared_ptr<vxlan_tunnel>
    mk_mcast_tunnel(Runtime &r,
                    const std::string &key,
                    uint32_t vni,
                    const std::string &maddr);

    static std::shared_ptr<VOM::interface>
    mk_bvi(Runtime &r,
           const std::string &key,
           const VOM::bridge_domain &bd,
           const VOM::route_domain &rd,
           const boost::optional<mac_address_t> &mac = boost::none);

  private:
    /**
     * Referene to runtime data.
     */
    Runtime &m_runtime;
};
};

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