You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

icmp.h 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef _IPXE_ICMP_H
  2. #define _IPXE_ICMP_H
  3. /** @file
  4. *
  5. * ICMP protocol
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. #include <stdint.h>
  10. #include <ipxe/iobuf.h>
  11. #include <ipxe/socket.h>
  12. #include <ipxe/tcpip.h>
  13. #include <ipxe/tables.h>
  14. /** An ICMP header */
  15. struct icmp_header {
  16. /** Type */
  17. uint8_t type;
  18. /** Code */
  19. uint8_t code;
  20. /** Checksum */
  21. uint16_t chksum;
  22. } __attribute__ (( packed ));
  23. /** An ICMP echo request/reply */
  24. struct icmp_echo {
  25. /** ICMPv6 header */
  26. struct icmp_header icmp;
  27. /** Identifier */
  28. uint16_t ident;
  29. /** Sequence number */
  30. uint16_t sequence;
  31. /** Data */
  32. uint8_t data[0];
  33. } __attribute__ (( packed ));
  34. /** An ICMP echo protocol */
  35. struct icmp_echo_protocol {
  36. /** Address family */
  37. sa_family_t family;
  38. /** Request type */
  39. uint8_t request;
  40. /** Reply type */
  41. uint8_t reply;
  42. /** TCP/IP protocol */
  43. struct tcpip_protocol *tcpip_protocol;
  44. /** Include network-layer checksum within packet */
  45. int net_checksum;
  46. };
  47. /** ICMP echo protocol table */
  48. #define ICMP_ECHO_PROTOCOLS \
  49. __table ( struct icmp_echo_protocol, "icmp_echo_protocols" )
  50. /** Declare an ICMP echo protocol */
  51. #define __icmp_echo_protocol __table_entry ( ICMP_ECHO_PROTOCOLS, 01 )
  52. #define ICMP_ECHO_REPLY 0
  53. #define ICMP_ECHO_REQUEST 8
  54. extern int icmp_tx_echo_request ( struct io_buffer *iobuf,
  55. struct sockaddr_tcpip *st_dest );
  56. extern int icmp_rx_echo_request ( struct io_buffer *iobuf,
  57. struct sockaddr_tcpip *st_src,
  58. struct icmp_echo_protocol *echo_protocol );
  59. extern int icmp_rx_echo_reply ( struct io_buffer *iobuf,
  60. struct sockaddr_tcpip *st_src );
  61. #endif /* _IPXE_ICMP_H */