aboutsummaryrefslogtreecommitdiffstats
path: root/src/VppSpineProxy.cpp
blob: b658e2b867bf0cbb50bbc09955cbbbbf893c31f0 (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
/* -*- 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
 */

#include <vom/om.hpp>
#include <vom/vxlan_tunnel.hpp>

#include "VppSpineProxy.hpp"

using namespace VOM;

namespace VPP
{
SpineProxy::SpineProxy(const boost::asio::ip::address_v4 &local,
                       const boost::asio::ip::address_v4 &remote_v4,
                       const boost::asio::ip::address_v4 &remote_v6,
                       const boost::asio::ip::address_v4 &remote_mac)
    : m_local(local)
    , m_remote_v4(remote_v4)
    , m_remote_v6(remote_v6)
    , m_remote_mac(remote_mac)
{
}

const std::shared_ptr<VOM::vxlan_tunnel>
SpineProxy::mk_v4(const std::string &key, uint32_t vnid)
{
    return (mk_intf(key, m_local, m_remote_v4, vnid));
}

const std::shared_ptr<VOM::vxlan_tunnel>
SpineProxy::mk_v6(const std::string &key, uint32_t vnid)
{
    return (mk_intf(key, m_local, m_remote_v6, vnid));
}

const std::shared_ptr<VOM::vxlan_tunnel>
SpineProxy::mk_mac(const std::string &key, uint32_t vnid)
{
    return (mk_intf(key, m_local, m_remote_mac, vnid));
}

const std::shared_ptr<VOM::vxlan_tunnel>
SpineProxy::mk_intf(const std::string &key,
                    boost::asio::ip::address_v4 &src,
                    boost::asio::ip::address_v4 &dst,
                    uint32_t vnid)
{
    std::shared_ptr<VOM::vxlan_tunnel> vt = std::make_shared<vxlan_tunnel>(
        src, dst, vnid, vxlan_tunnel::mode_t::GBP_L2);
    OM::write(key, *vt);

    return vt;
}
};

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