Vanetza
Loading...
Searching...
No Matches
next_hop.hpp
1
#ifndef NEXT_HOP_HPP_ON0AKMBY
2
#define NEXT_HOP_HPP_ON0AKMBY
3
4
#include <vanetza/geonet/packet.hpp>
5
#include <vanetza/geonet/pending_packet.hpp>
6
#include <vanetza/geonet/pdu_variant.hpp>
7
#include <vanetza/net/mac_address.hpp>
8
9
namespace
vanetza
10
{
11
namespace
geonet
12
{
13
14
/**
15
* NextHop is the result of GeoNet forwarding algorithms.
16
* It may convey a destination link-layer address or one of the states "discarded" and "buffered".
17
*/
18
class
NextHop
19
{
20
public
:
21
using
Packet
=
PendingPacket<GbcPdu, const MacAddress&>
;
22
23
NextHop
();
24
NextHop
(
NextHop
&&) =
default
;
25
NextHop
& operator=(
NextHop
&&) =
default
;
26
27
/**
28
* Test if forwarding decision is to discard the packet.
29
* \return true if discarded
30
*/
31
bool
discarded
()
const
;
32
33
/**
34
* Test if forwarding decided to buffer the packet.
35
* \return true if packet got buffered
36
*/
37
bool
buffered
()
const
;
38
39
/**
40
* Test if stored packet and link-layer address are valid.
41
* \return if valid
42
*/
43
bool
valid
()
const
;
44
45
/**
46
* Access stored link-layer address.
47
*
48
* The returned address is only meaningful if NextHop is valid.
49
* \return link-layer address
50
*/
51
const
MacAddress
&
mac
()
const
;
52
53
/**
54
* Prepare for immediate packet transmission (not discarded, not buffered).
55
*
56
* valid() will return true after invocation of this method.
57
* \param packet the packet to be transmitted
58
* \param destination link-layer destination address
59
*/
60
void
transmit
(
Packet
&& packet,
const
MacAddress
& destination);
61
62
/**
63
* Set the NextHop state to discarded.
64
*/
65
void
discard
();
66
67
/**
68
* Set the NextHop state to buffered.
69
*/
70
void
buffer
();
71
72
/**
73
* Invoke further packet processing.
74
*
75
* It is safe to call this method though packet has been discarded or buffered.
76
* \return true if a valid packet (after previous transmit()) has been processed
77
*/
78
bool
process
() &&;
79
80
private
:
81
enum class
State { Valid, Discarded, Buffered };
82
83
State m_state;
84
MacAddress
m_destination;
85
Packet
m_packet;
86
};
87
88
}
// namespace geonet
89
}
// namespace vanetza
90
91
#endif
/* NEXT_HOP_HPP_ON0AKMBY */
92
vanetza::MacAddress
Definition:
mac_address.hpp:19
vanetza::geonet::NextHop
Definition:
next_hop.hpp:19
vanetza::geonet::NextHop::process
bool process() &&
Definition:
next_hop.cpp:32
vanetza::geonet::NextHop::valid
bool valid() const
Definition:
next_hop.cpp:22
vanetza::geonet::NextHop::discarded
bool discarded() const
Definition:
next_hop.cpp:12
vanetza::geonet::NextHop::discard
void discard()
Definition:
next_hop.cpp:50
vanetza::geonet::NextHop::mac
const MacAddress & mac() const
Definition:
next_hop.cpp:27
vanetza::geonet::NextHop::buffered
bool buffered() const
Definition:
next_hop.cpp:17
vanetza::geonet::NextHop::transmit
void transmit(Packet &&packet, const MacAddress &destination)
Definition:
next_hop.cpp:43
vanetza::geonet::NextHop::buffer
void buffer()
Definition:
next_hop.cpp:55
vanetza::geonet::PendingPacket< GbcPdu, const MacAddress & >
vanetza
geonet
next_hop.hpp
Generated on Thu Nov 30 2023 12:03:35 for Vanetza by
1.9.6