27 singular_db<l3_list::key_t, l3_list> l3_list::m_db;
32 std::map<handle_t, std::weak_ptr<l3_list>> l3_list::m_hdl_db;
71 m_db.release(m_key,
this);
74 std::shared_ptr<l3_list>
77 return find_or_add(*
this);
96 s <<
"acl-list:[" << m_key <<
" " << m_hdl.
to_string() <<
" rules:[";
98 for (
auto rule : m_rules) {
99 s << rule.to_string() <<
" ";
110 m_rules.insert(rule);
125 std::shared_ptr<l3_list>
128 return (m_hdl_db[handle].lock());
131 std::shared_ptr<l3_list>
134 return (m_db.find(key));
137 std::shared_ptr<l3_list>
138 l3_list::find_or_add(
const l3_list& temp)
140 return (m_db.find_or_add(temp.
key(), temp));
144 l3_list::handle_i()
const 146 return (m_hdl.
data());
152 std::shared_ptr<l3_list> sp =
find(key);
155 m_hdl_db[item.
data()] = sp;
162 m_hdl_db.erase(item.
data());
189 std::shared_ptr<list_cmds::l3_dump_cmd>
cmd =
190 std::make_shared<list_cmds::l3_dump_cmd>();
195 for (
auto& record : *cmd) {
196 auto& payload = record.get_payload();
198 const handle_t hdl(payload.acl_index);
199 l3_list acl(hdl, std::string(reinterpret_cast<const char*>(payload.tag)));
201 for (
unsigned int ii = 0; ii < payload.count; ii++) {
203 payload.r[ii].src_ip_addr,
204 payload.r[ii].src_ip_prefix_len);
206 payload.r[ii].dst_ip_addr,
207 payload.r[ii].dst_ip_prefix_len);
238 l3_list::event_handler::order()
const 244 l3_list::event_handler::handle_replay()
250 l3_list::update(
const l3_list& obj)
255 if (
rc_t::OK != m_hdl.
rc() || obj.m_rules != m_rules) {
263 m_rules = obj.m_rules;
282 l3_list::replay(
void)
An L3 ACL list comprises a set of match actions rules to be applied to packets.
std::shared_ptr< l3_list > singular() const
Return the 'sigular instance' of the ACL that matches this object.
void set_src_from_port(uint16_t srcport_or_icmptype_first)
Set Src port or ICMP Type first.
static const action_t & from_int(uint8_t i)
Get the enum type from a VPP integer value.
void set_dst_from_port(uint16_t dstport_or_icmpcode_first)
Set Dst port or ICMP code first.
void db_dump(const DB &db, std::ostream &os)
Print each of the objects in the DB into the stream provided.
void set_tcp_flags_value(uint8_t tcp_flags_value)
Set TCP flags value.
const std::string key_t
In the opflex world each entity is known by a URI which can be converted into a string.
std::multiset< l3_rule > rules_t
The rule container type.
std::string to_string() const
convert to string format for debug purposes
static void register_handler(const std::vector< std::string > &cmds, const std::string &help, command_handler *ch)
Register a command handler for inspection.
std::string key_t
The KEY can be used to uniquely identify the ACL.
const rules_t & rules() const
static rc_t write()
Write/Execute all commands hitherto enqueued.
static const log_level_t DEBUG
void set_tcp_flags_mask(uint8_t tcp_flags_mask)
Set TCP flags mask.
static std::shared_ptr< l3_list > find(const handle_t &handle)
std::string to_string() const
convert to string format for debug purposes
T & data()
Return the data read/written.
void set_src_to_port(uint16_t srcport_or_icmptype_last)
Set Src port or ICMP Type last.
const key_t & key() const
static void add(const key_t &key, const HW::item< handle_t > &item)
rc_t rc() const
Get the HW return code.
void remove(const l3_rule &rule)
Remove a rule from the list.
A command class that Create the list.
A cmd class that Deletes an ACL.
void set_dst_to_port(uint16_t dstport_or_icmpcode_last)
Set Dst port or ICMP code last.
static void dump(std::ostream &os)
Dump all ACLs into the stream provided.
A type declaration of an interface handle in VPP.
static rc_t commit(const client_db::key_t &key, const OBJ &obj)
Make the State in VPP reflect the expressed desired state.
void event_handler(void *tls_async)
void set_proto(uint8_t proto)
Set proto.
dependency_t
There needs to be a strict order in which object types are read from VPP (at boot time) and replayed ...
static const rc_t OK
The HW write was successfull.
static void enqueue(cmd *f)
Enqueue A command for execution.
void insert(const l3_rule &rule)
Insert priority sorted a rule into the list.
bool operator==(const l3_list &l) const
Comparison operator - for UT.
The VPP Object Model (VOM) library.
l3_list(const key_t &key)
Construct a new object matching the desried state.
An ACL rule is the building block of an ACL.
A representation of a method call to VPP.
void reset()
reset the value of the handle to ~0
static bool register_listener(listener *listener)
Register a listener of events.
const handle_t & handle() const
Return the VPP assign handle.