aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp-api/vom/ra_config.cpp
blob: de424a4d436e2eed03bcf005a0bfb4aee20a7133 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
 * Copyright (c) 2017 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <sstream>

#include "vom/ra_config.hpp"

namespace VOM {

/**
 * Construct a new object matching the desried state
 */
ra_config::ra_config(uint8_t suppress,
                     uint8_t send_unicast,
                     uint8_t default_router,
                     uint32_t max_interval)
  : m_suppress(suppress)
  , m_managed(0)
  , m_other(0)
  , m_ll_option(0)
  , m_send_unicast(send_unicast)
  , m_cease(0)
  , m_default_router(default_router)
  , m_max_interval(max_interval)
  , m_min_interval((max_interval * 3) / 4)
  , m_lifetime(600)
  , m_initial_count(3)
  , m_initial_interval(16)
{
}

void
ra_config::to_vpp(vapi_payload_sw_interface_ip6nd_ra_config& ra_config) const
{
  ra_config.suppress = m_suppress;
  ra_config.managed = m_managed;
  ra_config.other = m_other;
  ra_config.ll_option = m_ll_option;
  ra_config.send_unicast = m_send_unicast;
  ra_config.cease = m_cease;
  ra_config.max_interval = m_max_interval;
  ra_config.min_interval = m_min_interval;
  ra_config.lifetime = m_lifetime;
  ra_config.initial_count = m_initial_count;
  ra_config.initial_interval = m_initial_interval;
}

bool
ra_config::operator==(const ra_config& other) const
{
  return ((m_suppress == other.m_suppress) &&
          (m_send_unicast == other.m_send_unicast) &&
          (m_default_router == other.m_default_router) &&
          (m_max_interval == other.m_max_interval));
}

std::string
ra_config::to_string() const
{
  std::ostringstream s;

  s << "ra-config:["
    << " suppress:" << m_suppress << " send-unicast:" << m_send_unicast
    << " default-router:" << m_default_router
    << " max_interval:" << m_max_interval << "]";

  return (s.str());
}
}
/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "mozilla")
 * End:
 */