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

@ -149,10 +149,10 @@ PROCESS_THREAD(cmdd_process, ev, data)
PROCESS_BEGIN();
tcp_listen(HTONS(6581));
tcp_listen(UIP_HTONS(6581));
memb_init(&conns);
uip_ipaddr(&ipaddr, 255,255,255,255);
udpconn = udp_new(&ipaddr, HTONS(6712), NULL);
udpconn = udp_new(&ipaddr, UIP_HTONS(6712), NULL);
while(1) {
PROCESS_WAIT_EVENT();

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) {

View File

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* @(#)$Id: codeprop.c,v 1.1 2006/06/18 07:44:36 adamdunkels Exp $
* @(#)$Id: codeprop.c,v 1.2 2010/10/19 18:29:03 adamdunkels Exp $
*/
/** \addtogroup esb
@ -170,9 +170,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);
codeprop_event_quit = process_alloc_event();
@ -204,9 +204,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;
@ -217,7 +217,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);
@ -246,12 +246,12 @@ 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) {
s.addr = htons(uh->addr);
if(uip_htons(uh->addr) <= s.addr) {
s.addr = uip_htons(uh->addr);
}
}
PT_YIELD(pt);
@ -269,8 +269,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);
}
/*---------------------------------------------------------------------*/
@ -281,7 +281,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);
@ -290,28 +290,28 @@ 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);
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) {
@ -324,8 +324,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);
}
@ -337,8 +337,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);
}
@ -386,7 +386,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 = uip_datalen() - sizeof(struct codeprop_tcphdr);
@ -451,7 +451,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) {

View File

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* @(#)$Id: tcp_loader.c,v 1.3 2006/12/20 13:38:34 bg- Exp $
* @(#)$Id: tcp_loader.c,v 1.4 2010/10/19 18:29:03 adamdunkels Exp $
*/
#include <stdio.h>
@ -70,7 +70,7 @@ PT_THREAD(recv_tcpthread(struct pt *pt))
goto thread_done;
}
s.len = htons(((struct codeprop_tcphdr *)uip_appdata)->len);
s.len = uip_htons(((struct codeprop_tcphdr *)uip_appdata)->len);
s.addr = 0;
uip_appdata += sizeof(struct codeprop_tcphdr);
uip_len -= sizeof(struct codeprop_tcphdr);
@ -118,11 +118,11 @@ PROCESS_THREAD(tcp_loader_process, ev, data)
{
PROCESS_BEGIN();
tcp_listen(HTONS(CODEPROP_DATA_PORT));
tcp_listen(UIP_HTONS(CODEPROP_DATA_PORT));
while(1) {
PROCESS_YIELD();
if(ev == tcpip_event && uip_conn->lport == HTONS(CODEPROP_DATA_PORT)) {
if(ev == tcpip_event && uip_conn->lport == UIP_HTONS(CODEPROP_DATA_PORT)) {
if(uip_connected()) { /* Really uip_connecting()!!! */
if(data == NULL) {
PT_INIT(&s.tcpthread_pt);

View File

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* @(#)$Id: tcp_loader2.c,v 1.2 2007/01/12 18:16:56 bg- Exp $
* @(#)$Id: tcp_loader2.c,v 1.3 2010/10/19 18:29:03 adamdunkels Exp $
*/
#include <stdio.h>
@ -77,7 +77,7 @@ PT_THREAD(recv_tcpthread(struct pt *pt))
goto thread_done;
}
s.len = htons(((struct codeprop_tcphdr *)uip_appdata)->len);
s.len = uip_htons(((struct codeprop_tcphdr *)uip_appdata)->len);
s.addr = 0;
uip_appdata += sizeof(struct codeprop_tcphdr);
uip_len -= sizeof(struct codeprop_tcphdr);
@ -128,11 +128,11 @@ PROCESS_THREAD(tcp_loader_process, ev, data)
{
PROCESS_BEGIN();
tcp_listen(HTONS(CODEPROP_DATA_PORT));
tcp_listen(UIP_HTONS(CODEPROP_DATA_PORT));
while(1) {
PROCESS_YIELD();
if(ev == tcpip_event && uip_conn->lport == HTONS(CODEPROP_DATA_PORT)) {
if(ev == tcpip_event && uip_conn->lport == UIP_HTONS(CODEPROP_DATA_PORT)) {
if(uip_connected()) { /* Really uip_connecting()!!! */
if(data == NULL) {
PT_INIT(&s.tcpthread_pt);

View File

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: smtp-socket.c,v 1.4 2010/05/31 15:22:08 nifi Exp $
* $Id: smtp-socket.c,v 1.5 2010/10/19 18:29:03 adamdunkels Exp $
*/
#include "smtp.h"
@ -213,7 +213,7 @@ smtp_send(char *to, char *cc, char *from, char *subject,
{
struct uip_conn *conn;
conn = tcp_connect(&smtpserver, HTONS(25), NULL);
conn = tcp_connect(&smtpserver, UIP_HTONS(25), NULL);
if(conn == NULL) {
return 0;
}

View File

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: ftp.c,v 1.9 2010/10/16 09:55:06 oliverschmidt Exp $
* $Id: ftp.c,v 1.10 2010/10/19 18:29:03 adamdunkels Exp $
*/
/* Note to self: It would be nice to have a "View" option in the download dialog. */
@ -436,7 +436,7 @@ PROCESS_THREAD(ftp_process, ev, data)
/* Either found a hostname, or not. */
if((char *)data != NULL &&
(ipaddrptr = resolv_lookup((char *)data)) != NULL) {
connection = ftpc_connect(ipaddrptr, HTONS(21));
connection = ftpc_connect(ipaddrptr, UIP_HTONS(21));
show_statustext("Connecting to ", hostname);
} else {
show_statustext("Host not found: ", hostname);
@ -515,15 +515,15 @@ PROCESS_THREAD(ftp_process, ev, data)
show_statustext("Resolving host ", hostname);
break;
}
connection = ftpc_connect(ipaddrptr, HTONS(21));
connection = ftpc_connect(ipaddrptr, UIP_HTONS(21));
show_statustext("Connecting to ", hostname);
} else {
connection = ftpc_connect(&ipaddr, HTONS(21));
connection = ftpc_connect(&ipaddr, UIP_HTONS(21));
show_statustext("Connecting to ", hostname);
}
#else /* UIP_UDP */
uiplib_ipaddrconv(hostname, &ipaddr);
connection = ftpc_connect(&ipaddr, HTONS(21));
connection = ftpc_connect(&ipaddr, UIP_HTONS(21));
show_statustext("Connecting to ", hostname);
#endif /* UIP_UDP */
}

View File

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: ftpc.c,v 1.4 2010/05/31 15:22:08 nifi Exp $
* $Id: ftpc.c,v 1.5 2010/10/19 18:29:03 adamdunkels Exp $
*/
#include "contiki.h"
#include "ftpc.h"
@ -123,7 +123,7 @@ void
ftpc_init(void)
{
memb_init(&connections);
/* tcp_listen(HTONS(DATAPORT));*/
/* tcp_listen(UIP_HTONS(DATAPORT));*/
}
/*---------------------------------------------------------------------------*/
void *
@ -141,7 +141,7 @@ ftpc_connect(uip_ipaddr_t *ipaddr, u16_t port)
c->codeptr = 0;
c->dataconn.type = TYPE_DATA;
c->dataconn.port = DATAPORT;
tcp_listen(HTONS(DATAPORT));
tcp_listen(UIP_HTONS(DATAPORT));
if(tcp_connect(ipaddr, port, c) == NULL) {
memb_free(&connections, c);
@ -190,9 +190,9 @@ handle_input(struct ftp_connection *c)
c->state == STATE_RETR_SENT ||
c->state == STATE_CONNECTED)) {
if(code == 226 || code == 550) {
tcp_unlisten(htons(c->dataconn.port));
tcp_unlisten(uip_htons(c->dataconn.port));
++c->dataconn.port;
tcp_listen(htons(c->dataconn.port));
tcp_listen(uip_htons(c->dataconn.port));
c->state = STATE_SEND_PORT;
}

View File

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: ircc.c,v 1.4 2008/11/28 00:15:43 adamdunkels Exp $
* $Id: ircc.c,v 1.5 2010/10/19 18:29:03 adamdunkels Exp $
*/
#include "contiki.h"
@ -472,7 +472,7 @@ struct ircc_state *
ircc_connect(struct ircc_state *s, char *servername, uip_ipaddr_t *ipaddr,
char *nick)
{
s->conn = tcp_connect((uip_ipaddr_t *)ipaddr, HTONS(PORT), s);
s->conn = tcp_connect((uip_ipaddr_t *)ipaddr, UIP_HTONS(PORT), s);
if(s->conn == NULL) {
return NULL;
}

View File

@ -31,7 +31,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: servreg-hack.c,v 1.2 2010/06/15 19:32:29 adamdunkels Exp $
* $Id: servreg-hack.c,v 1.3 2010/10/19 18:29:03 adamdunkels Exp $
*/
/**
@ -355,12 +355,12 @@ PROCESS_THREAD(servreg_hack_process, ev, data)
PROCESS_BEGIN();
/* Create outbound UDP connection. */
outconn = udp_broadcast_new(HTONS(UDP_PORT), NULL);
udp_bind(outconn, HTONS(UDP_PORT));
outconn = udp_broadcast_new(UIP_HTONS(UDP_PORT), NULL);
udp_bind(outconn, UIP_HTONS(UDP_PORT));
/* Create inbound UDP connection. */
inconn = udp_new(NULL, HTONS(UDP_PORT), NULL);
udp_bind(inconn, HTONS(UDP_PORT));
inconn = udp_new(NULL, UIP_HTONS(UDP_PORT), NULL);
udp_bind(inconn, UIP_HTONS(UDP_PORT));
etimer_set(&periodic, PERIOD_TIME);
etimer_set(&sendtimer, random_rand() % (PERIOD_TIME));

View File

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: shell-netstat.c,v 1.1 2009/05/10 21:02:24 adamdunkels Exp $
* $Id: shell-netstat.c,v 1.2 2010/10/19 18:29:03 adamdunkels Exp $
*/
#include <string.h>
@ -119,12 +119,12 @@ PROCESS_THREAD(shell_netstat_process, ev, data)
conn = &uip_conns[i];
snprintf(buf, BUFLEN,
"%d, %u.%u.%u.%u:%u, %s, %u, %u, %c %c",
htons(conn->lport),
uip_htons(conn->lport),
conn->ripaddr.u8[0],
conn->ripaddr.u8[1],
conn->ripaddr.u8[2],
conn->ripaddr.u8[3],
htons(conn->rport),
uip_htons(conn->rport),
states[conn->tcpstateflags & UIP_TS_MASK],
conn->nrtx,
conn->timer,

View File

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: shell-ping.c,v 1.4 2010/05/31 15:22:08 nifi Exp $
* $Id: shell-ping.c,v 1.5 2010/10/19 18:29:03 adamdunkels Exp $
*/
#include <string.h>
@ -113,7 +113,7 @@ send_ping(uip_ipaddr_t *dest_addr)
UIP_ICMP_BUF->type = ICMP_ECHO;
UIP_ICMP_BUF->icode = 0;
UIP_ICMP_BUF->id = 0xadad;
UIP_ICMP_BUF->seqno = htons(seqno++);
UIP_ICMP_BUF->seqno = uip_htons(seqno++);
uip_len = UIP_ICMPH_LEN + UIP_IPH_LEN + PING_DATALEN;
UIP_IP_BUF->len[0] = (u8_t)((uip_len) >> 8);

View File

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: shell-udpsend.c,v 1.6 2010/05/31 15:22:08 nifi Exp $
* $Id: shell-udpsend.c,v 1.7 2010/10/19 18:29:03 adamdunkels Exp $
*/
#include <string.h>
@ -95,11 +95,11 @@ PROCESS_THREAD(shell_udpsend_process, ev, data)
port = shell_strtolong(next, &nextptr);
uiplib_ipaddrconv(server, &serveraddr);
udpconn = udp_new(&serveraddr, htons(port), NULL);
udpconn = udp_new(&serveraddr, uip_htons(port), NULL);
if(next != nextptr) {
local_port = shell_strtolong(nextptr, &nextptr);
udp_bind(udpconn, htons(local_port));
udp_bind(udpconn, uip_htons(local_port));
}
running = 1;

View File

@ -29,7 +29,7 @@
*
* This file is part of the Contiki desktop environment
*
* $Id: simpletelnet.c,v 1.6 2010/05/31 15:22:08 nifi Exp $
* $Id: simpletelnet.c,v 1.7 2010/10/19 18:29:03 adamdunkels Exp $
*
*/
@ -185,7 +185,7 @@ connect(void)
}
conn = tcp_connect(addrptr, htons(port), &ts_appstate);
conn = tcp_connect(addrptr, uip_htons(port), &ts_appstate);
if(conn == NULL) {
show("Out of memory error");
return;

View File

@ -28,7 +28,7 @@
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: telnet.c,v 1.2 2009/03/05 23:56:56 adamdunkels Exp $
* $Id: telnet.c,v 1.3 2010/10/19 18:29:03 adamdunkels Exp $
*
*/
@ -108,7 +108,7 @@ telnet_connect(struct telnet_state *s, uip_ipaddr_t *addr, u16_t port)
{
struct uip_conn *conn;
conn = tcp_connect(addr, htons(port), s);
conn = tcp_connect(addr, uip_htons(port), s);
if(conn == NULL) {
return NULL;
}

View File

@ -28,7 +28,7 @@
*
* This file is part of the Contiki desktop OS.
*
* $Id: telnetd.c,v 1.13 2008/10/31 18:07:13 adamdunkels Exp $
* $Id: telnetd.c,v 1.14 2010/10/19 18:29:03 adamdunkels Exp $
*
*/
@ -179,7 +179,7 @@ PROCESS_THREAD(telnetd_process, ev, data)
{
PROCESS_BEGIN();
tcp_listen(HTONS(23));
tcp_listen(UIP_HTONS(23));
buf_init(&buf);
shell_init();

View File

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: twitter.c,v 1.2 2009/05/11 17:31:13 adamdunkels Exp $
* $Id: twitter.c,v 1.3 2010/10/19 18:29:03 adamdunkels Exp $
*/
/**
@ -233,7 +233,7 @@ PROCESS_THREAD(twitter_process, ev, data)
/* Open a TCP connection to port 80 on twitter.com */
conn = tcp_connect(&s->addr, htons(80), s);
conn = tcp_connect(&s->addr, uip_htons(80), s);
if(conn == NULL) {
PRINTF("Could not open TCP connection\n");
/* memb_free(&conns, s);*/

View File

@ -28,7 +28,7 @@
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: vnc-viewer.c,v 1.3 2007/09/01 00:56:03 matsutsuka Exp $
* $Id: vnc-viewer.c,v 1.4 2010/10/19 18:29:03 adamdunkels Exp $
*
*/
@ -84,7 +84,7 @@ vnc_viewer_connect(u16_t *server, u8_t display)
vnc_draw_init();
memset(vs, 0, sizeof(struct vnc_viewer_state));
conn = uip_connect((uip_ipaddr_t *)server, htons(5900 + display));
conn = uip_connect((uip_ipaddr_t *)server, uip_htons(5900 + display));
if(conn == NULL) {
return;
}
@ -127,9 +127,9 @@ senddata(void)
((struct rfb_set_pixel_format *)dataptr)->format.depth = 8;
((struct rfb_set_pixel_format *)dataptr)->format.endian = 1;
((struct rfb_set_pixel_format *)dataptr)->format.truecolor = 1;
((struct rfb_set_pixel_format *)dataptr)->format.red_max = htons(7);
((struct rfb_set_pixel_format *)dataptr)->format.green_max = htons(7);
((struct rfb_set_pixel_format *)dataptr)->format.blue_max = htons(3);
((struct rfb_set_pixel_format *)dataptr)->format.red_max = uip_htons(7);
((struct rfb_set_pixel_format *)dataptr)->format.green_max = uip_htons(7);
((struct rfb_set_pixel_format *)dataptr)->format.blue_max = uip_htons(3);
((struct rfb_set_pixel_format *)dataptr)->format.red_shift = 0;
((struct rfb_set_pixel_format *)dataptr)->format.green_shift = 3;
((struct rfb_set_pixel_format *)dataptr)->format.blue_shift = 6;
@ -140,7 +140,7 @@ senddata(void)
case VNC_SEND_ENCODINGS:
PRINTF(("Sending ENCODINGS\n"));
((struct rfb_set_encodings *)dataptr)->type = RFB_SET_ENCODINGS;
((struct rfb_set_encodings *)dataptr)->encodings = htons(1);
((struct rfb_set_encodings *)dataptr)->encodings = uip_htons(1);
dataptr += sizeof(struct rfb_set_encodings);
dataptr[0] = dataptr[1] = dataptr[2] = 0;
dataptr[3] = RFB_ENC_RAW;
@ -153,19 +153,19 @@ senddata(void)
case VNC_SEND_UPDATERQ:
((struct rfb_fb_update_request *)dataptr)->type = RFB_FB_UPDATE_REQ;
((struct rfb_fb_update_request *)dataptr)->incremental = 0;
((struct rfb_fb_update_request *)dataptr)->x = htons(vnc_draw_viewport_x());
((struct rfb_fb_update_request *)dataptr)->y = htons(vnc_draw_viewport_y());
((struct rfb_fb_update_request *)dataptr)->w = htons(vnc_draw_viewport_w());
((struct rfb_fb_update_request *)dataptr)->h = htons(vnc_draw_viewport_h());
((struct rfb_fb_update_request *)dataptr)->x = uip_htons(vnc_draw_viewport_x());
((struct rfb_fb_update_request *)dataptr)->y = uip_htons(vnc_draw_viewport_y());
((struct rfb_fb_update_request *)dataptr)->w = uip_htons(vnc_draw_viewport_w());
((struct rfb_fb_update_request *)dataptr)->h = uip_htons(vnc_draw_viewport_h());
uip_send(uip_appdata, sizeof(struct rfb_fb_update_request));
break;
case VNC_SEND_UPDATERQ_INC:
((struct rfb_fb_update_request *)dataptr)->type = RFB_FB_UPDATE_REQ;
((struct rfb_fb_update_request *)dataptr)->incremental = 1;
((struct rfb_fb_update_request *)dataptr)->x = htons(vnc_draw_viewport_x());
((struct rfb_fb_update_request *)dataptr)->y = htons(vnc_draw_viewport_y());
((struct rfb_fb_update_request *)dataptr)->w = htons(vnc_draw_viewport_w());
((struct rfb_fb_update_request *)dataptr)->h = htons(vnc_draw_viewport_h());
((struct rfb_fb_update_request *)dataptr)->x = uip_htons(vnc_draw_viewport_x());
((struct rfb_fb_update_request *)dataptr)->y = uip_htons(vnc_draw_viewport_y());
((struct rfb_fb_update_request *)dataptr)->w = uip_htons(vnc_draw_viewport_w());
((struct rfb_fb_update_request *)dataptr)->h = uip_htons(vnc_draw_viewport_h());
uip_send(uip_appdata, sizeof(struct rfb_fb_update_request));
break;
@ -182,9 +182,9 @@ senddata(void)
((struct rfb_pointer_event *)dataptr)->buttonmask =
vs->event_queue[vs->eventptr_unacked].ev.ptr.buttonmask;
((struct rfb_pointer_event *)dataptr)->x =
htons(vs->event_queue[vs->eventptr_unacked].ev.ptr.x);
uip_htons(vs->event_queue[vs->eventptr_unacked].ev.ptr.x);
((struct rfb_pointer_event *)dataptr)->y =
htons(vs->event_queue[vs->eventptr_unacked].ev.ptr.y);
uip_htons(vs->event_queue[vs->eventptr_unacked].ev.ptr.y);
/* uip_send(uip_appdata, sizeof(struct rfb_pointer_event));*/
dataptr += sizeof(struct rfb_pointer_event);
dataleft -= sizeof(struct rfb_pointer_event);
@ -209,13 +209,13 @@ senddata(void)
((struct rfb_fb_update_request *)dataptr)->type = RFB_FB_UPDATE_REQ;
((struct rfb_fb_update_request *)dataptr)->incremental = 0;
((struct rfb_fb_update_request *)dataptr)->x =
htons(vs->event_queue[vs->eventptr_unacked].ev.urq.x);
uip_htons(vs->event_queue[vs->eventptr_unacked].ev.urq.x);
((struct rfb_fb_update_request *)dataptr)->y =
htons(vs->event_queue[vs->eventptr_unacked].ev.urq.y);
uip_htons(vs->event_queue[vs->eventptr_unacked].ev.urq.y);
((struct rfb_fb_update_request *)dataptr)->w =
htons(vs->event_queue[vs->eventptr_unacked].ev.urq.w);
uip_htons(vs->event_queue[vs->eventptr_unacked].ev.urq.w);
((struct rfb_fb_update_request *)dataptr)->h =
htons(vs->event_queue[vs->eventptr_unacked].ev.urq.h);
uip_htons(vs->event_queue[vs->eventptr_unacked].ev.urq.h);
/* uip_send(uip_appdata, sizeof(struct rfb_fb_update_request)); */
dataptr += sizeof(struct rfb_fb_update_request);
dataleft -= sizeof(struct rfb_fb_update_request);
@ -319,12 +319,12 @@ recv_update_rect(CC_REGISTER_ARG struct rfb_fb_update_rect_hdr *rhdr,
rhdr->encoding[2]) == 0) {
switch(rhdr->encoding[3]) {
case RFB_ENC_RAW:
vs->rectstateleft = (u32_t)htons(rhdr->rect.w) * (u32_t)htons(rhdr->rect.h);
vs->rectstateleft = (u32_t)uip_htons(rhdr->rect.w) * (u32_t)uip_htons(rhdr->rect.h);
vs->rectstate = VNC_RECTSTATE_RAW;
vs->rectstatex0 = vs->rectstatex = htons(rhdr->rect.x);
vs->rectstatey0 = vs->rectstatey = htons(rhdr->rect.y);
vs->rectstatew = htons(rhdr->rect.w);
vs->rectstateh = htons(rhdr->rect.h);
vs->rectstatex0 = vs->rectstatex = uip_htons(rhdr->rect.x);
vs->rectstatey0 = vs->rectstatey = uip_htons(rhdr->rect.y);
vs->rectstatew = uip_htons(rhdr->rect.w);
vs->rectstateh = uip_htons(rhdr->rect.h);
vs->rectstatex2 = vs->rectstatex0 + vs->rectstatew;
vs->rectstatey2 = vs->rectstatey0 + vs->rectstateh;
break;
@ -333,11 +333,11 @@ recv_update_rect(CC_REGISTER_ARG struct rfb_fb_update_rect_hdr *rhdr,
rrehdr = (struct rfb_rre_hdr *)((u8_t *)rhdr +
sizeof(struct rfb_fb_update_rect_hdr));
PRINTF(("Received RRE subrects %d (%d)\n",
(htons(rrehdr->subrects[1]) << 16) +
htons(rrehdr->subrects[0]),
(uip_htons(rrehdr->subrects[1]) << 16) +
uip_htons(rrehdr->subrects[0]),
rrehdr->bgpixel));
vs->rectstateleft = ((u32_t)(htons(rrehdr->subrects[1]) << 16) +
(u32_t)htons(rrehdr->subrects[0]));
vs->rectstateleft = ((u32_t)(uip_htons(rrehdr->subrects[1]) << 16) +
(u32_t)uip_htons(rrehdr->subrects[0]));
vs->rectstate = VNC_RECTSTATE_RRE;
break;
@ -457,13 +457,13 @@ handle_data(CC_REGISTER_ARG u8_t *data, u16_t datalen)
break;
case VNC_WAIT_SINIT:
/* PRINTF(("Server init: w %d h %d, bps %d, d %d, name '%s'\n",
htons(((struct rfb_server_init *)data)->width),
htons(((struct rfb_server_init *)data)->height),
uip_htons(((struct rfb_server_init *)data)->width),
uip_htons(((struct rfb_server_init *)data)->height),
((struct rfb_server_init *)data)->format.bps,
((struct rfb_server_init *)data)->format.depth,
((u8_t *)data + sizeof(struct rfb_server_init))));*/
vs->w = htons(((struct rfb_server_init *)data)->width);
vs->h = htons(((struct rfb_server_init *)data)->height);
vs->w = uip_htons(((struct rfb_server_init *)data)->width);
vs->h = uip_htons(((struct rfb_server_init *)data)->height);
vs->sendmsg = VNC_SEND_PFMT;
vs->waitmsg = VNC_WAIT_NONE;
break;
@ -473,7 +473,7 @@ handle_data(CC_REGISTER_ARG u8_t *data, u16_t datalen)
switch(*data) {
case RFB_FB_UPDATE:
vs->waitmsg = VNC_WAIT_UPDATE_RECT;
vs->rectsleft = htons(((struct rfb_fb_update *)data)->rects);
vs->rectsleft = uip_htons(((struct rfb_fb_update *)data)->rects);
PRINTF(("Handling RFB FB UPDATE for %d rects\n", vs->rectsleft));
break;

View File

@ -29,7 +29,7 @@
*
* This file is part of the "contiki" web browser.
*
* $Id: webclient.c,v 1.10 2010/06/14 14:08:17 nifi Exp $
* $Id: webclient.c,v 1.11 2010/10/19 18:29:03 adamdunkels Exp $
*
*/
@ -151,7 +151,7 @@ webclient_get(const char *host, u16_t port, const char *file)
#endif /* UIP_UDP */
}
conn = tcp_connect(ipaddr, htons(port), NULL);
conn = tcp_connect(ipaddr, uip_htons(port), NULL);
if(conn == NULL) {
return 0;

View File

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: httpd-cfs.c,v 1.24 2010/09/28 20:40:52 oliverschmidt Exp $
* $Id: httpd-cfs.c,v 1.25 2010/10/19 18:29:03 adamdunkels Exp $
*/
#include <stdio.h>
@ -271,7 +271,7 @@ httpd_appcall(void *state)
void
httpd_init(void)
{
tcp_listen(HTONS(80));
tcp_listen(UIP_HTONS(80));
memb_init(&conns);
#if URLCONV
urlconv_init();

View File

@ -28,7 +28,7 @@
*
* This file is part of the uIP TCP/IP stack.
*
* $Id: httpd-cgi.c,v 1.15 2009/08/12 18:23:37 dak664 Exp $
* $Id: httpd-cgi.c,v 1.16 2010/10/19 18:29:03 adamdunkels Exp $
*
*/
@ -163,9 +163,9 @@ make_tcp_stats(void *arg)
httpd_sprint_ip6(conn->ripaddr, buf);
return snprintf((char *)uip_appdata, uip_mss(),
"<tr align=\"center\"><td>%d</td><td>%s:%u</td><td>%s</td><td>%u</td><td>%u</td><td>%c %c</td></tr>\r\n",
htons(conn->lport),
uip_htons(conn->lport),
buf,
htons(conn->rport),
uip_htons(conn->rport),
states[conn->tcpstateflags & UIP_TS_MASK],
conn->nrtx,
conn->timer,
@ -174,12 +174,12 @@ make_tcp_stats(void *arg)
#else
return snprintf((char *)uip_appdata, uip_mss(),
"<tr align=\"center\"><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),
uip_htons(conn->lport),
conn->ripaddr.u8[0],
conn->ripaddr.u8[1],
conn->ripaddr.u8[2],
conn->ripaddr.u8[3],
htons(conn->rport),
uip_htons(conn->rport),
states[conn->tcpstateflags & UIP_TS_MASK],
conn->nrtx,
conn->timer,

View File

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: httpd.c,v 1.18 2010/04/11 20:54:39 oliverschmidt Exp $
* $Id: httpd.c,v 1.19 2010/10/19 18:29:03 adamdunkels Exp $
*/
#include <stdio.h>
@ -336,7 +336,7 @@ httpd_appcall(void *state)
void
httpd_init(void)
{
tcp_listen(HTONS(80));
tcp_listen(UIP_HTONS(80));
memb_init(&conns);
httpd_cgi_init();
}
@ -362,7 +362,7 @@ httpd_sprint_ip6(uip_ip6addr_t addr, char * result)
i += zerocnt;
numprinted += zerocnt;
} else {
result += sprintf(result, "%x", (unsigned int)(ntohs(addr.u16[i])));
result += sprintf(result, "%x", (unsigned int)(uip_ntohs(addr.u16[i])));
i++;
numprinted++;
}

View File

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: httpd-socket.c,v 1.1 2007/05/26 22:18:48 oliverschmidt Exp $
* $Id: httpd-socket.c,v 1.2 2010/10/19 18:29:03 adamdunkels Exp $
*/
#include "contiki.h"
@ -187,7 +187,7 @@ httpd_appcall(void *state)
void
httpd_init(void)
{
tcp_listen(HTONS(80));
tcp_listen(UIP_HTONS(80));
memb_init(&conns);
}
/*---------------------------------------------------------------------------*/

View File

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* @(#)$Id: ctk-termtelnet.c,v 1.1 2007/05/26 21:46:28 oliverschmidt Exp $
* @(#)$Id: ctk-termtelnet.c,v 1.2 2010/10/19 18:29:03 adamdunkels Exp $
*/
#include "contiki.h"
#include "loader.h"
@ -648,7 +648,7 @@ LOADER_INIT_FUNC(ctk_termtelnet_init, arg)
EK_EVENTHANDLER(eventhandler, ev, data)
{
if(ev == EK_EVENT_INIT) {
tcp_listen(HTONS(PORT));
tcp_listen(UIP_HTONS(PORT));
} else if(ev == tcpip_event) {
ctk_termtelnet_appcall(data);
}

View File

@ -41,7 +41,7 @@
*
* This file is part of the "ctk" console GUI toolkit for cc65
*
* $Id: ctk-vncserver-service.c,v 1.1 2007/05/23 23:19:13 oliverschmidt Exp $
* $Id: ctk-vncserver-service.c,v 1.2 2010/10/19 18:29:03 adamdunkels Exp $
*
*/
@ -1123,7 +1123,7 @@ EK_EVENTHANDLER(eventhandler, ev, data)
switch(ev) {
case EK_EVENT_INIT:
case EK_EVENT_REPLACE:
tcp_listen(HTONS(5900));
tcp_listen(UIP_HTONS(5900));
for(i = 0; i < CTK_VNCSERVER_CONF_NUMCONNS; ++i) {
conns[i].state = VNC_DEALLOCATED;

View File

@ -47,7 +47,7 @@
*
* This file is part of the Mycal Modified uIP TCP/IP stack.
*
* $Id: ipcp.c,v 1.1 2007/05/26 07:14:39 oliverschmidt Exp $
* $Id: ipcp.c,v 1.2 2010/10/19 18:29:03 adamdunkels Exp $
*
*/
@ -438,7 +438,7 @@ ipcp_task(u8_t *buffer)
/* Write length */
t = bptr - buffer;
/* length here - code and ID + */
pkt->len = htons(t);
pkt->len = uip_htons(t);
DEBUG1(("\n**Sending IPCP Request packet\n"));

View File

@ -44,7 +44,7 @@
*
* This file is part of the Mycal Modified uIP TCP/IP stack.
*
* $Id: