mavtables
0.2.1
MAVLink router and firewall.
|
#include <Chain.hpp>
Public Member Functions | |
Chain (const Chain &other) | |
Chain (Chain &&other)=default | |
Chain (std::string name_, std::vector< std::unique_ptr< Rule >> &&rules={}) | |
TEST_VIRTUAL | ~Chain ()=default |
TEST_VIRTUAL Action | action (const Packet &packet, const MAVAddress &address) |
void | append (std::unique_ptr< Rule > rule) |
const std::string & | name () const |
Chain & | operator= (const Chain &other) |
Chain & | operator= (Chain &&other)=default |
Friends | |
bool | operator== (const Chain &lhs, const Chain &rhs) |
bool | operator!= (const Chain &lhs, const Chain &rhs) |
std::ostream & | operator<< (std::ostream &os, const Chain &chain) |
A filter chain, containing a list of rules to check packets against.
Chain::Chain | ( | const Chain & | other | ) |
Copy constructor.
other | Chain to copy from. |
Definition at line 38 of file Chain.cpp.
References Rule::clone(), and rule.
Chain::Chain | ( | std::string | name, |
std::vector< std::unique_ptr< Rule >> && | rules = {} |
||
) |
Construct a new filter chain.
name | The name of the filter chain. This is only used when printing the chain. The name cannot contain whitespace. |
rules | A vector of the rules used in the filter chain. This must be moved from since the vector is made up of std::unique_ptr's. |
std::invalid_argument | if the name contains whitespace. |
|
default |
Action Chain::action | ( | const Packet & | packet, |
const MAVAddress & | address | ||
) |
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 filter chain will loop through all the rules and the first one that matches and returns something other than the continue Action will be taken as the result.
packet | The packet to determine whether to allow or not. |
address | The address the packet will be sent out on if the action allows it. |
RecursionError | if a rule loops back to this chain. |
Definition at line 90 of file Chain.cpp.
References Rule::action(), Action::CONTINUE, Action::make_continue(), and rule.
void Chain::append | ( | std::unique_ptr< Rule > | rule | ) |
const std::string & Chain::name | ( | ) | const |
Assignment operator.
other | Chain to copy from. |
Definition at line 138 of file Chain.cpp.
References Rule::clone(), and rule.
Assignment operator (by move semantics).
other | Chain to move from. |
|
friend |
Print the given filter chain to to the given output stream.
An example is:
os | The output stream to print to. |
chain | The filter chain to print. |