libtins
4.0
|
Reassembles fragmented IP packets. More...
#include <ip_reassembler.h>
Public Types | |
enum | PacketStatus { NOT_FRAGMENTED, FRAGMENTED, REASSEMBLED } |
enum | OverlappingTechnique { NONE } |
Public Member Functions | |
TINS_DEPRECATED (typedef PacketStatus packet_status) | |
IPv4Reassembler () | |
IPv4Reassembler (OverlappingTechnique technique) | |
PacketStatus | process (PDU &pdu) |
Processes a PDU and tries to reassemble it. More... | |
void | clear_streams () |
void | remove_stream (uint16_t id, IPv4Address addr1, IPv4Address addr2) |
Removes all of the packets and data stored that belongs to IP headers whose identifier, source and destination addresses are equal to the provided parameters. More... | |
Reassembles fragmented IP packets.
This class is fairly simple: just feed packets into it using IPv4Reassembler::process. If the return value is IPv4Reassembler::FRAGMENTED, then the packet is fragmented and we haven't yet seen the missing fragments, hence we can't reassemble it. If the function returns either IPv4Reassembler::NOT_FRAGMENTED (meaning the packet wasn't fragmented) or IPv4Reassembler::REASSEMBLED (meaning the packet was fragmented but it's now reassembled), then you can process the packet normally.
Simple example:
The type used to represent the overlapped segment reassembly technique to be used.
Tins::IPv4Reassembler::IPv4Reassembler | ( | ) |
Default constructor
Tins::IPv4Reassembler::IPv4Reassembler | ( | OverlappingTechnique | technique | ) |
Constructs an IPV4Reassembler.
technique | The technique to be used for reassembling overlapped fragments. |
void Tins::IPv4Reassembler::clear_streams | ( | ) |
Removes all of the packets and data stored.
IPv4Reassembler::PacketStatus Tins::IPv4Reassembler::process | ( | PDU & | pdu | ) |
Processes a PDU and tries to reassemble it.
This method tries to reassemble the provided packet. If the packet is successfully reassembled using previously processed packets, its contents will be modified so that it contains the whole payload and not just a fragment.
pdu | The PDU to process. |
void Tins::IPv4Reassembler::remove_stream | ( | uint16_t | id, |
IPv4Address | addr1, | ||
IPv4Address | addr2 | ||
) |