Poco::Net

class ICMPPacket

File Information

Library: Net
Package: ICMP
Header: Poco/Net/ICMPPacket.h

Description

This class is the ICMP packet abstraction.

Member Summary

Member Functions: errorDescription, getDataSize, maxPacketSize, packet, packetSize, sequence, setDataSize, time, typeDescription, validReplyID

Constructors

ICMPPacket

ICMPPacket(
    SocketAddress::Family family,
    int dataSize = 48
);

Creates an ICMPPacket of specified family.

Destructor

~ICMPPacket

~ICMPPacket();

Destroys the ICMPPacket.

Member Functions

errorDescription

std::string errorDescription(
    Poco::UInt8 * buffer,
    int length,
    int & type,
    int & code
);

Returns error description string. If supplied buffer contains an ICMP echo reply packet, an empty string is returned indicating the absence of error. If type and code of the error can be determined, they are assigned to the type and code respectively.

Supplied buffer includes IP header, ICMP header and data.

getDataSize

int getDataSize() const;

Returns data size.

maxPacketSize

int maxPacketSize() const;

Returns the total length of packet (header + data);

packet

const Poco::UInt8 * packet();

Returns raw ICMP packet. ICMP header and data are included in the returned packet.

packetSize

int packetSize() const;

Returns the total length of packet (header + data);

sequence

Poco::UInt16 sequence() const;

Returns the most recent sequence number generated.

setDataSize

void setDataSize(
    int dataSize
);

Sets data size.

time

struct timeval time(
    Poco::UInt8 * buffer = 0,
    int length = 0
) const;

Returns current epoch time if either buffer or length are equal to zero. Otherwise, it extracts the time value from the supplied buffer and returns the extracted value.

Supplied buffer includes IP header, ICMP header and data.

typeDescription

std::string typeDescription(
    int typeId
);

Returns the description of the packet type.

validReplyID

bool validReplyID(
    Poco::UInt8 * buffer,
    int length
) const;

Returns true if the extracted id is recognized (equals the process id).

Supplied buffer includes IP header, ICMP header and data.