blob: 1cf096370826831e2ba0460feb5c9b3989af3e4b [file] [log] [blame]
Neale Ranns812ed392017-10-16 04:20:13 -07001/*
2 * Copyright (c) 2017 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#include <sstream>
17
18#include "vom/ra_prefix.hpp"
19
20namespace VOM {
21ra_prefix::ra_prefix(const route::prefix_t& pfx,
22 uint8_t use_default,
23 uint8_t no_advertise,
24 uint32_t val_lifetime,
25 uint32_t pref_lifetime)
26 : m_pfx(pfx)
27 , m_use_default(use_default)
28 , m_no_advertise(no_advertise)
29 , m_off_link(0)
30 , m_no_autoconfig(0)
31 , m_no_onlink(0)
32 , m_val_lifetime(val_lifetime)
33 , m_pref_lifetime(pref_lifetime)
34{
35}
36
37void
38ra_prefix::to_vpp(vapi_payload_sw_interface_ip6nd_ra_prefix& ra_prefix) const
39{
40 uint8_t is_ipv6 = 0;
41
42 m_pfx.to_vpp(&is_ipv6, ra_prefix.address, &ra_prefix.address_length);
43
44 ra_prefix.use_default = m_use_default;
45 ra_prefix.no_advertise = m_no_advertise;
46 ra_prefix.off_link = m_off_link;
47 ra_prefix.no_autoconfig = m_no_autoconfig;
48 ra_prefix.no_onlink = m_no_onlink;
49 ra_prefix.val_lifetime = m_val_lifetime;
50 ra_prefix.pref_lifetime = m_pref_lifetime;
51}
52
53bool
54ra_prefix::operator==(const ra_prefix& other) const
55{
56 return ((m_pfx == other.m_pfx) && (m_use_default == other.m_use_default) &&
57 (m_no_advertise == other.m_no_advertise) &&
58 (m_val_lifetime == other.m_val_lifetime) &&
59 (m_pref_lifetime == other.m_pref_lifetime));
60}
61
62std::string
63ra_prefix::to_string() const
64{
65 std::ostringstream s;
66
67 s << "ra-pfx-config:["
68 << " pfx:" << m_pfx.to_string() << " use-default:" << m_use_default
69 << " no-advertise:" << m_no_advertise << " val-lifetime:" << m_val_lifetime
70 << " pref-lifetime:" << m_pref_lifetime << "]";
71
72 return (s.str());
73}
74
75const route::prefix_t&
76ra_prefix::prefix() const
77{
78 return (m_pfx);
79}
80}
81
82/*
83 * fd.io coding-style-patch-verification: ON
84 *
85 * Local Variables:
86 * eval: (c-set-style "mozilla")
87 * End:
88 */