summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/icmp.h
diff options
context:
space:
mode:
authorMichael Brown2013-10-21 15:10:07 +0200
committerMichael Brown2013-10-21 16:08:12 +0200
commit5c2ffc26cc9b73ef60cbd123cd90f499dc01bbc2 (patch)
tree5dc77a8f4b54549e1468ecf93d1cd5cc454f6e60 /src/include/ipxe/icmp.h
parent[resolv] Use sock_aton() to allow parsing of arbitrary numeric addresses (diff)
downloadipxe-5c2ffc26cc9b73ef60cbd123cd90f499dc01bbc2.tar.gz
ipxe-5c2ffc26cc9b73ef60cbd123cd90f499dc01bbc2.tar.xz
ipxe-5c2ffc26cc9b73ef60cbd123cd90f499dc01bbc2.zip
[icmp] Add support for sending ICMP echo requests
Merge common functionality between IPv4 and IPv6 ICMP echo handling, and add support for transmitting ICMP echo requests and delivering ICMP echo replies to a (not yet implemented) ping_rx() function. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe/icmp.h')
-rw-r--r--src/include/ipxe/icmp.h50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/include/ipxe/icmp.h b/src/include/ipxe/icmp.h
index e402ce40e..0480ddfaf 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 */