![](/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
- Committer:
- etherealflaim
- Date:
- 2010-10-12
- Revision:
- 8:1c1f6ce348c6
- Parent:
- 6:66c4cd9073aa
File content as of revision 8:1c1f6ce348c6:
#ifndef ICMP_H #define ICMP_H #include "net.h" /** \file icmp.h \brief ICMP frame header This file contains the memory map and associated functions for ICMP packet creation and deconstruction. */ #define ICMP_ECHO_REPLY 0x00 #define ICMP_ECHO_REQUEST 0x08 #define IPPROTO_ICMP 0x01 /// ICMP packet memory map 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[]; ///< Data memory map } ICMP_Packet; /// Convert from wire to host or host to wire endianness inline void fix_endian_icmp(ICMP_Packet *segment) { fix_endian_u16(&segment->checksum); fix_endian_u16(&segment->id); fix_endian_u16(&segment->sequence); } /// Print the ICMP packet 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