From a453acd32501d29358a0c03c84bb0a95968d9296 Mon Sep 17 00:00:00 2001 From: nifi Date: Wed, 9 Jun 2010 08:36:43 +0000 Subject: [PATCH] Added support for IPv6 URLs --- apps/shell/shell-wget.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/apps/shell/shell-wget.c b/apps/shell/shell-wget.c index daed7950b..32c713aef 100644 --- a/apps/shell/shell-wget.c +++ b/apps/shell/shell-wget.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: shell-wget.c,v 1.2 2010/05/31 15:22:08 nifi Exp $ + * $Id: shell-wget.c,v 1.3 2010/06/09 08:36:43 nifi Exp $ */ /** @@ -40,8 +40,6 @@ #include "contiki.h" #include "shell.h" -#include "dev/leds.h" -#include "dev/watchdog.h" #include "webclient.h" @@ -63,7 +61,7 @@ SHELL_COMMAND(wget_command, static void open_url(char *url) { - unsigned char i; + unsigned char i, c; static char host[32]; char *file; register char *urlptr; @@ -92,17 +90,28 @@ open_url(char *url) /* Find host part of the URL. */ urlptr = &url[7]; + if(*urlptr == '[') { + /* IPv6 address */ + c = ']'; + ++urlptr; + } else { + c = ':'; + } for(i = 0; i < sizeof(host); ++i) { if(*urlptr == 0 || *urlptr == '/' || *urlptr == ' ' || - *urlptr == ':') { + *urlptr == c) { host[i] = 0; break; } host[i] = *urlptr; ++urlptr; } + if(*urlptr == ']') { + /* Move past end of IPv6 host */ + urlptr++; + } /* XXX: Here we should find the port part of the URL, but this isn't currently done because of laziness from the programmer's side