A simple but substantial change: uIP used the htons()/HTONS() macro

functions for converting between host and network byte order. These
names are the de facto standard names for this functionality because
of the original BSD TCP/IP implementation. But they cause problems for
uIP/Contiki: some platforms define these names themselves (Mac OS,
most notably), causing compilation problems for Contiki on those
platforms.

This commit changes all htons to uip_htons instead. Same goes for
htonl, ntohs, and ntohl. All-caps versions as well.
This commit is contained in:
adamdunkels 2010-10-19 18:29:03 +00:00
parent 5a46c629de
commit 5585d72c86
115 changed files with 675 additions and 675 deletions

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* @(#)$Id: codeprop-tmp.c,v 1.5 2009/02/27 14:28:02 nvt-se Exp $
* @(#)$Id: codeprop-tmp.c,v 1.6 2010/10/19 18:29:03 adamdunkels Exp $
*/
/** \addtogroup esb
@ -173,9 +173,9 @@ PROCESS_THREAD(codeprop_process, ev, data)
PT_INIT(&s.udpthread_pt);
PT_INIT(&s.recv_udpthread_pt);
tcp_listen(HTONS(CODEPROP_DATA_PORT));
tcp_listen(UIP_HTONS(CODEPROP_DATA_PORT));
udp_conn = udp_broadcast_new(HTONS(CODEPROP_DATA_PORT), NULL);
udp_conn = udp_broadcast_new(UIP_HTONS(CODEPROP_DATA_PORT), NULL);
s.state = STATE_NONE;
s.received = 0;
@ -203,9 +203,9 @@ send_udpdata(struct codeprop_udphdr *uh)
{
u16_t len;
uh->type = HTONS(TYPE_DATA);
uh->addr = htons(s.addr);
uh->id = htons(s.id);
uh->type = UIP_HTONS(TYPE_DATA);
uh->addr = uip_htons(s.addr);
uh->id = uip_htons(s.id);
if(s.len - s.addr > UDPDATASIZE) {
len = UDPDATASIZE;
@ -218,7 +218,7 @@ send_udpdata(struct codeprop_udphdr *uh)
/* eeprom_read(EEPROMFS_ADDR_CODEPROP + s.addr,
&uh->data[0], len);*/
uh->len = htons(s.len);
uh->len = uip_htons(s.len);
PRINTF(("codeprop: sending packet from address 0x%04x\n", s.addr));
uip_udp_send(len + UDPHEADERSIZE);
@ -247,13 +247,13 @@ PT_THREAD(send_udpthread(struct pt *pt))
PT_WAIT_UNTIL(pt, uip_newdata() || etimer_expired(&s.sendtimer));
if(uip_newdata()) {
if(uh->type == HTONS(TYPE_NACK)) {
if(uh->type == UIP_HTONS(TYPE_NACK)) {
PRINTF(("send_udpthread: got NACK for address 0x%x (now 0x%x)\n",
htons(uh->addr), s.addr));
uip_htons(uh->addr), s.addr));
/* Only accept a NACK if it points to a lower byte. */
if(htons(uh->addr) <= s.addr) {
if(uip_htons(uh->addr) <= s.addr) {
/* beep();*/
s.addr = htons(uh->addr);
s.addr = uip_htons(uh->addr);
}
}
PT_YIELD(pt);
@ -271,8 +271,8 @@ PT_THREAD(send_udpthread(struct pt *pt))
static void
send_nack(struct codeprop_udphdr *uh, unsigned short addr)
{
uh->type = HTONS(TYPE_NACK);
uh->addr = htons(addr);
uh->type = UIP_HTONS(TYPE_NACK);
uh->addr = uip_htons(addr);
uip_udp_send(UDPHEADERSIZE);
}
/*---------------------------------------------------------------------*/
@ -283,7 +283,7 @@ PT_THREAD(recv_udpthread(struct pt *pt))
struct codeprop_udphdr *uh = (struct codeprop_udphdr *)uip_appdata;
/* if(uip_newdata()) {
PRINTF(("recv_udpthread: id %d uh->id %d\n", s.id, htons(uh->id)));
PRINTF(("recv_udpthread: id %d uh->id %d\n", s.id, uip_htons(uh->id)));
}*/
PT_BEGIN(pt);
@ -292,29 +292,29 @@ PT_THREAD(recv_udpthread(struct pt *pt))
do {
PT_WAIT_UNTIL(pt, uip_newdata() &&
uh->type == HTONS(TYPE_DATA) &&
htons(uh->id) > s.id);
uh->type == UIP_HTONS(TYPE_DATA) &&
uip_htons(uh->id) > s.id);
if(htons(uh->addr) != 0) {
if(uip_htons(uh->addr) != 0) {
s.addr = 0;
send_nack(uh, 0);
}
} while(htons(uh->addr) != 0);
} while(uip_htons(uh->addr) != 0);
/* leds_on(LEDS_YELLOW);
beep_down(10000);*/
s.addr = 0;
s.id = htons(uh->id);
s.len = htons(uh->len);
s.id = uip_htons(uh->id);
s.len = uip_htons(uh->len);
timer_set(&s.timer, CONNECTION_TIMEOUT);
/* process_post(PROCESS_BROADCAST, codeprop_event_quit, (process_data_t)NULL); */
while(s.addr < s.len) {
if(htons(uh->addr) == s.addr) {
if(uip_htons(uh->addr) == s.addr) {
/* leds_blink();*/
len = uip_datalen() - UDPHEADERSIZE;
if(len > 0) {
@ -331,8 +331,8 @@ PT_THREAD(recv_udpthread(struct pt *pt))
s.addr += len;
}
} else if(htons(uh->addr) > s.addr) {
PRINTF(("sending nack since 0x%x != 0x%x\n", htons(uh->addr), s.addr));
} else if(uip_htons(uh->addr) > s.addr) {
PRINTF(("sending nack since 0x%x != 0x%x\n", uip_htons(uh->addr), s.addr));
send_nack(uh, s.addr);
}
@ -344,8 +344,8 @@ PT_THREAD(recv_udpthread(struct pt *pt))
timer_set(&s.nacktimer, HIT_NACK_TIMEOUT);
PT_YIELD_UNTIL(pt, timer_expired(&s.nacktimer) ||
(uip_newdata() &&
uh->type == HTONS(TYPE_DATA) &&
htons(uh->id) == s.id));
uh->type == UIP_HTONS(TYPE_DATA) &&
uip_htons(uh->id) == s.id));
if(timer_expired(&s.nacktimer)) {
send_nack(uh, s.addr);
}
@ -394,7 +394,7 @@ PT_THREAD(recv_tcpthread(struct pt *pt))
uip_abort();
}
th = (struct codeprop_tcphdr *)uip_appdata;
s.len = htons(th->len);
s.len = uip_htons(th->len);
s.addr = 0;
uip_appdata += sizeof(struct codeprop_tcphdr);
datalen -= sizeof(struct codeprop_tcphdr);
@ -484,7 +484,7 @@ uipcall(void *state)
recv_udpthread(&s.recv_udpthread_pt);
send_udpthread(&s.udpthread_pt);
} else {
if(uip_conn->lport == HTONS(CODEPROP_DATA_PORT)) {
if(uip_conn->lport == UIP_HTONS(CODEPROP_DATA_PORT)) {
if(uip_connected()) {
if(state == NULL) {