Added support for IPv6 URLs
This commit is contained in:
parent
b21d2494bc
commit
a453acd325
1 changed files with 14 additions and 5 deletions
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* 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 "contiki.h"
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
#include "dev/leds.h"
|
|
||||||
#include "dev/watchdog.h"
|
|
||||||
|
|
||||||
#include "webclient.h"
|
#include "webclient.h"
|
||||||
|
|
||||||
|
@ -63,7 +61,7 @@ SHELL_COMMAND(wget_command,
|
||||||
static void
|
static void
|
||||||
open_url(char *url)
|
open_url(char *url)
|
||||||
{
|
{
|
||||||
unsigned char i;
|
unsigned char i, c;
|
||||||
static char host[32];
|
static char host[32];
|
||||||
char *file;
|
char *file;
|
||||||
register char *urlptr;
|
register char *urlptr;
|
||||||
|
@ -92,17 +90,28 @@ open_url(char *url)
|
||||||
|
|
||||||
/* Find host part of the URL. */
|
/* Find host part of the URL. */
|
||||||
urlptr = &url[7];
|
urlptr = &url[7];
|
||||||
|
if(*urlptr == '[') {
|
||||||
|
/* IPv6 address */
|
||||||
|
c = ']';
|
||||||
|
++urlptr;
|
||||||
|
} else {
|
||||||
|
c = ':';
|
||||||
|
}
|
||||||
for(i = 0; i < sizeof(host); ++i) {
|
for(i = 0; i < sizeof(host); ++i) {
|
||||||
if(*urlptr == 0 ||
|
if(*urlptr == 0 ||
|
||||||
*urlptr == '/' ||
|
*urlptr == '/' ||
|
||||||
*urlptr == ' ' ||
|
*urlptr == ' ' ||
|
||||||
*urlptr == ':') {
|
*urlptr == c) {
|
||||||
host[i] = 0;
|
host[i] = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
host[i] = *urlptr;
|
host[i] = *urlptr;
|
||||||
++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
|
/* 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
|
currently done because of laziness from the programmer's side
|
||||||
|
|
Loading…
Add table
Reference in a new issue