summaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
authorJakub Grajciar <jgrajcia@cisco.com>2020-03-11 12:47:32 +0100
committerOle Trøan <otroan@employees.org>2020-03-26 17:45:58 +0000
commitaad1ee149403994194cf37cef4530b042ba7df3a (patch)
treea3a3cfabc2bbbc94ecaed842d15fc94c9136be9e /extras
parent4897d77c6d4d5d04eb7e02bda57dc6c7005a609f (diff)
acl: API cleanup
Use consistent API types. Type: fix Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com> Change-Id: If90d753f129312400c4c3669bb86289d0c3e0d99 Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
Diffstat (limited to 'extras')
-rw-r--r--extras/vom/vom/acl_l2_list.cpp25
-rw-r--r--extras/vom/vom/acl_l3_list.cpp24
-rw-r--r--extras/vom/vom/acl_list_cmds.cpp43
3 files changed, 45 insertions, 47 deletions
diff --git a/extras/vom/vom/acl_l2_list.cpp b/extras/vom/vom/acl_l2_list.cpp
index 939fb348d0b..5b05ebdafd4 100644
--- a/extras/vom/vom/acl_l2_list.cpp
+++ b/extras/vom/vom/acl_l2_list.cpp
@@ -42,28 +42,24 @@ l2_list::event_handler::event_handler()
l2_list::l2_list(const key_t& key)
: m_hdl(handle_t::INVALID)
, m_key(key)
-{
-}
+{}
l2_list::l2_list(const handle_t& hdl, const key_t& key)
: m_hdl(hdl)
, m_key(key)
-{
-}
+{}
l2_list::l2_list(const key_t& key, const rules_t& rules)
: m_hdl(handle_t::INVALID)
, m_key(key)
, m_rules(rules)
-{
-}
+{}
l2_list::l2_list(const l2_list& o)
: m_hdl(o.m_hdl)
, m_key(o.m_key)
, m_rules(o.m_rules)
-{
-}
+{}
l2_list::~l2_list()
{
@@ -199,11 +195,14 @@ l2_list::event_handler::handle_populate(const client_db::key_t& key)
l2_list acl(hdl, std::string(reinterpret_cast<const char*>(payload.tag)));
for (unsigned int ii = 0; ii < payload.count; ii++) {
- const route::prefix_t pfx(payload.r[ii].is_ipv6,
- payload.r[ii].src_ip_addr,
- payload.r[ii].src_ip_prefix_len);
- l2_rule rule(ii, action_t::from_int(payload.r[ii].is_permit), pfx,
- { payload.r[ii].src_mac }, { payload.r[ii].src_mac_mask });
+ const route::prefix_t pfx(payload.r[ii].src_prefix.address.af,
+ (uint8_t*)&payload.r[ii].src_prefix.address.un,
+ payload.r[ii].src_prefix.len);
+ l2_rule rule(ii,
+ action_t::from_int(payload.r[ii].is_permit),
+ pfx,
+ { payload.r[ii].src_mac },
+ { payload.r[ii].src_mac_mask });
acl.insert(rule);
}
diff --git a/extras/vom/vom/acl_l3_list.cpp b/extras/vom/vom/acl_l3_list.cpp
index d3e44746ae1..5f1152f0a8f 100644
--- a/extras/vom/vom/acl_l3_list.cpp
+++ b/extras/vom/vom/acl_l3_list.cpp
@@ -42,28 +42,24 @@ l3_list::event_handler::event_handler()
l3_list::l3_list(const key_t& key)
: m_hdl(handle_t::INVALID)
, m_key(key)
-{
-}
+{}
l3_list::l3_list(const handle_t& hdl, const key_t& key)
: m_hdl(hdl)
, m_key(key)
-{
-}
+{}
l3_list::l3_list(const key_t& key, const rules_t& rules)
: m_hdl(handle_t::INVALID)
, m_key(key)
, m_rules(rules)
-{
-}
+{}
l3_list::l3_list(const l3_list& o)
: m_hdl(o.m_hdl)
, m_key(o.m_key)
, m_rules(o.m_rules)
-{
-}
+{}
l3_list::~l3_list()
{
@@ -199,12 +195,12 @@ l3_list::event_handler::handle_populate(const client_db::key_t& key)
l3_list acl(hdl, std::string(reinterpret_cast<const char*>(payload.tag)));
for (unsigned int ii = 0; ii < payload.count; ii++) {
- const route::prefix_t src(payload.r[ii].is_ipv6,
- payload.r[ii].src_ip_addr,
- payload.r[ii].src_ip_prefix_len);
- const route::prefix_t dst(payload.r[ii].is_ipv6,
- payload.r[ii].dst_ip_addr,
- payload.r[ii].dst_ip_prefix_len);
+ const route::prefix_t src(payload.r[ii].src_prefix.address.af,
+ (uint8_t*)&payload.r[ii].src_prefix.address.un,
+ payload.r[ii].src_prefix.len);
+ const route::prefix_t dst(payload.r[ii].dst_prefix.address.af,
+ (uint8_t*)&payload.r[ii].dst_prefix.address.un,
+ payload.r[ii].dst_prefix.len);
l3_rule rule(ii, action_t::from_int(payload.r[ii].is_permit), src, dst);
rule.set_proto(payload.r[ii].proto);
diff --git a/extras/vom/vom/acl_list_cmds.cpp b/extras/vom/vom/acl_list_cmds.cpp
index 343b2e5d513..f873fd171c1 100644
--- a/extras/vom/vom/acl_list_cmds.cpp
+++ b/extras/vom/vom/acl_list_cmds.cpp
@@ -24,9 +24,10 @@ namespace list_cmds {
static void
to_vpp(const l2_rule& rule, vapi_type_macip_acl_rule& payload)
{
- payload.is_permit = rule.action().value();
- rule.src_ip().to_vpp(&payload.is_ipv6, payload.src_ip_addr,
- &payload.src_ip_prefix_len);
+ payload.is_permit = (vapi_enum_acl_action)rule.action().value();
+ rule.src_ip().to_vpp((uint8_t*)&payload.src_prefix.address.af,
+ (uint8_t*)&payload.src_prefix.address.un,
+ &payload.src_prefix.len);
rule.mac().to_bytes(payload.src_mac, 6);
rule.mac_mask().to_bytes(payload.src_mac_mask, 6);
}
@@ -34,13 +35,15 @@ to_vpp(const l2_rule& rule, vapi_type_macip_acl_rule& payload)
static void
to_vpp(const l3_rule& rule, vapi_type_acl_rule& payload)
{
- payload.is_permit = rule.action().value();
- rule.src().to_vpp(&payload.is_ipv6, payload.src_ip_addr,
- &payload.src_ip_prefix_len);
- rule.dst().to_vpp(&payload.is_ipv6, payload.dst_ip_addr,
- &payload.dst_ip_prefix_len);
-
- payload.proto = rule.proto();
+ payload.is_permit = (vapi_enum_acl_action)rule.action().value();
+ rule.src().to_vpp((uint8_t*)&payload.src_prefix.address.af,
+ (uint8_t*)&payload.src_prefix.address.un,
+ &payload.src_prefix.len);
+ rule.dst().to_vpp((uint8_t*)&payload.dst_prefix.address.af,
+ (uint8_t*)&payload.dst_prefix.address.un,
+ &payload.dst_prefix.len);
+
+ payload.proto = (vapi_enum_ip_proto)rule.proto();
payload.srcport_or_icmptype_first = rule.srcport_or_icmptype_first();
payload.srcport_or_icmptype_last = rule.srcport_or_icmptype_last();
payload.dstport_or_icmpcode_first = rule.dstport_or_icmpcode_first();
@@ -50,7 +53,7 @@ to_vpp(const l3_rule& rule, vapi_type_acl_rule& payload)
payload.tcp_flags_value = rule.tcp_flags_value();
}
-template <>
+template<>
rc_t
l3_update_cmd::issue(connection& con)
{
@@ -61,8 +64,8 @@ l3_update_cmd::issue(connection& con)
payload.acl_index = m_hw_item.data().value();
payload.count = m_rules.size();
memset(payload.tag, 0, sizeof(payload.tag));
- memcpy(payload.tag, m_key.c_str(),
- std::min(m_key.length(), sizeof(payload.tag)));
+ memcpy(
+ payload.tag, m_key.c_str(), std::min(m_key.length(), sizeof(payload.tag)));
auto it = m_rules.cbegin();
@@ -82,7 +85,7 @@ l3_update_cmd::issue(connection& con)
return rc_t::OK;
}
-template <>
+template<>
rc_t
l3_delete_cmd::issue(connection& con)
{
@@ -101,7 +104,7 @@ l3_delete_cmd::issue(connection& con)
return rc_t::OK;
}
-template <>
+template<>
rc_t
l3_dump_cmd::issue(connection& con)
{
@@ -117,7 +120,7 @@ l3_dump_cmd::issue(connection& con)
return rc_t::OK;
}
-template <>
+template<>
rc_t
l2_update_cmd::issue(connection& con)
{
@@ -128,8 +131,8 @@ l2_update_cmd::issue(connection& con)
// payload.acl_index = m_hw_item.data().value();
payload.count = m_rules.size();
memset(payload.tag, 0, sizeof(payload.tag));
- memcpy(payload.tag, m_key.c_str(),
- std::min(m_key.length(), sizeof(payload.tag)));
+ memcpy(
+ payload.tag, m_key.c_str(), std::min(m_key.length(), sizeof(payload.tag)));
auto it = m_rules.cbegin();
@@ -149,7 +152,7 @@ l2_update_cmd::issue(connection& con)
return rc_t::OK;
}
-template <>
+template<>
rc_t
l2_delete_cmd::issue(connection& con)
{
@@ -168,7 +171,7 @@ l2_delete_cmd::issue(connection& con)
return rc_t::OK;
}
-template <>
+template<>
rc_t
l2_dump_cmd::issue(connection& con)
{