1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#ifndef RGJ_FREE_SOCKETS_PING_EXAMPLE
#define RGJ_FREE_SOCKETS_PING_EXAMPLE
#include <skstream/skstream.h>
#define ICMP_ECHOREPLY 0
#define ICMP_ECHOREQ 8
// IP Header -- RFC 791
struct IP_HEADER
{
unsigned char VIHL; // Version and IHL
unsigned char TOS; // Type Of Service
short TotLen; // Total Length
short ID; // Identification
short FlagOff; // Flags and Fragment Offset
unsigned char TTL; // Time To Live
unsigned char Protocol; // Protocol
unsigned short Checksum; // Checksum
in_addr iaSrc; // Internet Address - Source
in_addr iaDst; // Internet Address - Destination
};
// ICMP Header - RFC 792
struct ICMP_HEADER
{
unsigned char Type; // Type
unsigned char Code; // Code
unsigned short Checksum; // Checksum
unsigned short ID; // Identification
unsigned short Seq; // Sequence
char Data; // Data
};
// ICMP Echo Request
#define REQ_DATASIZE 32 // Echo Request Data size
struct ECHO_REQUEST {
ICMP_HEADER icmpHdr;
unsigned long dwTime;
char cData[REQ_DATASIZE];
};
// ICMP Echo Reply
struct ECHO_REPLY {
IP_HEADER ipHdr;
ECHO_REQUEST echoRequest;
};
#endif
|