FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
ra_prefix.cpp
Go to the documentation of this file.
1 /*
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/api_types.hpp"
19 #include "vom/ra_prefix.hpp"
20 
21 namespace VOM {
23  uint8_t use_default,
24  uint8_t no_advertise,
25  uint32_t val_lifetime,
26  uint32_t pref_lifetime)
27  : m_pfx(pfx)
28  , m_use_default(use_default)
29  , m_no_advertise(no_advertise)
30  , m_off_link(0)
31  , m_no_autoconfig(0)
32  , m_no_onlink(0)
33  , m_val_lifetime(val_lifetime)
34  , m_pref_lifetime(pref_lifetime)
35 {
36 }
37 
38 void
39 ra_prefix::to_vpp(vapi_payload_sw_interface_ip6nd_ra_prefix& ra_prefix) const
40 {
41  ra_prefix.prefix = to_api(m_pfx);
42 
43  ra_prefix.use_default = m_use_default;
44  ra_prefix.no_advertise = m_no_advertise;
45  ra_prefix.off_link = m_off_link;
46  ra_prefix.no_autoconfig = m_no_autoconfig;
47  ra_prefix.no_onlink = m_no_onlink;
48  ra_prefix.val_lifetime = m_val_lifetime;
49  ra_prefix.pref_lifetime = m_pref_lifetime;
50 }
51 
52 bool
53 ra_prefix::operator==(const ra_prefix& other) const
54 {
55  return ((m_pfx == other.m_pfx) && (m_use_default == other.m_use_default) &&
56  (m_no_advertise == other.m_no_advertise) &&
57  (m_val_lifetime == other.m_val_lifetime) &&
58  (m_pref_lifetime == other.m_pref_lifetime));
59 }
60 
63 {
64  std::ostringstream s;
65 
66  s << "ra-pfx-config:["
67  << " pfx:" << m_pfx.to_string() << " use-default:" << m_use_default
68  << " no-advertise:" << m_no_advertise << " val-lifetime:" << m_val_lifetime
69  << " pref-lifetime:" << m_pref_lifetime << "]";
70 
71  return (s.str());
72 }
73 
74 const route::prefix_t&
76 {
77  return (m_pfx);
78 }
79 }
80 
81 /*
82  * fd.io coding-style-patch-verification: OFF
83  *
84  * Local Variables:
85  * eval: (c-set-style "mozilla")
86  * End:
87  */
VOM::route::prefix_t
A prefix defintion.
Definition: prefix.hpp:131
VOM
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
VOM::ra_prefix
A representation of RA prefix configuration on given interface.
Definition: ra_prefix.hpp:27
VOM::ra_prefix::ra_prefix
ra_prefix(const route::prefix_t &pfx, uint8_t use_default, uint8_t no_advertise, uint32_t val_lifetime, uint32_t pref_lifetime)
Construct a new object matching the desried state.
Definition: ra_prefix.cpp:22
VOM::route::prefix_t::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: prefix.cpp:214
VOM::ra_prefix::operator==
bool operator==(const ra_prefix &ra_prefix) const
Comparison operator - only used for UT.
Definition: ra_prefix.cpp:53
VOM::ra_prefix::prefix
const route::prefix_t & prefix() const
Return the prefix associated with this ra prefix.
Definition: ra_prefix.cpp:75
VOM::to_api
vapi_enum_ip_neighbor_flags to_api(const neighbour::flags_t &f)
Definition: api_types.cpp:21
VOM::ra_prefix::to_string
std::string to_string() const
convert to string format for debug purposes
Definition: ra_prefix.cpp:62
ra_prefix.hpp
VOM::ra_prefix::to_vpp
void to_vpp(vapi_payload_sw_interface_ip6nd_ra_prefix &ra_prefix) const
Convert the ra prefix configuration to Vpp Api.
Definition: ra_prefix.cpp:39
api_types.hpp
string
const char *const string
Definition: cJSON.h:172