This is a low-level network debugging utility that utilizes raw packet i/o to construct and deconstruct tcp, udp, ipv4, arp, and icmp packets over ethernet.

Dependencies:   mbed

Revision:
0:d494b853ce97
Child:
2:e8e09adc41fc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/net/icmp.h	Tue Oct 12 05:32:59 2010 +0000
@@ -0,0 +1,35 @@
+#ifndef ICMP_H
+#define ICMP_H
+
+#include "net.h"
+
+#define ICMP_ECHO_REPLY   0x00
+#define ICMP_ECHO_REQUEST 0x08
+#define IPPROTO_ICMP      0x01
+typedef struct {
+    u8 type;        // type of ICMP message
+    u8 code;        // code number associated with certain message types
+    u16 checksum; 
+    u16 id;         // ID value, returned in ECHO REPLY
+    u16 sequence;   // Sequence value to be returned with ECHO REPLY
+    u8 data[];      
+} ICMP_Packet;
+
+inline void fix_endian_icmp(ICMP_Packet *segment)
+{
+  fix_endian_u16(&segment->checksum);
+  fix_endian_u16(&segment->id);
+  fix_endian_u16(&segment->sequence);
+}
+
+inline void print_icmp(ICMP_Packet *segment)
+{
+  main_log.printf("ICMP Packet:");
+  main_log.printf("  Type:      0x%02X", segment->type);
+  main_log.printf("  Code:      0x%02X", segment->code);
+  main_log.printf("  Checksum:  0x%04X", segment->checksum);
+  main_log.printf("  ID:        0x%04X", segment->id);
+  main_log.printf("  Sequence:  0x%04X", segment->sequence);
+}
+
+#endif
\ No newline at end of file