diff --git a/src/apps/tftp/tftp_server.c b/src/apps/tftp/tftp_server.c index 6da94d48..07f6170e 100644 --- a/src/apps/tftp/tftp_server.c +++ b/src/apps/tftp/tftp_server.c @@ -412,4 +412,14 @@ tftp_init(const struct tftp_context *ctx) return ERR_OK; } +/** @ingroup tftp + * Deinitialize ("turn off") TFTP server. + */ +void tftp_cleanup(void) +{ + LWIP_ASSERT("Cleanup called on non-initialized TFTP", tftp_state.upcb != NULL); + udp_remove(tftp_state.upcb); + memset(&tftp_state, 0, sizeof(tftp_state)); +} + #endif /* LWIP_UDP */ diff --git a/src/include/lwip/apps/tftp_server.h b/src/include/lwip/apps/tftp_server.h index a27ed961..0a7fbee0 100644 --- a/src/include/lwip/apps/tftp_server.h +++ b/src/include/lwip/apps/tftp_server.h @@ -86,6 +86,7 @@ struct tftp_context { }; err_t tftp_init(const struct tftp_context* ctx); +void tftp_cleanup(void); #ifdef __cplusplus }