diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/ipxe/errfile.h | 3 | ||||
-rw-r--r-- | src/include/ipxe/icmp.h | 50 | ||||
-rw-r--r-- | src/include/ipxe/icmpv6.h | 23 | ||||
-rw-r--r-- | src/include/ipxe/ndp.h | 2 | ||||
-rw-r--r-- | src/include/ipxe/ping.h | 18 |
5 files changed, 71 insertions, 25 deletions
diff --git a/src/include/ipxe/errfile.h b/src/include/ipxe/errfile.h index c55107a..376f88c 100644 --- a/src/include/ipxe/errfile.h +++ b/src/include/ipxe/errfile.h @@ -184,7 +184,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #define ERRFILE_slam ( ERRFILE_NET | 0x00160000 ) #define ERRFILE_ib_sma ( ERRFILE_NET | 0x00170000 ) #define ERRFILE_ib_packet ( ERRFILE_NET | 0x00180000 ) -#define ERRFILE_icmp ( ERRFILE_NET | 0x00190000 ) +#define ERRFILE_icmpv4 ( ERRFILE_NET | 0x00190000 ) #define ERRFILE_ib_qset ( ERRFILE_NET | 0x001a0000 ) #define ERRFILE_ib_gma ( ERRFILE_NET | 0x001b0000 ) #define ERRFILE_ib_pathrec ( ERRFILE_NET | 0x001c0000 ) @@ -216,6 +216,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #define ERRFILE_oncrpc_iob ( ERRFILE_NET | 0x00360000 ) #define ERRFILE_neighbour ( ERRFILE_NET | 0x00370000 ) #define ERRFILE_socket ( ERRFILE_NET | 0x00380000 ) +#define ERRFILE_icmp ( ERRFILE_NET | 0x00390000 ) #define ERRFILE_image ( ERRFILE_IMAGE | 0x00000000 ) #define ERRFILE_elf ( ERRFILE_IMAGE | 0x00010000 ) diff --git a/src/include/ipxe/icmp.h b/src/include/ipxe/icmp.h index e402ce4..0480ddf 100644 --- a/src/include/ipxe/icmp.h +++ b/src/include/ipxe/icmp.h @@ -9,6 +9,12 @@ FILE_LICENCE ( GPL2_OR_LATER ); +#include <stdint.h> +#include <ipxe/iobuf.h> +#include <ipxe/socket.h> +#include <ipxe/tcpip.h> +#include <ipxe/tables.h> + /** An ICMP header */ struct icmp_header { /** Type */ @@ -19,7 +25,49 @@ struct icmp_header { uint16_t chksum; } __attribute__ (( packed )); -#define ICMP_ECHO_RESPONSE 0 +/** An ICMP echo request/reply */ +struct icmp_echo { + /** ICMPv6 header */ + struct icmp_header icmp; + /** Identifier */ + uint16_t ident; + /** Sequence number */ + uint16_t sequence; + /** Data */ + uint8_t data[0]; +} __attribute__ (( packed )); + +/** An ICMP echo protocol */ +struct icmp_echo_protocol { + /** Address family */ + sa_family_t family; + /** Request type */ + uint8_t request; + /** Reply type */ + uint8_t reply; + /** TCP/IP protocol */ + struct tcpip_protocol *tcpip_protocol; + /** Include network-layer checksum within packet */ + int net_checksum; +}; + +/** ICMP echo protocol table */ +#define ICMP_ECHO_PROTOCOLS \ + __table ( struct icmp_echo_protocol, "icmp_echo_protocols" ) + +/** Declare an ICMP echo protocol */ +#define __icmp_echo_protocol __table_entry ( ICMP_ECHO_PROTOCOLS, 01 ) + +#define ICMP_ECHO_REPLY 0 #define ICMP_ECHO_REQUEST 8 +extern int icmp_tx_echo_request ( struct io_buffer *iobuf, + struct sockaddr_tcpip *st_dest ); + +extern int icmp_rx_echo_request ( struct io_buffer *iobuf, + struct sockaddr_tcpip *st_src, + struct icmp_echo_protocol *echo_protocol ); +extern int icmp_rx_echo_reply ( struct io_buffer *iobuf, + struct sockaddr_tcpip *st_src ); + #endif /* _IPXE_ICMP_H */ diff --git a/src/include/ipxe/icmpv6.h b/src/include/ipxe/icmpv6.h index c8f0be0..c09a71a 100644 --- a/src/include/ipxe/icmpv6.h +++ b/src/include/ipxe/icmpv6.h @@ -13,28 +13,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include <ipxe/tables.h> #include <ipxe/iobuf.h> #include <ipxe/netdevice.h> - -/** An ICMPv6 header */ -struct icmpv6_header { - /** Type */ - uint8_t type; - /** Code */ - uint8_t code; - /** Checksum */ - uint16_t chksum; -} __attribute__ (( packed )); - -/** An ICMPv6 echo request/reply */ -struct icmpv6_echo { - /** ICMPv6 header */ - struct icmpv6_header icmp; - /** Identifier */ - uint16_t ident; - /** Sequence number */ - uint16_t sequence; - /** Data */ - uint8_t data[0]; -} __attribute__ (( packed )); +#include <ipxe/icmp.h> /** An ICMPv6 handler */ struct icmpv6_handler { diff --git a/src/include/ipxe/ndp.h b/src/include/ipxe/ndp.h index 7b98637..1f05e9a 100644 --- a/src/include/ipxe/ndp.h +++ b/src/include/ipxe/ndp.h @@ -31,7 +31,7 @@ struct ndp_option { /** An NDP header */ struct ndp_header { /** ICMPv6 header */ - struct icmpv6_header icmp; + struct icmp_header icmp; /** Flags */ uint8_t flags; /** Reserved */ diff --git a/src/include/ipxe/ping.h b/src/include/ipxe/ping.h new file mode 100644 index 0000000..6cd376b --- /dev/null +++ b/src/include/ipxe/ping.h @@ -0,0 +1,18 @@ +#ifndef _IPXE_PING_H +#define _IPXE_PING_H + +/** @file + * + * ICMP ping protocol + * + */ + +FILE_LICENCE ( GPL2_OR_LATER ); + +#include <ipxe/iobuf.h> +#include <ipxe/tcpip.h> + +extern int ping_rx ( struct io_buffer *iobuf, + struct sockaddr_tcpip *st_src ); + +#endif /* _IPXE_PING_H */ |