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

Committer:
etherealflaim
Date:
Tue Oct 12 06:10:41 2010 +0000
Revision:
2:e8e09adc41fc
Parent:
0:d494b853ce97
Child:
3:c32d9660b888
Finished documentation for net/ directory

Who changed what in which revision?

UserRevisionLine numberNew contents of line
etherealflaim 0:d494b853ce97 1 #ifndef ICMP_H
etherealflaim 0:d494b853ce97 2 #define ICMP_H
etherealflaim 0:d494b853ce97 3
etherealflaim 0:d494b853ce97 4 #include "net.h"
etherealflaim 0:d494b853ce97 5
etherealflaim 2:e8e09adc41fc 6 /// \file ICMP Packet
etherealflaim 2:e8e09adc41fc 7
etherealflaim 0:d494b853ce97 8 #define ICMP_ECHO_REPLY 0x00
etherealflaim 0:d494b853ce97 9 #define ICMP_ECHO_REQUEST 0x08
etherealflaim 0:d494b853ce97 10 #define IPPROTO_ICMP 0x01
etherealflaim 2:e8e09adc41fc 11
etherealflaim 2:e8e09adc41fc 12 /// Memory map of ICMP packet
etherealflaim 0:d494b853ce97 13 typedef struct {
etherealflaim 2:e8e09adc41fc 14 u8 type; ///< type of ICMP message
etherealflaim 2:e8e09adc41fc 15 u8 code; ///< code number associated with certain message types
etherealflaim 0:d494b853ce97 16 u16 checksum;
etherealflaim 2:e8e09adc41fc 17 u16 id; ///< ID value, returned in ECHO REPLY
etherealflaim 2:e8e09adc41fc 18 u16 sequence; ///< Sequence value to be returned with ECHO REPLY
etherealflaim 2:e8e09adc41fc 19 u8 data[]; ///< Data memory map
etherealflaim 0:d494b853ce97 20 } ICMP_Packet;
etherealflaim 0:d494b853ce97 21
etherealflaim 2:e8e09adc41fc 22 /// Convert from wire to host or host to wire endianness
etherealflaim 0:d494b853ce97 23 inline void fix_endian_icmp(ICMP_Packet *segment)
etherealflaim 0:d494b853ce97 24 {
etherealflaim 0:d494b853ce97 25 fix_endian_u16(&segment->checksum);
etherealflaim 0:d494b853ce97 26 fix_endian_u16(&segment->id);
etherealflaim 0:d494b853ce97 27 fix_endian_u16(&segment->sequence);
etherealflaim 0:d494b853ce97 28 }
etherealflaim 0:d494b853ce97 29
etherealflaim 2:e8e09adc41fc 30 /// Print the ICMP packet
etherealflaim 0:d494b853ce97 31 inline void print_icmp(ICMP_Packet *segment)
etherealflaim 0:d494b853ce97 32 {
etherealflaim 0:d494b853ce97 33 main_log.printf("ICMP Packet:");
etherealflaim 0:d494b853ce97 34 main_log.printf(" Type: 0x%02X", segment->type);
etherealflaim 0:d494b853ce97 35 main_log.printf(" Code: 0x%02X", segment->code);
etherealflaim 0:d494b853ce97 36 main_log.printf(" Checksum: 0x%04X", segment->checksum);
etherealflaim 0:d494b853ce97 37 main_log.printf(" ID: 0x%04X", segment->id);
etherealflaim 0:d494b853ce97 38 main_log.printf(" Sequence: 0x%04X", segment->sequence);
etherealflaim 0:d494b853ce97 39 }
etherealflaim 0:d494b853ce97 40
etherealflaim 0:d494b853ce97 41 #endif