public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Andre Renaud <andre@bluewatersys.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support
Date: Fri, 18 Jan 2008 11:42:43 +1300	[thread overview]
Message-ID: <478FD9E3.3060700@bluewatersys.com> (raw)
In-Reply-To: <1200607712-1381-1-git-send-email-plagnioj@jcrosoft.com>

Couldn't this be done as follows instead? This way there is no need to allocate any more 
memory on the stack, and no need for a new configuration option.

Andre

Signed-off-by: Andre Renaud <andre@bluewatesys.com>

diff --git a/common/cmd_net.c b/common/cmd_net.c
index 21682c0..b86ca86 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -51,7 +51,7 @@ int do_tftpb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 U_BOOT_CMD(
     tftpboot,    3,    1,    do_tftpb,
     "tftpboot- boot image via network using TFTP protocol\n",
-    "[loadAddress] [bootfilename]\n"
+    "[loadAddress] [[hostIPaddr:]bootfilename]\n"
 );
 
 int do_rarpb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
diff --git a/net/tftp.c b/net/tftp.c
index 8b95bcf..262ff79 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -34,7 +34,7 @@
 #define TFTP_ERROR    5
 #define TFTP_OACK    6
 
-
+static IPaddr_t TftpServerIP;
 static int    TftpServerPort;        /* The UDP port at their end        */
 static int    TftpOurPort;        /* The UDP port at our end        */
 static int    TftpTimeoutCount;
@@ -231,7 +242,7 @@ TftpSend (void)
         break;
     }
 
-    NetSendUDPPacket(NetServerEther, NetServerIP, TftpServerPort, TftpOurPort, len);
+    NetSendUDPPacket(NetServerEther, TftpServerIP, TftpServerPort, TftpOurPort, len);
 }
 
 
@@ -453,30 +464,43 @@ TftpStart (void)
     char *ep;             /* Environment pointer */
 #endif
 
+    TftpServerIP = NetServerIP;
     if (BootFile[0] == '\0') {
         sprintf(default_filename, "%02lX%02lX%02lX%02lX.img",
             NetOurIP & 0xFF,
             (NetOurIP >>  8) & 0xFF,
             (NetOurIP >> 16) & 0xFF,
             (NetOurIP >> 24) & 0xFF    );
         tftp_filename = default_filename;
 
         printf ("*** Warning: no boot file name; using '%s'\n",
             tftp_filename);
     } else {
+        char *p=BootFile;
+        p = strchr (p, ':');
+        if (p != NULL) {
+            TftpServerIP = string_to_ip (BootFile);
+            ++p;
+            tftp_filename = p;
+        } else
+            tftp_filename = BootFile;
     }
 
 #if defined(CONFIG_NET_MULTI)
     printf ("Using %s device\n", eth_get_name());
 #endif
-    puts ("TFTP from server ");    print_IPaddr (NetServerIP);
+    puts ("TFTP from server ");    print_IPaddr (TftpServerIP);
     puts ("; our IP address is ");    print_IPaddr (NetOurIP);
 
     /* Check if we need to send across this subnet */
     if (NetOurGatewayIP && NetOurSubnetMask) {
-        IPaddr_t OurNet     = NetOurIP    & NetOurSubnetMask;
-        IPaddr_t ServerNet     = NetServerIP & NetOurSubnetMask;
+        IPaddr_t OurNet    = NetOurIP    & NetOurSubnetMask;
+        IPaddr_t ServerNet    = TftpServerIP & NetOurSubnetMask;
 
         if (OurNet != ServerNet) {
         puts ("; sending through gateway ");

  parent reply	other threads:[~2008-01-17 22:42 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-11 23:43 [U-Boot-Users] [PATCH] TFTP: add host ip addr support Jean-Christophe PLAGNIOL-VILLARD
2008-01-15 13:50 ` Jean-Christophe PLAGNIOL-VILLARD
2008-01-16  3:19 ` Ben Warren
2008-01-16  7:19   ` Jean-Christophe PLAGNIOL-VILLARD
2008-01-16 15:49     ` Ben Warren
2008-01-16 17:33       ` Jean-Christophe PLAGNIOL-VILLARD
2008-01-16 20:27         ` Ben Warren
2008-01-16 20:40           ` Wolfgang Denk
2008-01-16 20:47             ` Ben Warren
2008-01-16 20:56               ` McMullan, Jason
2008-01-16 21:26                 ` Wolfgang Denk
2008-01-16 22:27                   ` Jean-Christophe PLAGNIOL-VILLARD
2008-01-16 23:09                     ` Wolfgang Denk
2008-01-16 23:33                       ` Ben Warren
2008-01-17 22:08                         ` [U-Boot-Users] [PATCH 0/1] " Jean-Christophe PLAGNIOL-VILLARD
2008-01-17 22:08                           ` [U-Boot-Users] [PATCH 1/1] Fix nfs command help to reflect that the serverip is optional Jean-Christophe PLAGNIOL-VILLARD
2008-01-17 22:29                             ` Ben Warren
2008-01-17 22:31                           ` [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support Wolfgang Denk
2008-01-17 22:42                           ` Andre Renaud [this message]
2008-01-18  0:19                             ` Ben Warren
2008-01-18  0:30                             ` Jean-Christophe PLAGNIOL-VILLARD
2008-01-16 21:23               ` [U-Boot-Users] [PATCH] " Wolfgang Denk
2008-01-16 21:38                 ` Ben Warren
2008-01-17 23:51                 ` Jean-Christophe PLAGNIOL-VILLARD
2008-01-18  0:14                   ` Jean-Christophe PLAGNIOL-VILLARD
2008-02-04 23:42                     ` Wolfgang Denk
2008-01-18  0:23                   ` Ben Warren
  -- strict thread matches above, loose matches on Subject: below --
2008-01-09 22:53 [U-Boot-Users] [PATCH 1/1] Fix nfs command help to reflect that the serverip is optional Wolfgang Denk
2008-01-10 23:01 ` [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support Jean-Christophe PLAGNIOL-VILLARD
2008-01-10 23:33   ` Andre Renaud
2008-01-11  0:12     ` Jean-Christophe PLAGNIOL-VILLARD
2007-12-24 16:40 [U-Boot-Users] [PATCH] " Jerry Van Baren
2008-01-09 21:31 ` [U-Boot-Users] [PATCH 0/1] " Jean-Christophe PLAGNIOL-VILLARD
2008-01-09 22:39   ` Wolfgang Denk
2008-01-10  9:46     ` Jean-Christophe PLAGNIOL-VILLARD
2008-01-10 22:43       ` Wolfgang Denk
2008-01-11 22:46       ` Ben Warren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=478FD9E3.3060700@bluewatersys.com \
    --to=andre@bluewatersys.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox