Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of ethspam by
icmp.h
00001 #ifndef ICMP_H 00002 #define ICMP_H 00003 00004 #include "net.h" 00005 00006 /** 00007 \file icmp.h 00008 \brief ICMP frame header 00009 00010 This file contains the memory map and associated functions for ICMP packet 00011 creation and deconstruction. 00012 */ 00013 00014 #define ICMP_ECHO_REPLY 0x00 00015 #define ICMP_ECHO_REQUEST 0x08 00016 #define IPPROTO_ICMP 0x01 00017 00018 /// ICMP packet memory map 00019 typedef struct { 00020 u8 type; ///< type of ICMP message 00021 u8 code; ///< code number associated with certain message types 00022 u16 checksum; 00023 u16 id; ///< ID value, returned in ECHO REPLY 00024 u16 sequence; ///< Sequence value to be returned with ECHO REPLY 00025 u8 data[]; ///< Data memory map 00026 } ICMP_Packet; 00027 00028 /// Convert from wire to host or host to wire endianness 00029 inline void fix_endian_icmp(ICMP_Packet *segment) 00030 { 00031 fix_endian_u16(&segment->checksum); 00032 fix_endian_u16(&segment->id); 00033 fix_endian_u16(&segment->sequence); 00034 } 00035 00036 /// Print the ICMP packet 00037 inline void print_icmp(ICMP_Packet *segment) 00038 { 00039 printf("ICMP Packet:"); 00040 printf(" Type: 0x%02X \n", segment->type); 00041 printf(" Code: 0x%02X \n", segment->code); 00042 printf(" Checksum: 0x%04X \n", segment->checksum); 00043 printf(" ID: 0x%04X \n", segment->id); 00044 printf(" Sequence: 0x%04X \n", segment->sequence); 00045 } 00046 00047 #endif
Generated on Fri Jul 15 2022 02:45:18 by
1.7.2
