Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

tftp.h 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #ifndef _TFTP_H
  2. #define _TFTP_H
  3. #define TFTP_PORT 69
  4. #define TFTP_DEFAULTSIZE_PACKET 512
  5. #define TFTP_MAX_PACKET 1432 /* 512 */
  6. #define TFTP_RRQ 1
  7. #define TFTP_WRQ 2
  8. #define TFTP_DATA 3
  9. #define TFTP_ACK 4
  10. #define TFTP_ERROR 5
  11. #define TFTP_OACK 6
  12. #define TFTP_CODE_EOF 1
  13. #define TFTP_CODE_MORE 2
  14. #define TFTP_CODE_ERROR 3
  15. #define TFTP_CODE_BOOT 4
  16. #define TFTP_CODE_CFG 5
  17. struct tftp_t {
  18. struct iphdr ip;
  19. struct udphdr udp;
  20. uint16_t opcode;
  21. union {
  22. uint8_t rrq[TFTP_DEFAULTSIZE_PACKET];
  23. struct {
  24. uint16_t block;
  25. uint8_t download[TFTP_MAX_PACKET];
  26. } data;
  27. struct {
  28. uint16_t block;
  29. } ack;
  30. struct {
  31. uint16_t errcode;
  32. uint8_t errmsg[TFTP_DEFAULTSIZE_PACKET];
  33. } err;
  34. struct {
  35. uint8_t data[TFTP_DEFAULTSIZE_PACKET+2];
  36. } oack;
  37. } u;
  38. } PACKED;
  39. /* define a smaller tftp packet solely for making requests to conserve stack
  40. 512 bytes should be enough */
  41. struct tftpreq_t {
  42. struct iphdr ip;
  43. struct udphdr udp;
  44. uint16_t opcode;
  45. union {
  46. uint8_t rrq[512];
  47. struct {
  48. uint16_t block;
  49. } ack;
  50. struct {
  51. uint16_t errcode;
  52. uint8_t errmsg[512-2];
  53. } err;
  54. } u;
  55. } PACKED;
  56. struct tftpreq_info_t {
  57. const char *name;
  58. unsigned short port;
  59. unsigned short blksize;
  60. } PACKED;
  61. struct tftpblk_info_t {
  62. char *data;
  63. unsigned int block;
  64. unsigned int len;
  65. int eof;
  66. } PACKED;
  67. #define TFTP_MIN_PACKET (sizeof(struct iphdr) + sizeof(struct udphdr) + 4)
  68. #endif /* _TFTP_H */