#include <senf/Packets/Packet.hh>
The ConcretePacket template class extends Packet to provide protocol/packet type specific aspects. These are packet constructors and access to the parsed packet fields.
The PacketType
template argument to ConcretePacket is a protocol specific and internal policy class which defines the protocol specific behavior. To access a specific type of packet, the library provides corresponding typedefs of ConcretePacket < SomePacketType > (e.g. EthernetPacket as typedef for ConcretePacket < EthernetPacketType >).
The new members provided by ConcretePacket over packet are mostly comprised of the packet constructors. These come in three major flavors:
createAfter() differs from Packet::parseNextAs() in that the former creates a new packet replacing any possibly existing data whereas the latter will interpret the already existing data as given by the type argument.
Definition at line 565 of file Packet.hh.
Classes |
|
struct | ParserProxy |
Public Types |
|
typedef PacketType | type |
Type of the packet. |
|
typedef PacketType::parser | Parser |
Public Member Functions |
|
ParserProxy | operator-> () const |
Access packet fields. |
|
Parser | parser () const |
Access packet field parser directly. |
|
Structors and default members |
|
ConcretePacket () | |
Create uninitialized packet handle. |
|
ConcretePacket | clone () const |
Create copy packet. |
|
static factory_t | factory () |
Return factory for packets of specific type. |
|
static ConcretePacket | create () |
Create default initialized packet. |
|
static ConcretePacket | create (senf::NoInit_t) |
Create uninitialized empty packet. |
|
static ConcretePacket | create (size_type size) |
Create default initialized packet. |
|
static ConcretePacket | create (size_type size, senf::NoInit_t) |
Create uninitialized packet. |
|
template<class ForwardReadableRange > | |
static ConcretePacket | create (ForwardReadableRange const &range) |
Create packet from given data. |
|
static ConcretePacket | createAfter (Packet const &packet) |
Create default initialized packet after packet. |
|
static ConcretePacket | createAfter (Packet const &packet, senf::NoInit_t) |
Create uninitialized empty packet afterpacket. |
|
static ConcretePacket | createAfter (Packet const &packet, size_type size) |
Create default initialized packet after packet. |
|
static ConcretePacket | createAfter (Packet const &packet, size_type size, senf::NoInit_t) |
Create uninitialized packet after packet. |
|
template<class ForwardReadableRange > | |
static ConcretePacket | createAfter (Packet const &packet, ForwardReadableRange const &range) |
Create packet from given data after packet. |
|
static ConcretePacket | createBefore (Packet const &packet) |
Create default initialized packet before packet. |
|
static ConcretePacket | createBefore (Packet const &packet, senf::NoInit_t) |
Create uninitialized empty packet before packet. |
|
static ConcretePacket | createInsertBefore (Packet const &packet) |
Insert default initialized packet before packet. |
|
static ConcretePacket | createInsertBefore (Packet const &packet, senf::NoInit_t) |
Insert uninitialized empty packet before packet. |
typedef PacketType::parser senf::ConcretePacket< PacketType >:: | ||||
Parser | ||||
typedef PacketType senf::ConcretePacket< PacketType >:: | ||||
type | ||||
senf::ConcretePacket< PacketType >:: | ||||
ConcretePacket | () | |||
Create uninitialized packet handle.
An uninitialized handle is not valid(). It does not allow any operation except assignment and checking for validity.
Definition at line 170 of file Packet.cti.
senf::ConcretePacket< PacketType > senf::ConcretePacket< PacketType >:: | ||||
clone | () | |||
Create copy packet.
clone() will create a complete copy of this
packet. The returned packet will have the same data, annotations and packet chain. It does however not share any data with the original packet.
Reimplemented from senf::Packet.
Definition at line 301 of file Packet.cti.
static ConcretePacket senf::ConcretePacket< PacketType >:: | ||||
create | ( | ForwardReadableRange const & | range | ) |
Create packet from given data.
The packet will be created from a copy of the given data. The data from the range will be copied directly into the packet representation. The data will not be validated in any way.
[in] | range | Boost.Range of data to construct packet from. |
senf::ConcretePacket< PacketType > senf::ConcretePacket< PacketType >:: | ||||
create | ( | size_type | size, | |
senf::NoInit_t | ) | |||
Create uninitialized packet.
Creates an uninitialized (all-zero) packet of the exact given size.
[in] | size | Size of the packet to create in bytes |
[in] | senf::noinit | This parameter must always have the value senf::noinit . |
Definition at line 205 of file Packet.cti.
senf::ConcretePacket< PacketType > senf::ConcretePacket< PacketType >:: | ||||
create | ( | size_type | size | ) |
Create default initialized packet.
This member will create a default initialized packet with the given size. If the size parameter is smaller than the minimum allowed packet size an exception will be thrown.
[in] | size | Size of the packet to create in bytes. |
TruncatedPacketException | if size is smaller than the smallest permissible size for this type of packet. |
Definition at line 198 of file Packet.cti.
senf::ConcretePacket< PacketType > senf::ConcretePacket< PacketType >:: | ||||
create | ( | senf::NoInit_t | ) | |
Create uninitialized empty packet.
This will create a completely empty and uninitialized packet with size() == 0
.
[in] | senf::noinit | This parameter must always have the value senf::noinit . |
Definition at line 191 of file Packet.cti.
senf::ConcretePacket< PacketType > senf::ConcretePacket< PacketType >:: | ||||
create | () | |||
Create default initialized packet.
The packet will be initialized to it's default empty state.
Definition at line 184 of file Packet.cti.
static ConcretePacket senf::ConcretePacket< PacketType >:: | ||||
createAfter | ( | Packet const & | packet, | |
ForwardReadableRange const & | range | ) | ||
Create packet from given data after packet.
The packet will be created from a copy of the given data. The data from the range will be copied directly into the packet representation. The data will not be validated in any way. It will be appended as next header/interpreter after packet in that packets interpreter chain.
[in] | packet | Packet to append new packet to. |
[in] | range | Boost.Range of data to construct packet from. |
senf::ConcretePacket< PacketType > senf::ConcretePacket< PacketType >:: | ||||
createAfter | ( | Packet const & | packet, | |
size_type | size, | |||
senf::NoInit_t | ) | |||
Create uninitialized packet after packet.
Creates an uninitialized (all-zero) packet of the exact given size. It will be appended as next header/interpreter after packet in that packets interpreter chain.
[in] | packet | Packet to append new packet to. |
[in] | size | Size of the packet to create in bytes |
[in] | senf::noinit | This parameter must always have the value senf::noinit . |
Definition at line 248 of file Packet.cti.
senf::ConcretePacket< PacketType > senf::ConcretePacket< PacketType >:: | ||||
createAfter | ( | Packet const & | packet, | |
size_type | size | ) | ||
Create default initialized packet after packet.
This member will create a default initialized packet with the given size. If the size parameter is smaller than the minimum allowed packet size an exception will be thrown. It will be appended as next header/interpreter after packet in that packets interpreter chain.
[in] | packet | Packet to append new packet to. |
[in] | size | Size of the packet to create in bytes. |
TruncatedPacketException | if size is smaller than the smallest permissible size for this type of packet. |
Definition at line 241 of file Packet.cti.
senf::ConcretePacket< PacketType > senf::ConcretePacket< PacketType >:: | ||||
createAfter | ( | Packet const & | packet, | |
senf::NoInit_t | ) | |||
Create uninitialized empty packet afterpacket.
This will create a completely empty and uninitialized packet with size() == 0
. It will be appended as next header/interpreter after packet in that packets interpreter chain.
[in] | packet | Packet to append new packet to. |
[in] | senf::noinit | This parameter must always have the value senf::noinit . |
Definition at line 234 of file Packet.cti.
senf::ConcretePacket< PacketType > senf::ConcretePacket< PacketType >:: | ||||
createAfter | ( | Packet const & | packet | ) |
Create default initialized packet after packet.
The packet will be initialized to it's default empty state. It will be appended as next header/interpreter after packet in that packets interpreter chain.
[in] | packet | Packet to append new packet to. |
Definition at line 227 of file Packet.cti.
senf::ConcretePacket< PacketType > senf::ConcretePacket< PacketType >:: | ||||
createBefore | ( | Packet const & | packet, | |
senf::NoInit_t | ) | |||
Create uninitialized empty packet before packet.
Creates a completely empty and uninitialized packet. It will be prepended as previous header/interpreter before packet in that packets interpreter chain.
[in] | packet | Packet to prepend new packet to. |
Definition at line 278 of file Packet.cti.
senf::ConcretePacket< PacketType > senf::ConcretePacket< PacketType >:: | ||||
createBefore | ( | Packet const & | packet | ) |
Create default initialized packet before packet.
The packet will be initialized to it's default empty state. It will be prepended as previous header/interpreter before packet in that packets interpreter chain.
[in] | packet | Packet to prepend new packet to. |
Definition at line 271 of file Packet.cti.
senf::ConcretePacket< PacketType > senf::ConcretePacket< PacketType >:: | ||||
createInsertBefore | ( | Packet const & | packet, | |
senf::NoInit_t | ) | |||
Insert uninitialized empty packet before packet.
Inserts a completely empty and uninitialized packet before packet into the header/interpreter chain.
[in] | packet | Packet before which to insert the new packet |
Definition at line 292 of file Packet.cti.
senf::ConcretePacket< PacketType > senf::ConcretePacket< PacketType >:: | ||||
createInsertBefore | ( | Packet const & | packet | ) |
Insert default initialized packet before packet.
The new packet header will be initialized to it' s default empty state. It will be inserted into the packet chain before packet.
[in] | packet | Packet before which to insert the new packet |
Definition at line 285 of file Packet.cti.
senf::ConcretePacket< PacketType >::factory_t senf::ConcretePacket< PacketType >:: | ||||
factory | () | |||
Return factory for packets of specific type.
This static member is like Packet::factory() for a specific packet of type PacketType
Definition at line 175 of file Packet.cti.
senf::ConcretePacket< PacketType >::ParserProxy senf::ConcretePacket< PacketType >:: | ||||
operator-> | () | |||
Access packet fields.
This operator allows to access the parsed fields of the packet using the notation packet->field()
. The fields of the packet are specified by the PacketType's parser
member.
The members are not strictly restricted to simple field access. The parser class may have any member which is needed for full packet access (e.g. checksum validation / recreation ...)
Definition at line 319 of file Packet.cti.
senf::ConcretePacket< PacketType >::Parser senf::ConcretePacket< PacketType >:: | ||||
parser | () | |||
Access packet field parser directly.
Access the parser of the packet. This is the same object returned by the operator->() operator. The operator however does not allow to access this object itself, only it's members.
Definition at line 311 of file Packet.cti.