diff options
author | sje <sje@4f64403b-2f21-0410-a795-97e2b3489a10> | 2006-11-01 14:44:34 +0000 |
---|---|---|
committer | sje <sje@4f64403b-2f21-0410-a795-97e2b3489a10> | 2006-11-01 14:44:34 +0000 |
commit | 49b4d6dd9d4d35adc9f02df4010a1a6b33faba63 (patch) | |
tree | 403d0508eed3d1e1c9b336251eff931f3f2511b1 /ping_protocol/rawping.h | |
parent | b61df7acc1235b3b2a66217d0d7358199c5d37f9 (diff) |
git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@12 4f64403b-2f21-0410-a795-97e2b3489a10
Diffstat (limited to 'ping_protocol/rawping.h')
-rw-r--r-- | ping_protocol/rawping.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/ping_protocol/rawping.h b/ping_protocol/rawping.h new file mode 100644 index 0000000..2201d19 --- /dev/null +++ b/ping_protocol/rawping.h @@ -0,0 +1,61 @@ +#ifndef _RAWPING_H
+#define _RAWPING_H
+
+#include "common.h" // to translate 'SOURCE_QUENCH' warning
+#include "options.h"
+#include "log.h"
+
+
+// ICMP protocol identifier
+#define ICMP_PROTO 1
+
+// ICMP packet types
+#define ICMP_ECHO_REPLY 0
+#define ICMP_DEST_UNREACH 3
+#define ICMP_TTL_EXPIRE 11
+#define ICMP_ECHO_REQUEST 8
+#define ICMP_SOURCE_QUENCH 4
+
+// Minimum ICMP packet size, in bytes
+#define ICMP_MIN 8
+
+#ifdef _MSC_VER
+// The following two structures need to be packed tightly, but unlike
+// Borland C++, Microsoft C++ does not do this by default.
+#pragma pack(1)
+#endif
+
+// The IP header
+struct IPHeader {
+ BYTE h_len:4; // Length of the header in dwords
+ BYTE version:4; // Version of IP
+ BYTE tos; // Type of service
+ USHORT total_len; // Length of the packet in dwords
+ USHORT ident; // unique identifier
+ USHORT flags; // Flags
+ BYTE ttl; // Time to live
+ BYTE proto; // Protocol number (TCP, UDP etc)
+ USHORT checksum; // IP checksum
+ ULONG source_ip;
+ ULONG dest_ip;
+};
+
+// ICMP header
+struct ICMPHeader {
+ BYTE type; // ICMP packet type
+ BYTE code; // Type sub code
+ USHORT checksum;
+ USHORT id;
+ USHORT seq;
+};
+
+#ifdef _MSC_VER
+#pragma pack()
+#endif
+
+extern USHORT ip_checksum(USHORT* buffer, int size);
+
+extern int init_raw_ping();
+extern int raw_ping(char *host, int timeout);
+extern int cleanup_raw_ping();
+#endif
\ No newline at end of file |