mavtables
0.2.1
MAVLink router and firewall.
|
#include <Accept.hpp>
Public Member Functions | |
Accept (std::optional< If > condition={}) | |
Accept (int priority, std::optional< If > condition={}) | |
virtual Action | action (const Packet &packet, const MAVAddress &address) const |
virtual std::unique_ptr< Rule > | clone () const |
virtual bool | operator== (const Rule &other) const |
virtual bool | operator!= (const Rule &other) const |
Protected Member Functions | |
virtual std::ostream & | print_ (std::ostream &os) const |
Protected Attributes | |
std::optional< If > | condition_ |
Rule to accept a packet, optionally with a priority.
Definition at line 35 of file Accept.hpp.
Accept::Accept | ( | std::optional< If > | condition = {} | ) |
Construct an accept rule, without a priority.
An accept rule is used to accept packet/address combinations that match the condition of the rule.
condition | The condition used to determine the rule matches a particular packet/address combination given to the action method. The default is {} which indicates the rule matches any packet/address combination. |
Definition at line 42 of file Accept.cpp.
Accept::Accept | ( | int | priority, |
std::optional< If > | condition = {} |
||
) |
Construct an accept rule, with a priority.
An accept rule is used to accept packet/address combinations that match the condition of the rule.
condition | The condition used to determine the rule matches a particular packet/address combination given to the action method. The default is {} which indicates the rule matches any packet/address combination. |
priority | The priority to accept packets with. A higher number is more important and will be routed first. |
Definition at line 61 of file Accept.cpp.
|
virtual |
Decide what to do with a Packet.
Determine what action to take with the given packet
sent to the given address
. The possible actions are documented in the Action class. The continue object is always returned if the condition was set and does not match the packet/address combination.
packet | The packet to determine whether to allow or not. |
address | The address the packet will be sent out on if the action dictates it. |
If the condition has not been set or it matches the given packet/address combination then it will return the accept Action object (with optional priority), otherwise it will return the continue Action object.
Implements Rule.
Definition at line 99 of file Accept.cpp.
References Rule::condition_, Action::make_accept(), and Action::make_continue().
|
virtual |
Return a copy of the Rule polymorphically.
This allows Rule's to be copied without knowing the derived type.
Implements Rule.
Definition at line 111 of file Accept.cpp.
References Rule::condition_.
|
virtual |
Inequality comparison.
Compares the type of the Rule and the condition (If) if set.
other | The other rule to compare this to. |
true | if this rule is not the same as other . |
false | if this rule is the same as other . |
Compares the priority (if set) associated with the rule as well.
Implements Rule.
Definition at line 138 of file Accept.cpp.
References Rule::condition_.
|
virtual |
Equality comparison.
Compares the type of the Rule and the condition (If) if set.
other | The other rule to compare this to. |
true | if this rule is the same as other . |
false | if this rule is not the same as other . |
Compares the priority (if set) associated with the rule as well.
Implements Rule.
Definition at line 126 of file Accept.cpp.
References Rule::condition_.
|
protectedvirtual |
Print the rule to the given output stream.
os | The output stream to print to. |
Prints "reject <Priority> <If Statement>"
where the priority and if statement are only printed if the priority or condition is set, respectively.
os | The output stream to print to. |
Implements Rule.
Definition at line 75 of file Accept.cpp.
References Rule::condition_.