Improve TFTP implementation

- implement server/client mode (API is nicer to use)
- Increase TFTP_MAX_MODE_LEN to be able to contain "netascii" transfer mode
- Adapt tftp_example to changes
This commit is contained in:
Dirk Ziegelmeier
2018-10-08 12:45:29 +02:00
parent de81e8bf19
commit 6c2fd2d25d
6 changed files with 82 additions and 24 deletions

View File

@@ -37,6 +37,7 @@
#include "lwip/apps/tftp_common.h"
err_t tftp_init_client(const struct tftp_context* ctx);
err_t tftp_get(void* handle, const ip_addr_t *addr, u16_t port, const char* fname, const char* mode);
err_t tftp_put(void* handle, const ip_addr_t *addr, u16_t port, const char* fname, const char* mode);

View File

@@ -94,7 +94,11 @@ struct tftp_context {
void (*error)(void* handle, int err, const char* msg, int size);
};
err_t tftp_init(const struct tftp_context* ctx);
#define LWIP_TFTP_MODE_SERVER 0x01
#define LWIP_TFTP_MODE_CLIENT 0x02
#define LWIP_TFTP_MODE_CLIENTSERVER (LWIP_TFTP_MODE_SERVER | LWIP_TFTP_MODE_CLIENT)
err_t tftp_init_common(u8_t mode, const struct tftp_context* ctx);
void tftp_cleanup(void);
#ifdef __cplusplus

View File

@@ -96,7 +96,7 @@
* Max. length of TFTP mode
*/
#if !defined TFTP_MAX_MODE_LEN || defined __DOXYGEN__
#define TFTP_MAX_MODE_LEN 7
#define TFTP_MAX_MODE_LEN 10
#endif
/**

View File

@@ -5,7 +5,7 @@
*
*/
/*
/*
* Redistribution and use in source and binary forms, with or without
* modification,are permitted provided that the following conditions are met:
*
@@ -37,4 +37,6 @@
#include "lwip/apps/tftp_common.h"
err_t tftp_init_server(const struct tftp_context* ctx);
#endif /* LWIP_HDR_APPS_TFTP_SERVER_H */