1 #ifndef _IPXE_ICMP_H 2 #define _IPXE_ICMP_H 3 4 /** @file 5 * 6 * ICMP protocol 7 * 8 */ 9 10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); 11 12 #include <stdint.h> 13 #include <ipxe/iobuf.h> 14 #include <ipxe/socket.h> 15 #include <ipxe/tcpip.h> 16 #include <ipxe/tables.h> 17 18 /** An ICMP header */ 19 struct icmp_header { 20 /** Type */ 21 uint8_t type; 22 /** Code */ 23 uint8_t code; 24 /** Checksum */ 25 uint16_t chksum; 26 } __attribute__ (( packed )); 27 28 /** An ICMP echo request/reply */ 29 struct icmp_echo { 30 /** ICMPv6 header */ 31 struct icmp_header icmp; 32 /** Identifier */ 33 uint16_t ident; 34 /** Sequence number */ 35 uint16_t sequence; 36 /** Data */ 37 uint8_t data[0]; 38 } __attribute__ (( packed )); 39 40 /** An ICMP echo protocol */ 41 struct icmp_echo_protocol { 42 /** Address family */ 43 sa_family_t family; 44 /** Request type */ 45 uint8_t request; 46 /** Reply type */ 47 uint8_t reply; 48 /** TCP/IP protocol */ 49 struct tcpip_protocol *tcpip_protocol; 50 /** Include network-layer checksum within packet */ 51 int net_checksum; 52 }; 53 54 /** ICMP echo protocol table */ 55 #define ICMP_ECHO_PROTOCOLS \ 56 __table ( struct icmp_echo_protocol, "icmp_echo_protocols" ) 57 58 /** Declare an ICMP echo protocol */ 59 #define __icmp_echo_protocol __table_entry ( ICMP_ECHO_PROTOCOLS, 01 ) 60 61 #define ICMP_ECHO_REPLY 0 62 #define ICMP_ECHO_REQUEST 8 63 64 extern int icmp_tx_echo_request ( struct io_buffer *iobuf, 65 struct sockaddr_tcpip *st_dest ); 66 67 extern int icmp_rx_echo_request ( struct io_buffer *iobuf, 68 struct sockaddr_tcpip *st_src, 69 struct icmp_echo_protocol *echo_protocol ); 70 extern int icmp_rx_echo_reply ( struct io_buffer *iobuf, 71 struct sockaddr_tcpip *st_src ); 72 73 #endif /* _IPXE_ICMP_H */ 74