TFTP: add host ip addr support
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest0 of 1 patch 0 repliesNew
Patches in v1 No applies recorded yet
The patch the cover letter announces is not in this archive.
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [U-Boot-Users] [PATCH 0/1] TFTP: add host ip addr support
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 <[email protected]>
common/cmd_net.c +1 -1
@@ -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[])
net/tftp.c +14 -5
@@ -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 " );