Updated API for uiplib and resolv to use uip_ipaddr_t instead of uint16_t for compability with IPv6

This commit is contained in:
nifi 2010-05-31 15:22:08 +00:00
parent c13bb8666b
commit b54c6e673b
22 changed files with 194 additions and 106 deletions

View file

@ -29,7 +29,7 @@
*
* This file is part of the "contiki" web browser.
*
* $Id: webclient.c,v 1.8 2010/02/01 19:44:30 oliverschmidt Exp $
* $Id: webclient.c,v 1.9 2010/05/31 15:22:08 nifi Exp $
*
*/
@ -133,25 +133,25 @@ webclient_close(void)
unsigned char
webclient_get(char *host, u16_t port, char *file)
{
uip_ipaddr_t addr;
struct uip_conn *conn;
u16_t *ipaddr;
static u16_t addr[2];
uip_ipaddr_t *ipaddr;
/* First check if the host is an IP address. */
ipaddr = &addr[0];
ipaddr = &addr;
if(uiplib_ipaddrconv(host, &addr) == 0) {
#if UIP_UDP
if(uiplib_ipaddrconv(host, (unsigned char *)addr) == 0) {
ipaddr = resolv_lookup(host);
if(ipaddr == NULL) {
return 0;
}
}
#else /* UIP_UDP */
uiplib_ipaddrconv(host, (unsigned char *)addr);
return 0;
#endif /* UIP_UDP */
}
conn = tcp_connect((uip_ipaddr_t *)ipaddr, htons(port), NULL);
conn = tcp_connect(ipaddr, htons(port), NULL);
if(conn == NULL) {
return 0;

View file

@ -29,7 +29,7 @@
*
* This file is part of the Contiki desktop environment
*
* $Id: www.c,v 1.12 2010/02/13 10:39:57 oliverschmidt Exp $
* $Id: www.c,v 1.13 2010/05/31 15:22:08 nifi Exp $
*
*/
@ -258,7 +258,7 @@ open_url(void)
static char host[32];
char *file;
register char *urlptr;
static u16_t addr[2];
static uip_ipaddr_t addr;
/* Trim off any spaces in the end of the url. */
urlptr = url + strlen(url) - 1;
@ -312,7 +312,7 @@ open_url(void)
#if UIP_UDP
/* Try to lookup the hostname. If it fails, we initiate a hostname
lookup and print out an informative message on the statusbar. */
if(uiplib_ipaddrconv(host, (unsigned char *)addr) == 0) {
if(uiplib_ipaddrconv(host, &addr) == 0) {
if(resolv_lookup(host) == NULL) {
resolv_query(host);
show_statustext("Resolving host...");
@ -320,7 +320,7 @@ open_url(void)
}
}
#else /* UIP_UDP */
uiplib_ipaddrconv(host, (unsigned char *)addr);
uiplib_ipaddrconv(host, &addr);
#endif /* UIP_UDP */
/* The hostname we present in the hostname table, so we send out the