tftp.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2019-02-26 tyx first implementation
  9. */
  10. #ifndef __TFTP_H__
  11. #define __TFTP_H__
  12. #define TFTP_OK (0)
  13. #define TFTP_ETIMEOUT (2)
  14. #define TFTP_EMEM (3)
  15. #define TFTP_ESYS (4)
  16. #define TFTP_EACK (5)
  17. #define TFTP_EBLK (6)
  18. #define TFTP_EDATA (7)
  19. #define TFTP_EFILE (8)
  20. #define TFTP_ECMD (9)
  21. #define TFTP_EINVAL (10)
  22. #define TFTP_EXFER (11)
  23. #define TFTP_EOTHER (10000)
  24. #define TFTP_MAX_RETRY (3)
  25. #define TFTP_SERVER_CONNECT_MAX (5)
  26. #define tftp_printf printf
  27. #if defined(RT_VERSION_CHECK)
  28. #if (RTTHREAD_VERSION >= RT_VERSION_CHECK(5, 0, 0))
  29. #define RT_WEAK rt_weak
  30. #else
  31. #define RT_WEAK RT_WEAK
  32. #endif
  33. #endif
  34. struct tftp_client
  35. {
  36. int max_retry;
  37. int err;
  38. void *_private;
  39. };
  40. struct tftp_server
  41. {
  42. int is_stop;
  43. int is_write;
  44. char *root_name;
  45. void *_private;
  46. };
  47. struct tftp_client *tftp_client_create(const char *ip_addr, int port);
  48. void tftp_client_destroy(struct tftp_client *client);
  49. int tftp_client_push(struct tftp_client *client, const char *local_name, const char *remote_name);
  50. int tftp_client_pull(struct tftp_client *client, const char *remote_name, const char *local_name);
  51. int tftp_client_err(struct tftp_client *client);
  52. struct tftp_server *tftp_server_create(const char *root_name, int port);
  53. void tftp_server_run(struct tftp_server *server);
  54. void tftp_server_destroy(struct tftp_server *server);
  55. void tftp_server_write_set(struct tftp_server *server, int is_write);
  56. #endif