iPXE
icmp.h
Go to the documentation of this file.
00001 #ifndef _IPXE_ICMP_H
00002 #define _IPXE_ICMP_H
00003 
00004 /** @file
00005  *
00006  * ICMP protocol
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <stdint.h>
00013 #include <ipxe/iobuf.h>
00014 #include <ipxe/socket.h>
00015 #include <ipxe/tcpip.h>
00016 #include <ipxe/tables.h>
00017 
00018 /** An ICMP header */
00019 struct icmp_header {
00020         /** Type */
00021         uint8_t type;
00022         /** Code */
00023         uint8_t code;
00024         /** Checksum */
00025         uint16_t chksum;
00026 } __attribute__ (( packed ));
00027 
00028 /** An ICMP echo request/reply */
00029 struct icmp_echo {
00030         /** ICMPv6 header */
00031         struct icmp_header icmp;
00032         /** Identifier */
00033         uint16_t ident;
00034         /** Sequence number */
00035         uint16_t sequence;
00036         /** Data */
00037         uint8_t data[0];
00038 } __attribute__ (( packed ));
00039 
00040 /** An ICMP echo protocol */
00041 struct icmp_echo_protocol {
00042         /** Address family */
00043         sa_family_t family;
00044         /** Request type */
00045         uint8_t request;
00046         /** Reply type */
00047         uint8_t reply;
00048         /** TCP/IP protocol */
00049         struct tcpip_protocol *tcpip_protocol;
00050         /** Include network-layer checksum within packet */
00051         int net_checksum;
00052 };
00053 
00054 /** ICMP echo protocol table */
00055 #define ICMP_ECHO_PROTOCOLS \
00056         __table ( struct icmp_echo_protocol, "icmp_echo_protocols" )
00057 
00058 /** Declare an ICMP echo protocol */
00059 #define __icmp_echo_protocol __table_entry ( ICMP_ECHO_PROTOCOLS, 01 )
00060 
00061 #define ICMP_ECHO_REPLY 0
00062 #define ICMP_ECHO_REQUEST 8
00063 
00064 extern int icmp_tx_echo_request ( struct io_buffer *iobuf,
00065                                   struct sockaddr_tcpip *st_dest );
00066 
00067 extern int icmp_rx_echo_request ( struct io_buffer *iobuf,
00068                                   struct sockaddr_tcpip *st_src,
00069                                   struct icmp_echo_protocol *echo_protocol );
00070 extern int icmp_rx_echo_reply ( struct io_buffer *iobuf,
00071                                 struct sockaddr_tcpip *st_src );
00072 
00073 #endif /* _IPXE_ICMP_H */