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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #ifndef _IPXE_TFTP_H
  2. #define _IPXE_TFTP_H
  3. /** @file
  4. *
  5. * TFTP protocol
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. #include <stdint.h>
  10. #define TFTP_PORT 69 /**< Default TFTP server port */
  11. #define TFTP_DEFAULT_BLKSIZE 512 /**< Default TFTP data block size */
  12. #define TFTP_MAX_BLKSIZE 1432
  13. #define TFTP_RRQ 1 /**< Read request opcode */
  14. #define TFTP_WRQ 2 /**< Write request opcode */
  15. #define TFTP_DATA 3 /**< Data block opcode */
  16. #define TFTP_ACK 4 /**< Data block acknowledgement opcode */
  17. #define TFTP_ERROR 5 /**< Error opcode */
  18. #define TFTP_OACK 6 /**< Options acknowledgement opcode */
  19. #define TFTP_ERR_FILE_NOT_FOUND 1 /**< File not found */
  20. #define TFTP_ERR_ACCESS_DENIED 2 /**< Access violation */
  21. #define TFTP_ERR_DISK_FULL 3 /**< Disk full or allocation exceeded */
  22. #define TFTP_ERR_ILLEGAL_OP 4 /**< Illegal TFTP operation */
  23. #define TFTP_ERR_UNKNOWN_TID 5 /**< Unknown transfer ID */
  24. #define TFTP_ERR_FILE_EXISTS 6 /**< File already exists */
  25. #define TFTP_ERR_UNKNOWN_USER 7 /**< No such user */
  26. #define TFTP_ERR_BAD_OPTS 8 /**< Option negotiation failed */
  27. #define MTFTP_PORT 1759 /**< Default MTFTP server port */
  28. /** A TFTP read request (RRQ) packet */
  29. struct tftp_rrq {
  30. uint16_t opcode;
  31. char data[0];
  32. } __attribute__ (( packed ));
  33. /** A TFTP data (DATA) packet */
  34. struct tftp_data {
  35. uint16_t opcode;
  36. uint16_t block;
  37. uint8_t data[0];
  38. } __attribute__ (( packed ));
  39. /** A TFTP acknowledgement (ACK) packet */
  40. struct tftp_ack {
  41. uint16_t opcode;
  42. uint16_t block;
  43. } __attribute__ (( packed ));
  44. /** A TFTP error (ERROR) packet */
  45. struct tftp_error {
  46. uint16_t opcode;
  47. uint16_t errcode;
  48. char errmsg[0];
  49. } __attribute__ (( packed ));
  50. /** A TFTP options acknowledgement (OACK) packet */
  51. struct tftp_oack {
  52. uint16_t opcode;
  53. char data[0];
  54. } __attribute__ (( packed ));
  55. /** The common header of all TFTP packets */
  56. struct tftp_common {
  57. uint16_t opcode;
  58. } __attribute__ (( packed ));
  59. /** A union encapsulating all TFTP packet types */
  60. union tftp_any {
  61. struct tftp_common common;
  62. struct tftp_rrq rrq;
  63. struct tftp_data data;
  64. struct tftp_ack ack;
  65. struct tftp_error error;
  66. struct tftp_oack oack;
  67. };
  68. #endif /* _IPXE_TFTP_H */