![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
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.
net/icmp.h@8:1c1f6ce348c6, 2010-10-12 (annotated)
- Committer:
- etherealflaim
- Date:
- Tue Oct 12 06:48:59 2010 +0000
- Revision:
- 8:1c1f6ce348c6
- Parent:
- 6:66c4cd9073aa
Documentation
Who changed what in which revision?
User | Revision | Line number | New 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 | 6:66c4cd9073aa | 6 | /** |
etherealflaim | 6:66c4cd9073aa | 7 | \file icmp.h |
etherealflaim | 6:66c4cd9073aa | 8 | \brief ICMP frame header |
etherealflaim | 6:66c4cd9073aa | 9 | |
etherealflaim | 6:66c4cd9073aa | 10 | This file contains the memory map and associated functions for ICMP packet |
etherealflaim | 6:66c4cd9073aa | 11 | creation and deconstruction. |
etherealflaim | 6:66c4cd9073aa | 12 | */ |
etherealflaim | 2:e8e09adc41fc | 13 | |
etherealflaim | 0:d494b853ce97 | 14 | #define ICMP_ECHO_REPLY 0x00 |
etherealflaim | 0:d494b853ce97 | 15 | #define ICMP_ECHO_REQUEST 0x08 |
etherealflaim | 0:d494b853ce97 | 16 | #define IPPROTO_ICMP 0x01 |
etherealflaim | 2:e8e09adc41fc | 17 | |
etherealflaim | 3:c32d9660b888 | 18 | /// ICMP packet memory map |
etherealflaim | 0:d494b853ce97 | 19 | typedef struct { |
etherealflaim | 2:e8e09adc41fc | 20 | u8 type; ///< type of ICMP message |
etherealflaim | 2:e8e09adc41fc | 21 | u8 code; ///< code number associated with certain message types |
etherealflaim | 0:d494b853ce97 | 22 | u16 checksum; |
etherealflaim | 2:e8e09adc41fc | 23 | u16 id; ///< ID value, returned in ECHO REPLY |
etherealflaim | 2:e8e09adc41fc | 24 | u16 sequence; ///< Sequence value to be returned with ECHO REPLY |
etherealflaim | 2:e8e09adc41fc | 25 | u8 data[]; ///< Data memory map |
etherealflaim | 0:d494b853ce97 | 26 | } ICMP_Packet; |
etherealflaim | 0:d494b853ce97 | 27 | |
etherealflaim | 2:e8e09adc41fc | 28 | /// Convert from wire to host or host to wire endianness |
etherealflaim | 0:d494b853ce97 | 29 | inline void fix_endian_icmp(ICMP_Packet *segment) |
etherealflaim | 0:d494b853ce97 | 30 | { |
etherealflaim | 0:d494b853ce97 | 31 | fix_endian_u16(&segment->checksum); |
etherealflaim | 0:d494b853ce97 | 32 | fix_endian_u16(&segment->id); |
etherealflaim | 0:d494b853ce97 | 33 | fix_endian_u16(&segment->sequence); |
etherealflaim | 0:d494b853ce97 | 34 | } |
etherealflaim | 0:d494b853ce97 | 35 | |
etherealflaim | 2:e8e09adc41fc | 36 | /// Print the ICMP packet |
etherealflaim | 0:d494b853ce97 | 37 | inline void print_icmp(ICMP_Packet *segment) |
etherealflaim | 0:d494b853ce97 | 38 | { |
etherealflaim | 0:d494b853ce97 | 39 | main_log.printf("ICMP Packet:"); |
etherealflaim | 0:d494b853ce97 | 40 | main_log.printf(" Type: 0x%02X", segment->type); |
etherealflaim | 0:d494b853ce97 | 41 | main_log.printf(" Code: 0x%02X", segment->code); |
etherealflaim | 0:d494b853ce97 | 42 | main_log.printf(" Checksum: 0x%04X", segment->checksum); |
etherealflaim | 0:d494b853ce97 | 43 | main_log.printf(" ID: 0x%04X", segment->id); |
etherealflaim | 0:d494b853ce97 | 44 | main_log.printf(" Sequence: 0x%04X", segment->sequence); |
etherealflaim | 0:d494b853ce97 | 45 | } |
etherealflaim | 0:d494b853ce97 | 46 | |
etherealflaim | 0:d494b853ce97 | 47 | #endif |