net: lwip: add TFTP support and tftpboot command
Implement do_tftpb(). This implementation of the tftp command
supports an optional port number. For example:
tftp 192.168.0.30:9069:file.bin
It also supports taking the server IP from ${tftpserverip} if
defined, before falling back to ${serverip}.
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
diff --git a/net/lwip/net-lwip.c b/net/lwip/net-lwip.c
index 3b08ffe..5c2bb2e 100644
--- a/net/lwip/net-lwip.c
+++ b/net/lwip/net-lwip.c
@@ -28,6 +28,7 @@
char *pxelinux_configfile;
/* Our IP addr (0 = unknown) */
struct in_addr net_ip;
+char net_boot_file_name[1024];
static err_t linkoutput(struct netif *netif, struct pbuf *p)
{
@@ -283,6 +284,21 @@
#endif
}
+int net_loop(enum proto_t protocol)
+{
+ char *argv[1];
+
+ switch (protocol) {
+ case TFTPGET:
+ argv[0] = "tftpboot";
+ return do_tftpb(NULL, 0, 1, argv);
+ default:
+ return -EINVAL;
+ }
+
+ return -EINVAL;
+}
+
u32_t sys_now(void)
{
return get_timer(0);