Patchwork [U-Boot] Add separate environment variable for tftp server

login
register
mail settings
Submitter Rory Toma
Date March 28, 2013, 9:58 p.m.
Message ID <5154BD18.8000605@ooma.com>
Download mbox | patch
Permalink /patch/232200/
State Rejected
Delegated to: Tom Rini
Headers show

Comments

Rory Toma - March 28, 2013, 9:58 p.m.
This patch uses the environment variable "tftpserverip" as the tftp 
server IP instead of serverip. If it is unset, it defaults to serverip.
From 049d0795c5fcffb0ddc8a43ea2f1b373afb5c2b1 Mon Sep 17 00:00:00 2001
From: Rory Toma <rory@furyondy.corp.ooma.com>
Date: Thu, 28 Mar 2013 14:52:16 -0700
Subject: [PATCH] tftp server patch

---
 include/net.h |    1 +
 net/net.c     |   10 +++++++---
 net/tftp.c    |    5 +++--
 3 files changed, 11 insertions(+), 5 deletions(-)

Patch

diff --git a/include/net.h b/include/net.h
index 970d4d1..df55182 100644
--- a/include/net.h
+++ b/include/net.h
@@ -420,6 +420,7 @@  extern uchar		NetOurEther[6];		/* Our ethernet address */
 extern uchar		NetServerEther[6];	/* Boot server enet address */
 extern IPaddr_t		NetOurIP;	/* Our    IP addr (0 = unknown) */
 extern IPaddr_t		NetServerIP;	/* Server IP addr (0 = unknown) */
+extern IPaddr_t		TftpRemoteIP;	/* tftp server IP addr */
 extern uchar		*NetTxPacket;		/* THE transmit packet */
 extern uchar		*NetRxPackets[PKTBUFSRX]; /* Receive packets */
 extern uchar		*NetRxPacket;		/* Current receive packet */
diff --git a/net/net.c b/net/net.c
index df94789..3bba2e2 100644
--- a/net/net.c
+++ b/net/net.c
@@ -142,8 +142,10 @@  uchar		NetOurEther[6];
 uchar		NetServerEther[6];
 /* Our IP addr (0 = unknown) */
 IPaddr_t	NetOurIP;
-/* Server IP addr (0 = unknown) */
+/* nfs Server IP addr (0 = unknown) */
 IPaddr_t	NetServerIP;
+/* tftp Server IP addr (if unset, it use NetServerIP) */
+IPaddr_t	TftpRemoteIP;
 /* Current receive packet */
 uchar *NetRxPacket;
 /* Current rx packet length */
@@ -264,6 +266,7 @@  static void NetInitLoop(void)
 		NetOurGatewayIP = getenv_IPaddr("gatewayip");
 		NetOurSubnetMask = getenv_IPaddr("netmask");
 		NetServerIP = getenv_IPaddr("serverip");
+		TftpRemoteIP = getenv_IPaddr("tftpserverip");
 		NetOurNativeVLAN = getenv_VLAN("nvlan");
 		NetOurVLAN = getenv_VLAN("vlan");
 #if defined(CONFIG_CMD_DNS)
@@ -1225,8 +1228,9 @@  static int net_check_prereq(enum proto_t protocol)
 #endif
 	case TFTPGET:
 	case TFTPPUT:
-		if (NetServerIP == 0) {
-			puts("*** ERROR: `serverip' not set\n");
+		if ((TftpRemoteIP == 0) || (NetServerIP == 0)) {
+			puts("*** ERROR: `serverip'
+				or `tftpserverip' not set\n");
 			return 1;
 		}
 #if	defined(CONFIG_CMD_PING) || defined(CONFIG_CMD_SNTP) || \
diff --git a/net/tftp.c b/net/tftp.c
index 09790eb..561341d 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -64,7 +64,6 @@  enum {
 	TFTP_ERR_FILE_ALREADY_EXISTS = 6,
 };
 
-static IPaddr_t TftpRemoteIP;
 /* The UDP port at their end */
 static int	TftpRemotePort;
 /* The UDP port at our end */
@@ -711,7 +710,9 @@  void TftpStart(enum proto_t protocol)
 	debug("TFTP blocksize = %i, timeout = %ld ms\n",
 		TftpBlkSizeOption, TftpTimeoutMSecs);
 
-	TftpRemoteIP = NetServerIP;
+	if (TftpRemoteIP == 0) {
+		TftpRemoteIP = NetServerIP;
+	}
 	if (BootFile[0] == '\0') {
 		sprintf(default_filename, "%02X%02X%02X%02X.img",
 			NetOurIP & 0xFF,