iPXE
icmp.h
Go to the documentation of this file.
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 */
22  /** Code */
24  /** Checksum */
26 } __attribute__ (( packed ));
27 
28 /** An ICMP echo request/reply */
29 struct icmp_echo {
30  /** ICMPv6 header */
31  struct icmp_header icmp;
32  /** Identifier */
34  /** Sequence number */
36  /** Data */
38 } __attribute__ (( packed ));
39 
40 /** An ICMP echo protocol */
42  /** Address family */
44  /** Request type */
46  /** Reply type */
48  /** TCP/IP protocol */
50  /** Include network-layer checksum within packet */
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 */
#define __attribute__(x)
Definition: compiler.h:10
int net_checksum
Include network-layer checksum within packet.
Definition: icmp.h:51
TCP/IP socket address.
Definition: tcpip.h:75
unsigned short uint16_t
Definition: stdint.h:11
An ICMP echo request/reply.
Definition: icmp.h:29
int icmp_tx_echo_request(struct io_buffer *iobuf, struct sockaddr_tcpip *st_dest)
Transmit ICMP echo request.
Definition: icmp.c:105
uint8_t code
Code.
Definition: icmp.h:23
I/O buffers.
uint16_t chksum
Checksum.
Definition: icmp.h:25
uint16_t ident
Identifier.
Definition: icmp.h:33
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
uint8_t type
Type.
Definition: icmp.h:21
int icmp_rx_echo_reply(struct io_buffer *iobuf, struct sockaddr_tcpip *st_src)
Process a received ICMP echo request.
Definition: icmp.c:196
uint16_t sa_family_t
A socket address family.
Definition: socket.h:85
Transport-network layer interface.
struct tcpip_protocol * tcpip_protocol
TCP/IP protocol.
Definition: icmp.h:49
uint8_t data[0]
Data.
Definition: icmp.h:37
uint8_t request
Request type.
Definition: icmp.h:45
int icmp_rx_echo_request(struct io_buffer *iobuf, struct sockaddr_tcpip *st_src, struct icmp_echo_protocol *echo_protocol)
Process a received ICMP echo request.
Definition: icmp.c:165
unsigned char uint8_t
Definition: stdint.h:10
A transport-layer protocol of the TCP/IP stack (eg.
Definition: tcpip.h:104
An ICMP echo protocol.
Definition: icmp.h:41
An ICMP header.
Definition: icmp.h:19
Linker tables.
sa_family_t family
Address family.
Definition: icmp.h:43
uint8_t reply
Reply type.
Definition: icmp.h:47
struct icmp_header icmp
ICMPv6 header.
Definition: icmp.h:31
Socket addresses.
A persistent I/O buffer.
Definition: iobuf.h:32
uint16_t sequence
Sequence number.
Definition: icmp.h:35