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.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. #define MTFTP_PORT 1759 /**< Default MTFTP server port */
  27. /** A TFTP read request (RRQ) packet */
  28. struct tftp_rrq {
  29. uint16_t opcode;
  30. char data[0];
  31. } __attribute__ (( packed ));
  32. /** A TFTP data (DATA) packet */
  33. struct tftp_data {
  34. uint16_t opcode;
  35. uint16_t block;
  36. uint8_t data[0];
  37. } __attribute__ (( packed ));
  38. /** A TFTP acknowledgement (ACK) packet */
  39. struct tftp_ack {
  40. uint16_t opcode;
  41. uint16_t block;
  42. } __attribute__ (( packed ));
  43. /** A TFTP error (ERROR) packet */
  44. struct tftp_error {
  45. uint16_t opcode;
  46. uint16_t errcode;
  47. char errmsg[0];
  48. } __attribute__ (( packed ));
  49. /** A TFTP options acknowledgement (OACK) packet */
  50. struct tftp_oack {
  51. uint16_t opcode;
  52. char data[0];
  53. } __attribute__ (( packed ));
  54. /** The common header of all TFTP packets */
  55. struct tftp_common {
  56. uint16_t opcode;
  57. } __attribute__ (( packed ));
  58. /** A union encapsulating all TFTP packet types */
  59. union tftp_any {
  60. struct tftp_common common;
  61. struct tftp_rrq rrq;
  62. struct tftp_data data;
  63. struct tftp_ack ack;
  64. struct tftp_error error;
  65. struct tftp_oack oack;
  66. };
  67. extern void tftp_set_request_blksize ( unsigned int blksize );
  68. #endif /* _GPXE_TFTP_H */