aboutsummaryrefslogtreecommitdiff
path: root/cmd/net.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/net.c')
-rw-r--r--cmd/net.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/cmd/net.c b/cmd/net.c
index addcad3..7681c97 100644
--- a/cmd/net.c
+++ b/cmd/net.c
@@ -14,6 +14,7 @@
#include <env.h>
#include <image.h>
#include <net.h>
+#include <net6.h>
#include <net/udp.h>
#include <net/sntp.h>
#include <net/ncsi.h>
@@ -45,12 +46,22 @@ int do_tftpb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
return ret;
}
+#if IS_ENABLED(CONFIG_IPV6)
+U_BOOT_CMD(
+ tftpboot, 4, 1, do_tftpb,
+ "boot image via network using TFTP protocol\n"
+ "To use IPv6 add -ipv6 parameter or use IPv6 hostIPaddr framed "
+ "with [] brackets",
+ "[loadAddress] [[hostIPaddr:]bootfilename] [" USE_IP6_CMD_PARAM "]"
+);
+#else
U_BOOT_CMD(
tftpboot, 3, 1, do_tftpb,
"load file via network using TFTP protocol",
"[loadAddress] [[hostIPaddr:]bootfilename]"
);
#endif
+#endif
#ifdef CONFIG_CMD_TFTPPUT
static int do_tftpput(struct cmd_tbl *cmdtp, int flag, int argc,
@@ -219,6 +230,17 @@ static int parse_args(enum proto_t proto, int argc, char *const argv[])
ulong addr;
char *end;
+ if (IS_ENABLED(CONFIG_IPV6)) {
+ use_ip6 = false;
+
+ /* IPv6 parameter has to be always *last* */
+ if (!strcmp(argv[argc - 1], USE_IP6_CMD_PARAM)) {
+ use_ip6 = true;
+ /* It is a hack not to break switch/case code */
+ --argc;
+ }
+ }
+
switch (argc) {
case 1:
if (CONFIG_IS_ENABLED(CMD_TFTPPUT) && proto == TFTPPUT)
@@ -300,6 +322,19 @@ static int netboot_common(enum proto_t proto, struct cmd_tbl *cmdtp, int argc,
bootstage_mark(BOOTSTAGE_ID_NET_START);
+ if (IS_ENABLED(CONFIG_IPV6) && !use_ip6) {
+ char *s, *e;
+ size_t len;
+
+ s = strchr(net_boot_file_name, '[');
+ e = strchr(net_boot_file_name, ']');
+ if (s && e) {
+ len = e - s;
+ if (!string_to_ip6(s + 1, len - 1, &net_server_ip6))
+ use_ip6 = true;
+ }
+ }
+
size = net_loop(proto);
if (size < 0) {
bootstage_error(BOOTSTAGE_ID_NET_NETLOOP_OK);