FD.io VPP  v19.08.3-2-gbabecb413
Vector Packet Processing
ra_config.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/ra_config.hpp"
19 
20 namespace VOM {
21 
22 /**
23  * Construct a new object matching the desried state
24  */
25 ra_config::ra_config(uint8_t suppress,
26  uint8_t send_unicast,
27  uint8_t default_router,
28  uint32_t max_interval)
29  : m_suppress(suppress)
30  , m_managed(0)
31  , m_other(0)
32  , m_ll_option(0)
33  , m_send_unicast(send_unicast)
34  , m_cease(0)
35  , m_default_router(default_router)
36  , m_max_interval(max_interval)
37  , m_min_interval((max_interval * 3) / 4)
38  , m_lifetime(600)
39  , m_initial_count(3)
40  , m_initial_interval(16)
41 {
42 }
43 
44 void
45 ra_config::to_vpp(vapi_payload_sw_interface_ip6nd_ra_config& ra_config) const
46 {
47  ra_config.suppress = m_suppress;
48  ra_config.managed = m_managed;
49  ra_config.other = m_other;
50  ra_config.ll_option = m_ll_option;
51  ra_config.send_unicast = m_send_unicast;
52  ra_config.cease = m_cease;
53  ra_config.max_interval = m_max_interval;
54  ra_config.min_interval = m_min_interval;
55  ra_config.lifetime = m_lifetime;
56  ra_config.initial_count = m_initial_count;
57  ra_config.initial_interval = m_initial_interval;
58 }
59 
60 bool
61 ra_config::operator==(const ra_config& other) const
62 {
63  return ((m_suppress == other.m_suppress) &&
64  (m_send_unicast == other.m_send_unicast) &&
65  (m_default_router == other.m_default_router) &&
66  (m_max_interval == other.m_max_interval));
67 }
68 
69 std::string
71 {
72  std::ostringstream s;
73 
74  s << "ra-config:["
75  << " suppress:" << m_suppress << " send-unicast:" << m_send_unicast
76  << " default-router:" << m_default_router
77  << " max_interval:" << m_max_interval << "]";
78 
79  return (s.str());
80 }
81 }
82 /*
83  * fd.io coding-style-patch-verification: ON
84  *
85  * Local Variables:
86  * eval: (c-set-style "mozilla")
87  * End:
88  */
ra_config(uint8_t suppress, uint8_t send_unicast, uint8_t default_router, uint32_t max_interval)
Construct a new object matching the desried state.
Definition: ra_config.cpp:25
std::string to_string() const
convert to string format for debug purposes
Definition: ra_config.cpp:70
bool operator==(const ra_config &ra_config) const
Comparison operator - only used for UT.
Definition: ra_config.cpp:61
void to_vpp(vapi_payload_sw_interface_ip6nd_ra_config &ra_config) const
convert the ra config to VPP API
Definition: ra_config.cpp:45
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
A representation of Router Advertisement configuration.
Definition: ra_config.hpp:25