public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH] TFTP: add host ip addr support
@ 2007-12-24 15:55 Jean-Christophe PLAGNIOL-VILLARD
  2007-12-24 16:40 ` Jerry Van Baren
  2007-12-26 20:42 ` [U-Boot-Users] [PATCH] " Haavard Skinnemoen
  0 siblings, 2 replies; 24+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2007-12-24 15:55 UTC (permalink / raw)
  To: u-boot

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"
 );
 
 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..d5d6e65 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 +231,7 @@ TftpSend (void)
 		break;
 	}
 
-	NetSendUDPPacket(NetServerEther, NetServerIP, TftpServerPort, TftpOurPort, len);
+	NetSendUDPPacket(NetServerEther, TftpServerIP, TftpServerPort, TftpOurPort, len);
 }
 
 
@@ -464,19 +464,27 @@ TftpStart (void)
 		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] 24+ messages in thread

* [U-Boot-Users] [PATCH] TFTP: add host ip addr support
  2007-12-24 15:55 [U-Boot-Users] [PATCH] TFTP: add host ip addr support Jean-Christophe PLAGNIOL-VILLARD
@ 2007-12-24 16:40 ` Jerry Van Baren
  2008-01-09 21:31   ` [U-Boot-Users] [PATCH 0/1] " Jean-Christophe PLAGNIOL-VILLARD
  2007-12-26 20:42 ` [U-Boot-Users] [PATCH] " Haavard Skinnemoen
  1 sibling, 1 reply; 24+ 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] 24+ messages in thread

* [U-Boot-Users] [PATCH] TFTP: add host ip addr support
  2007-12-24 15:55 [U-Boot-Users] [PATCH] TFTP: add host ip addr support Jean-Christophe PLAGNIOL-VILLARD
  2007-12-24 16:40 ` Jerry Van Baren
@ 2007-12-26 20:42 ` Haavard Skinnemoen
  2007-12-26 23:09   ` Wolfgang Denk
  1 sibling, 1 reply; 24+ messages in thread
From: Haavard Skinnemoen @ 2007-12-26 20:42 UTC (permalink / raw)
  To: u-boot

On Mon, 24 Dec 2007 16:55:38 +0100
Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote:

> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD
> <plagnioj@jcrosoft.com>

Jean-Christophe, I love your work, but your changelogs totally suck.
Could you please add a bit of text explaining what kind of problem this
patch solves?

Haavard

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

* [U-Boot-Users] [PATCH] TFTP: add host ip addr support
  2007-12-26 20:42 ` [U-Boot-Users] [PATCH] " Haavard Skinnemoen
@ 2007-12-26 23:09   ` Wolfgang Denk
  0 siblings, 0 replies; 24+ messages in thread
From: Wolfgang Denk @ 2007-12-26 23:09 UTC (permalink / raw)
  To: u-boot

In message <20071226214227.499a2109@siona> you wrote:
> On Mon, 24 Dec 2007 16:55:38 +0100
> Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> wrote:
> 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD
> > <plagnioj@jcrosoft.com>
> 
> Jean-Christophe, I love your work, but your changelogs totally suck.
> Could you please add a bit of text explaining what kind of problem this
> patch solves?

I support this request.

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
Testing can show the presense of bugs, but not their absence.
                                                   -- Edsger Dijkstra

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

* [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support
  2007-12-24 16:40 ` Jerry Van Baren
@ 2008-01-09 21:31   ` 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:39     ` [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support Wolfgang Denk
  0 siblings, 2 replies; 24+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2008-01-09 21:31 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..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"
 );
 
 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..d5d6e65 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 +231,7 @@ TftpSend (void)
 		break;
 	}
 
-	NetSendUDPPacket(NetServerEther, NetServerIP, TftpServerPort, TftpOurPort, len);
+	NetSendUDPPacket(NetServerEther, TftpServerIP, TftpServerPort, TftpOurPort, len);
 }
 
 
@@ -464,19 +464,27 @@ TftpStart (void)
 		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] 24+ messages in thread

* [U-Boot-Users] [PATCH 1/1] Fix nfs command help to reflect that the serverip is optional
  2008-01-09 21:31   ` [U-Boot-Users] [PATCH 0/1] " Jean-Christophe PLAGNIOL-VILLARD
@ 2008-01-09 21:31     ` Jean-Christophe PLAGNIOL-VILLARD
  2008-01-09 22:26       ` Ben Warren
  2008-01-09 22:35       ` [U-Boot-Users] [PATCH 1/1] Fix nfs command help to reflect that the serverip is optional Wolfgang Denk
  2008-01-09 22:39     ` [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support Wolfgang Denk
  1 sibling, 2 replies; 24+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2008-01-09 21:31 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

diff --git a/common/cmd_net.c b/common/cmd_net.c
index e03ffbf..894d863 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -87,7 +87,7 @@ int do_nfs (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 U_BOOT_CMD(
 	nfs,	3,	1,	do_nfs,
 	"nfs\t- boot image via network using NFS protocol\n",
-	"[loadAddress] [host ip addr:bootfilename]\n"
+	"[loadAddress] [[host ip addr]:bootfilename]\n"
 );
 #endif
 
-- 
1.5.3.7

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

* [U-Boot-Users] [PATCH 1/1] Fix nfs command help to reflect that the serverip is optional
  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-09 22:35       ` [U-Boot-Users] [PATCH 1/1] Fix nfs command help to reflect that the serverip is optional Wolfgang Denk
  1 sibling, 1 reply; 24+ messages in thread
From: Ben Warren @ 2008-01-09 22:26 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 e03ffbf..894d863 100644
> --- a/common/cmd_net.c
> +++ b/common/cmd_net.c
> @@ -87,7 +87,7 @@ int do_nfs (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
>  U_BOOT_CMD(
>  	nfs,	3,	1,	do_nfs,
>  	"nfs\t- boot image via network using NFS protocol\n",
> -	"[loadAddress] [host ip addr:bootfilename]\n"
> +	"[loadAddress] [[host ip addr]:bootfilename]\n"
>  );
>  #endif
>  
>   
Sorry for being a PITA, but since we're changing documentation shouldn't 
this be:

-	"[loadAddress] [host ip addr:bootfilename]\n"
+	"[loadAddress] [[host ip addr:]bootfilename]\n"


Can you spot the difference?

regards,
Ben

 

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

* [U-Boot-Users] [PATCH 1/1] Fix nfs command help to reflect that the serverip is optional
  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:35       ` Wolfgang Denk
  1 sibling, 0 replies; 24+ messages in thread
From: Wolfgang Denk @ 2008-01-09 22:35 UTC (permalink / raw)
  To: u-boot

In message <1199914268-29217-2-git-send-email-plagnioj@jcrosoft.com> you wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> 
> diff --git a/common/cmd_net.c b/common/cmd_net.c
> index e03ffbf..894d863 100644
> --- a/common/cmd_net.c
> +++ b/common/cmd_net.c
> @@ -87,7 +87,7 @@ int do_nfs (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
>  U_BOOT_CMD(
>  	nfs,	3,	1,	do_nfs,
>  	"nfs\t- boot image via network using NFS protocol\n",
> -	"[loadAddress] [host ip addr:bootfilename]\n"
> +	"[loadAddress] [[host ip addr]:bootfilename]\n"
>  );
>  #endif

Rejected, because this is not correct:

=> print serverip
serverip=192.168.1.1
=> nfs 200000 :/opt/eldk/ppc_4xx/images/uImage
Using ppc_4xx_eth0 device
File transfer via NFS from server 0.0.0.0; our IP address is
192.168.80.2
Filename '/opt/eldk/ppc_4xx/images/uImage'.
Load address: 0x200000
Loading: *** ERROR: Cannot mount
...

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
Make it right before you make it faster.

^ permalink raw reply	[flat|nested] 24+ 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 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:39     ` Wolfgang Denk
  2008-01-10  9:46       ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 1 reply; 24+ 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] 24+ messages in thread

* [U-Boot-Users] [PATCH 1/1] Fix nfs command help to reflect that the serverip is optional
  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
  0 siblings, 1 reply; 24+ messages in thread
From: Wolfgang Denk @ 2008-01-09 22:53 UTC (permalink / raw)
  To: u-boot

In message <47854A1E.5060704@gmail.com> you wrote:
>
> > -	"[loadAddress] [host ip addr:bootfilename]\n"
> > +	"[loadAddress] [[host ip addr]:bootfilename]\n"
> >  );
> >  #endif
> >  
> >   
> Sorry for being a PITA, but since we're changing documentation shouldn't 
> this be:

You're not a PITA, but a careful reader.

> -	"[loadAddress] [host ip addr:bootfilename]\n"
> +	"[loadAddress] [[host ip addr:]bootfilename]\n"
> 
> 
> Can you spot the difference?

Indeed - it's the difference between right and wrong, between working
and failing.

Also, I ask to change this (as gvb previously recommended) into

	"[loadAddress] [[HostIpAddr:]bootfilename]\n"


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
EMACS belongs in <sys/errno.h>: Editor too big!

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

* [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support
  2008-01-09 22:39     ` [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support 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
                           ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2008-01-10  9:46 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..4e3d489 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"
 );
 
 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..d5d6e65 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 +231,7 @@ TftpSend (void)
 		break;
 	}
 
-	NetSendUDPPacket(NetServerEther, NetServerIP, TftpServerPort, TftpOurPort, len);
+	NetSendUDPPacket(NetServerEther, TftpServerIP, TftpServerPort, TftpOurPort, len);
 }
 
 
@@ -464,19 +464,27 @@ TftpStart (void)
 		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] 24+ messages in thread

* [U-Boot-Users] [PATCH 1/1] Fix nfs command help to reflect that the serverip is optional
  2008-01-10  9:46       ` Jean-Christophe PLAGNIOL-VILLARD
@ 2008-01-10  9:46         ` Jean-Christophe PLAGNIOL-VILLARD
  2008-01-10 22:44           ` Wolfgang Denk
  2008-01-10 22:43         ` [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support Wolfgang Denk
  2008-01-11 22:46         ` Ben Warren
  2 siblings, 1 reply; 24+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2008-01-10  9:46 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

diff --git a/common/cmd_net.c b/common/cmd_net.c
index 4e3d489..fec87b6 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -87,7 +87,7 @@ int do_nfs (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 U_BOOT_CMD(
 	nfs,	3,	1,	do_nfs,
 	"nfs\t- boot image via network using NFS protocol\n",
-	"[loadAddress] [host ip addr:bootfilename]\n"
+	"[loadAddress] [[host ip addr:]bootfilename]\n"
 );
 #endif
 
-- 
1.5.3.7

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

* [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support
  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:43         ` Wolfgang Denk
  2008-01-11 22:46         ` Ben Warren
  2 siblings, 0 replies; 24+ messages in thread
From: Wolfgang Denk @ 2008-01-10 22:43 UTC (permalink / raw)
  To: u-boot

In message <1199958365-18516-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..4e3d489 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"

Rejected. Please READ what I wrote before. Heed gvb's suggestion.

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
Hiring experienced unix people is  like  a  built-in  filter  against
idiots. Hiring experienced NT people provides no such guarantee.
            -- Miguel Cruz in WgL96.349$CC.122704 at typhoon2.ba-dsg.net

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

* [U-Boot-Users] [PATCH 1/1] Fix nfs command help to reflect that the serverip is optional
  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
  0 siblings, 0 replies; 24+ messages in thread
From: Wolfgang Denk @ 2008-01-10 22:44 UTC (permalink / raw)
  To: u-boot

In message <1199958365-18516-2-git-send-email-plagnioj@jcrosoft.com> you wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> 
> diff --git a/common/cmd_net.c b/common/cmd_net.c
> index 4e3d489..fec87b6 100644
> --- a/common/cmd_net.c
> +++ b/common/cmd_net.c
> @@ -87,7 +87,7 @@ int do_nfs (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
>  U_BOOT_CMD(
>  	nfs,	3,	1,	do_nfs,
>  	"nfs\t- boot image via network using NFS protocol\n",
> -	"[loadAddress] [host ip addr:bootfilename]\n"
> +	"[loadAddress] [[host ip addr:]bootfilename]\n"

Rejected. Please see previous reject message for the reason.

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
In the beginning, there was nothing, which exploded.
                                - Terry Pratchett, _Lords and Ladies_

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

* [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support
  2008-01-09 22:53         ` Wolfgang Denk
@ 2008-01-10 23:01           ` 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-10 23:33             ` [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support Andre Renaud
  0 siblings, 2 replies; 24+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2008-01-10 23:01 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..d5d6e65 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 +231,7 @@ TftpSend (void)
 		break;
 	}
 
-	NetSendUDPPacket(NetServerEther, NetServerIP, TftpServerPort, TftpOurPort, len);
+	NetSendUDPPacket(NetServerEther, TftpServerIP, TftpServerPort, TftpOurPort, len);
 }
 
 
@@ -464,19 +464,27 @@ TftpStart (void)
 		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] 24+ messages in thread

* [U-Boot-Users] [PATCH 1/1] Fix nfs command help to reflect that the serverip is optional
  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             ` Jean-Christophe PLAGNIOL-VILLARD
  2008-01-10 23:33             ` [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support Andre Renaud
  1 sibling, 0 replies; 24+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2008-01-10 23:01 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

diff --git a/common/cmd_net.c b/common/cmd_net.c
index b86ca86..dbf6b86 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -87,7 +87,7 @@ int do_nfs (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 U_BOOT_CMD(
 	nfs,	3,	1,	do_nfs,
 	"nfs\t- boot image via network using NFS protocol\n",
-	"[loadAddress] [host ip addr:bootfilename]\n"
+	"[loadAddress] [[hostIPaddr:]bootfilename]\n"
 );
 #endif
 
-- 
1.5.3.7

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

* [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support
  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-10 23:33             ` Andre Renaud
  2008-01-11  0:12               ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 1 reply; 24+ messages in thread
From: Andre Renaud @ 2008-01-10 23:33 UTC (permalink / raw)
  To: u-boot

Jean-Christophe PLAGNIOL-VILLARD wrote:
> @@ -464,19 +464,27 @@ TftpStart (void)
>  		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);
> +		}

Doesn't this mean that TftpServerIP will be undefined if no server is
specified. Should it not be:

@@ -464,19 +464,27 @@ TftpStart (void)
 		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 {
+			TftpServerIP = NetServerIP;
+			strcpy (tftp_filename, BootFile);
+		}

Andre

-- 
Bluewater Systems Ltd - ARM Technology Solutions Centre

       Andre Renaud                             Bluewater Systems Ltd
Phone: +64 3 3779127 (Aus 1 800 148 751)        Level 17, 119 Armagh St
Fax:   +64 3 3779135                            PO Box 13889
Email: arenaud at bluewatersys.com                 Christchurch
Web:   http://www.bluewatersys.com              New Zealand

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

* [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support
  2008-01-10 23:33             ` [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support Andre Renaud
@ 2008-01-11  0:12               ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 24+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2008-01-11  0:12 UTC (permalink / raw)
  To: u-boot

On 12:33 Fri 11 Jan     , Andre Renaud wrote:
> Jean-Christophe PLAGNIOL-VILLARD wrote:
 
> Doesn't this mean that TftpServerIP will be undefined if no server is
> specified. Should it not be:
> 
> @@ -464,19 +464,27 @@ TftpStart (void)
>  		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 {
> +			TftpServerIP = NetServerIP;
> +			strcpy (tftp_filename, BootFile);
> +		}
> 
I will prefer
+       TftpServerIP = NetServerIP;
        if (BootFile[0] == '\0') {
                sprintf(default_filename, "%02lX%02lX%02lX%02lX.img",
                        NetOurIP & 0xFF,
@@ -464,19 +465,26 @@ TftpStart (void)
                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);
> Andre
> 
> -- 
> Bluewater Systems Ltd - ARM Technology Solutions Centre
> 
>        Andre Renaud                             Bluewater Systems Ltd
> Phone: +64 3 3779127 (Aus 1 800 148 751)        Level 17, 119 Armagh St
> Fax:   +64 3 3779135                            PO Box 13889
> Email: arenaud at bluewatersys.com                 Christchurch
> Web:   http://www.bluewatersys.com              New Zealand

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

* [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support
  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:43         ` [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support Wolfgang Denk
@ 2008-01-11 22:46         ` Ben Warren
  2 siblings, 0 replies; 24+ messages in thread
From: Ben Warren @ 2008-01-11 22:46 UTC (permalink / raw)
  To: u-boot

Jean-Christophe PLAGNIOL-VILLARD wrote:

<snip>

This doesn't work.
Baseline: (before patch applied):

=> tftp 100000 mpc8349emds/u-boot.bin.newnfs                                    
Speed: 100, full duplex                                                         
Using TSEC0 device                                                              
TFTP from server 10.69.69.21; our IP address is 10.69.69.201                    
Filename 'mpc8349emds/u-boot.bin.newnfs'.                                       
Load address: 0x100000                                                          
Loading: #######################################                                
done                                                                            
Bytes transferred = 198116 (305e4 hex)


Problem #1. First time through, with patch. Doesn't use serverip, so no 
default server:

=> tftp 100000 mpc8349emds/u-boot.bin                                           
Speed: 100, full duplex                                                         
Using TSEC0 device                                                              
TFTP from server 0.0.0.0; our IP address is 10.69.69.201; sending through gatew1
Filename '<NULL>'.                                                              
Load address: 0x100000                                                          
Loading: *                                                                      
TFTP error: 'File not found' (1)                                                
Starting again           


Problem #2. Doesn't parse file name:

=> tftp 100000 10.69.69.21:mpc8349emds/u-boot.bin                               
Speed: 100, full duplex                                                         
Using TSEC0 device                                                              
TFTP from server 10.69.69.21; our IP address is 10.69.69.201                    
Filename '<NULL>'.                                                              
Load address: 0x100000                                                          
Loading: ##################################                                     
done                                                                            
Bytes transferred = 170996 (29bf4 hex)


Please fix these if you want the code included.

regards,
Ben

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

* [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support
  2008-01-16 23:33 Ben Warren
@ 2008-01-17 22:08 ` Jean-Christophe PLAGNIOL-VILLARD
  2008-01-17 22:31   ` Wolfgang Denk
  2008-01-17 22:42   ` Andre Renaud
  0 siblings, 2 replies; 24+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2008-01-17 22:08 UTC (permalink / raw)
  To: u-boot

allow to use a different server as set in serverip
add CONFIG_LONG_TFTP_FILE_NAME to allow long file name default as 1024
can be reconfigured whit CONFIG_LONG_TFTP_FILE_NAME_MAX_LEN

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..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;
@@ -55,7 +55,18 @@ static int	TftpState;
 
 #define DEFAULT_NAME_LEN	(8 + 4 + 1)
 static char default_filename[DEFAULT_NAME_LEN];
-static char *tftp_filename;
+
+#ifdef CONFIG_LONG_TFTP_FILE_NAME
+# ifndef CONFIG_LONG_TFTP_FILE_NAME_MAX_LEN
+#  define MAX_LEN 1024
+# else
+#  define MAX_LEN CONFIG_LONG_TFTP_FILE_NAME_MAX_LEN
+# endif
+#else
+#define MAX_LEN 128
+#endif
+
+static char tftp_filename[MAX_LEN];
 
 #ifdef CFG_DIRECT_FLASH_TFTP
 extern flash_info_t flash_info[];
@@ -231,7 +242,7 @@ TftpSend (void)
 		break;
 	}
 
-	NetSendUDPPacket(NetServerEther, NetServerIP, TftpServerPort, TftpOurPort, len);
+	NetSendUDPPacket(NetServerEther, TftpServerIP, TftpServerPort, TftpOurPort, len);
 }
 
 
@@ -372,7 +383,7 @@ TftpHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len)
 #ifdef CONFIG_MCAST_TFTP
 		/* if I am the MasterClient, actively calculate what my next
 		 * needed block is; else I'm passive; not ACKING
- 		 */
+		 */
 		if (Multicast) {
 			if (len < TftpBlkSize)  {
 				TftpEndingBlock = TftpBlock;
@@ -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;
+
+		strncpy(tftp_filename, default_filename, MAX_LEN);
+		tftp_filename[MAX_LEN-1] = 0;
 
 		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;
+			strncpy(tftp_filename, p, MAX_LEN);
+			tftp_filename[MAX_LEN-1] = 0;
+		} else {
+			strncpy(tftp_filename, BootFile, MAX_LEN);
+			tftp_filename[MAX_LEN-1] = 0;
+		}
 	}
 
 #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 ");
@@ -522,7 +546,7 @@ TftpStart (void)
 	/* Revert TftpBlkSize to dflt */
 	TftpBlkSize = TFTP_BLOCK_SIZE;
 #ifdef CONFIG_MCAST_TFTP
-    	mcast_cleanup();
+	mcast_cleanup();
 #endif
 
 	TftpSend ();
-- 
1.5.3.7

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

* [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support
  2008-01-17 22:08 ` [U-Boot-Users] [PATCH 0/1] " Jean-Christophe PLAGNIOL-VILLARD
@ 2008-01-17 22:31   ` Wolfgang Denk
  2008-01-17 22:42   ` Andre Renaud
  1 sibling, 0 replies; 24+ messages in thread
From: Wolfgang Denk @ 2008-01-17 22:31 UTC (permalink / raw)
  To: u-boot

In message <1200607712-1381-1-git-send-email-plagnioj@jcrosoft.com> you wrote:
> allow to use a different server as set in serverip
> add CONFIG_LONG_TFTP_FILE_NAME to allow long file name default as 1024
> can be reconfigured whit CONFIG_LONG_TFTP_FILE_NAME_MAX_LEN
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> 
> diff --git a/net/tftp.c b/net/tftp.c
> index 8b95bcf..262ff79 100644
> --- a/net/tftp.c
> +++ b/net/tftp.c
...
> @@ -55,7 +55,18 @@ static int	TftpState;
>  
>  #define DEFAULT_NAME_LEN	(8 + 4 + 1)
>  static char default_filename[DEFAULT_NAME_LEN];
> -static char *tftp_filename;
> +
> +#ifdef CONFIG_LONG_TFTP_FILE_NAME
> +# ifndef CONFIG_LONG_TFTP_FILE_NAME_MAX_LEN
> +#  define MAX_LEN 1024
> +# else
> +#  define MAX_LEN CONFIG_LONG_TFTP_FILE_NAME_MAX_LEN
> +# endif
> +#else
> +#define MAX_LEN 128
> +#endif
> +
> +static char tftp_filename[MAX_LEN];

We don't need *two* new defines. Just use one, say
CONFIG_TFTP_FILE_NAME_MAX_LEN

> @@ -372,7 +383,7 @@ TftpHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len)
>  #ifdef CONFIG_MCAST_TFTP
>  		/* if I am the MasterClient, actively calculate what my next
>  		 * needed block is; else I'm passive; not ACKING
> - 		 */
> +		 */
>  		if (Multicast) {
>  			if (len < TftpBlkSize)  {
>  				TftpEndingBlock = TftpBlock;
> @@ -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;
> +
> +		strncpy(tftp_filename, default_filename, MAX_LEN);
> +		tftp_filename[MAX_LEN-1] = 0;
>  
>  		printf ("*** Warning: no boot file name; using '%s'\n",
>  			tftp_filename);
>  	} else {
> -		tftp_filename = BootFile;
> +		char *p=BootFile;
> +		p = strchr (p, ':');

Blank line after declarations. And make this:

		char *p = strchr (BootFile, ':');

> +		if (p != NULL) {

Please swap the "if" and "else" branches and use "if (p == NULL)"


> +			TftpServerIP = string_to_ip (BootFile);

Note that there is no terminating '0' at *p ! You might want to insert
one for robustness.


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
Vulcans worship peace above all.
	-- McCoy, "Return to Tomorrow", stardate 4768.3

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

* [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support
  2008-01-17 22:08 ` [U-Boot-Users] [PATCH 0/1] " Jean-Christophe PLAGNIOL-VILLARD
  2008-01-17 22:31   ` 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
  1 sibling, 2 replies; 24+ messages in thread
From: Andre Renaud @ 2008-01-17 22:42 UTC (permalink / raw)
  To: u-boot

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 ");

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

* [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support
  2008-01-17 22:42   ` Andre Renaud
@ 2008-01-18  0:19     ` Ben Warren
  2008-01-18  0:30     ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 0 replies; 24+ messages in thread
From: Ben Warren @ 2008-01-18  0:19 UTC (permalink / raw)
  To: u-boot

Andre Renaud wrote:
> 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.
>
>   
This is nice, because it works in-place and doesn't need the second 
buffer. One concern, though (see below)
> 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);
>   
I don't know if string_to_ip() works properly on a string of the format 
a.b.c.d:filename
> +            ++p;
> +            tftp_filename = p;
> +        } else
> +            tftp_filename = BootFile;
>      }
>  
>   
Alternatively:

	char *p = strchr(Bootfile, ':');
	if (p && *(p+1) != '\0') {
		tftp_filename = P + 1;
		*p = '\0';
		TftpServerIP = string_to_ip(Bootfile);
	} else
		tftp_filename = Bootfile;


*** Note: I haven't tried compiling this and it was written quickly, so 
may be garbage! Just ask Wolfgang...

regards,
Ben

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

* [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support
  2008-01-17 22:42   ` Andre Renaud
  2008-01-18  0:19     ` Ben Warren
@ 2008-01-18  0:30     ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 0 replies; 24+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2008-01-18  0:30 UTC (permalink / raw)
  To: u-boot

On 11:42 Fri 18 Jan     , Andre Renaud wrote:
> 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>
> 

Andren,
	At least add my Signed-off

Best Regards,
J.

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

end of thread, other threads:[~2008-01-18  0:30 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-24 15:55 [U-Boot-Users] [PATCH] TFTP: add host ip addr support Jean-Christophe PLAGNIOL-VILLARD
2007-12-24 16:40 ` 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-10 23:33             ` [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support Andre Renaud
2008-01-11  0:12               ` Jean-Christophe PLAGNIOL-VILLARD
2008-01-09 22:35       ` [U-Boot-Users] [PATCH 1/1] Fix nfs command help to reflect that the serverip is optional Wolfgang Denk
2008-01-09 22:39     ` [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support 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
2008-01-10 22:43         ` [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support Wolfgang Denk
2008-01-11 22:46         ` Ben Warren
2007-12-26 20:42 ` [U-Boot-Users] [PATCH] " Haavard Skinnemoen
2007-12-26 23:09   ` Wolfgang Denk
  -- strict thread matches above, loose matches on Subject: below --
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:31   ` 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

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