diff options
author | 2018-04-25 19:11:15 +0200 | |
---|---|---|
committer | 2018-04-27 11:35:07 +0000 | |
commit | 164e5f8c63652028ecb9c3570e1ea8618b163071 (patch) | |
tree | 7423f5abbc61b761df9a679c7974f17613736020 /extras/vom/vom/ra_prefix.cpp | |
parent | aa682a39b76ee043f65313f23e134bf18fe7a47e (diff) |
Move VOM to extras/vom
Change-Id: Iea174f03dfba3bd06024db0f0cc373532300dcae
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'extras/vom/vom/ra_prefix.cpp')
-rw-r--r-- | extras/vom/vom/ra_prefix.cpp | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/extras/vom/vom/ra_prefix.cpp b/extras/vom/vom/ra_prefix.cpp new file mode 100644 index 00000000000..1cf09637082 --- /dev/null +++ b/extras/vom/vom/ra_prefix.cpp @@ -0,0 +1,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_prefix.hpp" + +namespace VOM { +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) + : m_pfx(pfx) + , m_use_default(use_default) + , m_no_advertise(no_advertise) + , m_off_link(0) + , m_no_autoconfig(0) + , m_no_onlink(0) + , m_val_lifetime(val_lifetime) + , m_pref_lifetime(pref_lifetime) +{ +} + +void +ra_prefix::to_vpp(vapi_payload_sw_interface_ip6nd_ra_prefix& ra_prefix) const +{ + uint8_t is_ipv6 = 0; + + m_pfx.to_vpp(&is_ipv6, ra_prefix.address, &ra_prefix.address_length); + + ra_prefix.use_default = m_use_default; + ra_prefix.no_advertise = m_no_advertise; + ra_prefix.off_link = m_off_link; + ra_prefix.no_autoconfig = m_no_autoconfig; + ra_prefix.no_onlink = m_no_onlink; + ra_prefix.val_lifetime = m_val_lifetime; + ra_prefix.pref_lifetime = m_pref_lifetime; +} + +bool +ra_prefix::operator==(const ra_prefix& other) const +{ + return ((m_pfx == other.m_pfx) && (m_use_default == other.m_use_default) && + (m_no_advertise == other.m_no_advertise) && + (m_val_lifetime == other.m_val_lifetime) && + (m_pref_lifetime == other.m_pref_lifetime)); +} + +std::string +ra_prefix::to_string() const +{ + std::ostringstream s; + + s << "ra-pfx-config:[" + << " pfx:" << m_pfx.to_string() << " use-default:" << m_use_default + << " no-advertise:" << m_no_advertise << " val-lifetime:" << m_val_lifetime + << " pref-lifetime:" << m_pref_lifetime << "]"; + + return (s.str()); +} + +const route::prefix_t& +ra_prefix::prefix() const +{ + return (m_pfx); +} +} + +/* + * fd.io coding-style-patch-verification: ON + * + * Local Variables: + * eval: (c-set-style "mozilla") + * End: + */ |