public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH] TFTP: add host ip addr support
@ 2008-01-11 23:43 Jean-Christophe PLAGNIOL-VILLARD
  2008-01-15 13:50 ` Jean-Christophe PLAGNIOL-VILLARD
  2008-01-16  3:19 ` Ben Warren
  0 siblings, 2 replies; 34+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2008-01-11 23:43 UTC (permalink / raw)
  To: u-boot

allow to use a different server as set in serverip

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.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..9d87e2c 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;
@@ -55,7 +55,7 @@ static int	TftpState;
 
 #define DEFAULT_NAME_LEN	(8 + 4 + 1)
 static char default_filename[DEFAULT_NAME_LEN];
-static char *tftp_filename;
+static char tftp_filename[2048];
 
 #ifdef CFG_DIRECT_FLASH_TFTP
 extern flash_info_t flash_info[];
@@ -231,7 +231,7 @@ TftpSend (void)
 		break;
 	}
 
-	NetSendUDPPacket(NetServerEther, NetServerIP, TftpServerPort, TftpOurPort, len);
+	NetSendUDPPacket(NetServerEther, TftpServerIP, TftpServerPort, TftpOurPort, len);
 }
 
 
@@ -453,30 +453,38 @@ 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;
+		strcpy (tftp_filename, default_filename);
 
 		printf ("*** Warning: no boot file name; using '%s'\n",
 			tftp_filename);
 	} else {
-		tftp_filename = BootFile;
+		char *p=BootFile;
+		p = strchr (p, ':');
+		if (p != NULL) {
+			TftpServerIP = string_to_ip (BootFile);
+			++p;
+			strcpy (tftp_filename, p);
+		} else 
+			strcpy (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 ServerNet 	= TftpServerIP & NetOurSubnetMask;
 
 	    if (OurNet != ServerNet) {
 		puts ("; sending through gateway ");
-- 
1.5.3.7

^ permalink raw reply related	[flat|nested] 34+ messages in thread
* [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support
  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
  0 siblings, 1 reply; 34+ messages in thread
From: Wolfgang Denk @ 2008-01-09 22:39 UTC (permalink / raw)
  To: u-boot

In message <1199914268-29217-1-git-send-email-plagnioj@jcrosoft.com> you wrote:
> allow to use a different server as set in serverip
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> 
> diff --git a/common/cmd_net.c b/common/cmd_net.c
> index 21682c0..e03ffbf 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] [[host ip addr]:bootfilename]\n"

NAK.

Ben, please don't apply. I reject this patch.

Jean-Christophe - as already discussed on IRC I really ask you to pay
attemtion to gvb's comments on your patch:

| Critique: the help is misleading: "host ip addr:" is optional so it 
| needs another set of [] around it.  Having spaces in "host ip addr" is 
| more readable, but makes it look like it is three things or perhaps a 
| keyword.
| 
| I would suggest the following, but there may be a better way...
| 	"[loadAddress] [[hostIPaddr:]bootfilename]\n"

Also make sure that you place the ';' in the right pair of brackets.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"The X11 source code style is ATROCIOUS and should not be used  as  a
model."                                                   - Doug Gwyn

^ permalink raw reply	[flat|nested] 34+ messages in thread
* [U-Boot-Users] [PATCH] TFTP: add host ip addr support
@ 2007-12-24 16:40 Jerry Van Baren
  2008-01-09 21:31 ` [U-Boot-Users] [PATCH 0/1] " Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 34+ messages in thread
From: Jerry Van Baren @ 2007-12-24 16:40 UTC (permalink / raw)
  To: u-boot

Jean-Christophe PLAGNIOL-VILLARD wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> 
> diff --git a/common/cmd_net.c b/common/cmd_net.c
> index 21682c0..2fb0e7c 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] [host ip addr:bootfilename]\n"

Hi Jean-Christophe,

Interesting.  I can see how that would be useful rather than having to 
modify the dhcp server configuration when you want to use an alternate 
server.

Critique: the help is misleading: "host ip addr:" is optional so it 
needs another set of [] around it.  Having spaces in "host ip addr" is 
more readable, but makes it look like it is three things or perhaps a 
keyword.

I would suggest the following, but there may be a better way...
	"[loadAddress] [[hostIPaddr:]bootfilename]\n"

Best regards,
gvb

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2008-02-04 23:42 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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:39 [U-Boot-Users] [PATCH 0/1] " Wolfgang Denk
2008-01-10  9:46 ` Jean-Christophe PLAGNIOL-VILLARD
2008-01-10  9:46   ` [U-Boot-Users] [PATCH 1/1] Fix nfs command help to reflect that the serverip is optional Jean-Christophe PLAGNIOL-VILLARD
2008-01-10 22:44     ` Wolfgang Denk
2007-12-24 16:40 [U-Boot-Users] [PATCH] TFTP: add host ip addr support Jerry Van Baren
2008-01-09 21:31 ` [U-Boot-Users] [PATCH 0/1] " Jean-Christophe PLAGNIOL-VILLARD
2008-01-09 21:31   ` [U-Boot-Users] [PATCH 1/1] Fix nfs command help to reflect that the serverip is optional Jean-Christophe PLAGNIOL-VILLARD
2008-01-09 22:26     ` Ben Warren
2008-01-09 22:53       ` 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:01           ` [U-Boot-Users] [PATCH 1/1] Fix nfs command help to reflect that the serverip is optional Jean-Christophe PLAGNIOL-VILLARD
2008-01-09 22:35     ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox