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.

tftp.h 2.1KB

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