More uip_ipaddr_t fixes.

This commit is contained in:
oliverschmidt 2006-09-18 23:27:42 +00:00
parent fca710e447
commit 3e92f843ba
4 changed files with 45 additions and 46 deletions

View file

@ -60,37 +60,36 @@ makebyte(u8_t byte, char *str)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
makeaddr(u16_t *addr, char *str) makeaddr(uip_ipaddr_t *addr, char *str)
{ {
str = makebyte(HTONS(addr[0]) >> 8, str); str = makebyte(addr->u8[0], str);
*str++ = '.'; *str++ = '.';
str = makebyte(HTONS(addr[0]) & 0xff, str); str = makebyte(addr->u8[1], str);
*str++ = '.'; *str++ = '.';
str = makebyte(HTONS(addr[1]) >> 8, str); str = makebyte(addr->u8[2], str);
*str++ = '.'; *str++ = '.';
str = makebyte(HTONS(addr[1]) & 0xff, str); str = makebyte(addr->u8[3], str);
*str++ = 0; *str++ = 0;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
makestrings(void) makestrings(void)
{ {
u16_t addr[2], *addrptr; uip_ipaddr_t addr, *addrptr;
uip_gethostaddr((uip_ipaddr_t *)addr); uip_gethostaddr(&addr);
makeaddr(addr, ipaddr); makeaddr(&addr, ipaddr);
uip_getnetmask((uip_ipaddr_t *)addr); uip_getnetmask(&addr);
makeaddr(addr, netmask); makeaddr(&addr, netmask);
uip_getdraddr((uip_ipaddr_t *)addr); uip_getdraddr(&addr);
makeaddr(addr, gateway); makeaddr(&addr, gateway);
addrptr = resolv_getserver(); addrptr = resolv_getserver();
if(addrptr != NULL) { if(addrptr != NULL) {
makeaddr(addrptr, dnsserver); makeaddr(addrptr, dnsserver);
} }
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
PROCESS_THREAD(dhcp_process, ev, data) PROCESS_THREAD(dhcp_process, ev, data)
@ -146,7 +145,7 @@ dhcpc_configured(const struct dhcpc_state *s)
uip_sethostaddr(&s->ipaddr); uip_sethostaddr(&s->ipaddr);
uip_setnetmask(&s->netmask); uip_setnetmask(&s->netmask);
uip_setdraddr(&s->default_router); uip_setdraddr(&s->default_router);
resolv_conf((u16_t *)&s->dnsaddr); resolv_conf(&s->dnsaddr);
set_statustext("Configured."); set_statustext("Configured.");
process_post(PROCESS_CURRENT(), SHOWCONFIG, NULL); process_post(PROCESS_CURRENT(), SHOWCONFIG, NULL);
} }

View file

@ -29,7 +29,7 @@
* *
* This file is part of the Contiki desktop environment * This file is part of the Contiki desktop environment
* *
* $Id: netconf.c,v 1.4 2006/09/18 22:48:05 oliverschmidt Exp $ * $Id: netconf.c,v 1.5 2006/09/18 23:27:42 oliverschmidt Exp $
* *
*/ */
@ -83,31 +83,31 @@ makebyte(u8_t byte, char *str)
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
static void static void
makeaddr(u16_t *addr, char *str) makeaddr(uip_ipaddr_t *addr, char *str)
{ {
str = makebyte(HTONS(addr[0]) >> 8, str); str = makebyte(addr->u8[0], str);
*str++ = '.'; *str++ = '.';
str = makebyte(HTONS(addr[0]) & 0xff, str); str = makebyte(addr->u8[1], str);
*str++ = '.'; *str++ = '.';
str = makebyte(HTONS(addr[1]) >> 8, str); str = makebyte(addr->u8[2], str);
*str++ = '.'; *str++ = '.';
str = makebyte(HTONS(addr[1]) & 0xff, str); str = makebyte(addr->u8[3], str);
*str++ = 0; *str++ = 0;
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
static void static void
makestrings(void) makestrings(void)
{ {
u16_t addr[2], *addrptr; uip_ipaddr_t addr, *addrptr;
uip_gethostaddr((uip_ipaddr_t *)addr); uip_gethostaddr(&addr);
makeaddr(addr, ipaddr); makeaddr(&addr, ipaddr);
uip_getnetmask((uip_ipaddr_t *)addr); uip_getnetmask(&addr);
makeaddr(addr, netmask); makeaddr(&addr, netmask);
uip_getdraddr((uip_ipaddr_t *)addr); uip_getdraddr(&addr);
makeaddr(addr, gateway); makeaddr(&addr, gateway);
addrptr = resolv_getserver(); addrptr = resolv_getserver();
if(addrptr != NULL) { if(addrptr != NULL) {
@ -127,26 +127,26 @@ nullterminate(char *cptr)
static void static void
apply_tcpipconfig(void) apply_tcpipconfig(void)
{ {
u16_t addr[2]; uip_ipaddr_t addr;
nullterminate(ipaddr); nullterminate(ipaddr);
if(uiplib_ipaddrconv(ipaddr, (unsigned char *)addr)) { if(uiplib_ipaddrconv(ipaddr, (unsigned char *)&addr)) {
uip_sethostaddr((uip_ipaddr_t *)addr); uip_sethostaddr(&addr);
} }
nullterminate(netmask); nullterminate(netmask);
if(uiplib_ipaddrconv(netmask, (unsigned char *)addr)) { if(uiplib_ipaddrconv(netmask, (unsigned char *)&addr)) {
uip_setnetmask((uip_ipaddr_t *)addr); uip_setnetmask(&addr);
} }
nullterminate(gateway); nullterminate(gateway);
if(uiplib_ipaddrconv(gateway, (unsigned char *)addr)) { if(uiplib_ipaddrconv(gateway, (unsigned char *)&addr)) {
uip_setdraddr((uip_ipaddr_t *)addr); uip_setdraddr(&addr);
} }
nullterminate(dnsserver); nullterminate(dnsserver);
if(uiplib_ipaddrconv(dnsserver, (unsigned char *)addr)) { if(uiplib_ipaddrconv(dnsserver, (unsigned char *)&addr)) {
resolv_conf(addr); resolv_conf(&addr);
} }
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/

View file

@ -57,7 +57,7 @@
* *
* This file is part of the uIP TCP/IP stack. * This file is part of the uIP TCP/IP stack.
* *
* $Id: resolv.c,v 1.3 2006/08/14 23:37:21 oliverschmidt Exp $ * $Id: resolv.c,v 1.4 2006/09/18 23:30:40 oliverschmidt Exp $
* *
*/ */
@ -453,13 +453,13 @@ resolv_lookup(char *name)
* been configured. * been configured.
*/ */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
u16_t * uip_ipaddr_t *
resolv_getserver(void) resolv_getserver(void)
{ {
if(resolv_conn == NULL) { if(resolv_conn == NULL) {
return NULL; return NULL;
} }
return resolv_conn->ripaddr.u16; return &resolv_conn->ripaddr;
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
/** /**
@ -470,11 +470,11 @@ resolv_getserver(void)
*/ */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
void void
resolv_conf(u16_t *dnsserver) resolv_conf(const uip_ipaddr_t *dnsserver)
{ {
static u16_t server[2]; static uip_ipaddr_t server;
uip_ipaddr_copy(server, dnsserver); uip_ipaddr_copy(&server, dnsserver);
process_post(&resolv_process, EVENT_NEW_SERVER, server); process_post(&resolv_process, EVENT_NEW_SERVER, &server);
/* if(resolv_conn != NULL) { /* if(resolv_conn != NULL) {
uip_udp_remove(resolv_conn); uip_udp_remove(resolv_conn);

View file

@ -34,7 +34,7 @@
* *
* This file is part of the uIP TCP/IP stack. * This file is part of the uIP TCP/IP stack.
* *
* $Id: resolv.h,v 1.2 2006/08/26 23:58:45 oliverschmidt Exp $ * $Id: resolv.h,v 1.3 2006/09/18 23:30:40 oliverschmidt Exp $
* *
*/ */
#ifndef __RESOLV_H__ #ifndef __RESOLV_H__
@ -51,8 +51,8 @@ CCIF extern process_event_t resolv_event_found;
void resolv_found(char *name, u16_t *ipaddr); void resolv_found(char *name, u16_t *ipaddr);
/* Functions. */ /* Functions. */
CCIF void resolv_conf(u16_t *dnsserver); CCIF void resolv_conf(const uip_ipaddr_t *dnsserver);
CCIF u16_t *resolv_getserver(void); CCIF uip_ipaddr_t *resolv_getserver(void);
void resolv_init(char *arg); void resolv_init(char *arg);
CCIF u16_t *resolv_lookup(char *name); CCIF u16_t *resolv_lookup(char *name);
CCIF void resolv_query(char *name); CCIF void resolv_query(char *name);