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 FILE_SECBOOT ( PERMITTED );
12 
13 #include <stdint.h>
14 #include <ipxe/iobuf.h>
15 #include <ipxe/socket.h>
16 #include <ipxe/tcpip.h>
17 #include <ipxe/tables.h>
18 
19 /** An ICMP header */
20 struct icmp_header {
21  /** Type */
23  /** Code */
25  /** Checksum */
27 } __attribute__ (( packed ));
28 
29 /** An ICMP echo request/reply */
30 struct icmp_echo {
31  /** ICMPv6 header */
32  struct icmp_header icmp;
33  /** Identifier */
35  /** Sequence number */
37  /** Data */
39 } __attribute__ (( packed ));
40 
41 /** An ICMP echo protocol */
43  /** Address family */
45  /** Request type */
47  /** Reply type */
49  /** TCP/IP protocol */
51  /** Include network-layer checksum within packet */
53 };
54 
55 /** ICMP echo protocol table */
56 #define ICMP_ECHO_PROTOCOLS \
57  __table ( struct icmp_echo_protocol, "icmp_echo_protocols" )
58 
59 /** Declare an ICMP echo protocol */
60 #define __icmp_echo_protocol __table_entry ( ICMP_ECHO_PROTOCOLS, 01 )
61 
62 #define ICMP_ECHO_REPLY 0
63 #define ICMP_ECHO_REQUEST 8
64 
65 extern int icmp_tx_echo_request ( struct io_buffer *iobuf,
66  struct sockaddr_tcpip *st_dest );
67 
68 extern int icmp_rx_echo_request ( struct io_buffer *iobuf,
69  struct sockaddr_tcpip *st_src,
70  struct icmp_echo_protocol *echo_protocol );
71 extern int icmp_rx_echo_reply ( struct io_buffer *iobuf,
72  struct sockaddr_tcpip *st_src );
73 
74 #endif /* _IPXE_ICMP_H */
#define __attribute__(x)
Definition: compiler.h:10
int net_checksum
Include network-layer checksum within packet.
Definition: icmp.h:52
TCP/IP socket address.
Definition: tcpip.h:76
unsigned short uint16_t
Definition: stdint.h:11
An ICMP echo request/reply.
Definition: icmp.h:30
int icmp_tx_echo_request(struct io_buffer *iobuf, struct sockaddr_tcpip *st_dest)
Transmit ICMP echo request.
Definition: icmp.c:106
uint8_t code
Code.
Definition: icmp.h:24
I/O buffers.
uint16_t chksum
Checksum.
Definition: icmp.h:26
uint16_t ident
Identifier.
Definition: icmp.h:34
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
uint8_t type
Type.
Definition: icmp.h:22
int icmp_rx_echo_reply(struct io_buffer *iobuf, struct sockaddr_tcpip *st_src)
Process a received ICMP echo request.
Definition: icmp.c:197
uint16_t sa_family_t
A socket address family.
Definition: socket.h:86
Transport-network layer interface.
struct tcpip_protocol * tcpip_protocol
TCP/IP protocol.
Definition: icmp.h:50
uint8_t data[0]
Data.
Definition: icmp.h:38
uint8_t request
Request type.
Definition: icmp.h:46
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:166
unsigned char uint8_t
Definition: stdint.h:10
A transport-layer protocol of the TCP/IP stack (eg.
Definition: tcpip.h:105
An ICMP echo protocol.
Definition: icmp.h:42
An ICMP header.
Definition: icmp.h:20
Linker tables.
FILE_SECBOOT(PERMITTED)
sa_family_t family
Address family.
Definition: icmp.h:44
uint8_t reply
Reply type.
Definition: icmp.h:48
struct icmp_header icmp
ICMPv6 header.
Definition: icmp.h:32
Socket addresses.
A persistent I/O buffer.
Definition: iobuf.h:38
uint16_t sequence
Sequence number.
Definition: icmp.h:36