[PATCH] tftp server patch
Rory Toma
rory at furyondy.corp.ooma.com
Thu Mar 28 22:52:16 CET 2013
---
include/net.h | 1 +
net/net.c | 10 +++++++---
net/tftp.c | 5 +++--
3 files changed, 11 insertions(+), 5 deletions(-)
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,
--
1.7.1
--------------030402000302090806080002--
More information about the U-Boot
mailing list