I'm reading the C++ code below:
// Take a whole packet from somewhere.
EthernetII packet = ...;
// Find the IP layer
const IP* ip = packet.find_pdu<IP>();
if(ip) {
// If the pointer is not null, then it will point to the IP layer
}
// Find the TCP layer. This will throw a pdu_not_found exception
// if there is no TCP layer in this packet.
const TCP& tcp = packet.rfind_pdu<TCP>();
The definition of PDU::rfind_pdu()
is below. My question is, should an argument not be passed to rfind_pdu()
? And what is the syntax that allows <IP>
to appended to the function call?
template<typename T> const T& Tins::PDU::rfind_pdu(PDUType type = T::pdu_flag) const inline
Finds and returns the first PDU that matches the given flag.
Parameters
flag
The flag which being searched.