mavtables  0.2.1
MAVLink router and firewall.
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Reject Class Reference

#include <Reject.hpp>

Inheritance diagram for Reject:
Inheritance graph
Collaboration diagram for Reject:
Collaboration graph

Public Member Functions

 Reject (std::optional< If > condition={})
 
virtual Action action (const Packet &packet, const MAVAddress &address) const
 
virtual std::unique_ptr< Ruleclone () 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< Ifcondition_
 

Detailed Description

Rule to reject a packet.

Definition at line 35 of file Reject.hpp.

Constructor & Destructor Documentation

◆ Reject()

Reject::Reject ( std::optional< If condition = {})

Construct a reject rule.

A reject rule is used to reject packet/address combinations that match the condition of the rule.

Parameters
conditionThe 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.
See also
action

Definition at line 42 of file Reject.cpp.

Member Function Documentation

◆ action()

Action Reject::action ( const Packet packet,
const MAVAddress address 
) const
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.

Parameters
packetThe packet to determine whether to allow or not.
addressThe address the packet will be sent out on if the action dictates it.
Returns
The action to take with the packet. If this is the accept object, it may also contain a priority for the packet.

If the condition has not been set or it matches the given packet/address combination then it will return the reject Action object, otherwise it will return the continue Action object.

Implements Rule.

Definition at line 72 of file Reject.cpp.

References Rule::condition_, Action::make_continue(), and Action::make_reject().

Here is the call graph for this function:

◆ clone()

std::unique_ptr< Rule > Reject::clone ( ) const
virtual

Return a copy of the Rule polymorphically.

This allows Rule's to be copied without knowing the derived type.

Returns
A pointer to a new object with base type Rule which is an exact copy of this one.

Implements Rule.

Definition at line 84 of file Reject.cpp.

References Rule::condition_.

◆ operator!=()

bool Reject::operator!= ( const Rule other) const
virtual

Inequality comparison.

Compares the type of the Rule and the condition (If) if set.

Parameters
otherThe other rule to compare this to.
Return values
trueif this rule is not the same as other.
falseif this rule is the same as other.

Implements Rule.

Definition at line 97 of file Reject.cpp.

References Rule::condition_.

◆ operator==()

bool Reject::operator== ( const Rule other) const
virtual

Equality comparison.

Compares the type of the Rule and the condition (If) if set.

Parameters
otherThe other rule to compare this to.
Return values
trueif this rule is the same as other.
falseif this rule is not the same as other.

Implements Rule.

Definition at line 90 of file Reject.cpp.

References Rule::condition_.

◆ print_()

std::ostream & Reject::print_ ( std::ostream &  os) const
protectedvirtual

Print the rule to the given output stream.

Parameters
osThe output stream to print to.
Returns
The output stream.

Prints "reject" or "reject <If Statement>" if the rule's condition was set.

Implements Rule.

Definition at line 53 of file Reject.cpp.

References Rule::condition_.

Member Data Documentation

◆ condition_

std::optional<If> Rule::condition_
protectedinherited

Definition at line 91 of file Rule.hpp.


The documentation for this class was generated from the following files: