mavtables  0.2.1
MAVLink router and firewall.
Public Types | Public Member Functions | Static Public Member Functions | Related Functions | List of all members
Action Class Reference

#include <Action.hpp>

Collaboration diagram for Action:
Collaboration graph

Public Types

enum  Option { ACCEPT, REJECT, CONTINUE, DEFAULT }
 

Public Member Functions

 Action (const Action &other)=default
 
 Action (Action &&other)=default
 
Action::Option action () const
 
void priority (int priority)
 
int priority () const
 
Actionoperator= (const Action &other)=default
 
Actionoperator= (Action &&other)=default
 

Static Public Member Functions

static Action make_accept (std::optional< int > priority={})
 
static Action make_reject ()
 
static Action make_continue ()
 
static Action make_default ()
 

Related Functions

(Note that these are not member functions.)

bool operator== (const Action &lhs, const Action &rhs)
 
bool operator!= (const Action &lhs, const Action &rhs)
 
std::ostream & operator<< (std::ostream &os, const Action &action)
 

Detailed Description

An action that is to be taken with a packet.

This is used as a return value to determine what to do with a packet.

Definition at line 30 of file Action.hpp.

Member Enumeration Documentation

◆ Option

Possible actions.

Enumerator
ACCEPT 

The packet has been accepted, possibly with priority.

REJECT 

The packet has been rejected.

CONTINUE 

Continue evaluating rules.

DEFAULT 

Use the default rule.

Definition at line 35 of file Action.hpp.

Constructor & Destructor Documentation

◆ Action() [1/2]

Action::Action ( const Action other)
default

Copy constructor.

Parameters
otherAction to copy from.
Here is the caller graph for this function:

◆ Action() [2/2]

Action::Action ( Action &&  other)
default

Move constructor.

Parameters
otherAction to move from.

Member Function Documentation

◆ action()

Action::Option Action::action ( ) const

Return the action that has been chosen.

Returns
The Action::Option enum associated with this action.

Definition at line 45 of file Action.cpp.

Here is the caller graph for this function:

◆ make_accept()

Action Action::make_accept ( std::optional< int >  priority = {})
static

Make a new action result with the Action::ACCEPT action.

An accept action indicates that the packet/address combination this action is the response to should be accepted without any further processing.

Parameters
priorityThe priority to accept the packet with. The default is to not apply a priority.
Returns
The new 'accept' action.

Definition at line 100 of file Action.cpp.

References ACCEPT, Action(), and priority().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_continue()

Action Action::make_continue ( )
static

Make a new action result with the Action::CONTINUE action.

A continue action indicates that filtering of the packet/address combination this action is the response should continue with the next Rule.

Returns
The new 'continue' action.

Definition at line 126 of file Action.cpp.

References Action(), and CONTINUE.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_default()

Action Action::make_default ( )
static

Make a new action result with the Action::DEFAULT action.

A default action indicates that the default action (defined in Filter) should be taken for the packet/address combination this action is the response to.

Returns
The new 'default' action.

Definition at line 140 of file Action.cpp.

References Action(), and DEFAULT.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_reject()

Action Action::make_reject ( )
static

Make a new action result with the Action::REJECT action.

A reject action indicates that the packet/address combination this action is the response to should be rejected without any further processing.

Returns
The new 'reject' action.

Definition at line 113 of file Action.cpp.

References Action(), and REJECT.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [1/2]

Action& Action::operator= ( const Action other)
default

Assignment operator.

Parameters
otherAction to copy from.

◆ operator=() [2/2]

Action& Action::operator= ( Action &&  other)
default

Assignment operator (by move semantics).

Parameters
otherAction to move from.

◆ priority() [1/2]

void Action::priority ( int  priority)

Set the priority of the action.

This only has an effect if the action is Action::ACCEPT and the priority has never been set before.

The default priority is 0. A higher priority will result in the packet being prioritized over other packets while a lower (negative) priority will de-prioritize the packet.

Parameters
priorityThe priority to apply to the accept action.

Definition at line 62 of file Action.cpp.

References ACCEPT, and priority().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ priority() [2/2]

int Action::priority ( ) const

Return the priority if it exists.

Returns
The priority of the action. This will always be 0 if the action is not Action::ACCEPT. It will also be 0 (the default priority) if the priority has never been set.

Definition at line 80 of file Action.cpp.

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator!=()

bool operator!= ( const Action lhs,
const Action rhs 
)
related

Inequality comparison.

Parameters
lhsThe left hand side action.
rhsThe right hand side action.
Return values
trueif lhs is not the same as rhs.
falseif lhs is the same as rhs.

Definition at line 168 of file Action.cpp.

References action(), and priority().

Here is the call graph for this function:

◆ operator<<()

std::ostream & operator<< ( std::ostream &  os,
const Action action 
)
related

Print the action to the given output stream.

Some examples are:

  • accept
  • accept with priority 3
  • reject
  • continue
  • default
Parameters
osThe output stream to print to.
actionThe action result to print.
Returns
The output stream.

Definition at line 188 of file Action.cpp.

References ACCEPT, action(), CONTINUE, DEFAULT, priority(), and REJECT.

Here is the call graph for this function:

◆ operator==()

bool operator== ( const Action lhs,
const Action rhs 
)
related

Equality comparison.

Parameters
lhsThe left hand side action.
rhsThe right hand side action.
Return values
trueif lhs is the same as rhs.
falseif lhs is not the same as rhs.

Definition at line 154 of file Action.cpp.

References action(), and priority().

Here is the call graph for this function:

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