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