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 desktop environment for the C64.
*
* $Id: email.c,v 1.7 2010/01/31 21:44:49 oliverschmidt Exp $
* $Id: email.c,v 1.8 2010/05/31 15:22:08 nifi Exp $
*
*/
@ -182,15 +182,16 @@ email_quit(void)
static void
applyconfig(void)
{
u16_t addr[2], *addrptr;
uip_ipaddr_t addr;
uip_ipaddr_t *addrptr;
char *cptr;
for(cptr = smtpserver; *cptr != ' ' && *cptr != 0; ++cptr);
*cptr = 0;
addrptr = &addr[0];
addrptr = &addr;
#if UIP_UDP
if(uiplib_ipaddrconv(smtpserver, (unsigned char *)addr) == 0) {
if(uiplib_ipaddrconv(smtpserver, &addr) == 0) {
addrptr = resolv_lookup(smtpserver);
if(addrptr == NULL) {
resolv_query(smtpserver);
@ -199,7 +200,7 @@ applyconfig(void)
}
}
#else /* UIP_UDP */
uiplib_ipaddrconv(smtpserver, (unsigned char *)addr);
uiplib_ipaddrconv(smtpserver, &addr);
#endif /* UIP_UDP */
smtp_configure("contiki", addrptr);

View file

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: smtp-socket.c,v 1.3 2007/11/18 01:00:50 oliverschmidt Exp $
* $Id: smtp-socket.c,v 1.4 2010/05/31 15:22:08 nifi Exp $
*/
#include "smtp.h"
@ -60,7 +60,7 @@ struct smtp_state {
static struct smtp_state s;
static char *localhostname;
static u16_t smtpserver[2];
static uip_ipaddr_t smtpserver;
#define ISO_nl 0x0a
#define ISO_cr 0x0d
@ -201,11 +201,10 @@ smtp_appcall(void *state)
}
/*---------------------------------------------------------------------------*/
void
smtp_configure(char *lhostname, u16_t *server)
smtp_configure(char *lhostname, uip_ipaddr_t *server)
{
localhostname = lhostname;
smtpserver[0] = server[0];
smtpserver[1] = server[1];
uip_ipaddr_copy(&smtpserver, server);
}
/*---------------------------------------------------------------------------*/
unsigned char
@ -214,7 +213,7 @@ smtp_send(char *to, char *cc, char *from, char *subject,
{
struct uip_conn *conn;
conn = tcp_connect((uip_ipaddr_t *)smtpserver, HTONS(25), NULL);
conn = tcp_connect(&smtpserver, HTONS(25), NULL);
if(conn == NULL) {
return 0;
}

View file

@ -28,7 +28,7 @@
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: smtp.h,v 1.2 2006/08/21 21:31:34 oliverschmidt Exp $
* $Id: smtp.h,v 1.3 2010/05/31 15:22:08 nifi Exp $
*
*/
#ifndef __SMTP_H__
@ -41,7 +41,7 @@
void smtp_done(unsigned char error);
/* Functions. */
void smtp_configure(char *localhostname, u16_t *smtpserver);
void smtp_configure(char *localhostname, uip_ipaddr_t *smtpserver);
unsigned char smtp_send(char *to, char *cc, char *from,
char *subject, char *msg,

View file

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: ftp.c,v 1.6 2008/02/08 22:50:23 oliverschmidt Exp $
* $Id: ftp.c,v 1.7 2010/05/31 15:22:08 nifi Exp $
*/
/* Note to self: It would be nice to have a "View" option in the download dialog. */
@ -312,7 +312,8 @@ make_connectionwindow(void)
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(ftp_process, ev, data)
{
u16_t ipaddr[2], *ipaddrptr;
uip_ipaddr_t ipaddr;
uip_ipaddr_t *ipaddrptr;
PROCESS_BEGIN();
@ -425,7 +426,7 @@ PROCESS_THREAD(ftp_process, ev, data)
} else if((struct ctk_button *)data == &connectbutton) {
ctk_dialog_close();
#if UIP_UDP
if(uiplib_ipaddrconv(hostname, (unsigned char *)ipaddr) == 0) {
if(uiplib_ipaddrconv(hostname, &ipaddr) == 0) {
ipaddrptr = resolv_lookup(hostname);
if(ipaddrptr == NULL) {
resolv_query(hostname);
@ -435,12 +436,12 @@ PROCESS_THREAD(ftp_process, ev, data)
connection = ftpc_connect(ipaddrptr, HTONS(21));
show_statustext("Connecting to ", hostname);
} else {
connection = ftpc_connect(ipaddr, HTONS(21));
connection = ftpc_connect(&ipaddr, HTONS(21));
show_statustext("Connecting to ", hostname);
}
#else /* UIP_UDP */
uiplib_ipaddrconv(hostname, (unsigned char *)ipaddr);
connection = ftpc_connect(ipaddr, HTONS(21));
uiplib_ipaddrconv(hostname, &ipaddr);
connection = ftpc_connect(&ipaddr, HTONS(21));
show_statustext("Connecting to ", hostname);
#endif /* UIP_UDP */
}

View file

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: ftpc.c,v 1.3 2008/01/04 23:30:57 oliverschmidt Exp $
* $Id: ftpc.c,v 1.4 2010/05/31 15:22:08 nifi Exp $
*/
#include "contiki.h"
#include "ftpc.h"
@ -127,7 +127,7 @@ ftpc_init(void)
}
/*---------------------------------------------------------------------------*/
void *
ftpc_connect(u16_t *ipaddr, u16_t port)
ftpc_connect(uip_ipaddr_t *ipaddr, u16_t port)
{
struct ftp_connection *c;
@ -143,7 +143,7 @@ ftpc_connect(u16_t *ipaddr, u16_t port)
c->dataconn.port = DATAPORT;
tcp_listen(HTONS(DATAPORT));
if(tcp_connect((uip_ipaddr_t *)ipaddr, port, c) == NULL) {
if(tcp_connect(ipaddr, port, c) == NULL) {
memb_free(&connections, c);
return NULL;
}

View file

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: ftpc.h,v 1.1 2006/06/17 22:41:11 adamdunkels Exp $
* $Id: ftpc.h,v 1.2 2010/05/31 15:22:08 nifi Exp $
*/
#ifndef __FTPC_H__
#define __FTPC_H__
@ -39,7 +39,7 @@
void ftpc_init(void);
void *ftpc_connect(u16_t *ipaddr, u16_t port);
void *ftpc_connect(uip_ipaddr_t *ipaddr, u16_t port);
char ftpc_list(void *connection);
void ftpc_cwd(void *connection, char *dir);
void ftpc_cdup(void *connection);

View file

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: irc.c,v 1.10 2008/11/28 00:14:57 adamdunkels Exp $
* $Id: irc.c,v 1.11 2010/05/31 15:22:08 nifi Exp $
*/
#include <string.h>
@ -246,8 +246,8 @@ PROCESS_THREAD(irc_process, ev, data)
ctk_window_open(&window);
ipaddr = &serveraddr;
#if UIP_UDP
if(uiplib_ipaddrconv(server, (u8_t *)&serveraddr) == 0) {
ipaddr = (uip_ipaddr_t *)resolv_lookup(server);
if(uiplib_ipaddrconv(server, &serveraddr) == 0) {
ipaddr = resolv_lookup(server);
if(ipaddr == NULL) {
resolv_query(server);
} else {
@ -255,7 +255,7 @@ PROCESS_THREAD(irc_process, ev, data)
}
}
#else /* UIP_UDP */
uiplib_ipaddrconv(server, (u8_t *)serveraddr);
uiplib_ipaddrconv(server, &serveraddr);
#endif /* UIP_UDP */
if(ipaddr != NULL) {
@ -265,7 +265,7 @@ PROCESS_THREAD(irc_process, ev, data)
#if UIP_UDP
} else if(ev == resolv_event_found) {
ipaddr = (uip_ipaddr_t *)resolv_lookup(server);
ipaddr = resolv_lookup(server);
if(ipaddr == NULL) {
ircc_text_output(&s, server, "hostname not found");
} else {

View file

@ -29,7 +29,7 @@
*
* This file is part of the Contiki desktop environment
*
* $Id: netconf.c,v 1.8 2008/02/08 22:51:01 oliverschmidt Exp $
* $Id: netconf.c,v 1.9 2010/05/31 15:22:08 nifi Exp $
*
*/
@ -136,23 +136,23 @@ apply_tcpipconfig(void)
uip_ipaddr_t addr;
nullterminate(ipaddr);
if(uiplib_ipaddrconv(ipaddr, (unsigned char *)&addr)) {
if(uiplib_ipaddrconv(ipaddr, &addr)) {
uip_sethostaddr(&addr);
}
nullterminate(netmask);
if(uiplib_ipaddrconv(netmask, (unsigned char *)&addr)) {
if(uiplib_ipaddrconv(netmask, &addr)) {
uip_setnetmask(&addr);
}
nullterminate(gateway);
if(uiplib_ipaddrconv(gateway, (unsigned char *)&addr)) {
if(uiplib_ipaddrconv(gateway, &addr)) {
uip_setdraddr(&addr);
}
#if UIP_UDP
nullterminate(dnsserver);
if(uiplib_ipaddrconv(dnsserver, (unsigned char *)&addr)) {
if(uiplib_ipaddrconv(dnsserver, &addr)) {
resolv_conf(&addr);
}
#endif /* UIP_UDP */

View file

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: shell-irc.c,v 1.1 2008/11/28 00:16:15 adamdunkels Exp $
* $Id: shell-irc.c,v 1.2 2010/05/31 15:22:08 nifi Exp $
*/
#include <string.h>
@ -142,7 +142,7 @@ PROCESS_THREAD(shell_irc_process, ev, data)
running = 1;
uiplib_ipaddrconv(server, (u8_t *)&serveraddr);
uiplib_ipaddrconv(server, &serveraddr);
ircc_connect(&s, server, &serveraddr, nick);
while(running) {
PROCESS_WAIT_EVENT();

View file

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: shell-ping.c,v 1.3 2010/03/17 12:27:52 joxe Exp $
* $Id: shell-ping.c,v 1.4 2010/05/31 15:22:08 nifi Exp $
*/
#include <string.h>
@ -142,7 +142,7 @@ PROCESS_THREAD(shell_ping_process, ev, data)
"ping <server>: server as address", "");
PROCESS_EXIT();
}
uiplib_ipaddrconv(data, (u8_t *)&remoteaddr);
uiplib_ipaddrconv(data, &remoteaddr);
send_ping(&remoteaddr);

View file

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: shell-tcpsend.c,v 1.4 2009/03/17 21:49:44 adamdunkels Exp $
* $Id: shell-tcpsend.c,v 1.5 2010/05/31 15:22:08 nifi Exp $
*/
#include <string.h>
@ -154,7 +154,7 @@ PROCESS_THREAD(shell_tcpsend_process, ev, data)
running = 1;
uiplib_ipaddrconv(server, (u8_t *)&serveraddr);
uiplib_ipaddrconv(server, &serveraddr);
telnet_connect(&s, &serveraddr, port);
while(running) {
PROCESS_WAIT_EVENT();

View file

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: shell-udpsend.c,v 1.5 2010/02/04 15:23:15 nifi Exp $
* $Id: shell-udpsend.c,v 1.6 2010/05/31 15:22:08 nifi Exp $
*/
#include <string.h>
@ -94,7 +94,7 @@ PROCESS_THREAD(shell_udpsend_process, ev, data)
++next;
port = shell_strtolong(next, &nextptr);
uiplib_ipaddrconv(server, (uint8_t *)&serveraddr);
uiplib_ipaddrconv(server, &serveraddr);
udpconn = udp_new(&serveraddr, htons(port), NULL);
if(next != nextptr) {

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: shell-wget.c,v 1.1 2008/11/09 12:36:23 adamdunkels Exp $
* $Id: shell-wget.c,v 1.2 2010/05/31 15:22:08 nifi Exp $
*/
/**
@ -67,7 +67,7 @@ open_url(char *url)
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;
@ -120,7 +120,7 @@ open_url(char *url)
/* 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) {
shell_output_str(&wget_command, "Not an IP address", "");
if(resolv_lookup(host) == NULL) {
shell_output_str(&wget_command, "Not resolved", "");

View file

@ -29,7 +29,7 @@
*
* This file is part of the Contiki desktop environment
*
* $Id: simpletelnet.c,v 1.5 2008/02/08 22:52:43 oliverschmidt Exp $
* $Id: simpletelnet.c,v 1.6 2010/05/31 15:22:08 nifi Exp $
*
*/
@ -151,7 +151,7 @@ show(char *text)
static void
connect(void)
{
u16_t addr[2], *addrptr;
uip_ipaddr_t addr, *addrptr;
u16_t port;
char *cptr;
struct uip_conn *conn;
@ -161,9 +161,9 @@ connect(void)
for(cptr = telnethost; *cptr != ' ' && *cptr != 0; ++cptr);
*cptr = 0;
addrptr = &addr[0];
addrptr = &addr;
#if UIP_UDP
if(uiplib_ipaddrconv(telnethost, (unsigned char *)addr) == 0) {
if(uiplib_ipaddrconv(telnethost, &addr) == 0) {
addrptr = resolv_lookup(telnethost);
if(addrptr == NULL) {
resolv_query(telnethost);
@ -172,7 +172,7 @@ connect(void)
}
}
#else /* UIP_UDP */
uiplib_ipaddrconv(telnethost, (unsigned char *)addr);
uiplib_ipaddrconv(telnethost, &addr);
#endif /* UIP_UDP */
port = 0;
@ -185,7 +185,7 @@ connect(void)
}
conn = tcp_connect((uip_ipaddr_t *)addrptr, htons(port), &ts_appstate);
conn = tcp_connect(addrptr, htons(port), &ts_appstate);
if(conn == NULL) {
show("Out of memory error");
return;

View file

@ -29,7 +29,7 @@
*
* This file is part of the Contiki VNC client
*
* $Id: vnc.c,v 1.1 2006/06/17 23:08:35 adamdunkels Exp $
* $Id: vnc.c,v 1.2 2010/05/31 15:22:08 nifi Exp $
*
*/
@ -124,7 +124,7 @@ show(char *text)
static void
connect(void)
{
u16_t addr[2], *addrptr;
uip_ipaddr_t addr, *addrptr;
u16_t port;
char *cptr;
@ -133,8 +133,8 @@ connect(void)
for(cptr = host; *cptr != ' ' && *cptr != 0; ++cptr);
*cptr = 0;
addrptr = &addr[0];
if(uiplib_ipaddrconv(host, (unsigned char *)addr) == 0) {
addrptr = &addr;
if(uiplib_ipaddrconv(host, &addr) == 0) {
addrptr = resolv_lookup(host);
if(addrptr == NULL) {
resolv_query(host);

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