diff mbox series

net: tftp: setup tftp_remote_ip and tftp_filename env variables

Message ID 20210301091703.3540605-1-art@khadas.com
State Needs Review / ACK
Delegated to: Tom Rini
Headers show
Series net: tftp: setup tftp_remote_ip and tftp_filename env variables | expand

Commit Message

Artem Lapkin March 1, 2021, 9:17 a.m. UTC
setup tftp_remote_ip and tftp_filename environment variable for next usage

Problem: no way determinate real filename and remote ip after tftp transfer
1) serverip can be different from real tftp remote ip 
2) filename same determined automatically

Example

=> setenv bootfile 192.168.100.80:/ && pxe get
...
=> printenv tftp_filename tftp_remote_ip serverip
tftp_filename=/pxelinux.cfg/default-arm-meson
tftp_remote_ip=192.168.100.80
serverip=192.168.100.1

Signed-off-by: Artem Lapkin <art@khadas.com>
---
 net/tftp.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/net/tftp.c b/net/tftp.c
index 6fdb1a82..448103a1 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -798,6 +798,12 @@  void tftp_start(enum proto_t protocol)
 #endif
 	       &tftp_remote_ip, &net_ip);
 
+	char tftp_remote_ip_str[22];
+
+	ip_to_string(tftp_remote_ip, tftp_remote_ip_str);
+	env_set("tftp_remote_ip", tftp_remote_ip_str);
+	env_set("tftp_filename", tftp_filename);
+
 	/* Check if we need to send across this subnet */
 	if (net_gateway.s_addr && net_netmask.s_addr) {
 		struct in_addr our_net;