Change typedef of uip_ipaddr_t from a vector type to a union.
typedef union uip_ip4addr_t { u16_t u16[2]; u8_t u8[4]; } uip_ip4addr_t; typedef uip_ip4addr_t uip_ipaddr_t; This implies that one must consistently pass pointers to uip_ipaddr_t:s and not mix and match pointers with uip_ipaddr_t:s as was done earlier.
This commit is contained in:
parent
2fe1ccf8c5
commit
fb94d50410
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: httpd-cgi.c,v 1.1 2006/06/17 22:41:14 adamdunkels Exp $
|
||||
* $Id: httpd-cgi.c,v 1.2 2006/08/09 16:13:39 bg- Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -157,10 +157,10 @@ make_tcp_stats(void *arg)
|
|||
return sprintf((char *)uip_appdata,
|
||||
"<tr><td>%d</td><td>%u.%u.%u.%u:%u</td><td>%s</td><td>%u</td><td>%u</td><td>%c %c</td></tr>\r\n",
|
||||
htons(conn->lport),
|
||||
htons(conn->ripaddr[0]) >> 8,
|
||||
htons(conn->ripaddr[0]) & 0xff,
|
||||
htons(conn->ripaddr[1]) >> 8,
|
||||
htons(conn->ripaddr[1]) & 0xff,
|
||||
conn->ripaddr.u8[0],
|
||||
conn->ripaddr.u8[1],
|
||||
conn->ripaddr.u8[2],
|
||||
conn->ripaddr.u8[3],
|
||||
htons(conn->rport),
|
||||
states[conn->tcpstateflags & UIP_TS_MASK],
|
||||
conn->nrtx,
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: httpd.c,v 1.1 2006/06/17 22:41:14 adamdunkels Exp $
|
||||
* $Id: httpd.c,v 1.2 2006/08/09 16:13:39 bg- Exp $
|
||||
*/
|
||||
|
||||
#include "contiki-net.h"
|
||||
|
@ -249,7 +249,7 @@ PT_THREAD(handle_input(struct httpd_state *s))
|
|||
strncpy(s->filename, &s->inputbuf[0], sizeof(s->filename));
|
||||
}
|
||||
|
||||
httpd_log_file(uip_conn->ripaddr, s->filename);
|
||||
httpd_log_file(&uip_conn->ripaddr, s->filename);
|
||||
|
||||
s->state = STATE_OUTPUT;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: httpd.h,v 1.1 2006/06/17 22:41:14 adamdunkels Exp $
|
||||
* $Id: httpd.h,v 1.2 2006/08/09 16:13:39 bg- Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -59,6 +59,6 @@ void httpd_init(void);
|
|||
void httpd_appcall(void *state);
|
||||
|
||||
void httpd_log(char *msg);
|
||||
void httpd_log_file(u16_t *requester, char *file);
|
||||
void httpd_log_file(uip_ipaddr_t *requester, char *file);
|
||||
|
||||
#endif /* __HTTPD_H__ */
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
*
|
||||
* This file is part of the Contiki OS.
|
||||
*
|
||||
* $Id: webserver-nogui.c,v 1.1 2006/06/17 22:41:15 adamdunkels Exp $
|
||||
* $Id: webserver-nogui.c,v 1.2 2006/08/09 16:13:39 bg- Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -59,7 +59,7 @@ PROCESS_THREAD(webserver_nogui_process, ev, data)
|
|||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
httpd_log_file(u16_t *requester, char *file)
|
||||
httpd_log_file(uip_ipaddr_t *requester, char *file)
|
||||
{
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
*
|
||||
* This file is part of the Contiki desktop environment for the C64.
|
||||
*
|
||||
* $Id: webserver.c,v 1.1 2006/06/17 22:41:15 adamdunkels Exp $
|
||||
* $Id: webserver.c,v 1.2 2006/08/09 16:13:39 bg- Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -89,7 +89,7 @@ PROCESS_THREAD(webserver_process, ev, data)
|
|||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
httpd_log_file(u16_t *requester, char *file)
|
||||
httpd_log_file(uip_ipaddr_t *requester, char *file)
|
||||
{
|
||||
int size;
|
||||
|
||||
|
@ -99,10 +99,10 @@ httpd_log_file(u16_t *requester, char *file)
|
|||
/* Print out IP address of requesting host. */
|
||||
size = sprintf(&log[LOG_WIDTH * (LOG_HEIGHT - 1)],
|
||||
"%d.%d.%d.%d: ",
|
||||
htons(requester[0]) >> 8,
|
||||
htons(requester[0]) & 0xff,
|
||||
htons(requester[1]) >> 8,
|
||||
htons(requester[1]) & 0xff);
|
||||
requester->u8[0],
|
||||
requester->u8[1],
|
||||
requester->u8[2],
|
||||
requester->u8[3]);
|
||||
|
||||
/* Copy filename into last line. */
|
||||
strncpy(&log[LOG_WIDTH * (LOG_HEIGHT - 1) + size], file, LOG_WIDTH - size);
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* @(#)$Id: cc2420.c,v 1.2 2006/08/02 14:33:36 bg- Exp $
|
||||
* @(#)$Id: cc2420.c,v 1.3 2006/08/09 16:13:39 bg- Exp $
|
||||
*/
|
||||
/*
|
||||
* This code is almost device independent and should be possible to
|
||||
|
@ -209,7 +209,7 @@ cc2420_send_data_ack(u16_t mac)
|
|||
h.fc0 = FC0_TYPE_DATA | FC0_INTRA_PAN;
|
||||
h.fc1 = FC1_DST_16 | FC1_SRC_16;
|
||||
|
||||
h.src = uip_hostaddr[1];
|
||||
h.src = uip_hostaddr.u16[1];
|
||||
h.dst = mac;
|
||||
|
||||
cc2420_send(&h, 10, NULL, 0);
|
||||
|
@ -491,8 +491,7 @@ PROCESS_THREAD(cc2420_process, ev, data)
|
|||
* If we are the unique receiver send DATA ACK.
|
||||
*/
|
||||
if (h.dst == 0xffff
|
||||
&& BUF->destipaddr[0] == uip_hostaddr[0]
|
||||
&& BUF->destipaddr[1] == uip_hostaddr[1])
|
||||
&& uip_ipaddr_cmp(&BUF->destipaddr, &uip_hostaddr))
|
||||
cc2420_send_data_ack(h.src);
|
||||
leds_toggle(LEDS_GREEN);
|
||||
tcpip_input();
|
||||
|
@ -630,7 +629,7 @@ neigbour_update(u16_t mac, int nretrans)
|
|||
void
|
||||
cc2420_recv_ok(uip_ipaddr_t *from)
|
||||
{
|
||||
neigbour_update((*from)[1], 0);
|
||||
neigbour_update(from->u16[1], 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
#include "dev/cc2420.h"
|
||||
|
||||
#define in_my_network(a) \
|
||||
(((a[0] ^ cc2420if.ipaddr[0]) & cc2420if.netmask[0]) == 0 && \
|
||||
((a[1] ^ cc2420if.ipaddr[1]) & cc2420if.netmask[1]) == 0)
|
||||
(((a[0] ^ cc2420if.ipaddr.u16[0]) & cc2420if.netmask.u16[0]) == 0 && \
|
||||
((a[1] ^ cc2420if.ipaddr.u16[1]) & cc2420if.netmask.u16[1]) == 0)
|
||||
|
||||
u8_t
|
||||
cc2420_send_ip(void)
|
||||
|
@ -26,21 +26,21 @@ cc2420_send_ip(void)
|
|||
h.fc0 = FC0_TYPE_DATA | FC0_REQ_ACK | FC0_INTRA_PAN;
|
||||
h.fc1 = FC1_DST_16 | FC1_SRC_16;
|
||||
|
||||
h.src = uip_hostaddr[1];
|
||||
if (BUF->destipaddr[0] == 0xffff && BUF->destipaddr[1] == 0xffff)
|
||||
h.src = uip_hostaddr.u16[1];
|
||||
if (uip_ipaddr_cmp(&BUF->destipaddr, &uip_broadcast_addr))
|
||||
h.dst = 0xffff;
|
||||
else {
|
||||
uip_ipaddr_t *next_gw;
|
||||
|
||||
if (in_my_network(BUF->destipaddr))
|
||||
if (in_my_network(BUF->destipaddr.u16))
|
||||
next_gw = &BUF->destipaddr;
|
||||
else
|
||||
next_gw = &uip_draddr; /* Default router. */
|
||||
|
||||
if (cc2420_check_remote((*next_gw)[1]) == 1)
|
||||
if (cc2420_check_remote(next_gw->u16[1]) == 1)
|
||||
h.dst = 0xffff; /* remote, use bcast */
|
||||
else
|
||||
h.dst = (*next_gw)[1]; /* local or unknown, use ucast */
|
||||
h.dst = next_gw->u16[1]; /* local or unknown, use ucast */
|
||||
}
|
||||
|
||||
/* Don't request MAC level ACKs for broadcast packets. */
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
#include "net/uaodv-rt.h"
|
||||
|
||||
#define in_my_network(a) \
|
||||
(((a[0] ^ cc2420if.ipaddr[0]) & cc2420if.netmask[0]) == 0 && \
|
||||
((a[1] ^ cc2420if.ipaddr[1]) & cc2420if.netmask[1]) == 0)
|
||||
(((a[0] ^ cc2420if.ipaddr.u16[0]) & cc2420if.netmask.u16[0]) == 0 && \
|
||||
((a[1] ^ cc2420if.ipaddr.u16[1]) & cc2420if.netmask.u16[1]) == 0)
|
||||
|
||||
u8_t
|
||||
cc2420_send_uaodv(void)
|
||||
|
@ -29,27 +29,27 @@ cc2420_send_uaodv(void)
|
|||
h.fc0 = FC0_TYPE_DATA | FC0_REQ_ACK | FC0_INTRA_PAN;
|
||||
h.fc1 = FC1_DST_16 | FC1_SRC_16;
|
||||
|
||||
h.src = uip_hostaddr[1];
|
||||
if (BUF->destipaddr[0] == 0xffff && BUF->destipaddr[1] == 0xffff)
|
||||
h.src = uip_hostaddr.u16[1];
|
||||
if (uip_ipaddr_cmp(&BUF->destipaddr, &uip_broadcast_addr))
|
||||
h.dst = 0xffff;
|
||||
else {
|
||||
uip_ipaddr_t *next_gw;
|
||||
|
||||
if (in_my_network(BUF->destipaddr))
|
||||
if (in_my_network(BUF->destipaddr.u16))
|
||||
next_gw = &BUF->destipaddr;
|
||||
else
|
||||
next_gw = &uip_draddr; /* Default router. */
|
||||
|
||||
if (cc2420_check_remote((*next_gw)[1]) == 0)
|
||||
h.dst = (*next_gw)[1]; /* local, use ucast */
|
||||
if (cc2420_check_remote(next_gw->u16[1]) == 0)
|
||||
h.dst = next_gw->u16[1]; /* local, use ucast */
|
||||
else { /* remote or unknown */
|
||||
struct uaodv_rt_entry *route = uaodv_request_route_to(next_gw);
|
||||
|
||||
if (route == NULL) {
|
||||
h.dst = (*next_gw)[1]; /* try local while waiting for route */
|
||||
h.dst = next_gw->u16[1]; /* try local while waiting for route */
|
||||
} else {
|
||||
if (cc2420_check_remote(route->nexthop[1]) == 1) {
|
||||
printf("LOST 0x%04x\n", route->nexthop[1]);
|
||||
if (cc2420_check_remote(route->nexthop.u16[1]) == 1) {
|
||||
printf("LOST 0x%04x\n", route->nexthop.u16[1]);
|
||||
/* Send bad route notification? */
|
||||
#ifdef UAODV_BAD_ROUTE
|
||||
uaodv_bad_route(route);
|
||||
|
@ -58,7 +58,7 @@ cc2420_send_uaodv(void)
|
|||
h.dst = 0xffff; /* revert to bcast */
|
||||
} else /* unknown */ {
|
||||
/* This will implicitly update neigbour table. */
|
||||
h.dst = route->nexthop[1];
|
||||
h.dst = route->nexthop.u16[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* @(#)$Id: dhcpc.c,v 1.2 2006/06/24 17:59:28 gpz Exp $
|
||||
* @(#)$Id: dhcpc.c,v 1.3 2006/08/09 16:13:39 bg- Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -116,7 +116,7 @@ add_req_ipaddr(u8_t *optptr)
|
|||
{
|
||||
*optptr++ = DHCP_OPTION_REQ_IPADDR;
|
||||
*optptr++ = 4;
|
||||
memcpy(optptr, s.ipaddr, 4);
|
||||
memcpy(optptr, s.ipaddr.u16, 4);
|
||||
return optptr + 4;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -149,7 +149,7 @@ create_msg(register struct dhcp_msg *m)
|
|||
m->secs = 0;
|
||||
m->flags = HTONS(BOOTP_BROADCAST); /* Broadcast bit. */
|
||||
/* uip_ipaddr_copy(m->ciaddr, uip_hostaddr);*/
|
||||
memcpy(m->ciaddr, uip_hostaddr, sizeof(m->ciaddr));
|
||||
memcpy(m->ciaddr, uip_hostaddr.u16, sizeof(m->ciaddr));
|
||||
memset(m->yiaddr, 0, sizeof(m->yiaddr));
|
||||
memset(m->siaddr, 0, sizeof(m->siaddr));
|
||||
memset(m->giaddr, 0, sizeof(m->giaddr));
|
||||
|
@ -203,13 +203,13 @@ parse_options(u8_t *optptr, int len)
|
|||
while(optptr < end) {
|
||||
switch(*optptr) {
|
||||
case DHCP_OPTION_SUBNET_MASK:
|
||||
memcpy(s.netmask, optptr + 2, 4);
|
||||
memcpy(s.netmask.u16, optptr + 2, 4);
|
||||
break;
|
||||
case DHCP_OPTION_ROUTER:
|
||||
memcpy(s.default_router, optptr + 2, 4);
|
||||
memcpy(s.default_router.u16, optptr + 2, 4);
|
||||
break;
|
||||
case DHCP_OPTION_DNS_SERVER:
|
||||
memcpy(s.dnsaddr, optptr + 2, 4);
|
||||
memcpy(s.dnsaddr.u16, optptr + 2, 4);
|
||||
break;
|
||||
case DHCP_OPTION_MSG_TYPE:
|
||||
type = *(optptr + 2);
|
||||
|
@ -237,7 +237,7 @@ parse_msg(void)
|
|||
if(m->op == DHCP_REPLY &&
|
||||
memcmp(m->xid, &xid, sizeof(xid)) == 0 &&
|
||||
memcmp(m->chaddr, s.mac_addr, s.mac_len) == 0) {
|
||||
memcpy(s.ipaddr, m->yiaddr, 4);
|
||||
memcpy(s.ipaddr.u16, m->yiaddr, 4);
|
||||
return parse_options(&m->options[4], uip_datalen());
|
||||
}
|
||||
return 0;
|
||||
|
@ -385,14 +385,14 @@ PT_THREAD(handle_dhcp(process_event_t ev, void *data))
|
|||
void
|
||||
dhcpc_init(const void *mac_addr, int mac_len)
|
||||
{
|
||||
u16_t addr[2];
|
||||
uip_ipaddr_t addr;
|
||||
|
||||
s.mac_addr = mac_addr;
|
||||
s.mac_len = mac_len;
|
||||
|
||||
s.state = STATE_INITIAL;
|
||||
uip_ipaddr(addr, 255,255,255,255);
|
||||
s.conn = udp_new(addr, HTONS(DHCPC_SERVER_PORT), NULL);
|
||||
uip_ipaddr(&addr, 255,255,255,255);
|
||||
s.conn = udp_new(&addr, HTONS(DHCPC_SERVER_PORT), NULL);
|
||||
if(s.conn != NULL) {
|
||||
udp_bind(s.conn, HTONS(DHCPC_CLIENT_PORT));
|
||||
}
|
||||
|
@ -410,11 +410,11 @@ dhcpc_appcall(process_event_t ev, void *data)
|
|||
void
|
||||
dhcpc_request(void)
|
||||
{
|
||||
u16_t ipaddr[2];
|
||||
uip_ipaddr_t ipaddr;
|
||||
|
||||
if(s.state == STATE_INITIAL) {
|
||||
uip_ipaddr(ipaddr, 0,0,0,0);
|
||||
uip_sethostaddr(ipaddr);
|
||||
uip_ipaddr(&ipaddr, 0,0,0,0);
|
||||
uip_sethostaddr(&ipaddr);
|
||||
handle_dhcp(PROCESS_EVENT_NONE, NULL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* @(#)$Id: dhcpc.h,v 1.1 2006/06/17 22:41:18 adamdunkels Exp $
|
||||
* @(#)$Id: dhcpc.h,v 1.2 2006/08/09 16:13:39 bg- Exp $
|
||||
*/
|
||||
#ifndef __DHCPC_H__
|
||||
#define __DHCPC_H__
|
||||
|
@ -45,10 +45,10 @@ struct dhcpc_state {
|
|||
u8_t serverid[4];
|
||||
|
||||
u16_t lease_time[2];
|
||||
u16_t ipaddr[2];
|
||||
u16_t netmask[2];
|
||||
u16_t dnsaddr[2];
|
||||
u16_t default_router[2];
|
||||
uip_ipaddr_t ipaddr;
|
||||
uip_ipaddr_t netmask;
|
||||
uip_ipaddr_t dnsaddr;
|
||||
uip_ipaddr_t default_router;
|
||||
};
|
||||
|
||||
void dhcpc_init(const void *mac_addr, int mac_len);
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* @(#)$Id: hc.c,v 1.1 2006/06/17 22:41:18 adamdunkels Exp $
|
||||
* @(#)$Id: hc.c,v 1.2 2006/08/09 16:13:39 bg- Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -49,7 +49,7 @@
|
|||
|
||||
struct hc_hdr {
|
||||
u16_t flagsport;
|
||||
u16_t srcipaddr[2];
|
||||
uip_ipaddr_t srcipaddr;
|
||||
};
|
||||
|
||||
struct udpip_hdr {
|
||||
|
@ -62,8 +62,7 @@ struct udpip_hdr {
|
|||
ttl,
|
||||
proto;
|
||||
u16_t ipchksum;
|
||||
u16_t srcipaddr[2],
|
||||
destipaddr[2];
|
||||
uip_ipaddr_t srcipaddr, destipaddr;
|
||||
|
||||
/* UDP header. */
|
||||
u16_t srcport,
|
||||
|
@ -121,11 +120,8 @@ hc_compress(void)
|
|||
uhdr->ipoffset[1] == 0x00 && /* No fragmented IP
|
||||
packets. */
|
||||
uhdr->proto == UIP_PROTO_UDP && /* Only UDP packets. */
|
||||
uhdr->destipaddr[0] == 0xffffU && /* Only link-local
|
||||
broadcast
|
||||
packets. */
|
||||
uhdr->destipaddr[1] == 0xffffU && /* Only link-local
|
||||
broadcast
|
||||
uip_ipaddr_cmp(&uhdr->destipaddr, &uip_broadcast_addr) && /* Only
|
||||
link-local broadcast
|
||||
packets. */
|
||||
uhdr->destport == uhdr->srcport && /* Only packets with
|
||||
the same destination
|
||||
|
@ -184,8 +180,7 @@ hc_inflate(void)
|
|||
hdr = (struct hc_hdr *)&uip_buf[UIP_LLH_LEN + UIP_IPUDPH_LEN -
|
||||
HC_HLEN];
|
||||
|
||||
uhdr->srcipaddr[0] = hdr->srcipaddr[0];
|
||||
uhdr->srcipaddr[1] = hdr->srcipaddr[1];
|
||||
uhdr->srcipaddr = hdr->srcipaddr;
|
||||
uhdr->srcport = hdr->flagsport & HTONS(0x3fff);
|
||||
uhdr->destport = hdr->flagsport & HTONS(0x3fff);
|
||||
|
||||
|
@ -202,7 +197,7 @@ hc_inflate(void)
|
|||
uhdr->ipoffset[0] = uhdr->ipoffset[1] = 0;
|
||||
uhdr->ttl = 2;
|
||||
uhdr->proto = UIP_PROTO_UDP;
|
||||
uhdr->destipaddr[0] = uhdr->destipaddr[1] = 0xffff;
|
||||
uhdr->destipaddr = uip_broadcast_addr;
|
||||
uhdr->udpchksum = 0;
|
||||
|
||||
uhdr->ipchksum = 0;
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: resolv.c,v 1.1 2006/06/17 22:41:18 adamdunkels Exp $
|
||||
* $Id: resolv.c,v 1.2 2006/08/09 16:13:39 bg- Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -356,7 +356,7 @@ PROCESS_THREAD(resolv_process, ev, data)
|
|||
uip_udp_remove(resolv_conn);
|
||||
}
|
||||
|
||||
resolv_conn = udp_new((u16_t *)data, HTONS(53), NULL);
|
||||
resolv_conn = udp_new((uip_ipaddr_t *)data, HTONS(53), NULL);
|
||||
|
||||
} else if(ev == tcpip_event) {
|
||||
if(uip_udp_conn->rport == HTONS(53)) {
|
||||
|
@ -459,7 +459,7 @@ resolv_getserver(void)
|
|||
if(resolv_conn == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return resolv_conn->ripaddr;
|
||||
return resolv_conn->ripaddr.u16;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: tcpip.c,v 1.2 2006/07/07 06:45:45 nifi Exp $
|
||||
* $Id: tcpip.c,v 1.3 2006/08/09 16:13:39 bg- Exp $
|
||||
*/
|
||||
|
||||
#include "contiki-conf.h"
|
||||
|
@ -188,12 +188,12 @@ udp_attach(struct uip_udp_conn *conn,
|
|||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
struct uip_udp_conn *
|
||||
udp_new(u16_t *ripaddr, u16_t port, void *appstate)
|
||||
udp_new(uip_ipaddr_t *ripaddr, u16_t port, void *appstate)
|
||||
{
|
||||
struct uip_udp_conn *c;
|
||||
uip_udp_appstate_t *s;
|
||||
|
||||
c = uip_udp_new((uip_ipaddr_t *)ripaddr, port);
|
||||
c = uip_udp_new(ripaddr, port);
|
||||
if(c == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -211,8 +211,8 @@ udp_broadcast_new(u16_t port, void *appstate)
|
|||
uip_ipaddr_t addr;
|
||||
struct uip_udp_conn *conn;
|
||||
|
||||
uip_ipaddr(addr, 255,255,255,255);
|
||||
conn = udp_new(addr, port, appstate);
|
||||
uip_ipaddr(&addr, 255,255,255,255);
|
||||
conn = udp_new(&addr, port, appstate);
|
||||
if(conn != NULL) {
|
||||
udp_bind(conn, port);
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: tcpip.h,v 1.1 2006/06/17 22:41:19 adamdunkels Exp $
|
||||
* $Id: tcpip.h,v 1.2 2006/08/09 16:13:39 bg- Exp $
|
||||
*/
|
||||
#ifndef __TCPIP_H__
|
||||
#define __TCPIP_H__
|
||||
|
@ -223,7 +223,7 @@ void udp_attach(struct uip_udp_conn *conn,
|
|||
* \return A pointer to the newly created connection, or NULL if
|
||||
* memory could not be allocated for the connection.
|
||||
*/
|
||||
struct uip_udp_conn *udp_new(u16_t *ripaddr, u16_t port,
|
||||
struct uip_udp_conn *udp_new(uip_ipaddr_t *ripaddr, u16_t port,
|
||||
void *appstate);
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: uaodv-rt.c,v 1.1 2006/06/17 22:41:19 adamdunkels Exp $
|
||||
* $Id: uaodv-rt.c,v 1.2 2006/08/09 16:13:39 bg- Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -76,8 +76,8 @@ uaodv_rt_add(uip_ipaddr_t *dest, uip_ipaddr_t *nexthop,
|
|||
}
|
||||
}
|
||||
|
||||
uip_ipaddr_copy(e->dest, dest);
|
||||
uip_ipaddr_copy(e->nexthop, nexthop);
|
||||
uip_ipaddr_copy(&e->dest, dest);
|
||||
uip_ipaddr_copy(&e->nexthop, nexthop);
|
||||
e->hop_count = hop_count;
|
||||
e->seqno = seqno;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: uaodv.c,v 1.1 2006/06/17 22:41:19 adamdunkels Exp $
|
||||
* $Id: uaodv.c,v 1.2 2006/08/09 16:13:39 bg- Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -82,13 +82,11 @@ print_debug(const char *fmt, ...)
|
|||
}
|
||||
#endif
|
||||
|
||||
#define uip_udp_sender() ((uip_ipaddr_t *)(((struct uip_udpip_hdr *)&uip_buf[UIP_LLH_LEN])->srcipaddr))
|
||||
|
||||
uip_ipaddr_t inaddr_broadcast = { 0xffff, 0xffff };
|
||||
#define uip_udp_sender() (&((struct uip_udpip_hdr *)&uip_buf[UIP_LLH_LEN])->srcipaddr)
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
sendto(uip_ipaddr_t *dest, char *buf, int len)
|
||||
sendto(const uip_ipaddr_t *dest, char *buf, int len)
|
||||
{
|
||||
/* XXX: this is a HACK! We're updating the uIP UDP connection
|
||||
"unicastconn" so that the destination address is the next-hop,
|
||||
|
@ -162,7 +160,7 @@ send_rerr(uip_ipaddr_t *addr, u32_t seqno)
|
|||
uip_ipaddr_copy(&rm->unreach[0].addr, addr);
|
||||
rm->unreach[0].seqno = seqno;
|
||||
|
||||
sendto(&inaddr_broadcast, (char *)rm, sizeof(struct uaodv_msg_rerr));
|
||||
sendto(&uip_broadcast_addr, (char *)rm, sizeof(struct uaodv_msg_rerr));
|
||||
|
||||
print_debug("Broadcasting initial RERR for %d.%d.%d.%d\n", ip2quad(addr));
|
||||
}
|
||||
|
@ -189,7 +187,7 @@ handle_incoming_rreq(void)
|
|||
#endif
|
||||
|
||||
/* Check if it is for our address. */
|
||||
if(uip_ipaddr_cmp(&rm->dest_addr, uip_hostaddr)) {
|
||||
if(uip_ipaddr_cmp(&rm->dest_addr, &uip_hostaddr)) {
|
||||
print_debug("RREQ for our address!\n");
|
||||
rt = uaodv_rt_lookup(&rm->src_addr);
|
||||
if(rt == NULL || rm->hop_count <= rt->hop_count) {
|
||||
|
@ -317,7 +315,7 @@ handle_incoming_rrep(void)
|
|||
);
|
||||
|
||||
}
|
||||
if(uip_ipaddr_cmp(&rm->src_addr, uip_hostaddr)) {
|
||||
if(uip_ipaddr_cmp(&rm->src_addr, &uip_hostaddr)) {
|
||||
print_debug("------- COMPLETE ROUTE FOUND\n");
|
||||
} else {
|
||||
|
||||
|
@ -365,7 +363,7 @@ handle_incoming_rerr(void)
|
|||
if(rt != NULL && uip_ipaddr_cmp(&rt->nexthop, uip_udp_sender())) {
|
||||
uaodv_rt_remove(rt);
|
||||
print_debug("RERR rebroadcast\n");
|
||||
sendto(&inaddr_broadcast, (char *)rm, sizeof(struct uaodv_msg_rerr));
|
||||
sendto(&uip_broadcast_addr, (char *)rm, sizeof(struct uaodv_msg_rerr));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: uip-fw.c,v 1.1 2006/06/17 22:41:19 adamdunkels Exp $
|
||||
* $Id: uip-fw.c,v 1.2 2006/08/09 16:13:39 bg- Exp $
|
||||
*/
|
||||
/**
|
||||
* \addtogroup uip
|
||||
|
@ -80,8 +80,7 @@ struct tcpip_hdr {
|
|||
u8_t ttl,
|
||||
proto;
|
||||
u16_t ipchksum;
|
||||
u16_t srcipaddr[2],
|
||||
destipaddr[2];
|
||||
uip_ipaddr_t srcipaddr, destipaddr;
|
||||
|
||||
/* TCP header. */
|
||||
u16_t srcport,
|
||||
|
@ -106,8 +105,7 @@ struct icmpip_hdr {
|
|||
ttl,
|
||||
proto;
|
||||
u16_t ipchksum;
|
||||
u16_t srcipaddr[2],
|
||||
destipaddr[2];
|
||||
uip_ipaddr_t srcipaddr, destipaddr;
|
||||
/* ICMP (echo) header. */
|
||||
u8_t type, icode;
|
||||
u16_t icmpchksum;
|
||||
|
@ -138,8 +136,8 @@ struct icmpip_hdr {
|
|||
struct fwcache_entry {
|
||||
u16_t timer;
|
||||
|
||||
u16_t srcipaddr[2];
|
||||
u16_t destipaddr[2];
|
||||
uip_ipaddr_t srcipaddr;
|
||||
uip_ipaddr_t destipaddr;
|
||||
u16_t ipid;
|
||||
u8_t proto;
|
||||
u8_t unused;
|
||||
|
@ -205,10 +203,12 @@ uip_fw_init(void)
|
|||
*/
|
||||
/*------------------------------------------------------------------------------*/
|
||||
static unsigned char
|
||||
ipaddr_maskcmp(u16_t *ipaddr, u16_t *netipaddr, u16_t *netmask)
|
||||
ipaddr_maskcmp(uip_ipaddr_t *ipaddr,
|
||||
uip_ipaddr_t *netipaddr,
|
||||
uip_ipaddr_t *netmask)
|
||||
{
|
||||
return (ipaddr[0] & netmask [0]) == (netipaddr[0] & netmask[0]) &&
|
||||
(ipaddr[1] & netmask[1]) == (netipaddr[1] & netmask[1]);
|
||||
return (ipaddr->u16[0] & netmask->u16[0]) == (netipaddr->u16[0] & netmask->u16[0]) &&
|
||||
(ipaddr->u16[1] & netmask->u16[1]) == (netipaddr->u16[1] & netmask->u16[1]);
|
||||
}
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
@ -222,7 +222,7 @@ ipaddr_maskcmp(u16_t *ipaddr, u16_t *netipaddr, u16_t *netmask)
|
|||
static void
|
||||
time_exceeded(void)
|
||||
{
|
||||
u16_t tmp16;
|
||||
uip_ipaddr_t tmpip;
|
||||
|
||||
/* We don't send out ICMP errors for ICMP messages. */
|
||||
if(ICMPBUF->proto == UIP_PROTO_ICMP) {
|
||||
|
@ -242,16 +242,15 @@ time_exceeded(void)
|
|||
|
||||
/* Set the IP destination address to be the source address of the
|
||||
original packet. */
|
||||
tmp16= BUF->destipaddr[0];
|
||||
BUF->destipaddr[0] = BUF->srcipaddr[0];
|
||||
BUF->srcipaddr[0] = tmp16;
|
||||
tmp16 = BUF->destipaddr[1];
|
||||
BUF->destipaddr[1] = BUF->srcipaddr[1];
|
||||
BUF->srcipaddr[1] = tmp16;
|
||||
tmpip = BUF->destipaddr;
|
||||
BUF->destipaddr = BUF->srcipaddr;
|
||||
BUF->srcipaddr = tmpip;
|
||||
tmpip = BUF->destipaddr;
|
||||
BUF->destipaddr = BUF->srcipaddr;
|
||||
BUF->srcipaddr = tmpip;
|
||||
|
||||
/* Set our IP address as the source address. */
|
||||
BUF->srcipaddr[0] = uip_hostaddr[0];
|
||||
BUF->srcipaddr[1] = uip_hostaddr[1];
|
||||
BUF->srcipaddr = uip_hostaddr;
|
||||
|
||||
/* The size of the ICMP time exceeded packet is 36 + the size of the
|
||||
IP header (20) = 56. */
|
||||
|
@ -301,10 +300,8 @@ fwcache_register(void)
|
|||
|
||||
fw->timer = FW_TIME;
|
||||
fw->ipid = BUF->ipid;
|
||||
fw->srcipaddr[0] = BUF->srcipaddr[0];
|
||||
fw->srcipaddr[1] = BUF->srcipaddr[1];
|
||||
fw->destipaddr[0] = BUF->destipaddr[0];
|
||||
fw->destipaddr[1] = BUF->destipaddr[1];
|
||||
fw->srcipaddr = BUF->srcipaddr;
|
||||
fw->destipaddr = BUF->destipaddr;
|
||||
fw->proto = BUF->proto;
|
||||
#if notdef
|
||||
fw->payload[0] = BUF->srcport;
|
||||
|
@ -328,8 +325,8 @@ find_netif(void)
|
|||
|
||||
/* Walk through every network interface to check for a match. */
|
||||
for(netif = netifs; netif != NULL; netif = netif->next) {
|
||||
if(ipaddr_maskcmp(BUF->destipaddr, netif->ipaddr,
|
||||
netif->netmask)) {
|
||||
if(ipaddr_maskcmp(&BUF->destipaddr, &netif->ipaddr,
|
||||
&netif->netmask)) {
|
||||
/* If there was a match, we break the loop. */
|
||||
return netif;
|
||||
}
|
||||
|
@ -369,8 +366,7 @@ uip_fw_output(void)
|
|||
#if UIP_BROADCAST
|
||||
/* Link local broadcasts go out on all interfaces. */
|
||||
if(/*BUF->proto == UIP_PROTO_UDP &&*/
|
||||
BUF->destipaddr[0] == 0xffff &&
|
||||
BUF->destipaddr[1] == 0xffff) {
|
||||
uip_ipaddr_cmp(&BUF->destipaddr, &uip_broadcast_addr)) {
|
||||
if(defaultnetif != NULL) {
|
||||
defaultnetif->output();
|
||||
}
|
||||
|
@ -410,15 +406,14 @@ uip_fw_forward(void)
|
|||
|
||||
/* First check if the packet is destined for ourselves and return 0
|
||||
to indicate that the packet should be processed locally. */
|
||||
if(BUF->destipaddr[0] == uip_hostaddr[0] &&
|
||||
BUF->destipaddr[1] == uip_hostaddr[1]) {
|
||||
if(uip_ipaddr_cmp(&BUF->destipaddr, &uip_hostaddr)) {
|
||||
return UIP_FW_LOCAL;
|
||||
}
|
||||
|
||||
/* If we use ping IP address configuration, and our IP address is
|
||||
not yet configured, we should intercept all ICMP echo packets. */
|
||||
#if UIP_PINGADDRCONF
|
||||
if((uip_hostaddr[0] | uip_hostaddr[1]) == 0 &&
|
||||
if(uip_ipaddr_cmp(&uip_hostaddr, &all_zeroes_addr) &&
|
||||
BUF->proto == UIP_PROTO_ICMP &&
|
||||
ICMPBUF->type == ICMP_ECHO) {
|
||||
return UIP_FW_LOCAL;
|
||||
|
@ -435,10 +430,8 @@ uip_fw_forward(void)
|
|||
fw->offset == BUF->ipoffset &&
|
||||
#endif
|
||||
fw->ipid == BUF->ipid &&
|
||||
fw->srcipaddr[0] == BUF->srcipaddr[0] &&
|
||||
fw->srcipaddr[1] == BUF->srcipaddr[1] &&
|
||||
fw->destipaddr[0] == BUF->destipaddr[0] &&
|
||||
fw->destipaddr[1] == BUF->destipaddr[1] &&
|
||||
uip_ipaddr_cmp(&fw->srcipaddr, &BUF->srcipaddr) &&
|
||||
uip_ipaddr_cmp(&fw->destipaddr, &BUF->destipaddr) &&
|
||||
#if notdef
|
||||
fw->payload[0] == BUF->srcport &&
|
||||
fw->payload[1] == BUF->destport &&
|
||||
|
@ -454,7 +447,7 @@ uip_fw_forward(void)
|
|||
of the packet. */
|
||||
if(BUF->ttl <= 1) {
|
||||
/* No time exceeded for broadcasts and multicasts! */
|
||||
if(BUF->destipaddr[0] == 0xffff && BUF->destipaddr[1] == 0xffff) {
|
||||
if(uip_ipaddr_cmp(&BUF->destipaddr, &uip_broadcast_addr)) {
|
||||
return UIP_FW_LOCAL;
|
||||
}
|
||||
time_exceeded();
|
||||
|
@ -476,7 +469,7 @@ uip_fw_forward(void)
|
|||
}
|
||||
|
||||
#if UIP_BROADCAST
|
||||
if(BUF->destipaddr[0] == 0xffff && BUF->destipaddr[1] == 0xffff) {
|
||||
if(uip_ipaddr_cmp(&BUF->destipaddr, &uip_broadcast_addr)) {
|
||||
return UIP_FW_LOCAL;
|
||||
}
|
||||
#endif /* UIP_BROADCAST */
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: uip-fw.h,v 1.1 2006/06/17 22:41:19 adamdunkels Exp $
|
||||
* $Id: uip-fw.h,v 1.2 2006/08/09 16:13:40 bg- Exp $
|
||||
*/
|
||||
#ifndef __UIP_FW_H__
|
||||
#define __UIP_FW_H__
|
||||
|
@ -54,8 +54,8 @@
|
|||
struct uip_fw_netif {
|
||||
struct uip_fw_netif *next; /**< Pointer to the next interface when
|
||||
linked in a list. */
|
||||
u16_t ipaddr[2]; /**< The IP address of this interface. */
|
||||
u16_t netmask[2]; /**< The netmask of the interface. */
|
||||
uip_ipaddr_t ipaddr; /**< The IP address of this interface. */
|
||||
uip_ipaddr_t netmask; /**< The netmask of the interface. */
|
||||
u8_t (* output)(void);
|
||||
/**< A pointer to the function that
|
||||
sends a packet. */
|
||||
|
@ -79,8 +79,8 @@ struct uip_fw_netif {
|
|||
*/
|
||||
#define UIP_FW_NETIF(ip1,ip2,ip3,ip4, nm1,nm2,nm3,nm4, outputfunc) \
|
||||
NULL, \
|
||||
{HTONS((ip1 << 8) | ip2), HTONS((ip3 << 8) | ip4)}, \
|
||||
{HTONS((nm1 << 8) | nm2), HTONS((nm3 << 8) | nm4)}, \
|
||||
{ .u16 = {HTONS((ip1 << 8) | ip2), HTONS((ip3 << 8) | ip4)} }, \
|
||||
{ .u16 = {HTONS((nm1 << 8) | nm2), HTONS((nm3 << 8) | nm4)} }, \
|
||||
outputfunc
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: uip-neighbor.c,v 1.1 2006/06/17 22:41:19 adamdunkels Exp $
|
||||
* $Id: uip-neighbor.c,v 1.2 2006/08/09 16:13:40 bg- Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -42,6 +42,7 @@
|
|||
#include "net/uip-neighbor.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define MAX_TIME 128
|
||||
|
||||
|
@ -82,7 +83,7 @@ uip_neighbor_periodic(void)
|
|||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
uip_neighbor_add(uip_ipaddr_t ipaddr, struct uip_neighbor_addr *addr)
|
||||
uip_neighbor_add(uip_ipaddr_t *ipaddr, struct uip_neighbor_addr *addr)
|
||||
{
|
||||
int i, oldest;
|
||||
u8_t oldest_time;
|
||||
|
@ -99,7 +100,7 @@ uip_neighbor_add(uip_ipaddr_t ipaddr, struct uip_neighbor_addr *addr)
|
|||
oldest = i;
|
||||
break;
|
||||
}
|
||||
if(uip_ipaddr_cmp(entries[i].ipaddr, addr)) {
|
||||
if(uip_ipaddr_cmp(&entries[i].ipaddr, ipaddr)) {
|
||||
oldest = i;
|
||||
break;
|
||||
}
|
||||
|
@ -112,17 +113,17 @@ uip_neighbor_add(uip_ipaddr_t ipaddr, struct uip_neighbor_addr *addr)
|
|||
/* Use the oldest or first free entry (either pointed to by the
|
||||
"oldest" variable). */
|
||||
entries[oldest].time = 0;
|
||||
uip_ipaddr_copy(entries[oldest].ipaddr, ipaddr);
|
||||
uip_ipaddr_copy(&entries[oldest].ipaddr, ipaddr);
|
||||
memcpy(&entries[oldest].addr, addr, sizeof(struct uip_neighbor_addr));
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static struct neighbor_entry *
|
||||
find_entry(uip_ipaddr_t ipaddr)
|
||||
find_entry(uip_ipaddr_t *ipaddr)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < ENTRIES; ++i) {
|
||||
if(uip_ipaddr_cmp(entries[i].ipaddr, ipaddr)) {
|
||||
if(uip_ipaddr_cmp(&entries[i].ipaddr, ipaddr)) {
|
||||
return &entries[i];
|
||||
}
|
||||
}
|
||||
|
@ -130,7 +131,7 @@ find_entry(uip_ipaddr_t ipaddr)
|
|||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
uip_neighbor_update(uip_ipaddr_t ipaddr)
|
||||
uip_neighbor_update(uip_ipaddr_t *ipaddr)
|
||||
{
|
||||
struct neighbor_entry *e;
|
||||
|
||||
|
@ -141,7 +142,7 @@ uip_neighbor_update(uip_ipaddr_t ipaddr)
|
|||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
struct uip_neighbor_addr *
|
||||
uip_neighbor_lookup(uip_ipaddr_t ipaddr)
|
||||
uip_neighbor_lookup(uip_ipaddr_t *ipaddr)
|
||||
{
|
||||
struct neighbor_entry *e;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: uip-neighbor.h,v 1.1 2006/06/17 22:41:19 adamdunkels Exp $
|
||||
* $Id: uip-neighbor.h,v 1.2 2006/08/09 16:13:40 bg- Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -53,9 +53,9 @@ struct uip_neighbor_addr {
|
|||
};
|
||||
|
||||
void uip_neighbor_init(void);
|
||||
void uip_neighbor_add(uip_ipaddr_t ipaddr, struct uip_neighbor_addr *addr);
|
||||
void uip_neighbor_update(uip_ipaddr_t ipaddr);
|
||||
struct uip_neighbor_addr *uip_neighbor_lookup(uip_ipaddr_t ipaddr);
|
||||
void uip_neighbor_add(uip_ipaddr_t *ipaddr, struct uip_neighbor_addr *addr);
|
||||
void uip_neighbor_update(uip_ipaddr_t *ipaddr);
|
||||
struct uip_neighbor_addr *uip_neighbor_lookup(uip_ipaddr_t *ipaddr);
|
||||
void uip_neighbor_periodic(void);
|
||||
|
||||
#endif /* __UIP-NEIGHBOR_H__ */
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: uip.c,v 1.1 2006/06/17 22:41:19 adamdunkels Exp $
|
||||
* $Id: uip.c,v 1.2 2006/08/09 16:13:40 bg- Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -106,13 +106,13 @@ const uip_ipaddr_t uip_broadcast_addr =
|
|||
#if UIP_CONF_IPV6
|
||||
{0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff};
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
{0xffff,0xffff};
|
||||
{ .u16 = {0xffff,0xffff} };
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
static const uip_ipaddr_t all_zeroes_addr =
|
||||
const uip_ipaddr_t all_zeroes_addr =
|
||||
#if UIP_CONF_IPV6
|
||||
{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000};
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
{0x0000,0x0000};
|
||||
{ .u16 = {0x0000,0x0000} };
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
|
||||
|
@ -334,7 +334,7 @@ upper_layer_chksum(u8_t proto)
|
|||
/* IP protocol and length fields. This addition cannot carry. */
|
||||
sum = upper_layer_len + proto;
|
||||
/* Sum IP source and destination addresses. */
|
||||
sum = chksum(sum, (u8_t *)&BUF->srcipaddr[0], 2 * sizeof(uip_ipaddr_t));
|
||||
sum = chksum(sum, (u8_t *)&BUF->srcipaddr, 2 * sizeof(uip_ipaddr_t));
|
||||
|
||||
/* Sum TCP header and data. */
|
||||
sum = chksum(sum, &uip_buf[UIP_IPH_LEN + UIP_LLH_LEN],
|
||||
|
@ -496,7 +496,7 @@ uip_udp_new(uip_ipaddr_t *ripaddr, u16_t rport)
|
|||
conn->lport = HTONS(lastport);
|
||||
conn->rport = rport;
|
||||
if(ripaddr == NULL) {
|
||||
memset(conn->ripaddr, 0, sizeof(uip_ipaddr_t));
|
||||
memset(&conn->ripaddr, 0, sizeof(uip_ipaddr_t));
|
||||
} else {
|
||||
uip_ipaddr_copy(&conn->ripaddr, ripaddr);
|
||||
}
|
||||
|
@ -881,7 +881,7 @@ uip_process(u8_t flag)
|
|||
}
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
if(uip_ipaddr_cmp(uip_hostaddr, all_zeroes_addr)) {
|
||||
if(uip_ipaddr_cmp(&uip_hostaddr, &all_zeroes_addr)) {
|
||||
/* If we are configured to use ping IP address configuration and
|
||||
hasn't been assigned an IP address yet, we accept all ICMP
|
||||
packets. */
|
||||
|
@ -901,7 +901,7 @@ uip_process(u8_t flag)
|
|||
#if UIP_BROADCAST
|
||||
DEBUG_PRINTF("UDP IP checksum 0x%04x\n", uip_ipchksum());
|
||||
if(BUF->proto == UIP_PROTO_UDP &&
|
||||
uip_ipaddr_cmp(BUF->destipaddr, uip_broadcast_addr)
|
||||
uip_ipaddr_cmp(&BUF->destipaddr, &uip_broadcast_addr)
|
||||
/*&&
|
||||
uip_ipchksum() == 0xffff*/) {
|
||||
goto udp_input;
|
||||
|
@ -910,7 +910,7 @@ uip_process(u8_t flag)
|
|||
|
||||
/* Check if the packet is destined for our IP address. */
|
||||
#if !UIP_CONF_IPV6
|
||||
if(!uip_ipaddr_cmp(BUF->destipaddr, uip_hostaddr)) {
|
||||
if(!uip_ipaddr_cmp(&BUF->destipaddr, &uip_hostaddr)) {
|
||||
UIP_STAT(++uip_stat.ip.drop);
|
||||
goto drop;
|
||||
}
|
||||
|
@ -979,9 +979,8 @@ uip_process(u8_t flag)
|
|||
the destination IP address of this ping packet and assign it to
|
||||
ourself. */
|
||||
#if UIP_PINGADDRCONF
|
||||
if((uip_hostaddr[0] | uip_hostaddr[1]) == 0) {
|
||||
uip_hostaddr[0] = BUF->destipaddr[0];
|
||||
uip_hostaddr[1] = BUF->destipaddr[1];
|
||||
if(uip_ipaddr_cmp(&uip_hostaddr, &all_zeroes_addr)) {
|
||||
uip_hostaddr = BUF->destipaddr;
|
||||
}
|
||||
#endif /* UIP_PINGADDRCONF */
|
||||
|
||||
|
@ -994,8 +993,8 @@ uip_process(u8_t flag)
|
|||
}
|
||||
|
||||
/* Swap IP addresses. */
|
||||
uip_ipaddr_copy(BUF->destipaddr, BUF->srcipaddr);
|
||||
uip_ipaddr_copy(BUF->srcipaddr, uip_hostaddr);
|
||||
uip_ipaddr_copy(&BUF->destipaddr, &BUF->srcipaddr);
|
||||
uip_ipaddr_copy(&BUF->srcipaddr, &uip_hostaddr);
|
||||
|
||||
UIP_STAT(++uip_stat.icmp.sent);
|
||||
goto send;
|
||||
|
@ -1105,9 +1104,9 @@ uip_process(u8_t flag)
|
|||
UDPBUF->destport == uip_udp_conn->lport &&
|
||||
(uip_udp_conn->rport == 0 ||
|
||||
UDPBUF->srcport == uip_udp_conn->rport) &&
|
||||
(uip_ipaddr_cmp(uip_udp_conn->ripaddr, all_zeroes_addr) ||
|
||||
uip_ipaddr_cmp(uip_udp_conn->ripaddr, uip_broadcast_addr) ||
|
||||
uip_ipaddr_cmp(BUF->srcipaddr, uip_udp_conn->ripaddr))) {
|
||||
(uip_ipaddr_cmp(&uip_udp_conn->ripaddr, &all_zeroes_addr) ||
|
||||
uip_ipaddr_cmp(&uip_udp_conn->ripaddr, &uip_broadcast_addr) ||
|
||||
uip_ipaddr_cmp(&BUF->srcipaddr, &uip_udp_conn->ripaddr))) {
|
||||
goto udp_found;
|
||||
}
|
||||
}
|
||||
|
@ -1145,8 +1144,8 @@ uip_process(u8_t flag)
|
|||
BUF->srcport = uip_udp_conn->lport;
|
||||
BUF->destport = uip_udp_conn->rport;
|
||||
|
||||
uip_ipaddr_copy(BUF->srcipaddr, uip_hostaddr);
|
||||
uip_ipaddr_copy(BUF->destipaddr, uip_udp_conn->ripaddr);
|
||||
uip_ipaddr_copy(&BUF->srcipaddr, &uip_hostaddr);
|
||||
uip_ipaddr_copy(&BUF->destipaddr, &uip_udp_conn->ripaddr);
|
||||
|
||||
uip_appdata = &uip_buf[UIP_LLH_LEN + UIP_IPTCPH_LEN];
|
||||
|
||||
|
@ -1183,7 +1182,7 @@ uip_process(u8_t flag)
|
|||
if(uip_connr->tcpstateflags != UIP_CLOSED &&
|
||||
BUF->destport == uip_connr->lport &&
|
||||
BUF->srcport == uip_connr->rport &&
|
||||
uip_ipaddr_cmp(BUF->srcipaddr, uip_connr->ripaddr)) {
|
||||
uip_ipaddr_cmp(&BUF->srcipaddr, &uip_connr->ripaddr)) {
|
||||
goto found;
|
||||
}
|
||||
}
|
||||
|
@ -1252,8 +1251,8 @@ uip_process(u8_t flag)
|
|||
BUF->destport = tmp16;
|
||||
|
||||
/* Swap IP addresses. */
|
||||
uip_ipaddr_copy(BUF->destipaddr, BUF->srcipaddr);
|
||||
uip_ipaddr_copy(BUF->srcipaddr, uip_hostaddr);
|
||||
uip_ipaddr_copy(&BUF->destipaddr, &BUF->srcipaddr);
|
||||
uip_ipaddr_copy(&BUF->srcipaddr, &uip_hostaddr);
|
||||
|
||||
/* And send out the RST packet! */
|
||||
goto tcp_send_noconn;
|
||||
|
@ -1299,7 +1298,7 @@ uip_process(u8_t flag)
|
|||
uip_connr->nrtx = 0;
|
||||
uip_connr->lport = BUF->destport;
|
||||
uip_connr->rport = BUF->srcport;
|
||||
uip_ipaddr_copy(uip_connr->ripaddr, BUF->srcipaddr);
|
||||
uip_ipaddr_copy(&uip_connr->ripaddr, &BUF->srcipaddr);
|
||||
uip_connr->tcpstateflags = UIP_SYN_RCVD;
|
||||
|
||||
uip_connr->snd_nxt[0] = iss[0];
|
||||
|
@ -1806,8 +1805,8 @@ uip_process(u8_t flag)
|
|||
BUF->srcport = uip_connr->lport;
|
||||
BUF->destport = uip_connr->rport;
|
||||
|
||||
uip_ipaddr_copy(BUF->srcipaddr, uip_hostaddr);
|
||||
uip_ipaddr_copy(BUF->destipaddr, uip_connr->ripaddr);
|
||||
uip_ipaddr_copy(&BUF->srcipaddr, &uip_hostaddr);
|
||||
uip_ipaddr_copy(&BUF->destipaddr, &uip_connr->ripaddr);
|
||||
|
||||
if(uip_connr->tcpstateflags & UIP_STOPPED) {
|
||||
/* If the connection has issued uip_stop(), we advertise a zero
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: uip.h,v 1.1 2006/06/17 22:41:19 adamdunkels Exp $
|
||||
* $Id: uip.h,v 1.2 2006/08/09 16:13:40 bg- Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -56,17 +56,30 @@
|
|||
#include "net/uipopt.h"
|
||||
|
||||
/**
|
||||
* Repressentation of an IP address.
|
||||
* Representation of an IP address.
|
||||
*
|
||||
*/
|
||||
typedef u16_t uip_ip4addr_t[2];
|
||||
typedef u16_t uip_ip6addr_t[8];
|
||||
typedef union uip_ip4addr_t {
|
||||
u16_t u16[2]; /* Must come first for now!!! */
|
||||
u8_t u8[4];
|
||||
#if 0
|
||||
u32_t u32;
|
||||
#endif
|
||||
} uip_ip4addr_t;
|
||||
|
||||
typedef union uip_ip6addr_t {
|
||||
u16_t u16[8];
|
||||
u8_t u8[16];
|
||||
} uip_ip6addr_t;
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
typedef uip_ip6addr_t uip_ipaddr_t;
|
||||
#else /* UIP_CONF_IPV6 */
|
||||
typedef uip_ip4addr_t uip_ipaddr_t;
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
#include "net/tcpip.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* First, the functions that should be called from the
|
||||
* system. Initialization, the periodic timer and incoming packets are
|
||||
|
@ -103,7 +116,7 @@ typedef uip_ip4addr_t uip_ipaddr_t;
|
|||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define uip_sethostaddr(addr) uip_ipaddr_copy(uip_hostaddr, (addr))
|
||||
#define uip_sethostaddr(addr) uip_ipaddr_copy(&uip_hostaddr, (addr))
|
||||
|
||||
/**
|
||||
* Get the IP address of this host.
|
||||
|
@ -123,7 +136,7 @@ typedef uip_ip4addr_t uip_ipaddr_t;
|
|||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define uip_gethostaddr(addr) uip_ipaddr_copy((addr), uip_hostaddr)
|
||||
#define uip_gethostaddr(addr) uip_ipaddr_copy((addr), &uip_hostaddr)
|
||||
|
||||
/**
|
||||
* Set the default router's IP address.
|
||||
|
@ -135,7 +148,7 @@ typedef uip_ip4addr_t uip_ipaddr_t;
|
|||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define uip_setdraddr(addr) uip_ipaddr_copy(uip_draddr, (addr))
|
||||
#define uip_setdraddr(addr) uip_ipaddr_copy(&uip_draddr, (addr))
|
||||
|
||||
/**
|
||||
* Set the netmask.
|
||||
|
@ -147,7 +160,7 @@ typedef uip_ip4addr_t uip_ipaddr_t;
|
|||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define uip_setnetmask(addr) uip_ipaddr_copy(uip_netmask, (addr))
|
||||
#define uip_setnetmask(addr) uip_ipaddr_copy(&uip_netmask, (addr))
|
||||
|
||||
|
||||
/**
|
||||
|
@ -158,7 +171,7 @@ typedef uip_ip4addr_t uip_ipaddr_t;
|
|||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define uip_getdraddr(addr) uip_ipaddr_copy((addr), uip_draddr)
|
||||
#define uip_getdraddr(addr) uip_ipaddr_copy((addr), &uip_draddr)
|
||||
|
||||
/**
|
||||
* Get the netmask.
|
||||
|
@ -168,7 +181,7 @@ typedef uip_ip4addr_t uip_ipaddr_t;
|
|||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define uip_getnetmask(addr) uip_ipaddr_copy((addr), uip_netmask)
|
||||
#define uip_getnetmask(addr) uip_ipaddr_copy((addr), &uip_netmask)
|
||||
|
||||
/** @} */
|
||||
|
||||
|
@ -838,8 +851,10 @@ struct uip_udp_conn *uip_udp_new(uip_ipaddr_t *ripaddr, u16_t rport);
|
|||
* \hideinitializer
|
||||
*/
|
||||
#define uip_ipaddr(addr, addr0,addr1,addr2,addr3) do { \
|
||||
((u16_t *)(addr))[0] = HTONS(((addr0) << 8) | (addr1)); \
|
||||
((u16_t *)(addr))[1] = HTONS(((addr2) << 8) | (addr3)); \
|
||||
(addr)->u8[0] = addr0; \
|
||||
(addr)->u8[1] = addr1; \
|
||||
(addr)->u8[2] = addr2; \
|
||||
(addr)->u8[3] = addr3; \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
|
@ -878,14 +893,7 @@ struct uip_udp_conn *uip_udp_new(uip_ipaddr_t *ripaddr, u16_t rport);
|
|||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#if !UIP_CONF_IPV6
|
||||
#define uip_ipaddr_copy(dest, src) do { \
|
||||
((u16_t *)dest)[0] = ((u16_t *)src)[0]; \
|
||||
((u16_t *)dest)[1] = ((u16_t *)src)[1]; \
|
||||
} while(0)
|
||||
#else /* !UIP_CONF_IPV6 */
|
||||
#define uip_ipaddr_copy(dest, src) memcpy(dest, src, sizeof(uip_ip6addr_t))
|
||||
#endif /* !UIP_CONF_IPV6 */
|
||||
#define uip_ipaddr_copy(dest, src) ((*dest) = (*src))
|
||||
|
||||
/**
|
||||
* Compare two IP addresses
|
||||
|
@ -908,8 +916,8 @@ struct uip_udp_conn *uip_udp_new(uip_ipaddr_t *ripaddr, u16_t rport);
|
|||
* \hideinitializer
|
||||
*/
|
||||
#if !UIP_CONF_IPV6
|
||||
#define uip_ipaddr_cmp(addr1, addr2) (((u16_t *)addr1)[0] == ((u16_t *)addr2)[0] && \
|
||||
((u16_t *)addr1)[1] == ((u16_t *)addr2)[1])
|
||||
#define uip_ipaddr_cmp(addr1, addr2) ((addr1)->u16[0] == (addr2)->u16[0] && \
|
||||
(addr1)->u16[1] == (addr2)->u16[1])
|
||||
#else /* !UIP_CONF_IPV6 */
|
||||
#define uip_ipaddr_cmp(addr1, addr2) (memcmp(addr1, addr2, sizeof(uip_ip6addr_t)) == 0)
|
||||
#endif /* !UIP_CONF_IPV6 */
|
||||
|
@ -992,7 +1000,7 @@ struct uip_udp_conn *uip_udp_new(uip_ipaddr_t *ripaddr, u16_t rport);
|
|||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define uip_ipaddr1(addr) (htons(((u16_t *)(addr))[0]) >> 8)
|
||||
#define uip_ipaddr1(addr) ((addr)->u8[0])
|
||||
|
||||
/**
|
||||
* Pick the second octet of an IP address.
|
||||
|
@ -1012,7 +1020,7 @@ struct uip_udp_conn *uip_udp_new(uip_ipaddr_t *ripaddr, u16_t rport);
|
|||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define uip_ipaddr2(addr) (htons(((u16_t *)(addr))[0]) & 0xff)
|
||||
#define uip_ipaddr2(addr) ((addr)->u8[1])
|
||||
|
||||
/**
|
||||
* Pick the third octet of an IP address.
|
||||
|
@ -1032,7 +1040,7 @@ struct uip_udp_conn *uip_udp_new(uip_ipaddr_t *ripaddr, u16_t rport);
|
|||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define uip_ipaddr3(addr) (htons(((u16_t *)(addr))[1]) >> 8)
|
||||
#define uip_ipaddr3(addr) ((addr)->u8[2])
|
||||
|
||||
/**
|
||||
* Pick the fourth octet of an IP address.
|
||||
|
@ -1052,7 +1060,7 @@ struct uip_udp_conn *uip_udp_new(uip_ipaddr_t *ripaddr, u16_t rport);
|
|||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define uip_ipaddr4(addr) (htons(((u16_t *)(addr))[1]) & 0xff)
|
||||
#define uip_ipaddr4(addr) ((addr)->u8[3])
|
||||
|
||||
/**
|
||||
* Convert 16-bit quantity from host byte order to network byte order.
|
||||
|
@ -1403,8 +1411,7 @@ struct uip_tcpip_hdr {
|
|||
ttl,
|
||||
proto;
|
||||
u16_t ipchksum;
|
||||
u16_t srcipaddr[2],
|
||||
destipaddr[2];
|
||||
uip_ipaddr_t srcipaddr, destipaddr;
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
/* TCP header. */
|
||||
|
@ -1440,8 +1447,7 @@ struct uip_icmpip_hdr {
|
|||
ttl,
|
||||
proto;
|
||||
u16_t ipchksum;
|
||||
u16_t srcipaddr[2],
|
||||
destipaddr[2];
|
||||
uip_ipaddr_t srcipaddr, destipaddr;
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
/* ICMP (echo) header. */
|
||||
|
@ -1477,8 +1483,7 @@ struct uip_udpip_hdr {
|
|||
ttl,
|
||||
proto;
|
||||
u16_t ipchksum;
|
||||
u16_t srcipaddr[2],
|
||||
destipaddr[2];
|
||||
uip_ipaddr_t srcipaddr, destipaddr;
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
|
||||
/* UDP header. */
|
||||
|
@ -1535,6 +1540,7 @@ extern const uip_ipaddr_t uip_hostaddr, uip_netmask, uip_draddr;
|
|||
extern uip_ipaddr_t uip_hostaddr, uip_netmask, uip_draddr;
|
||||
#endif /* UIP_FIXEDADDR */
|
||||
extern const uip_ipaddr_t uip_broadcast_addr;
|
||||
extern const uip_ipaddr_t all_zeroes_addr;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: uip_arp.c,v 1.1 2006/06/17 22:41:19 adamdunkels Exp $
|
||||
* $Id: uip_arp.c,v 1.2 2006/08/09 16:13:40 bg- Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -71,9 +71,9 @@ struct arp_hdr {
|
|||
u8_t protolen;
|
||||
u16_t opcode;
|
||||
struct uip_eth_addr shwaddr;
|
||||
u16_t sipaddr[2];
|
||||
uip_ipaddr_t sipaddr;
|
||||
struct uip_eth_addr dhwaddr;
|
||||
u16_t dipaddr[2];
|
||||
uip_ipaddr_t dipaddr;
|
||||
};
|
||||
|
||||
struct ethip_hdr {
|
||||
|
@ -87,8 +87,7 @@ struct ethip_hdr {
|
|||
ttl,
|
||||
proto;
|
||||
u16_t ipchksum;
|
||||
u16_t srcipaddr[2],
|
||||
destipaddr[2];
|
||||
uip_ipaddr_t srcipaddr, destipaddr;
|
||||
};
|
||||
|
||||
#define ARP_REQUEST 1
|
||||
|
@ -97,7 +96,7 @@ struct ethip_hdr {
|
|||
#define ARP_HWTYPE_ETH 1
|
||||
|
||||
struct arp_entry {
|
||||
u16_t ipaddr[2];
|
||||
uip_ipaddr_t ipaddr;
|
||||
struct uip_eth_addr ethaddr;
|
||||
u8_t time;
|
||||
};
|
||||
|
@ -107,7 +106,7 @@ static const struct uip_eth_addr broadcast_ethaddr =
|
|||
static const u16_t broadcast_ipaddr[2] = {0xffff,0xffff};
|
||||
|
||||
static struct arp_entry arp_table[UIP_ARPTAB_SIZE];
|
||||
static u16_t ipaddr[2];
|
||||
static uip_ipaddr_t ipaddr;
|
||||
static u8_t i, c;
|
||||
|
||||
static u8_t arptime;
|
||||
|
@ -125,7 +124,7 @@ void
|
|||
uip_arp_init(void)
|
||||
{
|
||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||
memset(arp_table[i].ipaddr, 0, 4);
|
||||
memset(&arp_table[i].ipaddr, 0, 4);
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
@ -146,16 +145,16 @@ uip_arp_timer(void)
|
|||
++arptime;
|
||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||
tabptr = &arp_table[i];
|
||||
if((tabptr->ipaddr[0] | tabptr->ipaddr[1]) != 0 &&
|
||||
if(uip_ipaddr_cmp(&tabptr->ipaddr, &all_zeroes_addr) &&
|
||||
arptime - tabptr->time >= UIP_ARP_MAXAGE) {
|
||||
memset(tabptr->ipaddr, 0, 4);
|
||||
memset(&tabptr->ipaddr, 0, 4);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
uip_arp_update(u16_t *ipaddr, struct uip_eth_addr *ethaddr)
|
||||
uip_arp_update(uip_ipaddr_t *ipaddr, struct uip_eth_addr *ethaddr)
|
||||
{
|
||||
register struct arp_entry *tabptr;
|
||||
/* Walk through the ARP mapping table and try to find an entry to
|
||||
|
@ -165,13 +164,11 @@ uip_arp_update(u16_t *ipaddr, struct uip_eth_addr *ethaddr)
|
|||
|
||||
tabptr = &arp_table[i];
|
||||
/* Only check those entries that are actually in use. */
|
||||
if(tabptr->ipaddr[0] != 0 &&
|
||||
tabptr->ipaddr[1] != 0) {
|
||||
if(!uip_ipaddr_cmp(&tabptr->ipaddr, &all_zeroes_addr)) {
|
||||
|
||||
/* Check if the source IP address of the incoming packet matches
|
||||
the IP address in this ARP table entry. */
|
||||
if(ipaddr[0] == tabptr->ipaddr[0] &&
|
||||
ipaddr[1] == tabptr->ipaddr[1]) {
|
||||
if(uip_ipaddr_cmp(ipaddr, &tabptr->ipaddr)) {
|
||||
|
||||
/* An old entry found, update this and return. */
|
||||
memcpy(tabptr->ethaddr.addr, ethaddr->addr, 6);
|
||||
|
@ -188,8 +185,7 @@ uip_arp_update(u16_t *ipaddr, struct uip_eth_addr *ethaddr)
|
|||
/* First, we try to find an unused entry in the ARP table. */
|
||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||
tabptr = &arp_table[i];
|
||||
if(tabptr->ipaddr[0] == 0 &&
|
||||
tabptr->ipaddr[1] == 0) {
|
||||
if(uip_ipaddr_cmp(&tabptr->ipaddr, &all_zeroes_addr)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -212,7 +208,7 @@ uip_arp_update(u16_t *ipaddr, struct uip_eth_addr *ethaddr)
|
|||
|
||||
/* Now, i is the ARP table entry which we will fill with the new
|
||||
information. */
|
||||
memcpy(tabptr->ipaddr, ipaddr, 4);
|
||||
tabptr->ipaddr = *ipaddr;
|
||||
memcpy(tabptr->ethaddr.addr, ethaddr->addr, 6);
|
||||
tabptr->time = arptime;
|
||||
}
|
||||
|
@ -290,11 +286,11 @@ uip_arp_arpin(void)
|
|||
reply. */
|
||||
/* if(BUF->dipaddr[0] == uip_hostaddr[0] &&
|
||||
BUF->dipaddr[1] == uip_hostaddr[1]) {*/
|
||||
if(uip_ipaddr_cmp(BUF->dipaddr, uip_hostaddr)) {
|
||||
if(uip_ipaddr_cmp(&BUF->dipaddr, &uip_hostaddr)) {
|
||||
/* First, we register the one who made the request in our ARP
|
||||
table, since it is likely that we will do more communication
|
||||
with this host in the future. */
|
||||
uip_arp_update(BUF->sipaddr, &BUF->shwaddr);
|
||||
uip_arp_update(&BUF->sipaddr, &BUF->shwaddr);
|
||||
|
||||
/* The reply opcode is 2. */
|
||||
BUF->opcode = HTONS(2);
|
||||
|
@ -304,10 +300,8 @@ uip_arp_arpin(void)
|
|||
memcpy(BUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
|
||||
memcpy(BUF->ethhdr.dest.addr, BUF->dhwaddr.addr, 6);
|
||||
|
||||
BUF->dipaddr[0] = BUF->sipaddr[0];
|
||||
BUF->dipaddr[1] = BUF->sipaddr[1];
|
||||
BUF->sipaddr[0] = uip_hostaddr[0];
|
||||
BUF->sipaddr[1] = uip_hostaddr[1];
|
||||
BUF->dipaddr = BUF->sipaddr;
|
||||
BUF->sipaddr = uip_hostaddr;
|
||||
|
||||
BUF->ethhdr.type = HTONS(UIP_ETHTYPE_ARP);
|
||||
uip_len = sizeof(struct arp_hdr);
|
||||
|
@ -318,8 +312,8 @@ uip_arp_arpin(void)
|
|||
for us. */
|
||||
/* if(BUF->dipaddr[0] == uip_hostaddr[0] &&
|
||||
BUF->dipaddr[1] == uip_hostaddr[1]) {*/
|
||||
if(uip_ipaddr_cmp(BUF->dipaddr, uip_hostaddr)) {
|
||||
uip_arp_update(BUF->sipaddr, &BUF->shwaddr);
|
||||
if(uip_ipaddr_cmp(&BUF->dipaddr, &uip_hostaddr)) {
|
||||
uip_arp_update(&BUF->sipaddr, &BUF->shwaddr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -367,23 +361,23 @@ uip_arp_out(void)
|
|||
packet with an ARP request for the IP address. */
|
||||
|
||||
/* First check if destination is a local broadcast. */
|
||||
if(uip_ipaddr_cmp(IPBUF->destipaddr, broadcast_ipaddr)) {
|
||||
if(uip_ipaddr_cmp(&IPBUF->destipaddr, &uip_broadcast_addr)) {
|
||||
memcpy(IPBUF->ethhdr.dest.addr, broadcast_ethaddr.addr, 6);
|
||||
} else {
|
||||
/* Check if the destination address is on the local network. */
|
||||
if(!uip_ipaddr_maskcmp(IPBUF->destipaddr, uip_hostaddr, uip_netmask)) {
|
||||
if(!uip_ipaddr_maskcmp(&IPBUF->destipaddr, &uip_hostaddr, &uip_netmask)) {
|
||||
/* Destination address was not on the local network, so we need to
|
||||
use the default router's IP address instead of the destination
|
||||
address when determining the MAC address. */
|
||||
uip_ipaddr_copy(ipaddr, uip_draddr);
|
||||
uip_ipaddr_copy(&ipaddr, &uip_draddr);
|
||||
} else {
|
||||
/* Else, we use the destination IP address. */
|
||||
uip_ipaddr_copy(ipaddr, IPBUF->destipaddr);
|
||||
uip_ipaddr_copy(&ipaddr, &IPBUF->destipaddr);
|
||||
}
|
||||
|
||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||
tabptr = &arp_table[i];
|
||||
if(uip_ipaddr_cmp(ipaddr, tabptr->ipaddr)) {
|
||||
if(uip_ipaddr_cmp(&ipaddr, &tabptr->ipaddr)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -397,8 +391,8 @@ uip_arp_out(void)
|
|||
memcpy(BUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
|
||||
memcpy(BUF->shwaddr.addr, uip_ethaddr.addr, 6);
|
||||
|
||||
uip_ipaddr_copy(BUF->dipaddr, ipaddr);
|
||||
uip_ipaddr_copy(BUF->sipaddr, uip_hostaddr);
|
||||
uip_ipaddr_copy(&BUF->dipaddr, &ipaddr);
|
||||
uip_ipaddr_copy(&BUF->sipaddr, &uip_hostaddr);
|
||||
BUF->opcode = HTONS(ARP_REQUEST); /* ARP request. */
|
||||
BUF->hwtype = HTONS(ARP_HWTYPE_ETH);
|
||||
BUF->protocol = HTONS(UIP_ETHTYPE_IP);
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: uipopt.h,v 1.1 2006/06/17 22:41:19 adamdunkels Exp $
|
||||
* $Id: uipopt.h,v 1.2 2006/08/09 16:13:40 bg- Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -540,7 +540,5 @@ typedef struct httpd_state uip_tcp_appstate_t
|
|||
*/
|
||||
/** @} */
|
||||
|
||||
#include "net/tcpip.h"
|
||||
|
||||
#endif /* __UIPOPT_H__ */
|
||||
/** @} */
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* @(#)$Id: contiki-esb-default-init-net.c,v 1.1 2006/06/17 22:41:27 adamdunkels Exp $
|
||||
* @(#)$Id: contiki-esb-default-init-net.c,v 1.2 2006/08/09 16:13:40 bg- Exp $
|
||||
*/
|
||||
|
||||
#include "contiki-esb.h"
|
||||
|
@ -44,7 +44,7 @@ static struct uip_fw_netif slipif =
|
|||
void
|
||||
init_net(void)
|
||||
{
|
||||
u16_t hostaddr[2];
|
||||
uip_ipaddr_t hostaddr;
|
||||
|
||||
rs232_set_input(slip_input_byte);
|
||||
|
||||
|
@ -53,8 +53,8 @@ init_net(void)
|
|||
|
||||
if (NODE_ID > 0) {
|
||||
/* node id is set, construct an ip address based on the node id */
|
||||
uip_ipaddr(hostaddr, 172, 16, 1, NODE_ID);
|
||||
uip_sethostaddr(hostaddr);
|
||||
uip_ipaddr(&hostaddr, 172, 16, 1, NODE_ID);
|
||||
uip_sethostaddr(&hostaddr);
|
||||
}
|
||||
uip_fw_register(&slipif);
|
||||
uip_fw_default(&tr1001if);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
*
|
||||
* This file is part of the Contiki OS
|
||||
*
|
||||
* $Id: contiki-main.c,v 1.1 2006/06/17 22:41:31 adamdunkels Exp $
|
||||
* $Id: contiki-main.c,v 1.2 2006/08/09 16:13:40 bg- Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -57,14 +57,14 @@ main(void)
|
|||
|
||||
autostart_start(autostart_processes);
|
||||
|
||||
uip_ipaddr(addr, 192,168,2,2);
|
||||
uip_sethostaddr(addr);
|
||||
uip_ipaddr(&addr, 192,168,2,2);
|
||||
uip_sethostaddr(&addr);
|
||||
|
||||
uip_ipaddr(addr, 192,168,2,1);
|
||||
uip_setdraddr(addr);
|
||||
uip_ipaddr(&addr, 192,168,2,1);
|
||||
uip_setdraddr(&addr);
|
||||
|
||||
uip_ipaddr(addr, 255,255,255,0);
|
||||
uip_setnetmask(addr);
|
||||
uip_ipaddr(&addr, 255,255,255,0);
|
||||
uip_setnetmask(&addr);
|
||||
|
||||
printf("Contiki initiated, now starting process scheduling\n");
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)$Id: dhclient.c,v 1.1 2006/08/02 14:44:46 bg- Exp $
|
||||
* @(#)$Id: dhclient.c,v 1.2 2006/08/09 16:13:40 bg- Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -100,7 +100,7 @@ main(int argc, char **argv)
|
|||
leds_toggle(LEDS_RED | LEDS_GREEN | LEDS_BLUE);
|
||||
slip_arch_init(); /* Must come before first printf */
|
||||
printf("Starting %s "
|
||||
"($Id: dhclient.c,v 1.1 2006/08/02 14:44:46 bg- Exp $)\n", __FILE__);
|
||||
"($Id: dhclient.c,v 1.2 2006/08/09 16:13:40 bg- Exp $)\n", __FILE__);
|
||||
ds2411_init();
|
||||
sensors_light_init();
|
||||
cc2420_init();
|
||||
|
@ -194,7 +194,7 @@ PROCESS_THREAD(dhclient_process, ev, data)
|
|||
|
||||
/* For now use 0.0.0.0 as our IP address. */
|
||||
uip_ipaddr(&uip_hostaddr, 0,0,0,0);
|
||||
cc2420_set_chan_pan_addr(RF_CHANNEL, panId, uip_hostaddr[1], ds2411_id);
|
||||
cc2420_set_chan_pan_addr(RF_CHANNEL, panId, uip_hostaddr.u16[1], ds2411_id);
|
||||
|
||||
/* Use only radio interface and enable forwarding. */
|
||||
uip_fw_default(&cc2420if);
|
||||
|
@ -230,18 +230,18 @@ dhcpc_configured(const struct dhcpc_state *s)
|
|||
process_start(&uaodv_process, NULL);
|
||||
}
|
||||
|
||||
uip_sethostaddr(s->ipaddr);
|
||||
uip_setnetmask(s->netmask);
|
||||
uip_setdraddr(s->default_router);
|
||||
uip_sethostaddr(&s->ipaddr);
|
||||
uip_setnetmask(&s->netmask);
|
||||
uip_setdraddr(&s->default_router);
|
||||
|
||||
uip_ipaddr_copy(&cc2420if.ipaddr, s->ipaddr);
|
||||
uip_ipaddr_copy(&cc2420if.netmask, s->netmask);
|
||||
uip_ipaddr_copy(&cc2420if.ipaddr, &s->ipaddr);
|
||||
uip_ipaddr_copy(&cc2420if.netmask, &s->netmask);
|
||||
/* resolv_conf(s->dnsaddr); */
|
||||
|
||||
/*
|
||||
* Now we also have a new short MAC address!
|
||||
*/
|
||||
cc2420_set_chan_pan_addr(RF_CHANNEL, panId, uip_hostaddr[1], ds2411_id);
|
||||
cc2420_set_chan_pan_addr(RF_CHANNEL, panId, uip_hostaddr.u16[1], ds2411_id);
|
||||
|
||||
/* Use only radio interface and enable forwarding. */
|
||||
uip_fw_init();
|
||||
|
@ -257,10 +257,10 @@ dhcpc_unconfigured(const struct dhcpc_state *s)
|
|||
is_configured = 0;
|
||||
process_exit(&uaodv_process);
|
||||
|
||||
uip_ipaddr(uip_hostaddr, 0,0,0,0);
|
||||
uip_ipaddr(uip_netmask, 0,0,0,0);
|
||||
uip_ipaddr(uip_draddr, 0,0,0,0);
|
||||
uip_ipaddr(&uip_hostaddr, 0,0,0,0);
|
||||
uip_ipaddr(&uip_netmask, 0,0,0,0);
|
||||
uip_ipaddr(&uip_draddr, 0,0,0,0);
|
||||
|
||||
/* New short MAC address. */
|
||||
cc2420_set_chan_pan_addr(RF_CHANNEL, panId, uip_hostaddr[1], ds2411_id);
|
||||
cc2420_set_chan_pan_addr(RF_CHANNEL, panId, uip_hostaddr.u16[1], ds2411_id);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)$Id: gateway.c,v 1.1 2006/08/02 14:44:46 bg- Exp $
|
||||
* @(#)$Id: gateway.c,v 1.2 2006/08/09 16:13:40 bg- Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -110,7 +110,7 @@ main(int argc, char **argv)
|
|||
leds_toggle(LEDS_RED | LEDS_GREEN | LEDS_BLUE);
|
||||
slip_arch_init(); /* Must come before first printf */
|
||||
printf("Starting %s "
|
||||
"($Id: gateway.c,v 1.1 2006/08/02 14:44:46 bg- Exp $)\n", __FILE__);
|
||||
"($Id: gateway.c,v 1.2 2006/08/09 16:13:40 bg- Exp $)\n", __FILE__);
|
||||
ds2411_init();
|
||||
sensors_light_init();
|
||||
cc2420_init();
|
||||
|
@ -128,7 +128,7 @@ main(int argc, char **argv)
|
|||
uip_ipaddr_copy(&uip_netmask, &cc2420if.netmask);
|
||||
printf("IP %d.%d.%d.%d netmask %d.%d.%d.%d\n",
|
||||
ip2quad(&uip_hostaddr), ip2quad(&uip_netmask));
|
||||
cc2420_set_chan_pan_addr(RF_CHANNEL, panId, uip_hostaddr[1], ds2411_id);
|
||||
cc2420_set_chan_pan_addr(RF_CHANNEL, panId, uip_hostaddr.u16[1], ds2411_id);
|
||||
|
||||
/*
|
||||
* Initialize Contiki and our processes.
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* @(#)$Id: udprecv.c,v 1.1 2006/08/02 14:44:46 bg- Exp $
|
||||
* @(#)$Id: udprecv.c,v 1.2 2006/08/09 16:13:40 bg- Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -51,7 +51,7 @@ PROCESS_THREAD(udprecv_process, ev, data)
|
|||
{
|
||||
uip_ipaddr_t any;
|
||||
uip_ipaddr(&any, 0,0,0,0);
|
||||
c = udp_new(any, HTONS(0), NULL);
|
||||
c = udp_new(&any, HTONS(0), NULL);
|
||||
uip_udp_bind(c, HTONS(4321));
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ PROCESS_THREAD(udprecv_process, ev, data)
|
|||
PROCESS_YIELD();
|
||||
|
||||
if(ev == tcpip_event && uip_newdata()) {
|
||||
u8_t *src = (u8_t *)((struct uip_udpip_hdr *)uip_buf)->srcipaddr;
|
||||
u8_t *src = ((struct uip_udpip_hdr *)uip_buf)->srcipaddr.u8;
|
||||
printf("%d.%d.%d.%d: %s\n",
|
||||
src[0], src[1], src[2], src[3], (char *)uip_appdata);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* @(#)$Id: udpsend.c,v 1.1 2006/08/02 14:44:46 bg- Exp $
|
||||
* @(#)$Id: udpsend.c,v 1.2 2006/08/09 16:13:40 bg- Exp $
|
||||
*/
|
||||
|
||||
/* Set the IP destination address to something different from the
|
||||
|
@ -60,7 +60,7 @@ PROCESS_THREAD(udpsend_process, ev, data)
|
|||
{
|
||||
uip_ipaddr_t addr;
|
||||
uip_ipaddr(&addr, 255,255,255,255); /* Change address here! */
|
||||
c = udp_new(addr, HTONS(4321), NULL);
|
||||
c = udp_new(&addr, HTONS(4321), NULL);
|
||||
c->ttl = 1; /* One hop only. */
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue