Updated API for uiplib and resolv to use uip_ipaddr_t instead of uint16_t for compability with IPv6
This commit is contained in:
parent
c13bb8666b
commit
b54c6e673b
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 */
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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", "");
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: resolv.c,v 1.8 2010/02/15 20:49:38 dak664 Exp $
|
||||
* $Id: resolv.c,v 1.9 2010/05/31 15:22:08 nifi Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -71,6 +71,31 @@
|
|||
#define NULL (void *)0
|
||||
#endif /* NULL */
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
|
||||
/* Currently this implementation only supports IPv4 DNS lookups.
|
||||
Until support for IPv6 is added, dummy functions are used to
|
||||
enable compilation with IPv6.
|
||||
*/
|
||||
|
||||
process_event_t resolv_event_found;
|
||||
|
||||
PROCESS(resolv_process, "DNS resolver");
|
||||
|
||||
void resolv_conf(const uip_ipaddr_t *dnsserver) { }
|
||||
uip_ipaddr_t *resolv_getserver(void) { return NULL; }
|
||||
uip_ipaddr_t *resolv_lookup(const char *name) { return NULL; }
|
||||
void resolv_query(const char *name) { }
|
||||
|
||||
PROCESS_THREAD(resolv_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
resolv_event_found = process_alloc_event();
|
||||
PROCESS_END();
|
||||
}
|
||||
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
|
||||
/** \internal The maximum number of retries when asking for a name. */
|
||||
#define MAX_RETRIES 8
|
||||
|
||||
|
@ -103,7 +128,7 @@ struct dns_answer {
|
|||
u16_t class;
|
||||
u16_t ttl[2];
|
||||
u16_t len;
|
||||
u16_t ipaddr[2];
|
||||
u8_t ipaddr[4];
|
||||
};
|
||||
|
||||
struct namemap {
|
||||
|
@ -118,7 +143,7 @@ struct namemap {
|
|||
u8_t seqno;
|
||||
u8_t err;
|
||||
char name[32];
|
||||
u16_t ipaddr[2];
|
||||
uip_ipaddr_t ipaddr;
|
||||
};
|
||||
|
||||
#ifndef UIP_CONF_RESOLV_ENTRIES
|
||||
|
@ -140,6 +165,8 @@ process_event_t resolv_event_found;
|
|||
|
||||
PROCESS(resolv_process, "DNS resolver");
|
||||
|
||||
static void resolv_found(char *name, uip_ipaddr_t *ipaddr);
|
||||
|
||||
enum {
|
||||
EVENT_NEW_SERVER=0
|
||||
};
|
||||
|
@ -180,8 +207,8 @@ check_entries(void)
|
|||
{
|
||||
register struct dns_hdr *hdr;
|
||||
char *query, *nptr, *nameptr;
|
||||
static u8_t i;
|
||||
static u8_t n;
|
||||
uint8_t i;
|
||||
uint8_t n;
|
||||
register struct namemap *namemapptr;
|
||||
|
||||
for(i = 0; i < RESOLV_ENTRIES; ++i) {
|
||||
|
@ -315,16 +342,17 @@ newdata(void)
|
|||
ans->class == HTONS(1) &&
|
||||
ans->len == HTONS(4)) {
|
||||
/* printf("IP address %d.%d.%d.%d\n",
|
||||
htons(ans->ipaddr[0]) >> 8,
|
||||
htons(ans->ipaddr[0]) & 0xff,
|
||||
htons(ans->ipaddr[1]) >> 8,
|
||||
htons(ans->ipaddr[1]) & 0xff);*/
|
||||
ans->ipaddr[0],
|
||||
ans->ipaddr[1],
|
||||
ans->ipaddr[2],
|
||||
ans->ipaddr[3]);*/
|
||||
/* XXX: we should really check that this IP address is the one
|
||||
we want. */
|
||||
namemapptr->ipaddr[0] = ans->ipaddr[0];
|
||||
namemapptr->ipaddr[1] = ans->ipaddr[1];
|
||||
for(i = 0; i < 4; i++) {
|
||||
namemapptr->ipaddr.u8[i] = ans->ipaddr[i];
|
||||
}
|
||||
|
||||
resolv_found(namemapptr->name, namemapptr->ipaddr);
|
||||
resolv_found(namemapptr->name, &namemapptr->ipaddr);
|
||||
return;
|
||||
} else {
|
||||
nameptr = nameptr + 10 + htons(ans->len);
|
||||
|
@ -387,7 +415,7 @@ PROCESS_THREAD(resolv_process, ev, data)
|
|||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
resolv_query(char *name)
|
||||
resolv_query(const char *name)
|
||||
{
|
||||
static u8_t i;
|
||||
static u8_t lseq, lseqi;
|
||||
|
@ -435,8 +463,8 @@ resolv_query(char *name)
|
|||
* hostnames.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
u16_t *
|
||||
resolv_lookup(char *name)
|
||||
uip_ipaddr_t *
|
||||
resolv_lookup(const char *name)
|
||||
{
|
||||
static u8_t i;
|
||||
struct namemap *nameptr;
|
||||
|
@ -447,7 +475,7 @@ resolv_lookup(char *name)
|
|||
nameptr = &names[i];
|
||||
if(nameptr->state == STATE_DONE &&
|
||||
strcmp(name, nameptr->name) == 0) {
|
||||
return nameptr->ipaddr;
|
||||
return &nameptr->ipaddr;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
@ -496,12 +524,13 @@ resolv_conf(const uip_ipaddr_t *dnsserver)
|
|||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
resolv_found(char *name, u16_t *ipaddr)
|
||||
static void
|
||||
resolv_found(char *name, uip_ipaddr_t *ipaddr)
|
||||
{
|
||||
process_post(PROCESS_BROADCAST, resolv_event_found, name);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
#endif /* UIP_UDP */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: resolv.h,v 1.3 2006/09/18 23:30:40 oliverschmidt Exp $
|
||||
* $Id: resolv.h,v 1.4 2010/05/31 15:22:08 nifi Exp $
|
||||
*
|
||||
*/
|
||||
#ifndef __RESOLV_H__
|
||||
|
@ -47,15 +47,11 @@
|
|||
*/
|
||||
CCIF extern process_event_t resolv_event_found;
|
||||
|
||||
/* Callbacks. */
|
||||
void resolv_found(char *name, u16_t *ipaddr);
|
||||
|
||||
/* Functions. */
|
||||
CCIF void resolv_conf(const uip_ipaddr_t *dnsserver);
|
||||
CCIF uip_ipaddr_t *resolv_getserver(void);
|
||||
void resolv_init(char *arg);
|
||||
CCIF u16_t *resolv_lookup(char *name);
|
||||
CCIF void resolv_query(char *name);
|
||||
CCIF uip_ipaddr_t *resolv_lookup(const char *name);
|
||||
CCIF void resolv_query(const char *name);
|
||||
|
||||
PROCESS_NAME(resolv_process);
|
||||
|
||||
|
|
|
@ -29,19 +29,78 @@
|
|||
*
|
||||
* This file is part of the uIP TCP/IP stack and the Contiki operating system.
|
||||
*
|
||||
* $Id: uiplib.c,v 1.1 2006/06/17 22:41:19 adamdunkels Exp $
|
||||
* $Id: uiplib.c,v 1.2 2010/05/31 15:22:08 nifi Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "net/uip.h"
|
||||
#include "net/uiplib.h"
|
||||
#include <string.h>
|
||||
|
||||
#define DEBUG DEBUG_NONE
|
||||
#include "net/uip-debug.h"
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
unsigned char
|
||||
uiplib_ipaddrconv(char *addrstr, unsigned char *ipaddr)
|
||||
int
|
||||
uiplib_ipaddrconv(const char *addrstr, uip_ipaddr_t *ipaddr)
|
||||
{
|
||||
#if UIP_CONF_IPV6
|
||||
uint16_t value;
|
||||
int tmp, len, zero;
|
||||
char c;
|
||||
|
||||
value = 0;
|
||||
zero = -1;
|
||||
for(len = 0; len < sizeof(uip_ipaddr_t) - 1; addrstr++) {
|
||||
c = *addrstr;
|
||||
if(c == ':' || c == '\0') {
|
||||
ipaddr->u8[len] = (value >> 8) & 0xff;
|
||||
ipaddr->u8[len + 1] = value & 0xff;
|
||||
len += 2;
|
||||
value = 0;
|
||||
|
||||
if(c == '\0') {
|
||||
break;
|
||||
}
|
||||
|
||||
if(*(addrstr + 1) == ':') {
|
||||
/* Zero compression */
|
||||
if(zero < 0) {
|
||||
zero = len;
|
||||
}
|
||||
addrstr++;
|
||||
}
|
||||
} else {
|
||||
if(c >= '0' && c <= '9') {
|
||||
tmp = c - '0';
|
||||
} else if(c >= 'a' && c <= 'f') {
|
||||
tmp = c - 'a' + 10;
|
||||
} else if(c >= 'A' && c <= 'F') {
|
||||
tmp = c - 'A' + 10;
|
||||
} else {
|
||||
PRINTF("uiplib: illegal char: '%c'\n", c);
|
||||
return 0;
|
||||
}
|
||||
value = (value << 4) + (tmp & 0xf);
|
||||
}
|
||||
}
|
||||
if(c != '\0') {
|
||||
PRINTF("uiplib: too large address\n");
|
||||
return 0;
|
||||
}
|
||||
if(len < sizeof(uip_ipaddr_t)) {
|
||||
if(zero < 0) {
|
||||
PRINTF("uiplib: too short address\n");
|
||||
return 0;
|
||||
}
|
||||
memmove(&ipaddr->u8[zero + sizeof(uip_ipaddr_t) - len],
|
||||
&ipaddr->u8[zero], len - zero);
|
||||
memset(&ipaddr->u8[zero], 0, sizeof(uip_ipaddr_t) - len);
|
||||
}
|
||||
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
|
||||
unsigned char tmp;
|
||||
char c;
|
||||
unsigned char i, j;
|
||||
|
@ -57,8 +116,7 @@ uiplib_ipaddrconv(char *addrstr, unsigned char *ipaddr)
|
|||
return 0;
|
||||
}
|
||||
if(c == '.' || c == 0) {
|
||||
*ipaddr = tmp;
|
||||
++ipaddr;
|
||||
ipaddr->u8[i] = tmp;
|
||||
tmp = 0;
|
||||
} else if(c >= '0' && c <= '9') {
|
||||
tmp = (tmp * 10) + (c - '0');
|
||||
|
@ -68,6 +126,7 @@ uiplib_ipaddrconv(char *addrstr, unsigned char *ipaddr)
|
|||
++addrstr;
|
||||
} while(c != '.' && c != 0);
|
||||
}
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,12 +37,14 @@
|
|||
*
|
||||
* This file is part of the Contiki desktop environment for the C64.
|
||||
*
|
||||
* $Id: uiplib.h,v 1.2 2006/08/26 23:58:45 oliverschmidt Exp $
|
||||
* $Id: uiplib.h,v 1.3 2010/05/31 15:22:08 nifi Exp $
|
||||
*
|
||||
*/
|
||||
#ifndef __UIPLIB_H__
|
||||
#define __UIPLIB_H__
|
||||
|
||||
#include "net/uip.h"
|
||||
|
||||
/**
|
||||
* \addtogroup uipconvfunc
|
||||
* @{
|
||||
|
@ -52,19 +54,20 @@
|
|||
* Convert a textual representation of an IP address to a numerical representation.
|
||||
*
|
||||
* This function takes a textual representation of an IP address in
|
||||
* the form a.b.c.d and converts it into a 4-byte array that can be
|
||||
* used by other uIP functions.
|
||||
* the form a.b.c.d for IPv4 or a:b:c:d:e:f:g:h for IPv6 and converts
|
||||
* it into a numeric IP address representation that can be used by
|
||||
* other uIP functions.
|
||||
*
|
||||
* \param addrstr A pointer to a string containing the IP address in
|
||||
* textual form.
|
||||
*
|
||||
* \param addr A pointer to a 4-byte array that will be filled in with
|
||||
* \param addr A pointer to a uip_ipaddr_t that will be filled in with
|
||||
* the numerical representation of the address.
|
||||
*
|
||||
* \retval 0 If the IP address could not be parsed.
|
||||
* \retval Non-zero If the IP address was parsed.
|
||||
*/
|
||||
CCIF unsigned char uiplib_ipaddrconv(char *addrstr, unsigned char *addr);
|
||||
CCIF int uiplib_ipaddrconv(const char *addrstr, uip_ipaddr_t *addr);
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
*
|
||||
* This file is part of the Contiki desktop environment
|
||||
*
|
||||
* $Id: wget.c,v 1.2 2010/02/12 10:14:09 oliverschmidt Exp $
|
||||
* $Id: wget.c,v 1.3 2010/05/31 15:22:08 nifi Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -56,7 +56,7 @@ static char url[128];
|
|||
static void
|
||||
start_get(void)
|
||||
{
|
||||
u16_t addr[2];
|
||||
uip_ipaddr_t addr;
|
||||
unsigned char i;
|
||||
static char host[32];
|
||||
char *file;
|
||||
|
@ -113,7 +113,7 @@ start_get(void)
|
|||
|
||||
#if UIP_UDP
|
||||
/* First check if the host is an IP address. */
|
||||
if(uiplib_ipaddrconv(host, (unsigned char *)addr) == 0) {
|
||||
if(uiplib_ipaddrconv(host, &addr) == 0) {
|
||||
|
||||
/* Try to lookup the hostname. If it fails, we initiate a hostname
|
||||
lookup and print out an informative message on the
|
||||
|
@ -125,7 +125,7 @@ start_get(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
|
||||
|
|
Loading…
Reference in a new issue