aboutsummaryrefslogtreecommitdiffstats
path: root/extras/vom
diff options
context:
space:
mode:
Diffstat (limited to 'extras/vom')
-rw-r--r--extras/vom/vom/dhcp_client.cpp22
-rw-r--r--extras/vom/vom/dhcp_client.hpp7
-rw-r--r--extras/vom/vom/dhcp_client_cmds.cpp10
-rw-r--r--extras/vom/vom/dhcp_client_cmds.hpp8
-rw-r--r--extras/vom/vom/prefix.cpp31
-rw-r--r--extras/vom/vom/prefix.hpp39
-rw-r--r--extras/vom/vom/route_api_types.cpp71
-rw-r--r--extras/vom/vom/route_api_types.hpp3
8 files changed, 174 insertions, 17 deletions
diff --git a/extras/vom/vom/dhcp_client.cpp b/extras/vom/vom/dhcp_client.cpp
index fcadfa69ded..e3a5b9d5559 100644
--- a/extras/vom/vom/dhcp_client.cpp
+++ b/extras/vom/vom/dhcp_client.cpp
@@ -15,6 +15,7 @@
#include "vom/dhcp_client.hpp"
#include "vom/dhcp_client_cmds.hpp"
+#include "vom/route_api_types.hpp"
#include "vom/singular_db_funcs.hpp"
namespace VOM {
@@ -47,11 +48,13 @@ dhcp_client::event_handler dhcp_client::m_evh;
dhcp_client::dhcp_client(const interface& itf,
const std::string& hostname,
bool set_broadcast_flag,
+ const ip_dscp_t& dscp,
event_listener* ev)
: m_itf(itf.singular())
, m_hostname(hostname)
, m_client_id(l2_address_t::ZERO)
, m_set_broadcast_flag(set_broadcast_flag)
+ , m_dscp(dscp)
, m_binding(0)
, m_evl(ev)
, m_event_cmd(get_event_cmd())
@@ -62,11 +65,13 @@ dhcp_client::dhcp_client(const interface& itf,
const std::string& hostname,
const l2_address_t& client_id,
bool set_broadcast_flag,
+ const ip_dscp_t& dscp,
event_listener* ev)
: m_itf(itf.singular())
, m_hostname(hostname)
, m_client_id(client_id)
, m_set_broadcast_flag(set_broadcast_flag)
+ , m_dscp(dscp)
, m_binding(0)
, m_evl(ev)
, m_event_cmd(get_event_cmd())
@@ -78,6 +83,7 @@ dhcp_client::dhcp_client(const dhcp_client& o)
, m_hostname(o.m_hostname)
, m_client_id(o.m_client_id)
, m_set_broadcast_flag(o.m_set_broadcast_flag)
+ , m_dscp(o.m_dscp)
, m_binding(0)
, m_evl(o.m_evl)
, m_event_cmd(o.m_event_cmd)
@@ -96,7 +102,7 @@ bool
dhcp_client::operator==(const dhcp_client& l) const
{
return ((key() == l.key()) && (m_hostname == l.m_hostname) &&
- (m_client_id == l.m_client_id));
+ (m_client_id == l.m_client_id && m_dscp == l.m_dscp));
}
const dhcp_client::key_t&
@@ -125,8 +131,8 @@ void
dhcp_client::replay()
{
if (m_binding) {
- HW::enqueue(new dhcp_client_cmds::bind_cmd(m_binding, m_itf->handle(),
- m_hostname, m_client_id));
+ HW::enqueue(new dhcp_client_cmds::bind_cmd(
+ m_binding, m_itf->handle(), m_hostname, m_client_id, false, m_dscp));
}
}
@@ -135,7 +141,8 @@ dhcp_client::to_string() const
{
std::ostringstream s;
s << "DHCP-client: " << m_itf->to_string() << " hostname:" << m_hostname
- << " client_id:[" << m_client_id << "] " << m_binding.to_string();
+ << " client_id:[" << m_client_id << "] "
+ << "dscp:" << m_dscp.to_string() << " " << m_binding.to_string();
if (m_lease)
s << " " << m_lease->to_string();
else
@@ -151,8 +158,8 @@ dhcp_client::update(const dhcp_client& desired)
* the desired state is always that the interface should be created
*/
if (!m_binding) {
- HW::enqueue(new dhcp_client_cmds::bind_cmd(m_binding, m_itf->handle(),
- m_hostname, m_client_id));
+ HW::enqueue(new dhcp_client_cmds::bind_cmd(
+ m_binding, m_itf->handle(), m_hostname, m_client_id, false, m_dscp));
}
if (desired.m_lease)
@@ -276,7 +283,8 @@ dhcp_client::event_handler::handle_populate(const client_db::key_t& key)
std::string hostname =
reinterpret_cast<const char*>(payload.lease.hostname);
l2_address_t l2(payload.client.id + 1);
- dhcp_client dc(*itf, hostname, l2, payload.client.set_broadcast_flag);
+ dhcp_client dc(*itf, hostname, l2, payload.client.set_broadcast_flag,
+ from_api(payload.client.dscp));
dc.lease(std::make_shared<dhcp_client::lease_t>(
s, itf, from_bytes(0, payload.lease.router_address), pfx, hostname,
mac_address_t(payload.lease.host_mac)));
diff --git a/extras/vom/vom/dhcp_client.hpp b/extras/vom/vom/dhcp_client.hpp
index 17c626ed0f1..8e8669a96ef 100644
--- a/extras/vom/vom/dhcp_client.hpp
+++ b/extras/vom/vom/dhcp_client.hpp
@@ -112,6 +112,7 @@ public:
dhcp_client(const interface& itf,
const std::string& hostname,
bool set_broadcast_flag = true,
+ const ip_dscp_t& dscp = ip_dscp_t::DSCP_CS0,
event_listener* ev = nullptr);
/**
@@ -121,6 +122,7 @@ public:
const std::string& hostname,
const l2_address_t& client_id,
bool set_broadcast_flag = true,
+ const ip_dscp_t& dscp = ip_dscp_t::DSCP_CS0,
event_listener* ev = nullptr);
/**
@@ -259,6 +261,11 @@ private:
const bool m_set_broadcast_flag;
/**
+ * DSCP setting for generated IP packets
+ */
+ const ip_dscp_t m_dscp;
+
+ /**
* HW configuration for the binding. The bool representing the
* do/don't bind.
*/
diff --git a/extras/vom/vom/dhcp_client_cmds.cpp b/extras/vom/vom/dhcp_client_cmds.cpp
index 9b632fe88f9..c1d4d49a495 100644
--- a/extras/vom/vom/dhcp_client_cmds.cpp
+++ b/extras/vom/vom/dhcp_client_cmds.cpp
@@ -14,6 +14,7 @@
*/
#include "vom/dhcp_client_cmds.hpp"
+#include "vom/route_api_types.hpp"
DEFINE_VAPI_MSG_IDS_DHCP_API_JSON;
@@ -24,12 +25,14 @@ bind_cmd::bind_cmd(HW::item<bool>& item,
const handle_t& itf,
const std::string& hostname,
const l2_address_t& client_id,
- bool set_broadcast_flag)
+ bool set_broadcast_flag,
+ const ip_dscp_t& dscp)
: rpc_cmd(item)
, m_itf(itf)
, m_hostname(hostname)
, m_client_id(client_id)
, m_set_broadcast_flag(set_broadcast_flag)
+ , m_dscp(dscp)
{
}
@@ -50,6 +53,7 @@ bind_cmd::issue(connection& con)
payload.client.pid = getpid();
payload.client.want_dhcp_event = 1;
payload.client.set_broadcast_flag = m_set_broadcast_flag;
+ payload.client.dscp = to_api(m_dscp);
memset(payload.client.hostname, 0, sizeof(payload.client.hostname));
memcpy(payload.client.hostname, m_hostname.c_str(),
@@ -71,7 +75,9 @@ bind_cmd::to_string() const
{
std::ostringstream s;
s << "Dhcp-client-bind: " << m_hw_item.to_string()
- << " itf:" << m_itf.to_string() << " hostname:" << m_hostname;
+ << " itf:" << m_itf.to_string() << " hostname:" << m_hostname
+ << " client_id:[" << m_client_id << "] "
+ << "dscp:" << m_dscp.to_string();
return (s.str());
}
diff --git a/extras/vom/vom/dhcp_client_cmds.hpp b/extras/vom/vom/dhcp_client_cmds.hpp
index 89fe7eefa73..10d4026f4f3 100644
--- a/extras/vom/vom/dhcp_client_cmds.hpp
+++ b/extras/vom/vom/dhcp_client_cmds.hpp
@@ -39,7 +39,8 @@ public:
const handle_t& itf,
const std::string& hostname,
const l2_address_t& client_id,
- bool set_braodcast_flag = false);
+ bool set_braodcast_flag,
+ const ip_dscp_t& dscp);
/**
* Issue the command to VPP/HW
@@ -75,6 +76,11 @@ private:
* Flag to control the setting the of DHCP discover's broadcast flag
*/
const bool m_set_broadcast_flag;
+
+ /**
+ * DSCP bits
+ */
+ const ip_dscp_t& m_dscp;
};
/**
diff --git a/extras/vom/vom/prefix.cpp b/extras/vom/vom/prefix.cpp
index a6305997f53..45cb6df54c9 100644
--- a/extras/vom/vom/prefix.cpp
+++ b/extras/vom/vom/prefix.cpp
@@ -96,6 +96,37 @@ nh_proto_t::from_address(const boost::asio::ip::address& addr)
return IPV4;
}
+const ip_dscp_t ip_dscp_t::DSCP_CS0(0, "CS0");
+const ip_dscp_t ip_dscp_t::DSCP_CS1(8, "CS1");
+const ip_dscp_t ip_dscp_t::DSCP_CS2(16, "CS2");
+const ip_dscp_t ip_dscp_t::DSCP_CS3(24, "CS3");
+const ip_dscp_t ip_dscp_t::DSCP_CS4(32, "CS4");
+const ip_dscp_t ip_dscp_t::DSCP_CS5(40, "CS5");
+const ip_dscp_t ip_dscp_t::DSCP_CS6(48, "CS6");
+const ip_dscp_t ip_dscp_t::DSCP_CS7(50, "CS7");
+const ip_dscp_t ip_dscp_t::DSCP_AF11(10, "AF11");
+const ip_dscp_t ip_dscp_t::DSCP_AF12(12, "AF12");
+const ip_dscp_t ip_dscp_t::DSCP_AF13(14, "AF13");
+const ip_dscp_t ip_dscp_t::DSCP_AF21(18, "AF21");
+const ip_dscp_t ip_dscp_t::DSCP_AF22(20, "AF22");
+const ip_dscp_t ip_dscp_t::DSCP_AF23(22, "AF23");
+const ip_dscp_t ip_dscp_t::DSCP_AF31(26, "AF31");
+const ip_dscp_t ip_dscp_t::DSCP_AF32(28, "AF32");
+const ip_dscp_t ip_dscp_t::DSCP_AF33(30, "AF33");
+const ip_dscp_t ip_dscp_t::DSCP_AF41(34, "AF41");
+const ip_dscp_t ip_dscp_t::DSCP_AF42(36, "AF42");
+const ip_dscp_t ip_dscp_t::DSCP_AF43(38, "AF43");
+const ip_dscp_t ip_dscp_t::DSCP_EF(46, "EF");
+
+ip_dscp_t::ip_dscp_t(int v, const std::string& s)
+ : enum_base<ip_dscp_t>(v, s)
+{
+}
+ip_dscp_t::ip_dscp_t(int v)
+ : enum_base<ip_dscp_t>(v, std::to_string(v))
+{
+}
+
/**
* The all Zeros prefix
*/
diff --git a/extras/vom/vom/prefix.hpp b/extras/vom/vom/prefix.hpp
index b75dc66f86e..fada1d3e274 100644
--- a/extras/vom/vom/prefix.hpp
+++ b/extras/vom/vom/prefix.hpp
@@ -75,6 +75,45 @@ private:
*/
std::ostream& operator<<(std::ostream& os, const l3_proto_t& l3p);
+/**
+ * IP DSCP values
+ */
+class ip_dscp_t : public enum_base<ip_dscp_t>
+{
+public:
+ /* unfortunately some of the CSX names are defined in terminos.h
+ * as macros, hence the longer names */
+ const static ip_dscp_t DSCP_CS0;
+ const static ip_dscp_t DSCP_CS1;
+ const static ip_dscp_t DSCP_CS2;
+ const static ip_dscp_t DSCP_CS3;
+ const static ip_dscp_t DSCP_CS4;
+ const static ip_dscp_t DSCP_CS5;
+ const static ip_dscp_t DSCP_CS6;
+ const static ip_dscp_t DSCP_CS7;
+ const static ip_dscp_t DSCP_AF11;
+ const static ip_dscp_t DSCP_AF12;
+ const static ip_dscp_t DSCP_AF13;
+ const static ip_dscp_t DSCP_AF21;
+ const static ip_dscp_t DSCP_AF22;
+ const static ip_dscp_t DSCP_AF23;
+ const static ip_dscp_t DSCP_AF31;
+ const static ip_dscp_t DSCP_AF32;
+ const static ip_dscp_t DSCP_AF33;
+ const static ip_dscp_t DSCP_AF41;
+ const static ip_dscp_t DSCP_AF42;
+ const static ip_dscp_t DSCP_AF43;
+ const static ip_dscp_t DSCP_EF;
+
+ /**
+ * Constructor allows the creation of any DSCP value
+ */
+ ip_dscp_t(int v);
+
+private:
+ ip_dscp_t(int v, const std::string& s);
+};
+
namespace route {
/**
* type def the table-id
diff --git a/extras/vom/vom/route_api_types.cpp b/extras/vom/vom/route_api_types.cpp
index 31acc84b6fb..b6ab6381b12 100644
--- a/extras/vom/vom/route_api_types.cpp
+++ b/extras/vom/vom/route_api_types.cpp
@@ -123,11 +123,68 @@ from_api(const vapi_type_fib_path& p)
return (route::path(route::path::special_t::DROP));
};
+vapi_enum_ip_dscp
+to_api(const ip_dscp_t& d)
+{
+ return static_cast<vapi_enum_ip_dscp>((int)d);
+}
+const ip_dscp_t&
+from_api(vapi_enum_ip_dscp d)
+{
+ switch (d) {
+ case IP_API_DSCP_CS0:
+ return ip_dscp_t::DSCP_CS0;
+ case IP_API_DSCP_CS1:
+ return ip_dscp_t::DSCP_CS1;
+ case IP_API_DSCP_CS2:
+ return ip_dscp_t::DSCP_CS2;
+ case IP_API_DSCP_CS3:
+ return ip_dscp_t::DSCP_CS3;
+ case IP_API_DSCP_CS4:
+ return ip_dscp_t::DSCP_CS4;
+ case IP_API_DSCP_CS5:
+ return ip_dscp_t::DSCP_CS5;
+ case IP_API_DSCP_CS6:
+ return ip_dscp_t::DSCP_CS6;
+ case IP_API_DSCP_CS7:
+ return ip_dscp_t::DSCP_CS7;
+ case IP_API_DSCP_EF:
+ return ip_dscp_t::DSCP_EF;
+ case IP_API_DSCP_AF11:
+ return ip_dscp_t::DSCP_AF11;
+ case IP_API_DSCP_AF12:
+ return ip_dscp_t::DSCP_AF12;
+ case IP_API_DSCP_AF13:
+ return ip_dscp_t::DSCP_AF13;
+ case IP_API_DSCP_AF21:
+ return ip_dscp_t::DSCP_AF21;
+ case IP_API_DSCP_AF22:
+ return ip_dscp_t::DSCP_AF22;
+ case IP_API_DSCP_AF23:
+ return ip_dscp_t::DSCP_AF23;
+ case IP_API_DSCP_AF31:
+ return ip_dscp_t::DSCP_AF31;
+ case IP_API_DSCP_AF32:
+ return ip_dscp_t::DSCP_AF32;
+ case IP_API_DSCP_AF33:
+ return ip_dscp_t::DSCP_AF33;
+ case IP_API_DSCP_AF41:
+ return ip_dscp_t::DSCP_AF41;
+ case IP_API_DSCP_AF42:
+ return ip_dscp_t::DSCP_AF42;
+ case IP_API_DSCP_AF43:
+ return ip_dscp_t::DSCP_AF43;
+ }
+
+ return ip_dscp_t::DSCP_CS0;
+}
+
}; // namespace VOM
- /*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "mozilla")
- * End:
- */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "mozilla")
+ * End:
+ */
diff --git a/extras/vom/vom/route_api_types.hpp b/extras/vom/vom/route_api_types.hpp
index 25d0902cda1..e741a9d5acc 100644
--- a/extras/vom/vom/route_api_types.hpp
+++ b/extras/vom/vom/route_api_types.hpp
@@ -26,6 +26,9 @@ void to_api(const route::path& p, vapi_type_fib_path& o);
route::path from_api(const vapi_type_fib_path& p);
+vapi_enum_ip_dscp to_api(const ip_dscp_t& d);
+const ip_dscp_t& from_api(vapi_enum_ip_dscp d);
+
}; // namespace VOM
/*