[PATCH 12/13] tftp: allow to change tftp port

Enrico Scholz enrico.scholz at sigma-chemnitz.de
Mon Jul 18 05:22:27 PDT 2022


useful e.g. when working with a local, non-privileged tftp server

Signed-off-by: Enrico Scholz <enrico.scholz at sigma-chemnitz.de>
---
 fs/tftp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/tftp.c b/fs/tftp.c
index 2c2ff081be51..400209c26023 100644
--- a/fs/tftp.c
+++ b/fs/tftp.c
@@ -78,6 +78,7 @@
 #define TFTP_ERR_RESEND	1
 
 static int g_tftp_window_size = TFTP_MAX_WINDOW_SIZE / 1;
+static int g_tftp_port = TFTP_PORT;
 
 struct tftp_block {
 	uint16_t id;
@@ -600,7 +601,7 @@ static struct file_priv *tftp_do_open(struct device_d *dev,
 		goto out;
 	}
 
-	priv->tftp_con = net_udp_new(tpriv->server, TFTP_PORT, tftp_handler,
+	priv->tftp_con = net_udp_new(tpriv->server, g_tftp_port, tftp_handler,
 			priv);
 	if (IS_ERR(priv->tftp_con)) {
 		ret = PTR_ERR(priv->tftp_con);
@@ -944,6 +945,7 @@ static struct fs_driver_d tftp_driver = {
 static int tftp_init(void)
 {
 	globalvar_add_simple_int("tftp.windowsize", &g_tftp_window_size, "%u");
+	globalvar_add_simple_int("tftp.port", &g_tftp_port, "%u");
 
 	return register_fs_driver(&tftp_driver);
 }
-- 
2.36.1




More information about the barebox mailing list