summaryrefslogtreecommitdiff
path: root/plugins/Ping/src/rawping.h
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2012-11-28 18:44:28 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2012-11-28 18:44:28 +0000
commit68fb5b69ea8403a3f9dcb70b3133eb10e1711000 (patch)
treec4e4e81724c9ea80fe7f2558991bda699961bc11 /plugins/Ping/src/rawping.h
parent80d65efb84ec7500cd02ca047d0177d642eb1871 (diff)
forgotten files
git-svn-id: http://svn.miranda-ng.org/main/trunk@2544 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Ping/src/rawping.h')
-rw-r--r--plugins/Ping/src/rawping.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/plugins/Ping/src/rawping.h b/plugins/Ping/src/rawping.h
new file mode 100644
index 0000000000..23d9df1d61
--- /dev/null
+++ b/plugins/Ping/src/rawping.h
@@ -0,0 +1,61 @@
+#ifndef _RAWPING_H
+#define _RAWPING_H
+
+#include "options.h"
+#include "log.h"
+
+
+// ICMP protocol identifier
+#define ICMP_PROTO 1
+
+// ICMP packet types
+#define PT_ICMP_ECHO_REPLY 0
+#define PT_ICMP_DEST_UNREACH 3
+#define PT_ICMP_TTL_EXPIRE 11
+#define PT_ICMP_ECHO_REQUEST 8
+#define PT_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