diff --git a/apps/cmdd/cmdd.c b/apps/cmdd/cmdd.c index 8ad31869c..2912b7410 100644 --- a/apps/cmdd/cmdd.c +++ b/apps/cmdd/cmdd.c @@ -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(); diff --git a/apps/codeprop/codeprop-tmp.c b/apps/codeprop/codeprop-tmp.c index b58f9bff6..06e7284ef 100644 --- a/apps/codeprop/codeprop-tmp.c +++ b/apps/codeprop/codeprop-tmp.c @@ -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) { diff --git a/apps/codeprop/codeprop.c b/apps/codeprop/codeprop.c index 867be0e42..046755f7e 100644 --- a/apps/codeprop/codeprop.c +++ b/apps/codeprop/codeprop.c @@ -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) { diff --git a/apps/codeprop/tcp_loader.c b/apps/codeprop/tcp_loader.c index 23b4f3b3e..bab36ca22 100644 --- a/apps/codeprop/tcp_loader.c +++ b/apps/codeprop/tcp_loader.c @@ -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 @@ -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); diff --git a/apps/codeprop/tcp_loader2.c b/apps/codeprop/tcp_loader2.c index 53e960995..115834de4 100644 --- a/apps/codeprop/tcp_loader2.c +++ b/apps/codeprop/tcp_loader2.c @@ -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 @@ -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); diff --git a/apps/email/smtp-socket.c b/apps/email/smtp-socket.c index b26c37f04..64dd2baf6 100644 --- a/apps/email/smtp-socket.c +++ b/apps/email/smtp-socket.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $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; } diff --git a/apps/ftp/ftp.c b/apps/ftp/ftp.c index 8fab882f8..2d5cf7906 100644 --- a/apps/ftp/ftp.c +++ b/apps/ftp/ftp.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $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 */ } diff --git a/apps/ftp/ftpc.c b/apps/ftp/ftpc.c index 26051128b..e3cd9e47e 100644 --- a/apps/ftp/ftpc.c +++ b/apps/ftp/ftpc.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $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; } diff --git a/apps/irc/ircc.c b/apps/irc/ircc.c index 6658058eb..7027a104f 100644 --- a/apps/irc/ircc.c +++ b/apps/irc/ircc.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $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; } diff --git a/apps/servreg-hack/servreg-hack.c b/apps/servreg-hack/servreg-hack.c index ad3e4712a..25cfc8695 100644 --- a/apps/servreg-hack/servreg-hack.c +++ b/apps/servreg-hack/servreg-hack.c @@ -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)); diff --git a/apps/shell/shell-netstat.c b/apps/shell/shell-netstat.c index 1fbb715cb..8f066a0a4 100644 --- a/apps/shell/shell-netstat.c +++ b/apps/shell/shell-netstat.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $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 @@ -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, diff --git a/apps/shell/shell-ping.c b/apps/shell/shell-ping.c index 7071b3b4c..f2f15adc4 100644 --- a/apps/shell/shell-ping.c +++ b/apps/shell/shell-ping.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $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 @@ -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); diff --git a/apps/shell/shell-udpsend.c b/apps/shell/shell-udpsend.c index fd3653d0a..1d3de33e7 100644 --- a/apps/shell/shell-udpsend.c +++ b/apps/shell/shell-udpsend.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $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 @@ -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; diff --git a/apps/telnet/simpletelnet.c b/apps/telnet/simpletelnet.c index e6cc77cdd..1efc45f3e 100644 --- a/apps/telnet/simpletelnet.c +++ b/apps/telnet/simpletelnet.c @@ -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; diff --git a/apps/telnet/telnet.c b/apps/telnet/telnet.c index ea703d877..8e7debc39 100644 --- a/apps/telnet/telnet.c +++ b/apps/telnet/telnet.c @@ -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; } diff --git a/apps/telnetd/telnetd.c b/apps/telnetd/telnetd.c index b2ca6e1e6..6eb24e17d 100644 --- a/apps/telnetd/telnetd.c +++ b/apps/telnetd/telnetd.c @@ -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(); diff --git a/apps/twitter/twitter.c b/apps/twitter/twitter.c index 5bd6dea56..f5675355f 100644 --- a/apps/twitter/twitter.c +++ b/apps/twitter/twitter.c @@ -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);*/ diff --git a/apps/vnc/vnc-viewer.c b/apps/vnc/vnc-viewer.c index d3078a5d4..b83d2c63a 100644 --- a/apps/vnc/vnc-viewer.c +++ b/apps/vnc/vnc-viewer.c @@ -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; diff --git a/apps/webbrowser/webclient.c b/apps/webbrowser/webclient.c index 5a7c4db5d..5f8f93fa9 100644 --- a/apps/webbrowser/webclient.c +++ b/apps/webbrowser/webclient.c @@ -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; diff --git a/apps/webserver/httpd-cfs.c b/apps/webserver/httpd-cfs.c index fd6e85776..627f6c086 100644 --- a/apps/webserver/httpd-cfs.c +++ b/apps/webserver/httpd-cfs.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $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 @@ -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(); diff --git a/apps/webserver/httpd-cgi.c b/apps/webserver/httpd-cgi.c index b86deaf50..722268ae3 100644 --- a/apps/webserver/httpd-cgi.c +++ b/apps/webserver/httpd-cgi.c @@ -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(), "%d%s:%u%s%u%u%c %c\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(), "%d%u.%u.%u.%u:%u%s%u%u%c %c\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, diff --git a/apps/webserver/httpd.c b/apps/webserver/httpd.c index 9bce0e54e..464496e5b 100644 --- a/apps/webserver/httpd.c +++ b/apps/webserver/httpd.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $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 @@ -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++; } diff --git a/backyard/apps/webserver/httpd-socket.c b/backyard/apps/webserver/httpd-socket.c index 03ee3b598..199fa9e3a 100644 --- a/backyard/apps/webserver/httpd-socket.c +++ b/backyard/apps/webserver/httpd-socket.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $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); } /*---------------------------------------------------------------------------*/ diff --git a/backyard/core/ctk/ctk-termtelnet.c b/backyard/core/ctk/ctk-termtelnet.c index 86d331199..924535c8d 100644 --- a/backyard/core/ctk/ctk-termtelnet.c +++ b/backyard/core/ctk/ctk-termtelnet.c @@ -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); } diff --git a/backyard/core/ctk/ctk-vncserver-service.c b/backyard/core/ctk/ctk-vncserver-service.c index 2b73c901d..f0e6b6279 100644 --- a/backyard/core/ctk/ctk-vncserver-service.c +++ b/backyard/core/ctk/ctk-vncserver-service.c @@ -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; diff --git a/backyard/core/net/ppp/ipcp.c b/backyard/core/net/ppp/ipcp.c index 241800110..24e51e75b 100644 --- a/backyard/core/net/ppp/ipcp.c +++ b/backyard/core/net/ppp/ipcp.c @@ -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")); diff --git a/backyard/core/net/ppp/lcp.c b/backyard/core/net/ppp/lcp.c index b0e7e4da5..5b095e86c 100644 --- a/backyard/core/net/ppp/lcp.c +++ b/backyard/core/net/ppp/lcp.c @@ -44,7 +44,7 @@ * * This file is part of the Mycal Modified uIP TCP/IP stack. * - * $Id: lcp.c,v 1.1 2007/05/26 07:14:39 oliverschmidt Exp $ + * $Id: lcp.c,v 1.2 2010/10/19 18:29:03 adamdunkels Exp $ * */ @@ -438,7 +438,7 @@ lcp_task(u8_t *buffer) #endif /* Write length */ t = bptr - buffer; - pkt->len = htons(t); /* length here - code and ID + */ + pkt->len = uip_htons(t); /* length here - code and ID + */ DEBUG1((" len %d\n",t)); diff --git a/backyard/core/net/ppp/pap.c b/backyard/core/net/ppp/pap.c index 6dbb5dcf6..d75fae5f8 100644 --- a/backyard/core/net/ppp/pap.c +++ b/backyard/core/net/ppp/pap.c @@ -41,7 +41,7 @@ * * This file is part of the Mycal Modified uIP TCP/IP stack. * - * $Id: pap.c,v 1.1 2007/05/26 07:14:39 oliverschmidt Exp $ + * $Id: pap.c,v 1.2 2010/10/19 18:29:03 adamdunkels Exp $ * */ @@ -171,7 +171,7 @@ pap_task(u8_t *buffer) /* Write length */ t = bptr - buffer; /* length here - code and ID + */ - pkt->len = htons(t); + pkt->len = uip_htons(t); DEBUG1((" Len %d\n",t)); diff --git a/backyard/core/net/ppp/ppp.c b/backyard/core/net/ppp/ppp.c index 2d7cecc2e..d0c1aa288 100644 --- a/backyard/core/net/ppp/ppp.c +++ b/backyard/core/net/ppp/ppp.c @@ -43,7 +43,7 @@ * * This file is part of the Mycal Modified uIP TCP/IP stack. * - * $Id: ppp.c,v 1.1 2007/05/26 07:14:40 oliverschmidt Exp $ + * $Id: ppp.c,v 1.2 2010/10/19 18:29:03 adamdunkels Exp $ * */ @@ -166,8 +166,8 @@ ppp_reject_protocol(u16_t protocol, u8_t *buffer, u16_t count) pkt = (LCPPKT *)buffer; pkt->code = PROT_REJ; /* Write Conf_rej */ /*pkt->id = tid++;*/ /* write tid */ - pkt->len = htons(count + 6); - *((u16_t *)(&pkt->data[0])) = htons(protocol); + pkt->len = uip_htons(count + 6); + *((u16_t *)(&pkt->data[0])) = uip_htons(protocol); ahdlc_tx(LCP, buffer, 0, (u16_t)(count + 6), 0); } diff --git a/backyard/cpu/avr/dev/rtl8019as-drv.c b/backyard/cpu/avr/dev/rtl8019as-drv.c index 1c8f7fc02..6d9c03389 100644 --- a/backyard/cpu/avr/dev/rtl8019as-drv.c +++ b/backyard/cpu/avr/dev/rtl8019as-drv.c @@ -31,7 +31,7 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: rtl8019as-drv.c,v 1.1 2007/05/26 21:29:12 oliverschmidt Exp $ + * $Id: rtl8019as-drv.c,v 1.2 2010/10/19 18:29:03 adamdunkels Exp $ * */ @@ -98,7 +98,7 @@ rtl8019_drv_idle(void) if(uip_len > 0) { /* A frame was avaliable (and is now read into the uip_buf), so we process it. */ - if(BUF->type == htons(UIP_ETHTYPE_IP)) { + if(BUF->type == uip_htons(UIP_ETHTYPE_IP)) { /* debug_print16(uip_len);*/ uip_arp_ipin(); uip_len -= sizeof(struct uip_eth_hdr); @@ -111,7 +111,7 @@ rtl8019_drv_idle(void) uip_arp_out(); rtl8019as_send(); } - } else if(BUF->type == htons(UIP_ETHTYPE_ARP)) { + } else if(BUF->type == uip_htons(UIP_ETHTYPE_ARP)) { uip_arp_arpin(); /* If the above function invocation resulted in data that should be sent out on the network, the global variable diff --git a/backyard/platform/c64/apps/cgterm.c b/backyard/platform/c64/apps/cgterm.c index f96be745a..3e4000e30 100644 --- a/backyard/platform/c64/apps/cgterm.c +++ b/backyard/platform/c64/apps/cgterm.c @@ -99,7 +99,7 @@ connect(u16_t *host, u16_t port) PSOCK_INIT(&s.sout, s.inputbuf, sizeof(s.inputbuf)); PT_INIT(&s.inpt); PT_INIT(&s.outpt); - return tcp_connect(host, htons(port), NULL); + return tcp_connect(host, uip_htons(port), NULL); } /*---------------------------------------------------------------------------*/ PROCESS(cgterm_process, "C/G terminal"); diff --git a/backyard/platform/c64/net/eth64-drv.c b/backyard/platform/c64/net/eth64-drv.c index 383b4f92d..dea171167 100644 --- a/backyard/platform/c64/net/eth64-drv.c +++ b/backyard/platform/c64/net/eth64-drv.c @@ -28,7 +28,7 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: eth64-drv.c,v 1.1 2007/05/23 23:11:29 oliverschmidt Exp $ + * $Id: eth64-drv.c,v 1.2 2010/10/19 18:29:04 adamdunkels Exp $ * */ @@ -64,11 +64,11 @@ pollhandler(void) if(uip_len > 0) { /* A frame was avaliable (and is now read into the uip_buf), so we process it. */ - if(BUF->type == HTONS(UIP_ETHTYPE_IP)) { + if(BUF->type == UIP_HTONS(UIP_ETHTYPE_IP)) { uip_arp_ipin(); uip_len -= sizeof(struct uip_eth_hdr); tcpip_input(); - } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) { + } else if(BUF->type == UIP_HTONS(UIP_ETHTYPE_ARP)) { uip_arp_arpin(); /* If the above function invocation resulted in data that should be sent out on the network, the global variable diff --git a/backyard/platform/c64/net/eth64-dump-drv.c b/backyard/platform/c64/net/eth64-dump-drv.c index 43e511419..ad9cf82ee 100644 --- a/backyard/platform/c64/net/eth64-dump-drv.c +++ b/backyard/platform/c64/net/eth64-dump-drv.c @@ -28,7 +28,7 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: eth64-dump-drv.c,v 1.1 2007/05/23 23:11:29 oliverschmidt Exp $ + * $Id: eth64-dump-drv.c,v 1.2 2010/10/19 18:29:04 adamdunkels Exp $ * */ @@ -86,11 +86,11 @@ pollhandler(void) /* A frame was avaliable (and is now read into the uip_buf), so we process it. */ - if(BUF->type == HTONS(UIP_ETHTYPE_IP)) { + if(BUF->type == UIP_HTONS(UIP_ETHTYPE_IP)) { uip_arp_ipin(); uip_len -= sizeof(struct uip_eth_hdr); tcpip_input(); - } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) { + } else if(BUF->type == UIP_HTONS(UIP_ETHTYPE_ARP)) { uip_arp_arpin(); /* If the above function invocation resulted in data that should be sent out on the network, the global variable diff --git a/backyard/platform/c64/net/rrnet-drv.c b/backyard/platform/c64/net/rrnet-drv.c index f994c8c40..cc04d894e 100644 --- a/backyard/platform/c64/net/rrnet-drv.c +++ b/backyard/platform/c64/net/rrnet-drv.c @@ -28,7 +28,7 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: rrnet-drv.c,v 1.1 2007/05/23 23:11:30 oliverschmidt Exp $ + * $Id: rrnet-drv.c,v 1.2 2010/10/19 18:29:04 adamdunkels Exp $ * */ @@ -65,11 +65,11 @@ pollhandler(void) if(uip_len > 0) { /* A frame was avaliable (and is now read into the uip_buf), so we process it. */ - if(BUF->type == HTONS(UIP_ETHTYPE_IP)) { + if(BUF->type == UIP_HTONS(UIP_ETHTYPE_IP)) { uip_arp_ipin(); uip_len -= sizeof(struct uip_eth_hdr); tcpip_input(); - } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) { + } else if(BUF->type == UIP_HTONS(UIP_ETHTYPE_ARP)) { uip_arp_arpin(); /* If the above function invocation resulted in data that should be sent out on the network, the global variable diff --git a/backyard/platform/c64/net/rrnet-dump-drv.c b/backyard/platform/c64/net/rrnet-dump-drv.c index 684ffdbae..b15694504 100644 --- a/backyard/platform/c64/net/rrnet-dump-drv.c +++ b/backyard/platform/c64/net/rrnet-dump-drv.c @@ -28,7 +28,7 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: rrnet-dump-drv.c,v 1.1 2007/05/23 23:11:30 oliverschmidt Exp $ + * $Id: rrnet-dump-drv.c,v 1.2 2010/10/19 18:29:04 adamdunkels Exp $ * */ @@ -86,11 +86,11 @@ pollhandler(void) /* A frame was avaliable (and is now read into the uip_buf), so we process it. */ - if(BUF->type == HTONS(UIP_ETHTYPE_IP)) { + if(BUF->type == UIP_HTONS(UIP_ETHTYPE_IP)) { uip_arp_ipin(); uip_len -= sizeof(struct uip_eth_hdr); tcpip_input(); - } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) { + } else if(BUF->type == UIP_HTONS(UIP_ETHTYPE_ARP)) { uip_arp_arpin(); /* If the above function invocation resulted in data that should be sent out on the network, the global variable diff --git a/backyard/platform/c64/net/tfe-drv.c b/backyard/platform/c64/net/tfe-drv.c index 1db7e5480..bc7a9832d 100644 --- a/backyard/platform/c64/net/tfe-drv.c +++ b/backyard/platform/c64/net/tfe-drv.c @@ -28,7 +28,7 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: tfe-drv.c,v 1.1 2007/05/23 23:11:30 oliverschmidt Exp $ + * $Id: tfe-drv.c,v 1.2 2010/10/19 18:29:04 adamdunkels Exp $ * */ @@ -64,11 +64,11 @@ pollhandler(void) if(uip_len > 0) { /* A frame was avaliable (and is now read into the uip_buf), so we process it. */ - if(BUF->type == HTONS(UIP_ETHTYPE_IP)) { + if(BUF->type == UIP_HTONS(UIP_ETHTYPE_IP)) { uip_arp_ipin(); uip_len -= sizeof(struct uip_eth_hdr); tcpip_input(); - } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) { + } else if(BUF->type == UIP_HTONS(UIP_ETHTYPE_ARP)) { uip_arp_arpin(); /* If the above function invocation resulted in data that should be sent out on the network, the global variable diff --git a/backyard/platform/c64/net/tfe-dump-drv.c b/backyard/platform/c64/net/tfe-dump-drv.c index 16d28ba8c..9710a8b6c 100644 --- a/backyard/platform/c64/net/tfe-dump-drv.c +++ b/backyard/platform/c64/net/tfe-dump-drv.c @@ -28,7 +28,7 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: tfe-dump-drv.c,v 1.1 2007/05/23 23:11:30 oliverschmidt Exp $ + * $Id: tfe-dump-drv.c,v 1.2 2010/10/19 18:29:04 adamdunkels Exp $ * */ @@ -122,11 +122,11 @@ EK_POLLHANDLER(pollhandler) dump_packet(); /* A frame was avaliable (and is now read into the uip_buf), so we process it. */ - if(BUF->type == HTONS(UIP_ETHTYPE_IP)) { + if(BUF->type == UIP_HTONS(UIP_ETHTYPE_IP)) { uip_arp_ipin(); uip_len -= sizeof(struct uip_eth_hdr); tcpip_input(); - } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) { + } else if(BUF->type == UIP_HTONS(UIP_ETHTYPE_ARP)) { uip_arp_arpin(); /* If the above function invocation resulted in data that should be sent out on the network, the global variable diff --git a/backyard/platform/gtk/contiki-main.c b/backyard/platform/gtk/contiki-main.c index d7d636438..2c4c3f196 100644 --- a/backyard/platform/gtk/contiki-main.c +++ b/backyard/platform/gtk/contiki-main.c @@ -29,7 +29,7 @@ * * This file is part of the Contiki desktop environment * - * $Id: contiki-main.c,v 1.1 2008/01/05 21:08:26 oliverschmidt Exp $ + * $Id: contiki-main.c,v 1.2 2010/10/19 18:29:04 adamdunkels Exp $ * */ @@ -167,7 +167,7 @@ main(int argc, char **argv) #undef LITTLE_ENDIAN #undef BIG_ENDIAN #undef BYTE_ORDER -#undef HTONS +#undef UIP_HTONS /*-----------------------------------------------------------------------------------*/ diff --git a/backyard/platform/sky/client.c b/backyard/platform/sky/client.c index a59773fd7..5b524385a 100644 --- a/backyard/platform/sky/client.c +++ b/backyard/platform/sky/client.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)$Id: client.c,v 1.1 2008/05/27 13:16:34 adamdunkels Exp $ + * @(#)$Id: client.c,v 1.2 2010/10/19 18:29:04 adamdunkels Exp $ */ /* @@ -86,7 +86,7 @@ struct uip_fw_netif cc2420if = PROCESS(button_process, "Button process"); /* Radio stuff in network byte order. */ -static u16_t panId = HTONS(0x2024); +static u16_t panId = UIP_HTONS(0x2024); #ifndef RF_CHANNEL #define RF_CHANNEL 15 @@ -104,7 +104,7 @@ main(int argc, char **argv) leds_toggle(LEDS_ALL); slip_arch_init(BAUD2UBR(115200)); /* Must come before first printf */ printf("Starting %s " - "($Id: client.c,v 1.1 2008/05/27 13:16:34 adamdunkels Exp $)\n", __FILE__); + "($Id: client.c,v 1.2 2010/10/19 18:29:04 adamdunkels Exp $)\n", __FILE__); ds2411_init(); sensors_light_init(); cc2420_init(); diff --git a/backyard/platform/sky/dhclient.c b/backyard/platform/sky/dhclient.c index 0d909fa58..05e2142da 100644 --- a/backyard/platform/sky/dhclient.c +++ b/backyard/platform/sky/dhclient.c @@ -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 2008/05/27 13:16:34 adamdunkels Exp $ + * @(#)$Id: dhclient.c,v 1.2 2010/10/19 18:29:04 adamdunkels Exp $ */ /* @@ -84,7 +84,7 @@ PROCESS(button_process, "Button process"); PROCESS(dhclient_process, "Dhclient process"); /* Radio stuff in network byte order. */ -static u16_t panId = HTONS(0x2024); +static u16_t panId = UIP_HTONS(0x2024); #ifndef RF_CHANNEL #define RF_CHANNEL 15 @@ -102,7 +102,7 @@ main(int argc, char **argv) leds_toggle(LEDS_ALL); slip_arch_init(BAUD2UBR(115200)); /* Must come before first printf */ printf("Starting %s " - "($Id: dhclient.c,v 1.1 2008/05/27 13:16:34 adamdunkels Exp $)\n", __FILE__); + "($Id: dhclient.c,v 1.2 2010/10/19 18:29:04 adamdunkels Exp $)\n", __FILE__); ds2411_init(); sensors_light_init(); cc2420_init(); diff --git a/backyard/platform/sky/gateway.c b/backyard/platform/sky/gateway.c index 3b801f5fd..04ae2ee46 100644 --- a/backyard/platform/sky/gateway.c +++ b/backyard/platform/sky/gateway.c @@ -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 2008/05/27 13:16:34 adamdunkels Exp $ + * @(#)$Id: gateway.c,v 1.2 2010/10/19 18:29:04 adamdunkels Exp $ */ /* @@ -107,7 +107,7 @@ static struct uip_fw_netif slipif = {UIP_FW_NETIF(0,0,0,0, 255,255,255,255, slip_send)}; /* Radio stuff in network byte order. */ -static u16_t panId = HTONS(0x2024); +static u16_t panId = UIP_HTONS(0x2024); #ifndef RF_CHANNEL #define RF_CHANNEL 15 @@ -125,7 +125,7 @@ main(int argc, char **argv) leds_toggle(LEDS_ALL); slip_arch_init(BAUD2UBR(115200)); /* Must come before first printf */ printf("Starting %s " - "($Id: gateway.c,v 1.1 2008/05/27 13:16:34 adamdunkels Exp $)\n", __FILE__); + "($Id: gateway.c,v 1.2 2010/10/19 18:29:04 adamdunkels Exp $)\n", __FILE__); ds2411_init(); sensors_light_init(); cc2420_init(); diff --git a/backyard/platform/sky/udprecv.c b/backyard/platform/sky/udprecv.c index 074d3488d..58807dd4f 100644 --- a/backyard/platform/sky/udprecv.c +++ b/backyard/platform/sky/udprecv.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: udprecv.c,v 1.1 2008/05/27 13:16:34 adamdunkels Exp $ + * @(#)$Id: udprecv.c,v 1.2 2010/10/19 18:29:04 adamdunkels Exp $ */ #include @@ -51,8 +51,8 @@ PROCESS_THREAD(udprecv_process, ev, data) { uip_ipaddr_t any; uip_ipaddr(&any, 0,0,0,0); - c = udp_new(&any, HTONS(0), NULL); - uip_udp_bind(c, HTONS(4321)); + c = udp_new(&any, UIP_HTONS(0), NULL); + uip_udp_bind(c, UIP_HTONS(4321)); } while(1) { diff --git a/backyard/platform/sky/udpsend.c b/backyard/platform/sky/udpsend.c index a970c0853..c95b2ae13 100644 --- a/backyard/platform/sky/udpsend.c +++ b/backyard/platform/sky/udpsend.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: udpsend.c,v 1.1 2008/05/27 13:16:34 adamdunkels Exp $ + * @(#)$Id: udpsend.c,v 1.2 2010/10/19 18:29:04 adamdunkels 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, UIP_HTONS(4321), NULL); c->ttl = 1; /* One hop only. */ } diff --git a/core/ctk/ctk-vncserver.c b/core/ctk/ctk-vncserver.c index 6e1330a62..fa433ce76 100644 --- a/core/ctk/ctk-vncserver.c +++ b/core/ctk/ctk-vncserver.c @@ -41,7 +41,7 @@ * * This file is part of the "ctk" console GUI toolkit for cc65 * - * $Id: ctk-vncserver.c,v 1.2 2006/08/30 22:24:12 oliverschmidt Exp $ + * $Id: ctk-vncserver.c,v 1.3 2010/10/19 18:29:04 adamdunkels Exp $ * */ @@ -1082,7 +1082,7 @@ PROCESS_THREAD(ctk_vncserver_process, ev, data) PROCESS_BEGIN(); - tcp_listen(HTONS(5900)); + tcp_listen(UIP_HTONS(5900)); for(i = 0; i < CTK_VNCSERVER_CONF_NUMCONNS; ++i) { conns[i].state = VNC_DEALLOCATED; diff --git a/core/ctk/vnc-out.c b/core/ctk/vnc-out.c index 654251e9b..69765e4e3 100644 --- a/core/ctk/vnc-out.c +++ b/core/ctk/vnc-out.c @@ -28,7 +28,7 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: vnc-out.c,v 1.2 2007/08/30 14:39:18 matsutsuka Exp $ + * $Id: vnc-out.c,v 1.3 2010/10/19 18:29:04 adamdunkels Exp $ * */ @@ -555,14 +555,14 @@ vnc_out_send_blank(CC_REGISTER_ARG struct vnc_server_state *vs) umsg = (struct rfb_fb_update *)uip_appdata; umsg->type = RFB_FB_UPDATE; - umsg->rects = HTONS(2); + umsg->rects = UIP_HTONS(2); ptr = (u8_t *)umsg + sizeof(struct rfb_fb_update); len = sizeof(struct rfb_fb_update); msglen = vnc_server_draw_rect(ptr, 0, 0, - HTONS(SCREEN_WIDTH), - HTONS(SCREEN_HEIGHT), + UIP_HTONS(SCREEN_WIDTH), + UIP_HTONS(SCREEN_HEIGHT), BORDER_COLOR); @@ -570,9 +570,9 @@ vnc_out_send_blank(CC_REGISTER_ARG struct vnc_server_state *vs) len += msglen; msglen = vnc_server_draw_rect(ptr, - HTONS(SCREEN_X), HTONS(SCREEN_Y), - HTONS(SCREEN_WIDTH - SCREEN_X * 2), - HTONS(SCREEN_HEIGHT - SCREEN_Y * 2), + UIP_HTONS(SCREEN_X), UIP_HTONS(SCREEN_Y), + UIP_HTONS(SCREEN_WIDTH - SCREEN_X * 2), + UIP_HTONS(SCREEN_HEIGHT - SCREEN_Y * 2), SCREEN_COLOR); uip_send(uip_appdata, len + msglen); @@ -690,11 +690,11 @@ vnc_out_send_update(CC_REGISTER_ARG struct vnc_server_state *vs) y * CTK_VNCFONT_HEIGHT, CTK_VNCFONT_WIDTH * numblanks, CTK_VNCFONT_HEIGHT));*/ - recthdr->rect.x = htons(SCREEN_X + (x - numblanks) * + recthdr->rect.x = uip_htons(SCREEN_X + (x - numblanks) * CTK_VNCFONT_WIDTH); - recthdr->rect.y = htons(SCREEN_Y + y * CTK_VNCFONT_HEIGHT); - recthdr->rect.w = htons(CTK_VNCFONT_WIDTH * numblanks); - recthdr->rect.h = HTONS(CTK_VNCFONT_HEIGHT); + recthdr->rect.y = uip_htons(SCREEN_Y + y * CTK_VNCFONT_HEIGHT); + recthdr->rect.w = uip_htons(CTK_VNCFONT_WIDTH * numblanks); + recthdr->rect.h = UIP_HTONS(CTK_VNCFONT_HEIGHT); recthdr->encoding[0] = recthdr->encoding[1] = recthdr->encoding[2] = 0; @@ -732,10 +732,10 @@ vnc_out_send_update(CC_REGISTER_ARG struct vnc_server_state *vs) /* recthdr = (struct rfb_fb_update_rect_hdr *)ptr;*/ recthdr = (struct rfb_fb_update_rect_hdr *)tmpbuf; - recthdr->rect.x = htons(SCREEN_X + x * CTK_VNCFONT_WIDTH); - recthdr->rect.y = htons(SCREEN_Y + y * CTK_VNCFONT_HEIGHT); - recthdr->rect.w = HTONS(CTK_VNCFONT_WIDTH); - recthdr->rect.h = HTONS(CTK_VNCFONT_HEIGHT); + recthdr->rect.x = uip_htons(SCREEN_X + x * CTK_VNCFONT_WIDTH); + recthdr->rect.y = uip_htons(SCREEN_Y + y * CTK_VNCFONT_HEIGHT); + recthdr->rect.w = UIP_HTONS(CTK_VNCFONT_WIDTH); + recthdr->rect.h = UIP_HTONS(CTK_VNCFONT_HEIGHT); recthdr->encoding[0] = recthdr->encoding[1] = recthdr->encoding[2] = 0; @@ -756,7 +756,7 @@ vnc_out_send_update(CC_REGISTER_ARG struct vnc_server_state *vs) loopend: - umsg->rects = htons(n); + umsg->rects = uip_htons(n); if(y == vs->y + vs->h && x == vs->x + vs->w) { vs->x2 = vs->y2 = 0; @@ -841,8 +841,8 @@ vnc_out_pointer_event(struct vnc_server_state *vs) ev = (struct rfb_pointer_event *)uip_appdata; - evx = htons(ev->x); - evy = htons(ev->y); + evx = uip_htons(ev->x); + evy = uip_htons(ev->y); if(evx > SCREEN_X && evx < SCREEN_WIDTH - 2 * SCREEN_X && evy > SCREEN_Y && evy < SCREEN_HEIGHT - 2 * SCREEN_Y) { diff --git a/core/ctk/vnc-server.c b/core/ctk/vnc-server.c index 020ab2999..9193aad73 100644 --- a/core/ctk/vnc-server.c +++ b/core/ctk/vnc-server.c @@ -28,7 +28,7 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: vnc-server.c,v 1.2 2007/08/30 14:39:17 matsutsuka Exp $ + * $Id: vnc-server.c,v 1.3 2010/10/19 18:29:04 adamdunkels Exp $ * */ @@ -164,16 +164,16 @@ vnc_server_send_data(struct vnc_server_state *vs) break; case VNC_INIT: initmsg = (struct rfb_server_init *)uip_appdata; - initmsg->width = htons(vs->width); - initmsg->height = htons(vs->height); + initmsg->width = uip_htons(vs->width); + initmsg->height = uip_htons(vs->height); /* BGR233 pixel format. */ initmsg->format.bps = 8; initmsg->format.depth = 8; initmsg->format.endian = 1; initmsg->format.truecolor = 1; - initmsg->format.red_max = htons(7); - initmsg->format.green_max = htons(7); - initmsg->format.blue_max = htons(3); + initmsg->format.red_max = uip_htons(7); + initmsg->format.green_max = uip_htons(7); + initmsg->format.blue_max = uip_htons(3); initmsg->format.red_shift = 0; initmsg->format.green_shift = 3; initmsg->format.blue_shift = 6; @@ -315,7 +315,7 @@ vnc_read_data(CC_REGISTER_ARG struct vnc_server_state *vs) case RFB_SET_ENCODINGS: PRINTF(("Set encodings\n")); vs->readlen = sizeof(struct rfb_set_encoding); - vs->readlen += htons(((struct rfb_set_encoding *)appdata)->encodings) * 4; + vs->readlen += uip_htons(((struct rfb_set_encoding *)appdata)->encodings) * 4; /* Make sure that client supports the encodings we use. */ /* XXX: not implemented yet. */ break; @@ -441,7 +441,7 @@ void vnc_server_appcall(struct vnc_server_state *vs) { - vs->type = htons(uip_conn->lport) - 5900; + vs->type = uip_htons(uip_conn->lport) - 5900; if(uip_connected()) { vnc_new(vs); diff --git a/core/dev/slip.c b/core/dev/slip.c index 17380c479..3ba3a5036 100644 --- a/core/dev/slip.c +++ b/core/dev/slip.c @@ -29,7 +29,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: slip.c,v 1.10 2010/03/17 07:10:25 nifi Exp $ + * @(#)$Id: slip.c,v 1.11 2010/10/19 18:29:04 adamdunkels Exp $ */ @@ -252,7 +252,7 @@ PROCESS_THREAD(slip_process, ev, data) u16_t nid = ip_id++; BUF->ipid[0] = nid >> 8; BUF->ipid[1] = nid; - nid = htons(nid); + nid = uip_htons(nid); nid = ~nid; /* negate */ BUF->ipchksum += nid; /* add */ if(BUF->ipchksum < nid) { /* 1-complement overflow? */ diff --git a/core/net/dhcpc.c b/core/net/dhcpc.c index 88aa08d50..a7213a51a 100644 --- a/core/net/dhcpc.c +++ b/core/net/dhcpc.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: dhcpc.c,v 1.8 2007/08/30 14:39:17 matsutsuka Exp $ + * @(#)$Id: dhcpc.c,v 1.9 2010/10/19 18:29:04 adamdunkels Exp $ */ #include @@ -147,7 +147,7 @@ create_msg(CC_REGISTER_ARG struct dhcp_msg *m) m->hops = 0; memcpy(m->xid, &xid, sizeof(m->xid)); m->secs = 0; - m->flags = HTONS(BOOTP_BROADCAST); /* Broadcast bit. */ + m->flags = UIP_HTONS(BOOTP_BROADCAST); /* Broadcast bit. */ /* uip_ipaddr_copy(m->ciaddr, uip_hostaddr);*/ memcpy(m->ciaddr, uip_hostaddr.u16, sizeof(m->ciaddr)); memset(m->yiaddr, 0, sizeof(m->yiaddr)); @@ -332,7 +332,7 @@ PT_THREAD(handle_dhcp(process_event_t ev, void *data)) printf("Got default router %d.%d.%d.%d\n", uip_ipaddr_to_quad(&s.default_router)); printf("Lease expires in %ld seconds\n", - ntohs(s.lease_time[0])*65536ul + ntohs(s.lease_time[1])); + uip_ntohs(s.lease_time[0])*65536ul + uip_ntohs(s.lease_time[1])); #endif dhcpc_configured(&s); @@ -341,9 +341,9 @@ PT_THREAD(handle_dhcp(process_event_t ev, void *data)) #define MAX_TICKS32 (~((u32_t)0)) #define IMIN(a, b) ((a) < (b) ? (a) : (b)) - if((ntohs(s.lease_time[0])*65536ul + ntohs(s.lease_time[1]))*CLOCK_SECOND/2 + if((uip_ntohs(s.lease_time[0])*65536ul + uip_ntohs(s.lease_time[1]))*CLOCK_SECOND/2 <= MAX_TICKS32) { - s.ticks = (ntohs(s.lease_time[0])*65536ul + ntohs(s.lease_time[1]) + s.ticks = (uip_ntohs(s.lease_time[0])*65536ul + uip_ntohs(s.lease_time[1]) )*CLOCK_SECOND/2; } else { s.ticks = MAX_TICKS32; @@ -357,9 +357,9 @@ PT_THREAD(handle_dhcp(process_event_t ev, void *data)) PT_YIELD_UNTIL(&s.pt, etimer_expired(&s.etimer)); } - if((ntohs(s.lease_time[0])*65536ul + ntohs(s.lease_time[1]))*CLOCK_SECOND/2 + if((uip_ntohs(s.lease_time[0])*65536ul + uip_ntohs(s.lease_time[1]))*CLOCK_SECOND/2 <= MAX_TICKS32) { - s.ticks = (ntohs(s.lease_time[0])*65536ul + ntohs(s.lease_time[1]) + s.ticks = (uip_ntohs(s.lease_time[0])*65536ul + uip_ntohs(s.lease_time[1]) )*CLOCK_SECOND/2; } else { s.ticks = MAX_TICKS32; @@ -405,9 +405,9 @@ dhcpc_init(const void *mac_addr, int mac_len) s.state = STATE_INITIAL; uip_ipaddr(&addr, 255,255,255,255); - s.conn = udp_new(&addr, HTONS(DHCPC_SERVER_PORT), NULL); + s.conn = udp_new(&addr, UIP_HTONS(DHCPC_SERVER_PORT), NULL); if(s.conn != NULL) { - udp_bind(s.conn, HTONS(DHCPC_CLIENT_PORT)); + udp_bind(s.conn, UIP_HTONS(DHCPC_CLIENT_PORT)); } PT_INIT(&s.pt); } diff --git a/core/net/hc.c b/core/net/hc.c index ca1febc9b..eb7602eb6 100644 --- a/core/net/hc.c +++ b/core/net/hc.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: hc.c,v 1.4 2007/08/30 14:39:17 matsutsuka Exp $ + * @(#)$Id: hc.c,v 1.5 2010/10/19 18:29:04 adamdunkels Exp $ */ /** @@ -127,14 +127,14 @@ hc_compress(u8_t *buf, int len) the same destination and source port number. */ - (uhdr->destport & HTONS(0xc000)) == 0) { /* Only packets with the two + (uhdr->destport & UIP_HTONS(0xc000)) == 0) { /* Only packets with the two highest bits in the port number equal to zero. */ - hdr->flagsport = htons( + hdr->flagsport = uip_htons( FLAGS_COMPRESSED | /* Compressed header. */ FLAGS_BROADCASTDATA | /* Broadcast data. */ - (htons(uhdr->destport) & 0x3fff)); + (uip_htons(uhdr->destport) & 0x3fff)); uip_ipaddr_copy(&hdr->srcipaddr, &uhdr->srcipaddr); /* Move the packet data to the end of the compressed header. */ @@ -170,8 +170,8 @@ hc_inflate(u8_t *buf, int len) hdr = (struct hc_hdr *)buf; /* First, check if the header in buf is compressed or not. */ - if((hdr->flagsport & HTONS(FLAGS_COMPRESSED)) != 0 && - (hdr->flagsport & HTONS(FLAGS_BROADCASTDATA)) != 0) { + if((hdr->flagsport & UIP_HTONS(FLAGS_COMPRESSED)) != 0 && + (hdr->flagsport & UIP_HTONS(FLAGS_BROADCASTDATA)) != 0) { /* Move packet data in memory to make room for the uncompressed header. */ memmove(&buf[UIP_IPUDPH_LEN - HC_HLEN], @@ -180,8 +180,8 @@ hc_inflate(u8_t *buf, int len) hdr = (struct hc_hdr *)&buf[UIP_IPUDPH_LEN - HC_HLEN]; uip_ipaddr_copy(&uhdr->srcipaddr, &hdr->srcipaddr); - uhdr->srcport = hdr->flagsport & HTONS(0x3fff); - uhdr->destport = hdr->flagsport & HTONS(0x3fff); + uhdr->srcport = hdr->flagsport & UIP_HTONS(0x3fff); + uhdr->destport = hdr->flagsport & UIP_HTONS(0x3fff); uhdr->udplen = len; diff --git a/core/net/rawpacket-udp.c b/core/net/rawpacket-udp.c index 9acae9b8c..8088daf22 100644 --- a/core/net/rawpacket-udp.c +++ b/core/net/rawpacket-udp.c @@ -28,7 +28,7 @@ c/* * * This file is part of the Contiki operating system. * - * $Id: rawpacket-udp.c,v 1.3 2007/11/17 18:05:21 adamdunkels Exp $ + * $Id: rawpacket-udp.c,v 1.4 2010/10/19 18:29:04 adamdunkels Exp $ */ /** @@ -55,7 +55,7 @@ rawpacket_udp_init(void) struct rawpacket_conn * rawpacket_setup(int id) { - return (struct rawpacket_conn *)udp_broadcast_new(HTONS(PORT + id), NULL); + return (struct rawpacket_conn *)udp_broadcast_new(UIP_HTONS(PORT + id), NULL); } /*---------------------------------------------------------------------------*/ void diff --git a/core/net/resolv.c b/core/net/resolv.c index 0a4cf7a27..ba952dd21 100644 --- a/core/net/resolv.c +++ b/core/net/resolv.c @@ -57,7 +57,7 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: resolv.c,v 1.9 2010/05/31 15:22:08 nifi Exp $ + * $Id: resolv.c,v 1.10 2010/10/19 18:29:04 adamdunkels Exp $ * */ @@ -237,9 +237,9 @@ check_entries(void) } hdr = (struct dns_hdr *)uip_appdata; memset(hdr, 0, sizeof(struct dns_hdr)); - hdr->id = htons(i); + hdr->id = uip_htons(i); hdr->flags1 = DNS_FLAG1_RD; - hdr->numquestions = HTONS(1); + hdr->numquestions = UIP_HTONS(1); query = (char *)uip_appdata + 12; nameptr = namemapptr->name; --nameptr; @@ -281,19 +281,19 @@ newdata(void) register struct namemap *namemapptr; hdr = (struct dns_hdr *)uip_appdata; - /* printf("ID %d\n", htons(hdr->id)); + /* printf("ID %d\n", uip_htons(hdr->id)); printf("Query %d\n", hdr->flags1 & DNS_FLAG1_RESPONSE); printf("Error %d\n", hdr->flags2 & DNS_FLAG2_ERR_MASK); printf("Num questions %d, answers %d, authrr %d, extrarr %d\n", - htons(hdr->numquestions), - htons(hdr->numanswers), - htons(hdr->numauthrr), - htons(hdr->numextrarr)); + uip_htons(hdr->numquestions), + uip_htons(hdr->numanswers), + uip_htons(hdr->numauthrr), + uip_htons(hdr->numextrarr)); */ /* The ID in the DNS header should be our entry into the name table. */ - i = (u8_t)htons(hdr->id); + i = (u8_t)uip_htons(hdr->id); namemapptr = &names[i]; if(i < RESOLV_ENTRIES && namemapptr->state == STATE_ASKING) { @@ -311,8 +311,8 @@ newdata(void) /* We only care about the question(s) and the answers. The authrr and the extrarr are simply discarded. */ - nquestions = (u8_t)htons(hdr->numquestions); - nanswers = (u8_t)htons(hdr->numanswers); + nquestions = (u8_t)uip_htons(hdr->numquestions); + nanswers = (u8_t)uip_htons(hdr->numanswers); /* Skip the name in the question. XXX: This should really be checked agains the name in the question, to be sure that they @@ -333,14 +333,14 @@ newdata(void) ans = (struct dns_answer *)nameptr; /* printf("Answer: type %x, class %x, ttl %x, length %x\n", - htons(ans->type), htons(ans->class), (htons(ans->ttl[0]) - << 16) | htons(ans->ttl[1]), htons(ans->len));*/ + uip_htons(ans->type), uip_htons(ans->class), (uip_htons(ans->ttl[0]) + << 16) | uip_htons(ans->ttl[1]), uip_htons(ans->len));*/ /* Check for IP address type and Internet class. Others are discarded. */ - if(ans->type == HTONS(1) && - ans->class == HTONS(1) && - ans->len == HTONS(4)) { + if(ans->type == UIP_HTONS(1) && + ans->class == UIP_HTONS(1) && + ans->len == UIP_HTONS(4)) { /* printf("IP address %d.%d.%d.%d\n", ans->ipaddr[0], ans->ipaddr[1], @@ -355,7 +355,7 @@ newdata(void) resolv_found(namemapptr->name, &namemapptr->ipaddr); return; } else { - nameptr = nameptr + 10 + htons(ans->len); + nameptr = nameptr + 10 + uip_htons(ans->len); } --nanswers; } @@ -391,10 +391,10 @@ PROCESS_THREAD(resolv_process, ev, data) if(resolv_conn != NULL) { uip_udp_remove(resolv_conn); } - resolv_conn = udp_new((uip_ipaddr_t *)data, HTONS(53), NULL); + resolv_conn = udp_new((uip_ipaddr_t *)data, UIP_HTONS(53), NULL); } else if(ev == tcpip_event) { - if(uip_udp_conn->rport == HTONS(53)) { + if(uip_udp_conn->rport == UIP_HTONS(53)) { if(uip_poll()) { check_entries(); } diff --git a/core/net/rime/rime-udp.c b/core/net/rime/rime-udp.c index b9c28d559..3e0f154db 100644 --- a/core/net/rime/rime-udp.c +++ b/core/net/rime/rime-udp.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: rime-udp.c,v 1.6 2010/06/14 19:19:17 adamdunkels Exp $ + * $Id: rime-udp.c,v 1.7 2010/10/19 18:29:04 adamdunkels Exp $ */ /** @@ -77,18 +77,18 @@ PROCESS_THREAD(rime_udp_process, ev, data) PROCESS_BEGIN(); - broadcast_conn = udp_broadcast_new(HTONS(RIME_UDP_PORT), NULL); + broadcast_conn = udp_broadcast_new(UIP_HTONS(RIME_UDP_PORT), NULL); if(broadcast_conn == NULL) { PRINTF("rime-udp: Failed to allocate a broadcast connection!\n"); } uip_create_unspecified(&ipaddr); - unicast_conn = udp_new(&ipaddr, HTONS(RIME_UDP_PORT), NULL); + unicast_conn = udp_new(&ipaddr, UIP_HTONS(RIME_UDP_PORT), NULL); if(unicast_conn == NULL) { PRINTF("rime-udp: Failed to allocate a unicast connection!\n"); } - udp_bind(unicast_conn, HTONS(RIME_UDP_PORT)); + udp_bind(unicast_conn, UIP_HTONS(RIME_UDP_PORT)); while(1) { PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event); diff --git a/core/net/sicslowpan.c b/core/net/sicslowpan.c index 12f26a91b..c7227cbf4 100644 --- a/core/net/sicslowpan.c +++ b/core/net/sicslowpan.c @@ -32,7 +32,7 @@ * * This file is part of the Contiki operating system. * - * $Id: sicslowpan.c,v 1.45 2010/09/23 19:57:50 joxe Exp $ + * $Id: sicslowpan.c,v 1.46 2010/10/19 18:29:04 adamdunkels Exp $ */ /** * \file @@ -621,34 +621,34 @@ compress_hdr_hc06(rimeaddr_t *rime_destaddr) /* UDP header compression */ if(UIP_IP_BUF->proto == UIP_PROTO_UDP) { PRINTF("IPHC: Uncompressed UDP ports on send side: %x, %x\n", - HTONS(UIP_UDP_BUF->srcport), HTONS(UIP_UDP_BUF->destport)); + UIP_HTONS(UIP_UDP_BUF->srcport), UIP_HTONS(UIP_UDP_BUF->destport)); /* Mask out the last 4 bits can be used as a mask */ - if(((HTONS(UIP_UDP_BUF->srcport) & 0xfff0) == SICSLOWPAN_UDP_4_BIT_PORT_MIN) && - ((HTONS(UIP_UDP_BUF->destport) & 0xfff0) == SICSLOWPAN_UDP_4_BIT_PORT_MIN)) { + if(((UIP_HTONS(UIP_UDP_BUF->srcport) & 0xfff0) == SICSLOWPAN_UDP_4_BIT_PORT_MIN) && + ((UIP_HTONS(UIP_UDP_BUF->destport) & 0xfff0) == SICSLOWPAN_UDP_4_BIT_PORT_MIN)) { /* we can compress 12 bits of both source and dest */ *hc06_ptr = SICSLOWPAN_NHC_UDP_CS_P_11; PRINTF("IPHC: remove 12 b of both source & dest with prefix 0xFOB\n"); *(hc06_ptr + 1) = - (u8_t)((HTONS(UIP_UDP_BUF->srcport) - + (u8_t)((UIP_HTONS(UIP_UDP_BUF->srcport) - SICSLOWPAN_UDP_4_BIT_PORT_MIN) << 4) + - (u8_t)((HTONS(UIP_UDP_BUF->destport) - + (u8_t)((UIP_HTONS(UIP_UDP_BUF->destport) - SICSLOWPAN_UDP_4_BIT_PORT_MIN)); hc06_ptr += 2; - } else if((HTONS(UIP_UDP_BUF->destport) & 0xff00) == SICSLOWPAN_UDP_8_BIT_PORT_MIN) { + } else if((UIP_HTONS(UIP_UDP_BUF->destport) & 0xff00) == SICSLOWPAN_UDP_8_BIT_PORT_MIN) { /* we can compress 8 bits of dest, leave source. */ *hc06_ptr = SICSLOWPAN_NHC_UDP_CS_P_01; PRINTF("IPHC: leave source, remove 8 bits of dest with prefix 0xF0\n"); memcpy(hc06_ptr + 1, &UIP_UDP_BUF->srcport, 2); *(hc06_ptr + 3) = - (u8_t)((HTONS(UIP_UDP_BUF->destport) - + (u8_t)((UIP_HTONS(UIP_UDP_BUF->destport) - SICSLOWPAN_UDP_8_BIT_PORT_MIN)); hc06_ptr += 4; - } else if((HTONS(UIP_UDP_BUF->srcport) & 0xff00) == SICSLOWPAN_UDP_8_BIT_PORT_MIN) { + } else if((UIP_HTONS(UIP_UDP_BUF->srcport) & 0xff00) == SICSLOWPAN_UDP_8_BIT_PORT_MIN) { /* we can compress 8 bits of src, leave dest. Copy compressed port */ *hc06_ptr = SICSLOWPAN_NHC_UDP_CS_P_10; PRINTF("IPHC: remove 8 bits of source with prefix 0xF0, leave dest. hch: %i\n", *hc06_ptr); *(hc06_ptr + 1) = - (u8_t)((HTONS(UIP_UDP_BUF->srcport) - + (u8_t)((UIP_HTONS(UIP_UDP_BUF->srcport) - SICSLOWPAN_UDP_8_BIT_PORT_MIN)); memcpy(hc06_ptr + 2, &UIP_UDP_BUF->destport, 2); hc06_ptr += 4; @@ -858,7 +858,7 @@ uncompress_hdr_hc06(u16_t ip_len) { memcpy(&SICSLOWPAN_UDP_BUF->srcport, hc06_ptr + 1, 2); memcpy(&SICSLOWPAN_UDP_BUF->destport, hc06_ptr + 3, 2); PRINTF("IPHC: Uncompressed UDP ports (ptr+5): %x, %x\n", - HTONS(SICSLOWPAN_UDP_BUF->srcport), HTONS(SICSLOWPAN_UDP_BUF->destport)); + UIP_HTONS(SICSLOWPAN_UDP_BUF->srcport), UIP_HTONS(SICSLOWPAN_UDP_BUF->destport)); hc06_ptr += 5; break; @@ -866,31 +866,31 @@ uncompress_hdr_hc06(u16_t ip_len) { /* 1 byte for NHC + source 16bit inline, dest = 0xF0 + 8 bit inline */ PRINTF("IPHC: Decompressing destination\n"); memcpy(&SICSLOWPAN_UDP_BUF->srcport, hc06_ptr + 1, 2); - SICSLOWPAN_UDP_BUF->destport = HTONS(SICSLOWPAN_UDP_8_BIT_PORT_MIN + (*(hc06_ptr + 3))); + SICSLOWPAN_UDP_BUF->destport = UIP_HTONS(SICSLOWPAN_UDP_8_BIT_PORT_MIN + (*(hc06_ptr + 3))); PRINTF("IPHC: Uncompressed UDP ports (ptr+4): %x, %x\n", - HTONS(SICSLOWPAN_UDP_BUF->srcport), HTONS(SICSLOWPAN_UDP_BUF->destport)); + UIP_HTONS(SICSLOWPAN_UDP_BUF->srcport), UIP_HTONS(SICSLOWPAN_UDP_BUF->destport)); hc06_ptr += 4; break; case SICSLOWPAN_NHC_UDP_CS_P_10: /* 1 byte for NHC + source = 0xF0 + 8bit inline, dest = 16 bit inline*/ PRINTF("IPHC: Decompressing source\n"); - SICSLOWPAN_UDP_BUF->srcport = HTONS(SICSLOWPAN_UDP_8_BIT_PORT_MIN + + SICSLOWPAN_UDP_BUF->srcport = UIP_HTONS(SICSLOWPAN_UDP_8_BIT_PORT_MIN + (*(hc06_ptr + 1))); memcpy(&SICSLOWPAN_UDP_BUF->destport, hc06_ptr + 2, 2); PRINTF("IPHC: Uncompressed UDP ports (ptr+4): %x, %x\n", - HTONS(SICSLOWPAN_UDP_BUF->srcport), HTONS(SICSLOWPAN_UDP_BUF->destport)); + UIP_HTONS(SICSLOWPAN_UDP_BUF->srcport), UIP_HTONS(SICSLOWPAN_UDP_BUF->destport)); hc06_ptr += 4; break; case SICSLOWPAN_NHC_UDP_CS_P_11: /* 1 byte for NHC, 1 byte for ports */ - SICSLOWPAN_UDP_BUF->srcport = HTONS(SICSLOWPAN_UDP_4_BIT_PORT_MIN + + SICSLOWPAN_UDP_BUF->srcport = UIP_HTONS(SICSLOWPAN_UDP_4_BIT_PORT_MIN + (*(hc06_ptr + 1) >> 4)); - SICSLOWPAN_UDP_BUF->destport = HTONS(SICSLOWPAN_UDP_4_BIT_PORT_MIN + + SICSLOWPAN_UDP_BUF->destport = UIP_HTONS(SICSLOWPAN_UDP_4_BIT_PORT_MIN + ((*(hc06_ptr + 1)) & 0x0F)); PRINTF("IPHC: Uncompressed UDP ports (ptr+2): %x, %x\n", - HTONS(SICSLOWPAN_UDP_BUF->srcport), HTONS(SICSLOWPAN_UDP_BUF->destport)); + UIP_HTONS(SICSLOWPAN_UDP_BUF->srcport), UIP_HTONS(SICSLOWPAN_UDP_BUF->destport)); hc06_ptr += 2; break; @@ -1052,10 +1052,10 @@ compress_hdr_hc1(rimeaddr_t *rime_destaddr) * SICSLOWPAN_UDP_PORT_MIN and SICSLOWPAN_UDP_PORT_MIN + 15 */ PRINTF("local/remote port %u/%u\n",UIP_UDP_BUF->srcport,UIP_UDP_BUF->destport); - if(HTONS(UIP_UDP_BUF->srcport) >= SICSLOWPAN_UDP_PORT_MIN && - HTONS(UIP_UDP_BUF->srcport) < SICSLOWPAN_UDP_PORT_MAX && - HTONS(UIP_UDP_BUF->destport) >= SICSLOWPAN_UDP_PORT_MIN && - HTONS(UIP_UDP_BUF->destport) < SICSLOWPAN_UDP_PORT_MAX) { + if(UIP_HTONS(UIP_UDP_BUF->srcport) >= SICSLOWPAN_UDP_PORT_MIN && + UIP_HTONS(UIP_UDP_BUF->srcport) < SICSLOWPAN_UDP_PORT_MAX && + UIP_HTONS(UIP_UDP_BUF->destport) >= SICSLOWPAN_UDP_PORT_MIN && + UIP_HTONS(UIP_UDP_BUF->destport) < SICSLOWPAN_UDP_PORT_MAX) { /* HC1 encoding */ RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_HC1_ENCODING] = 0xFB; @@ -1064,9 +1064,9 @@ compress_hdr_hc1(rimeaddr_t *rime_destaddr) RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_TTL] = UIP_IP_BUF->ttl; RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_PORTS] = - (u8_t)((HTONS(UIP_UDP_BUF->srcport) - + (u8_t)((UIP_HTONS(UIP_UDP_BUF->srcport) - SICSLOWPAN_UDP_PORT_MIN) << 4) + - (u8_t)((HTONS(UIP_UDP_BUF->destport) - SICSLOWPAN_UDP_PORT_MIN)); + (u8_t)((UIP_HTONS(UIP_UDP_BUF->destport) - SICSLOWPAN_UDP_PORT_MIN)); memcpy(&RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_CHKSUM], &UIP_UDP_BUF->udpchksum, 2); rime_hdr_len += SICSLOWPAN_HC1_HC_UDP_HDR_LEN; uncomp_hdr_len += UIP_UDPH_LEN; @@ -1144,10 +1144,10 @@ uncompress_hdr_hc1(u16_t ip_len) { SICSLOWPAN_IP_BUF->ttl = RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_TTL]; /* UDP ports, len, checksum */ SICSLOWPAN_UDP_BUF->srcport = - HTONS(SICSLOWPAN_UDP_PORT_MIN + + UIP_HTONS(SICSLOWPAN_UDP_PORT_MIN + (RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_PORTS] >> 4)); SICSLOWPAN_UDP_BUF->destport = - HTONS(SICSLOWPAN_UDP_PORT_MIN + + UIP_HTONS(SICSLOWPAN_UDP_PORT_MIN + (RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_PORTS] & 0x0F)); memcpy(&SICSLOWPAN_UDP_BUF->udpchksum, &RIME_HC1_HC_UDP_PTR[RIME_HC1_HC_UDP_CHKSUM], 2); uncomp_hdr_len += UIP_UDPH_LEN; @@ -1333,10 +1333,10 @@ output(uip_lladdr_t *localdest) * Note that the length is in units of 8 bytes */ /* RIME_FRAG_BUF->dispatch_size = */ -/* htons((SICSLOWPAN_DISPATCH_FRAG1 << 8) | uip_len); */ +/* uip_htons((SICSLOWPAN_DISPATCH_FRAG1 << 8) | uip_len); */ SET16(RIME_FRAG_PTR, RIME_FRAG_DISPATCH_SIZE, ((SICSLOWPAN_DISPATCH_FRAG1 << 8) | uip_len)); -/* RIME_FRAG_BUF->tag = htons(my_tag); */ +/* RIME_FRAG_BUF->tag = uip_htons(my_tag); */ SET16(RIME_FRAG_PTR, RIME_FRAG_TAG, my_tag); /* Copy payload and send */ @@ -1366,7 +1366,7 @@ output(uip_lladdr_t *localdest) */ rime_hdr_len = SICSLOWPAN_FRAGN_HDR_LEN; /* RIME_FRAG_BUF->dispatch_size = */ -/* htons((SICSLOWPAN_DISPATCH_FRAGN << 8) | uip_len); */ +/* uip_htons((SICSLOWPAN_DISPATCH_FRAGN << 8) | uip_len); */ SET16(RIME_FRAG_PTR, RIME_FRAG_DISPATCH_SIZE, ((SICSLOWPAN_DISPATCH_FRAGN << 8) | uip_len)); rime_payload_len = (MAC_MAX_PAYLOAD - rime_hdr_len) & 0xf8; @@ -1462,9 +1462,9 @@ input(void) case SICSLOWPAN_DISPATCH_FRAG1: PRINTFI("sicslowpan input: FRAG1 "); frag_offset = 0; -/* frag_size = (ntohs(RIME_FRAG_BUF->dispatch_size) & 0x07ff); */ +/* frag_size = (uip_ntohs(RIME_FRAG_BUF->dispatch_size) & 0x07ff); */ frag_size = GET16(RIME_FRAG_PTR, RIME_FRAG_DISPATCH_SIZE) & 0x07ff; -/* frag_tag = ntohs(RIME_FRAG_BUF->tag); */ +/* frag_tag = uip_ntohs(RIME_FRAG_BUF->tag); */ frag_tag = GET16(RIME_FRAG_PTR, RIME_FRAG_TAG); PRINTFI("size %d, tag %d, offset %d)\n", frag_size, frag_tag, frag_offset); diff --git a/core/net/tcpdump.c b/core/net/tcpdump.c index 81cea0791..c6789eebd 100644 --- a/core/net/tcpdump.c +++ b/core/net/tcpdump.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: tcpdump.c,v 1.2 2006/10/09 11:53:56 adamdunkels Exp $ + * @(#)$Id: tcpdump.c,v 1.3 2010/10/19 18:29:04 adamdunkels Exp $ */ #include "contiki-net.h" @@ -238,13 +238,13 @@ tcpdump_format(u8_t *packet, u16_t packetlen, } } else if(IPBUF->proto == UIP_PROTO_UDP) { return s(" UDP", - n(htons(UDPBUF->destport), d( + n(uip_htons(UDPBUF->destport), d( n(IPBUF->destipaddr[3], d( n(IPBUF->destipaddr[2], d( n(IPBUF->destipaddr[1], d( n(IPBUF->destipaddr[0], s(" ", - n(htons(UDPBUF->srcport), d( + n(uip_htons(UDPBUF->srcport), d( n(IPBUF->srcipaddr[3], d( n(IPBUF->srcipaddr[2], d( n(IPBUF->srcipaddr[1], d( @@ -253,21 +253,21 @@ tcpdump_format(u8_t *packet, u16_t packetlen, /* return sprintf(buf, "%d.%d.%d.%d.%d %d.%d.%d.%d.%d UDP", IPBUF->srcipaddr[0], IPBUF->srcipaddr[1], IPBUF->srcipaddr[2], IPBUF->srcipaddr[3], - htons(UDPBUF->srcport), + uip_htons(UDPBUF->srcport), IPBUF->destipaddr[0], IPBUF->destipaddr[1], IPBUF->destipaddr[2], IPBUF->destipaddr[3], - htons(UDPBUF->destport));*/ + uip_htons(UDPBUF->destport));*/ } else if(IPBUF->proto == UIP_PROTO_TCP) { tcpflags(TCPBUF->flags, flags); return s(flags, s(" ", - n(htons(TCPBUF->destport), d( + n(uip_htons(TCPBUF->destport), d( n(IPBUF->destipaddr[3], d( n(IPBUF->destipaddr[2], d( n(IPBUF->destipaddr[1], d( n(IPBUF->destipaddr[0], s(" ", - n(htons(TCPBUF->srcport), d( + n(uip_htons(TCPBUF->srcport), d( n(IPBUF->srcipaddr[3], d( n(IPBUF->srcipaddr[2], d( n(IPBUF->srcipaddr[1], d( @@ -276,10 +276,10 @@ tcpdump_format(u8_t *packet, u16_t packetlen, /* return sprintf(buf, "%d.%d.%d.%d.%d %d.%d.%d.%d.%d %s", IPBUF->srcipaddr[0], IPBUF->srcipaddr[1], IPBUF->srcipaddr[2], IPBUF->srcipaddr[3], - htons(TCPBUF->srcport), + uip_htons(TCPBUF->srcport), IPBUF->destipaddr[0], IPBUF->destipaddr[1], IPBUF->destipaddr[2], IPBUF->destipaddr[3], - htons(TCPBUF->destport), + uip_htons(TCPBUF->destport), flags); */ } else { strcpy(buf, "Unrecognized protocol"); diff --git a/core/net/tcpip.h b/core/net/tcpip.h index eaf8557b1..12573d1ec 100644 --- a/core/net/tcpip.h +++ b/core/net/tcpip.h @@ -62,7 +62,7 @@ * * Author: Adam Dunkels * - * $Id: tcpip.h,v 1.16 2010/02/05 12:43:37 nifi Exp $ + * $Id: tcpip.h,v 1.17 2010/10/19 18:29:04 adamdunkels Exp $ */ #ifndef __TCPIP_H__ #define __TCPIP_H__ @@ -120,7 +120,7 @@ CCIF void tcp_attach(struct uip_conn *conn, * with the new connection request. * * \note Port numbers must always be given in network byte order. The - * functions HTONS() and htons() can be used to convert port numbers + * functions UIP_HTONS() and uip_htons() can be used to convert port numbers * from host byte order to network byte order. * * \param port The port number in network byte order. @@ -134,7 +134,7 @@ CCIF void tcp_listen(u16_t port); * This function closes a listening TCP port. * * \note Port numbers must always be given in network byte order. The - * functions HTONS() and htons() can be used to convert port numbers + * functions UIP_HTONS() and uip_htons() can be used to convert port numbers * from host byte order to network byte order. * * \param port The port number in network byte order. @@ -151,7 +151,7 @@ CCIF void tcp_unlisten(u16_t port); * together with uIP events to the process. * * \note The port number must be provided in network byte order so a - * conversion with HTONS() usually is necessary. + * conversion with UIP_HTONS() usually is necessary. * * \note This function will only create the connection. The connection * is not opened directly. uIP will try to open the connection the @@ -215,7 +215,7 @@ void udp_attach(struct uip_udp_conn *conn, * remote endpoint. * * \note The port number must be provided in network byte order so a - * conversion with HTONS() usually is necessary. + * conversion with UIP_HTONS() usually is necessary. * * \sa udp_bind() * @@ -253,7 +253,7 @@ struct uip_udp_conn *udp_broadcast_new(u16_t port, void *appstate); * connection to a specified local port, this function should be used. * * \note The port number must be provided in network byte order so a - * conversion with HTONS() usually is necessary. + * conversion with UIP_HTONS() usually is necessary. * * \param conn A pointer to the UDP connection that is to be bound. * \param port The port number in network byte order to which to bind diff --git a/core/net/uaodv-rt.c b/core/net/uaodv-rt.c index 1217b4af7..9e02181d8 100644 --- a/core/net/uaodv-rt.c +++ b/core/net/uaodv-rt.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: uaodv-rt.c,v 1.7 2007/05/13 15:14:48 bg- Exp $ + * $Id: uaodv-rt.c,v 1.8 2010/10/19 18:29:04 adamdunkels Exp $ */ /** @@ -81,7 +81,7 @@ uaodv_rt_add(uip_ipaddr_t *dest, uip_ipaddr_t *nexthop, uip_ipaddr_copy(&e->dest, dest); uip_ipaddr_copy(&e->nexthop, nexthop); e->hop_count = hop_count; - e->hseqno = ntohl(*seqno); + e->hseqno = uip_ntohl(*seqno); e->is_bad = 0; /* New entry goes first. */ diff --git a/core/net/uaodv.c b/core/net/uaodv.c index db8ad6633..12973d430 100644 --- a/core/net/uaodv.c +++ b/core/net/uaodv.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: uaodv.c,v 1.37 2010/01/20 09:58:16 fros4943 Exp $ + * $Id: uaodv.c,v 1.38 2010/10/19 18:29:04 adamdunkels Exp $ */ /** @@ -70,7 +70,7 @@ last_known_seqno(uip_ipaddr_t *host) struct uaodv_rt_entry *route = uaodv_rt_lookup_any(host); if(route != NULL) - return htonl(route->hseqno); + return uip_htonl(route->hseqno); return 0; } @@ -193,11 +193,11 @@ send_rreq(uip_ipaddr_t *addr) rm->flags = 0; rm->reserved = 0; rm->hop_count = 0; - rm->rreq_id = htonl(rreq_id++); + rm->rreq_id = uip_htonl(rreq_id++); uip_ipaddr_copy(&rm->dest_addr, addr); uip_gethostaddr(&rm->orig_addr); my_hseqno++; /* Always */ - rm->orig_seqno = htonl(my_hseqno); + rm->orig_seqno = uip_htonl(my_hseqno); bcastconn->ttl = MY_NET_DIAMETER; len = sizeof(struct uaodv_msg_rreq); len += add_rreq_extensions(rm + 1); @@ -220,7 +220,7 @@ send_rrep(uip_ipaddr_t *dest, uip_ipaddr_t *nexthop, uip_ipaddr_t *orig, uip_ipaddr_copy(&rm->orig_addr, orig); rm->dest_seqno = *seqno; uip_ipaddr_copy(&rm->dest_addr, dest); - rm->lifetime = HTONL(MY_ROUTE_TIMEOUT); + rm->lifetime = UIP_HTONL(MY_ROUTE_TIMEOUT); sendto(nexthop, rm, sizeof(struct uaodv_msg_rrep)); } /*---------------------------------------------------------------------------*/ @@ -256,9 +256,9 @@ handle_incoming_rreq(void) uip_ipaddr_to_quad(&BUF->srcipaddr), uip_ipaddr_to_quad(&BUF->destipaddr), BUF->ttl, - uip_ipaddr_to_quad(&rm->orig_addr), ntohl(rm->orig_seqno), + uip_ipaddr_to_quad(&rm->orig_addr), uip_ntohl(rm->orig_seqno), rm->hop_count, - uip_ipaddr_to_quad(&rm->dest_addr), ntohl(rm->dest_seqno)); + uip_ipaddr_to_quad(&rm->dest_addr), uip_ntohl(rm->dest_seqno)); if(uip_ipaddr_cmp(&rm->orig_addr, &uip_hostaddr)) { return; /* RREQ looped back! */ @@ -308,8 +308,8 @@ handle_incoming_rreq(void) /* New reverse route? */ rt = uaodv_rt_lookup(&rm->orig_addr); if(rt == NULL - || (SCMP32(ntohl(rm->orig_seqno), rt->hseqno) > 0) /* New route. */ - || (SCMP32(ntohl(rm->orig_seqno), rt->hseqno) == 0 + || (SCMP32(uip_ntohl(rm->orig_seqno), rt->hseqno) > 0) /* New route. */ + || (SCMP32(uip_ntohl(rm->orig_seqno), rt->hseqno) == 0 && rm->hop_count < rt->hop_count)) { /* Better route. */ print_debug("Inserting1\n"); rt = uaodv_rt_add(&rm->orig_addr, uip_udp_sender(), @@ -324,7 +324,7 @@ handle_incoming_rreq(void) fw = uaodv_rt_lookup(&rm->dest_addr); if(!(rm->flags & UAODV_RREQ_UNKSEQNO) && fw != NULL - && SCMP32(fw->hseqno, ntohl(rm->dest_seqno)) <= 0) { + && SCMP32(fw->hseqno, uip_ntohl(rm->dest_seqno)) <= 0) { fw = NULL; } } @@ -335,7 +335,7 @@ handle_incoming_rreq(void) print_debug("RREQ for known route\n"); uip_ipaddr_copy(&dest_addr, &rm->dest_addr); uip_ipaddr_copy(&orig_addr, &rm->orig_addr); - net_seqno = htonl(fw->hseqno); + net_seqno = uip_htonl(fw->hseqno); send_rrep(&dest_addr, &rt->nexthop, &orig_addr, &net_seqno, fw->hop_count + 1); } else if(uip_ipaddr_cmp(&rm->dest_addr, &uip_hostaddr)) { @@ -347,11 +347,11 @@ handle_incoming_rreq(void) my_hseqno++; if(!(rm->flags & UAODV_RREQ_UNKSEQNO) - && SCMP32(my_hseqno, ntohl(rm->dest_seqno)) < 0) { + && SCMP32(my_hseqno, uip_ntohl(rm->dest_seqno)) < 0) { print_debug("New my_hseqno %lu\n", my_hseqno); /* We have rebooted. */ - my_hseqno = ntohl(rm->dest_seqno) + 1; + my_hseqno = uip_ntohl(rm->dest_seqno) + 1; } - net_seqno = htonl(my_hseqno); + net_seqno = uip_htonl(my_hseqno); send_rrep(&dest_addr, &rt->nexthop, &orig_addr, &net_seqno, 0); } else if(BUF->ttl > 1) { int len; @@ -396,7 +396,7 @@ handle_incoming_rrep(void) } #endif /* Sometimes it helps to send a non-requested RREP in response! */ - net_seqno = htonl(my_hseqno); + net_seqno = uip_htonl(my_hseqno); send_rrep(&uip_hostaddr, &BUF->srcipaddr, &BUF->srcipaddr, &net_seqno, 0); #endif return; @@ -406,14 +406,14 @@ handle_incoming_rrep(void) " dest=%d.%d.%d.%d seq=%lu hops=%u orig=%d.%d.%d.%d\n", uip_ipaddr_to_quad(&BUF->srcipaddr), uip_ipaddr_to_quad(&BUF->destipaddr), - uip_ipaddr_to_quad(&rm->dest_addr), ntohl(rm->dest_seqno), + uip_ipaddr_to_quad(&rm->dest_addr), uip_ntohl(rm->dest_seqno), rm->hop_count, uip_ipaddr_to_quad(&rm->orig_addr)); rt = uaodv_rt_lookup(&rm->dest_addr); /* New forward route? */ - if(rt == NULL || (SCMP32(ntohl(rm->dest_seqno), rt->hseqno) > 0)) { + if(rt == NULL || (SCMP32(uip_ntohl(rm->dest_seqno), rt->hseqno) > 0)) { print_debug("Inserting3\n"); rt = uaodv_rt_add(&rm->dest_addr, uip_udp_sender(), rm->hop_count, &rm->dest_seqno); @@ -469,7 +469,7 @@ handle_incoming_rerr(void) uip_ipaddr_to_quad(&BUF->srcipaddr), uip_ipaddr_to_quad(&BUF->destipaddr), uip_ipaddr_to_quad((uip_ipaddr_t *)&rm->unreach[0]), - ntohl(rm->unreach[0].seqno)); + uip_ntohl(rm->unreach[0].seqno)); if(uip_ipaddr_cmp(&rm->unreach[0].addr, &uip_hostaddr)) return; @@ -477,11 +477,11 @@ handle_incoming_rerr(void) rt = uaodv_rt_lookup_any(&rm->unreach[0].addr); if(rt != NULL && uip_ipaddr_cmp(&rt->nexthop, uip_udp_sender())) { if((rm->flags & UAODV_RERR_UNKNOWN) || rm->unreach[0].seqno == 0 - || SCMP32(rt->hseqno, ntohl(rm->unreach[0].seqno)) <= 0) { + || SCMP32(rt->hseqno, uip_ntohl(rm->unreach[0].seqno)) <= 0) { rt->is_bad = 1; if(rm->flags & UAODV_RERR_UNKNOWN) { rm->flags &= ~UAODV_RERR_UNKNOWN; - rm->unreach[0].seqno = htonl(rt->hseqno); + rm->unreach[0].seqno = uip_htonl(rt->hseqno); } print_debug("RERR rebroadcast\n"); uip_udp_packet_send(bcastconn, rm, sizeof(struct uaodv_msg_rerr)); @@ -529,7 +529,7 @@ uaodv_bad_dest(uip_ipaddr_t *dest) bad_seqno = 0; /* Or flag this in RERR? */ else { rt->is_bad = 1; - bad_seqno = htonl(rt->hseqno); + bad_seqno = uip_htonl(rt->hseqno); } uip_ipaddr_copy(&bad_dest, dest); @@ -576,8 +576,8 @@ PROCESS_THREAD(uaodv_process, ev, data) printf("uaodv_process starting %lu\n", (unsigned long) my_hseqno); - bcastconn = udp_broadcast_new(HTONS(UAODV_UDPPORT), NULL); - unicastconn = udp_broadcast_new(HTONS(UAODV_UDPPORT), NULL); + bcastconn = udp_broadcast_new(UIP_HTONS(UAODV_UDPPORT), NULL); + unicastconn = udp_broadcast_new(UIP_HTONS(UAODV_UDPPORT), NULL); while(1) { PROCESS_WAIT_EVENT(); diff --git a/core/net/uip-fw.c b/core/net/uip-fw.c index c87e55fd5..d1ad38da9 100644 --- a/core/net/uip-fw.c +++ b/core/net/uip-fw.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: uip-fw.c,v 1.11 2008/02/08 09:12:57 nifi Exp $ + * $Id: uip-fw.c,v 1.12 2010/10/19 18:29:04 adamdunkels Exp $ */ /** * \addtogroup uip @@ -413,7 +413,7 @@ uip_fw_forward(void) #ifdef AODV_COMPLIANCE #define udp ((struct uip_udpip_hdr *)&uip_buf[UIP_LLH_LEN]) - if(udp->proto == UIP_PROTO_UDP && udp->destport == HTONS(UAODV_UDPPORT)) { + if(udp->proto == UIP_PROTO_UDP && udp->destport == UIP_HTONS(UAODV_UDPPORT)) { return UIP_FW_LOCAL; } #endif @@ -466,10 +466,10 @@ uip_fw_forward(void) BUF->ttl = BUF->ttl - 1; /* Update the IP checksum. */ - if(BUF->ipchksum >= HTONS(0xffff - 0x0100)) { - BUF->ipchksum = BUF->ipchksum + HTONS(0x0100) + 1; + if(BUF->ipchksum >= UIP_HTONS(0xffff - 0x0100)) { + BUF->ipchksum = BUF->ipchksum + UIP_HTONS(0x0100) + 1; } else { - BUF->ipchksum = BUF->ipchksum + HTONS(0x0100); + BUF->ipchksum = BUF->ipchksum + UIP_HTONS(0x0100); } if(uip_len > 0) { diff --git a/core/net/uip-icmp6.c b/core/net/uip-icmp6.c index 20a223f76..0c4066ecc 100644 --- a/core/net/uip-icmp6.c +++ b/core/net/uip-icmp6.c @@ -179,7 +179,7 @@ uip_icmp6_error_output(u8_t type, u8_t code, u32_t param) { UIP_ICMP_BUF->type = type; UIP_ICMP_BUF->icode = code; - UIP_ICMP6_ERROR_BUF->param = htonl(param); + UIP_ICMP6_ERROR_BUF->param = uip_htonl(param); UIP_IP_BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8); UIP_IP_BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff); UIP_ICMP_BUF->icmpchksum = 0; diff --git a/core/net/uip-nd6.c b/core/net/uip-nd6.c index 96cc91eca..8bd60fe5d 100644 --- a/core/net/uip-nd6.c +++ b/core/net/uip-nd6.c @@ -632,9 +632,9 @@ uip_nd6_ra_output(uip_ipaddr_t * dest) UIP_ND6_RA_BUF->flags_reserved = (UIP_ND6_M_FLAG << 7) | (UIP_ND6_O_FLAG << 6); - UIP_ND6_RA_BUF->router_lifetime = htons(UIP_ND6_ROUTER_LIFETIME); - //UIP_ND6_RA_BUF->reachable_time = htonl(uip_ds6_if.reachable_time); - //UIP_ND6_RA_BUF->retrans_timer = htonl(uip_ds6_if.retrans_timer); + UIP_ND6_RA_BUF->router_lifetime = uip_htons(UIP_ND6_ROUTER_LIFETIME); + //UIP_ND6_RA_BUF->reachable_time = uip_htonl(uip_ds6_if.reachable_time); + //UIP_ND6_RA_BUF->retrans_timer = uip_htonl(uip_ds6_if.retrans_timer); UIP_ND6_RA_BUF->reachable_time = 0; UIP_ND6_RA_BUF->retrans_timer = 0; @@ -650,8 +650,8 @@ uip_nd6_ra_output(uip_ipaddr_t * dest) UIP_ND6_OPT_PREFIX_BUF->len = UIP_ND6_OPT_PREFIX_INFO_LEN / 8; UIP_ND6_OPT_PREFIX_BUF->preflen = prefix->length; UIP_ND6_OPT_PREFIX_BUF->flagsreserved1 = prefix->l_a_reserved; - UIP_ND6_OPT_PREFIX_BUF->validlt = htonl(prefix->vlifetime); - UIP_ND6_OPT_PREFIX_BUF->preferredlt = htonl(prefix->plifetime); + UIP_ND6_OPT_PREFIX_BUF->validlt = uip_htonl(prefix->vlifetime); + UIP_ND6_OPT_PREFIX_BUF->preferredlt = uip_htonl(prefix->plifetime); UIP_ND6_OPT_PREFIX_BUF->reserved2 = 0; uip_ipaddr_copy(&(UIP_ND6_OPT_PREFIX_BUF->prefix), &(prefix->ipaddr)); nd6_opt_offset += UIP_ND6_OPT_PREFIX_INFO_LEN; @@ -669,8 +669,8 @@ uip_nd6_ra_output(uip_ipaddr_t * dest) UIP_ND6_OPT_MTU_BUF->type = UIP_ND6_OPT_MTU; UIP_ND6_OPT_MTU_BUF->len = UIP_ND6_OPT_MTU_LEN >> 3; UIP_ND6_OPT_MTU_BUF->reserved = 0; - //UIP_ND6_OPT_MTU_BUF->mtu = htonl(uip_ds6_if.link_mtu); - UIP_ND6_OPT_MTU_BUF->mtu = htonl(1500); + //UIP_ND6_OPT_MTU_BUF->mtu = uip_htonl(uip_ds6_if.link_mtu); + UIP_ND6_OPT_MTU_BUF->mtu = uip_htonl(1500); uip_len += UIP_ND6_OPT_MTU_LEN; nd6_opt_offset += UIP_ND6_OPT_MTU_LEN; @@ -760,13 +760,13 @@ uip_nd6_ra_input(void) if(UIP_ND6_RA_BUF->reachable_time != 0) { if(uip_ds6_if.base_reachable_time != - ntohl(UIP_ND6_RA_BUF->reachable_time)) { - uip_ds6_if.base_reachable_time = ntohl(UIP_ND6_RA_BUF->reachable_time); + uip_ntohl(UIP_ND6_RA_BUF->reachable_time)) { + uip_ds6_if.base_reachable_time = uip_ntohl(UIP_ND6_RA_BUF->reachable_time); uip_ds6_if.reachable_time = uip_ds6_compute_reachable_time(); } } if(UIP_ND6_RA_BUF->retrans_timer != 0) { - uip_ds6_if.retrans_timer = ntohl(UIP_ND6_RA_BUF->retrans_timer); + uip_ds6_if.retrans_timer = uip_ntohl(UIP_ND6_RA_BUF->retrans_timer); } /* Options processing */ @@ -801,13 +801,13 @@ uip_nd6_ra_input(void) case UIP_ND6_OPT_MTU: PRINTF("Processing MTU option in RA\n"); uip_ds6_if.link_mtu = - ntohl(((uip_nd6_opt_mtu *) UIP_ND6_OPT_HDR_BUF)->mtu); + uip_ntohl(((uip_nd6_opt_mtu *) UIP_ND6_OPT_HDR_BUF)->mtu); break; case UIP_ND6_OPT_PREFIX_INFO: PRINTF("Processing PREFIX option in RA\n"); nd6_opt_prefix_info = (uip_nd6_opt_prefix_info *) UIP_ND6_OPT_HDR_BUF; - if((ntohl(nd6_opt_prefix_info->validlt) >= - ntohl(nd6_opt_prefix_info->preferredlt)) + if((uip_ntohl(nd6_opt_prefix_info->validlt) >= + uip_ntohl(nd6_opt_prefix_info->preferredlt)) && (!uip_is_addr_link_local(&nd6_opt_prefix_info->prefix))) { /* on-link flag related processing */ if(nd6_opt_prefix_info->flagsreserved1 & UIP_ND6_RA_FLAG_ONLINK) { @@ -819,7 +819,7 @@ uip_nd6_ra_input(void) if(nd6_opt_prefix_info->validlt != UIP_ND6_INFINITE_LIFETIME) { prefix = uip_ds6_prefix_add(&nd6_opt_prefix_info->prefix, nd6_opt_prefix_info->preflen, - ntohl(nd6_opt_prefix_info-> + uip_ntohl(nd6_opt_prefix_info-> validlt)); } else { prefix = uip_ds6_prefix_add(&nd6_opt_prefix_info->prefix, @@ -837,9 +837,9 @@ uip_nd6_ra_input(void) default: PRINTF("Updating timer of prefix"); PRINT6ADDR(&prefix->ipaddr); - PRINTF("new value %lu\n", ntohl(nd6_opt_prefix_info->validlt)); + PRINTF("new value %lu\n", uip_ntohl(nd6_opt_prefix_info->validlt)); stimer_set(&prefix->vlifetime, - ntohl(nd6_opt_prefix_info->validlt)); + uip_ntohl(nd6_opt_prefix_info->validlt)); prefix->isinfinite = 0; break; } @@ -857,15 +857,15 @@ uip_nd6_ra_input(void) if((addr != NULL) && (addr->type == ADDR_AUTOCONF)) { if(nd6_opt_prefix_info->validlt != UIP_ND6_INFINITE_LIFETIME) { /* The processing below is defined in RFC4862 section 5.5.3 e */ - if((ntohl(nd6_opt_prefix_info->validlt) > 2 * 60 * 60) || - (ntohl(nd6_opt_prefix_info->validlt) > + if((uip_ntohl(nd6_opt_prefix_info->validlt) > 2 * 60 * 60) || + (uip_ntohl(nd6_opt_prefix_info->validlt) > stimer_remaining(&addr->vlifetime))) { PRINTF("Updating timer of address"); PRINT6ADDR(&addr->ipaddr); PRINTF("new value %lu\n", - ntohl(nd6_opt_prefix_info->validlt)); + uip_ntohl(nd6_opt_prefix_info->validlt)); stimer_set(&addr->vlifetime, - ntohl(nd6_opt_prefix_info->validlt)); + uip_ntohl(nd6_opt_prefix_info->validlt)); } else { stimer_set(&addr->vlifetime, 2 * 60 * 60); PRINTF("Updating timer of address "); @@ -877,11 +877,11 @@ uip_nd6_ra_input(void) addr->isinfinite = 1; } } else { - if(ntohl(nd6_opt_prefix_info->validlt) == + if(uip_ntohl(nd6_opt_prefix_info->validlt) == UIP_ND6_INFINITE_LIFETIME) { uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF); } else { - uip_ds6_addr_add(&ipaddr, ntohl(nd6_opt_prefix_info->validlt), + uip_ds6_addr_add(&ipaddr, uip_ntohl(nd6_opt_prefix_info->validlt), ADDR_AUTOCONF); } } @@ -904,10 +904,10 @@ uip_nd6_ra_input(void) if(defrt == NULL) { uip_ds6_defrt_add(&UIP_IP_BUF->srcipaddr, (unsigned - long)(ntohs(UIP_ND6_RA_BUF->router_lifetime))); + long)(uip_ntohs(UIP_ND6_RA_BUF->router_lifetime))); } else { stimer_set(&(defrt->lifetime), - (unsigned long)(ntohs(UIP_ND6_RA_BUF->router_lifetime))); + (unsigned long)(uip_ntohs(UIP_ND6_RA_BUF->router_lifetime))); } } else { if(defrt != NULL) { diff --git a/core/net/uip.c b/core/net/uip.c index e808b1e70..3fe8dfff0 100644 --- a/core/net/uip.c +++ b/core/net/uip.c @@ -41,7 +41,7 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: uip.c,v 1.29 2010/05/30 09:46:12 oliverschmidt Exp $ + * $Id: uip.c,v 1.30 2010/10/19 18:29:04 adamdunkels Exp $ * */ @@ -302,7 +302,7 @@ chksum(u16_t sum, const u8_t *data, u16_t len) u16_t uip_chksum(u16_t *data, u16_t len) { - return htons(chksum(0, (u8_t *)data, len)); + return uip_htons(chksum(0, (u8_t *)data, len)); } /*---------------------------------------------------------------------------*/ #ifndef UIP_ARCH_IPCHKSUM @@ -313,7 +313,7 @@ uip_ipchksum(void) sum = chksum(0, &uip_buf[UIP_LLH_LEN], UIP_IPH_LEN); DEBUG_PRINTF("uip_ipchksum: sum 0x%04x\n", sum); - return (sum == 0) ? 0xffff : htons(sum); + return (sum == 0) ? 0xffff : uip_htons(sum); } #endif /*---------------------------------------------------------------------------*/ @@ -340,7 +340,7 @@ upper_layer_chksum(u8_t proto) sum = chksum(sum, &uip_buf[UIP_IPH_LEN + UIP_LLH_LEN], upper_layer_len); - return (sum == 0) ? 0xffff : htons(sum); + return (sum == 0) ? 0xffff : uip_htons(sum); } /*---------------------------------------------------------------------------*/ #if UIP_CONF_IPV6 @@ -413,7 +413,7 @@ uip_connect(uip_ipaddr_t *ripaddr, u16_t rport) for(c = 0; c < UIP_CONNS; ++c) { conn = &uip_conns[c]; if(conn->tcpstateflags != UIP_CLOSED && - conn->lport == htons(lastport)) { + conn->lport == uip_htons(lastport)) { goto again; } } @@ -452,7 +452,7 @@ uip_connect(uip_ipaddr_t *ripaddr, u16_t rport) conn->rto = UIP_RTO; conn->sa = 0; conn->sv = 16; /* Initial value of the RTT variance. */ - conn->lport = htons(lastport); + conn->lport = uip_htons(lastport); conn->rport = rport; uip_ipaddr_copy(&conn->ripaddr, ripaddr); @@ -475,7 +475,7 @@ uip_udp_new(const uip_ipaddr_t *ripaddr, u16_t rport) } for(c = 0; c < UIP_UDP_CONNS; ++c) { - if(uip_udp_conns[c].lport == htons(lastport)) { + if(uip_udp_conns[c].lport == uip_htons(lastport)) { goto again; } } @@ -493,7 +493,7 @@ uip_udp_new(const uip_ipaddr_t *ripaddr, u16_t rport) return 0; } - conn->lport = HTONS(lastport); + conn->lport = UIP_HTONS(lastport); conn->rport = rport; if(ripaddr == NULL) { memset(&conn->ripaddr, 0, sizeof(uip_ipaddr_t)); @@ -935,7 +935,7 @@ uip_process(u8_t flag) address) as well. However, we will cheat here and accept all multicast packets that are sent to the ff02::/16 addresses. */ if(!uip_ipaddr_cmp(&BUF->destipaddr, &uip_hostaddr) && - BUF->destipaddr.u16[0] != HTONS(0xff02)) { + BUF->destipaddr.u16[0] != UIP_HTONS(0xff02)) { UIP_STAT(++uip_stat.ip.drop); goto drop; } @@ -1000,10 +1000,10 @@ uip_process(u8_t flag) ICMPBUF->type = ICMP_ECHO_REPLY; - if(ICMPBUF->icmpchksum >= HTONS(0xffff - (ICMP_ECHO << 8))) { - ICMPBUF->icmpchksum += HTONS(ICMP_ECHO << 8) + 1; + if(ICMPBUF->icmpchksum >= UIP_HTONS(0xffff - (ICMP_ECHO << 8))) { + ICMPBUF->icmpchksum += UIP_HTONS(ICMP_ECHO << 8) + 1; } else { - ICMPBUF->icmpchksum += HTONS(ICMP_ECHO << 8); + ICMPBUF->icmpchksum += UIP_HTONS(ICMP_ECHO << 8); } /* Swap IP addresses. */ @@ -1191,7 +1191,7 @@ uip_process(u8_t flag) BUF->ttl = uip_udp_conn->ttl; BUF->proto = UIP_PROTO_UDP; - UDPBUF->udplen = HTONS(uip_slen + UIP_UDPH_LEN); + UDPBUF->udplen = UIP_HTONS(uip_slen + UIP_UDPH_LEN); UDPBUF->udpchksum = 0; BUF->srcport = uip_udp_conn->lport; @@ -1939,15 +1939,15 @@ uip_process(u8_t flag) } /*---------------------------------------------------------------------------*/ u16_t -htons(u16_t val) +uip_htons(u16_t val) { - return HTONS(val); + return UIP_HTONS(val); } u32_t -htonl(u32_t val) +uip_htonl(u32_t val) { - return HTONL(val); + return UIP_HTONL(val); } /*---------------------------------------------------------------------------*/ void diff --git a/core/net/uip.h b/core/net/uip.h index 6629e9a25..f04ebd0d9 100644 --- a/core/net/uip.h +++ b/core/net/uip.h @@ -47,7 +47,7 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: uip.h,v 1.34 2010/05/30 09:46:12 oliverschmidt Exp $ + * $Id: uip.h,v 1.35 2010/10/19 18:29:04 adamdunkels Exp $ * */ @@ -290,14 +290,14 @@ void uip_setipid(u16_t id); #define BUF ((struct uip_eth_hdr *)&uip_buf[0]) uip_len = ethernet_devicedrver_poll(); if(uip_len > 0) { - if(BUF->type == HTONS(UIP_ETHTYPE_IP)) { + if(BUF->type == UIP_HTONS(UIP_ETHTYPE_IP)) { uip_arp_ipin(); uip_input(); if(uip_len > 0) { uip_arp_out(); ethernet_devicedriver_send(); } - } else if(BUF->type == HTONS(UIP_ETHTYPE_ARP)) { + } else if(BUF->type == UIP_HTONS(UIP_ETHTYPE_ARP)) { uip_arp_arpin(); if(uip_len > 0) { ethernet_devicedriver_send(); @@ -504,10 +504,10 @@ CCIF extern uip_buf_t uip_aligned_buf; * Start listening to the specified port. * * \note Since this function expects the port number in network byte - * order, a conversion using HTONS() or htons() is necessary. + * order, a conversion using UIP_HTONS() or uip_htons() is necessary. * \code - uip_listen(HTONS(80)); + uip_listen(UIP_HTONS(80)); \endcode * * \param port A 16-bit port number in network byte order. @@ -518,10 +518,10 @@ void uip_listen(u16_t port); * Stop listening to the specified port. * * \note Since this function expects the port number in network byte - * order, a conversion using HTONS() or htons() is necessary. + * order, a conversion using UIP_HTONS() or uip_htons() is necessary. * \code - uip_unlisten(HTONS(80)); + uip_unlisten(UIP_HTONS(80)); \endcode * * \param port A 16-bit port number in network byte order. @@ -543,13 +543,13 @@ void uip_unlisten(u16_t port); * has been configured by defining UIP_ACTIVE_OPEN to 1 in uipopt.h. * * \note Since this function requires the port number to be in network - * byte order, a conversion using HTONS() or htons() is necessary. + * byte order, a conversion using UIP_HTONS() or uip_htons() is necessary. * \code uip_ipaddr_t ipaddr; uip_ipaddr(&ipaddr, 192,168,1,2); - uip_connect(&ipaddr, HTONS(80)); + uip_connect(&ipaddr, UIP_HTONS(80)); \endcode * * \param ripaddr The IP address of the remote host. @@ -816,9 +816,9 @@ CCIF void uip_send(const void *data, int len); struct uip_udp_conn *c; uip_ipaddr(&addr, 192,168,2,1); - c = uip_udp_new(&addr, HTONS(12345)); + c = uip_udp_new(&addr, UIP_HTONS(12345)); if(c != NULL) { - uip_udp_bind(c, HTONS(12344)); + uip_udp_bind(c, UIP_HTONS(12344)); } \endcode * \param ripaddr The IP address of the remote host. @@ -903,7 +903,7 @@ struct uip_udp_conn *uip_udp_new(const uip_ipaddr_t *ripaddr, u16_t rport); struct uip_conn *c; uip_ipaddr(&ipaddr, 192,168,1,2); - c = uip_connect(&ipaddr, HTONS(80)); + c = uip_connect(&ipaddr, UIP_HTONS(80)); \endcode * * \param addr A pointer to a uip_ipaddr_t variable that will be @@ -931,14 +931,14 @@ struct uip_udp_conn *uip_udp_new(const uip_ipaddr_t *ripaddr, u16_t rport); * \hideinitializer */ #define uip_ip6addr(addr, addr0,addr1,addr2,addr3,addr4,addr5,addr6,addr7) do { \ - (addr)->u16[0] = HTONS(addr0); \ - (addr)->u16[1] = HTONS(addr1); \ - (addr)->u16[2] = HTONS(addr2); \ - (addr)->u16[3] = HTONS(addr3); \ - (addr)->u16[4] = HTONS(addr4); \ - (addr)->u16[5] = HTONS(addr5); \ - (addr)->u16[6] = HTONS(addr6); \ - (addr)->u16[7] = HTONS(addr7); \ + (addr)->u16[0] = UIP_HTONS(addr0); \ + (addr)->u16[1] = UIP_HTONS(addr1); \ + (addr)->u16[2] = UIP_HTONS(addr2); \ + (addr)->u16[3] = UIP_HTONS(addr3); \ + (addr)->u16[4] = UIP_HTONS(addr4); \ + (addr)->u16[5] = UIP_HTONS(addr5); \ + (addr)->u16[6] = UIP_HTONS(addr6); \ + (addr)->u16[7] = UIP_HTONS(addr7); \ } while(0) /** @@ -1184,41 +1184,41 @@ struct uip_udp_conn *uip_udp_new(const uip_ipaddr_t *ripaddr, u16_t rport); * * This macro is primarily used for converting constants from host * byte order to network byte order. For converting variables to - * network byte order, use the htons() function instead. + * network byte order, use the uip_htons() function instead. * * \hideinitializer */ -#ifndef HTONS +#ifndef UIP_HTONS # if UIP_BYTE_ORDER == UIP_BIG_ENDIAN -# define HTONS(n) (n) -# define HTONL(n) (n) +# define UIP_HTONS(n) (n) +# define UIP_HTONL(n) (n) # else /* UIP_BYTE_ORDER == UIP_BIG_ENDIAN */ -# define HTONS(n) (u16_t)((((u16_t) (n)) << 8) | (((u16_t) (n)) >> 8)) -# define HTONL(n) (((u32_t)HTONS(n) << 16) | HTONS((u32_t)(n) >> 16)) +# define UIP_HTONS(n) (u16_t)((((u16_t) (n)) << 8) | (((u16_t) (n)) >> 8)) +# define UIP_HTONL(n) (((u32_t)UIP_HTONS(n) << 16) | UIP_HTONS((u32_t)(n) >> 16)) # endif /* UIP_BYTE_ORDER == UIP_BIG_ENDIAN */ #else -#error "HTONS already defined!" -#endif /* HTONS */ +#error "UIP_HTONS already defined!" +#endif /* UIP_HTONS */ /** * Convert 16-bit quantity from host byte order to network byte order. * * This function is primarily used for converting variables from host * byte order to network byte order. For converting constants to - * network byte order, use the HTONS() macro instead. + * network byte order, use the UIP_HTONS() macro instead. */ -#ifndef htons -CCIF u16_t htons(u16_t val); -#endif /* htons */ -#ifndef ntohs -#define ntohs htons +#ifndef uip_htons +CCIF u16_t uip_htons(u16_t val); +#endif /* uip_htons */ +#ifndef uip_ntohs +#define uip_ntohs uip_htons #endif -#ifndef htonl -CCIF u32_t htonl(u32_t val); -#endif /* htonl */ -#ifndef ntohl -#define ntohl htonl +#ifndef uip_htonl +CCIF u32_t uip_htonl(u32_t val); +#endif /* uip_htonl */ +#ifndef uip_ntohl +#define uip_ntohl uip_htonl #endif /** @} */ @@ -1993,7 +1993,7 @@ CCIF extern uip_lladdr_t uip_lladdr; /** \brief set IP address a to the link local all-routers multicast address */ #define uip_create_linklocal_allrouters_mcast(a) uip_ip6addr(a, 0xff02, 0, 0, 0, 0, 0, 0, 0x0002) #define uip_create_linklocal_prefix(addr) do { \ - (addr)->u16[0] = HTONS(0xfe80); \ + (addr)->u16[0] = UIP_HTONS(0xfe80); \ (addr)->u16[1] = 0; \ (addr)->u16[2] = 0; \ (addr)->u16[3] = 0; \ diff --git a/core/net/uip6.c b/core/net/uip6.c index 9ad6a4320..5d0478b52 100644 --- a/core/net/uip6.c +++ b/core/net/uip6.c @@ -41,7 +41,7 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: uip6.c,v 1.23 2010/05/24 10:07:34 joxe Exp $ + * $Id: uip6.c,v 1.24 2010/10/19 18:29:04 adamdunkels Exp $ * */ @@ -337,7 +337,7 @@ chksum(u16_t sum, const u8_t *data, u16_t len) u16_t uip_chksum(u16_t *data, u16_t len) { - return htons(chksum(0, (u8_t *)data, len)); + return uip_htons(chksum(0, (u8_t *)data, len)); } /*---------------------------------------------------------------------------*/ #ifndef UIP_ARCH_IPCHKSUM @@ -348,7 +348,7 @@ uip_ipchksum(void) sum = chksum(0, &uip_buf[UIP_LLH_LEN], UIP_IPH_LEN); PRINTF("uip_ipchksum: sum 0x%04x\n", sum); - return (sum == 0) ? 0xffff : htons(sum); + return (sum == 0) ? 0xffff : uip_htons(sum); } #endif /*---------------------------------------------------------------------------*/ @@ -370,7 +370,7 @@ upper_layer_chksum(u8_t proto) sum = chksum(sum, &uip_buf[UIP_IPH_LEN + UIP_LLH_LEN + uip_ext_len], upper_layer_len); - return (sum == 0) ? 0xffff : htons(sum); + return (sum == 0) ? 0xffff : uip_htons(sum); } /*---------------------------------------------------------------------------*/ u16_t @@ -443,7 +443,7 @@ uip_connect(uip_ipaddr_t *ripaddr, u16_t rport) for(c = 0; c < UIP_CONNS; ++c) { conn = &uip_conns[c]; if(conn->tcpstateflags != UIP_CLOSED && - conn->lport == htons(lastport)) { + conn->lport == uip_htons(lastport)) { goto again; } } @@ -482,7 +482,7 @@ uip_connect(uip_ipaddr_t *ripaddr, u16_t rport) conn->rto = UIP_RTO; conn->sa = 0; conn->sv = 16; /* Initial value of the RTT variance. */ - conn->lport = htons(lastport); + conn->lport = uip_htons(lastport); conn->rport = rport; uip_ipaddr_copy(&conn->ripaddr, ripaddr); @@ -507,7 +507,7 @@ uip_udp_new(const uip_ipaddr_t *ripaddr, u16_t rport) } for(c = 0; c < UIP_UDP_CONNS; ++c) { - if(uip_udp_conns[c].lport == htons(lastport)) { + if(uip_udp_conns[c].lport == uip_htons(lastport)) { goto again; } } @@ -525,7 +525,7 @@ uip_udp_new(const uip_ipaddr_t *ripaddr, u16_t rport) return 0; } - conn->lport = HTONS(lastport); + conn->lport = UIP_HTONS(lastport); conn->rport = rport; if(ripaddr == NULL) { memset(&conn->ripaddr, 0, sizeof(uip_ipaddr_t)); @@ -634,7 +634,7 @@ uip_reass(void) uip_ipaddr_cmp(&FBUF->destipaddr, &UIP_IP_BUF->destipaddr) && UIP_FRAG_BUF->id == uip_id) { len = uip_len - uip_ext_len - UIP_IPH_LEN - UIP_FRAGH_LEN; - offset = (ntohs(UIP_FRAG_BUF->offsetresmore) & 0xfff8); + offset = (uip_ntohs(UIP_FRAG_BUF->offsetresmore) & 0xfff8); /* in byte, originaly in multiple of 8 bytes*/ PRINTF("len %d\n", len); PRINTF("offset %d\n", offset); @@ -666,7 +666,7 @@ uip_reass(void) /* If this fragment has the More Fragments flag set to zero, it is the last fragment*/ - if((ntohs(UIP_FRAG_BUF->offsetresmore) & IP_MF) == 0) { + if((uip_ntohs(UIP_FRAG_BUF->offsetresmore) & IP_MF) == 0) { uip_reassflags |= UIP_REASS_FLAG_LASTFRAG; /*calculate the size of the entire packet*/ uip_reasslen = offset + len; @@ -1442,7 +1442,7 @@ uip_process(u8_t flag) UIP_IP_BUF->ttl = uip_udp_conn->ttl; UIP_IP_BUF->proto = UIP_PROTO_UDP; - UIP_UDP_BUF->udplen = HTONS(uip_slen + UIP_UDPH_LEN); + UIP_UDP_BUF->udplen = UIP_HTONS(uip_slen + UIP_UDPH_LEN); UIP_UDP_BUF->udpchksum = 0; UIP_UDP_BUF->srcport = uip_udp_conn->lport; @@ -2189,15 +2189,15 @@ uip_process(u8_t flag) } /*---------------------------------------------------------------------------*/ u16_t -htons(u16_t val) +uip_htons(u16_t val) { - return HTONS(val); + return UIP_HTONS(val); } u32_t -htonl(u32_t val) +uip_htonl(u32_t val) { - return HTONL(val); + return UIP_HTONL(val); } /*---------------------------------------------------------------------------*/ void diff --git a/core/net/uip_arp.c b/core/net/uip_arp.c index d15fbab1d..fb2c17df5 100644 --- a/core/net/uip_arp.c +++ b/core/net/uip_arp.c @@ -54,7 +54,7 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: uip_arp.c,v 1.5 2008/02/07 01:35:00 adamdunkels Exp $ + * $Id: uip_arp.c,v 1.6 2010/10/19 18:29:04 adamdunkels Exp $ * */ @@ -290,7 +290,7 @@ uip_arp_arpin(void) uip_len = 0; switch(BUF->opcode) { - case HTONS(ARP_REQUEST): + case UIP_HTONS(ARP_REQUEST): /* ARP request. If it asked for our address, we send out a reply. */ /* if(BUF->dipaddr[0] == uip_hostaddr[0] && @@ -306,7 +306,7 @@ uip_arp_arpin(void) with this host in the future. */ uip_arp_update(&BUF->sipaddr, &BUF->shwaddr); - BUF->opcode = HTONS(ARP_REPLY); + BUF->opcode = UIP_HTONS(ARP_REPLY); memcpy(BUF->dhwaddr.addr, BUF->shwaddr.addr, 6); memcpy(BUF->shwaddr.addr, uip_ethaddr.addr, 6); @@ -316,11 +316,11 @@ uip_arp_arpin(void) uip_ipaddr_copy(&BUF->dipaddr, &BUF->sipaddr); uip_ipaddr_copy(&BUF->sipaddr, &uip_hostaddr); - BUF->ethhdr.type = HTONS(UIP_ETHTYPE_ARP); + BUF->ethhdr.type = UIP_HTONS(UIP_ETHTYPE_ARP); uip_len = sizeof(struct arp_hdr); } break; - case HTONS(ARP_REPLY): + case UIP_HTONS(ARP_REPLY): /* ARP reply. We insert or update the ARP table if it was meant for us. */ if(uip_ipaddr_cmp(&BUF->dipaddr, &uip_hostaddr)) { @@ -404,12 +404,12 @@ uip_arp_out(void) 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); + BUF->opcode = UIP_HTONS(ARP_REQUEST); /* ARP request. */ + BUF->hwtype = UIP_HTONS(ARP_HWTYPE_ETH); + BUF->protocol = UIP_HTONS(UIP_ETHTYPE_IP); BUF->hwlen = 6; BUF->protolen = 4; - BUF->ethhdr.type = HTONS(UIP_ETHTYPE_ARP); + BUF->ethhdr.type = UIP_HTONS(UIP_ETHTYPE_ARP); uip_appdata = &uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN]; @@ -422,7 +422,7 @@ uip_arp_out(void) } memcpy(IPBUF->ethhdr.src.addr, uip_ethaddr.addr, 6); - IPBUF->ethhdr.type = HTONS(UIP_ETHTYPE_IP); + IPBUF->ethhdr.type = UIP_HTONS(UIP_ETHTYPE_IP); uip_len += sizeof(struct uip_eth_hdr); } diff --git a/cpu/6502/net/ethernet-drv.c b/cpu/6502/net/ethernet-drv.c index f7b18f94a..4a5231d42 100644 --- a/cpu/6502/net/ethernet-drv.c +++ b/cpu/6502/net/ethernet-drv.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: ethernet-drv.c,v 1.2 2007/11/27 20:54:10 oliverschmidt Exp $ + * @(#)$Id: ethernet-drv.c,v 1.3 2010/10/19 18:29:04 adamdunkels Exp $ */ #include @@ -61,15 +61,15 @@ pollhandler(void) if(uip_len > 0) { #if UIP_CONF_IPV6 - if(BUF->type == htons(UIP_ETHTYPE_IPV6)) { + if(BUF->type == uip_htons(UIP_ETHTYPE_IPV6)) { uip_neighbor_add(&IPBUF->srcipaddr, &BUF->src); tcpip_input(); } else #endif /* UIP_CONF_IPV6 */ - if(BUF->type == htons(UIP_ETHTYPE_IP)) { + if(BUF->type == uip_htons(UIP_ETHTYPE_IP)) { uip_len -= sizeof(struct uip_eth_hdr); tcpip_input(); - } else if(BUF->type == htons(UIP_ETHTYPE_ARP)) { + } else if(BUF->type == uip_htons(UIP_ETHTYPE_ARP)) { uip_arp_arpin(); /* If the above function invocation resulted in data that should be sent out on the network, the global variable diff --git a/cpu/arm/at91sam7s/loader/codeprop-otf.c b/cpu/arm/at91sam7s/loader/codeprop-otf.c index fa739d38b..5a914ae74 100644 --- a/cpu/arm/at91sam7s/loader/codeprop-otf.c +++ b/cpu/arm/at91sam7s/loader/codeprop-otf.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: codeprop-otf.c,v 1.1 2009/07/11 14:18:50 ksb Exp $ + * @(#)$Id: codeprop-otf.c,v 1.2 2010/10/19 18:29:04 adamdunkels Exp $ */ /** \addtogroup esb @@ -175,9 +175,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; @@ -205,9 +205,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; @@ -220,7 +220,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); @@ -249,13 +249,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); @@ -273,8 +273,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); } /*---------------------------------------------------------------------*/ @@ -285,7 +285,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); @@ -294,29 +294,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) { @@ -333,8 +333,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); } @@ -346,8 +346,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); } @@ -395,7 +395,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 += CODEPROP_TCPHDR_SIZE; datalen -= CODEPROP_TCPHDR_SIZE; @@ -493,7 +493,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) { diff --git a/cpu/arm/common/usb/cdc-eth/cdc-eth.c b/cpu/arm/common/usb/cdc-eth/cdc-eth.c index 1e85872fd..ac9e729a6 100644 --- a/cpu/arm/common/usb/cdc-eth/cdc-eth.c +++ b/cpu/arm/common/usb/cdc-eth/cdc-eth.c @@ -118,15 +118,15 @@ PROCESS_THREAD(usb_eth_process, ev , data) /* printf("Received: %d bytes\n", uip_len); */ memcpy(uip_buf, recv_data, uip_len); #if UIP_CONF_IPV6 - if(BUF->type == htons(UIP_ETHTYPE_IPV6)) { + if(BUF->type == uip_htons(UIP_ETHTYPE_IPV6)) { uip_neighbor_add(&IPBUF->srcipaddr, &BUF->src); tcpip_input(); } else #endif /* UIP_CONF_IPV6 */ - if(BUF->type == htons(UIP_ETHTYPE_IP)) { + if(BUF->type == uip_htons(UIP_ETHTYPE_IP)) { uip_len -= sizeof(struct uip_eth_hdr); tcpip_input(); - } else if(BUF->type == htons(UIP_ETHTYPE_ARP)) { + } else if(BUF->type == uip_htons(UIP_ETHTYPE_ARP)) { uip_arp_arpin(); /* If the above function invocation resulted in data that should be sent out on the network, the global variable diff --git a/cpu/arm/common/usb/cdc-eth/dhcps.c b/cpu/arm/common/usb/cdc-eth/dhcps.c index f994d0b12..fd295f831 100644 --- a/cpu/arm/common/usb/cdc-eth/dhcps.c +++ b/cpu/arm/common/usb/cdc-eth/dhcps.c @@ -29,7 +29,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: dhcps.c,v 1.1 2009/07/11 14:37:11 ksb Exp $ + * @(#)$Id: dhcps.c,v 1.2 2010/10/19 18:29:04 adamdunkels Exp $ */ #include @@ -256,7 +256,7 @@ add_lease_time(uint8_t *optptr) uint32_t lt; *optptr++ = DHCP_OPTION_LEASE_TIME; *optptr++ = 4; - lt = HTONL(config->default_lease_time); + lt = UIP_HTONL(config->default_lease_time); memcpy(optptr, <, 4); return optptr + 4; } @@ -381,13 +381,13 @@ PROCESS_THREAD(dhcp_server_process, ev , data) printf("DHCP server starting\n"); uip_ipaddr(&any_addr, 0,0,0,0); uip_ipaddr(&bcast_addr, 255,255,255,255); - conn = udp_new(&any_addr, HTONS(DHCPS_CLIENT_PORT), NULL); + conn = udp_new(&any_addr, UIP_HTONS(DHCPS_CLIENT_PORT), NULL); if (!conn) goto exit; - send_conn = udp_new(&bcast_addr, HTONS(DHCPS_CLIENT_PORT), NULL); + send_conn = udp_new(&bcast_addr, UIP_HTONS(DHCPS_CLIENT_PORT), NULL); if (!send_conn) goto exit; - uip_udp_bind(conn, HTONS(DHCPS_SERVER_PORT)); - uip_udp_bind(send_conn, HTONS(DHCPS_SERVER_PORT)); + uip_udp_bind(conn, UIP_HTONS(DHCPS_SERVER_PORT)); + uip_udp_bind(send_conn, UIP_HTONS(DHCPS_SERVER_PORT)); while(1) { PROCESS_WAIT_EVENT(); if(ev == tcpip_event) { diff --git a/cpu/avr/dev/rtl8019-drv.c b/cpu/avr/dev/rtl8019-drv.c index ea5f9745e..a65a68dd5 100644 --- a/cpu/avr/dev/rtl8019-drv.c +++ b/cpu/avr/dev/rtl8019-drv.c @@ -29,7 +29,7 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: rtl8019-drv.c,v 1.2 2007/05/26 23:05:36 oliverschmidt Exp $ + * $Id: rtl8019-drv.c,v 1.3 2010/10/19 18:29:04 adamdunkels Exp $ * */ @@ -59,15 +59,15 @@ pollhandler(void) if(uip_len > 0) { #if UIP_CONF_IPV6 - if(BUF->type == htons(UIP_ETHTYPE_IPV6)) { + if(BUF->type == uip_htons(UIP_ETHTYPE_IPV6)) { uip_neighbor_add(&IPBUF->srcipaddr, &BUF->src); tcpip_input(); } else #endif /* UIP_CONF_IPV6 */ - if(BUF->type == htons(UIP_ETHTYPE_IP)) { + if(BUF->type == uip_htons(UIP_ETHTYPE_IP)) { uip_len -= sizeof(struct uip_eth_hdr); tcpip_input(); - } else if(BUF->type == htons(UIP_ETHTYPE_ARP)) { + } else if(BUF->type == uip_htons(UIP_ETHTYPE_ARP)) { uip_arp_arpin(); /* If the above function invocation resulted in data that should be sent out on the network, the global variable diff --git a/cpu/cc2430/uip_arch.c b/cpu/cc2430/uip_arch.c index 923882f8a..c0010c69a 100644 --- a/cpu/cc2430/uip_arch.c +++ b/cpu/cc2430/uip_arch.c @@ -27,7 +27,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: uip_arch.c,v 1.1 2009/09/08 20:07:35 zdshelby Exp $ + * $Id: uip_arch.c,v 1.2 2010/10/19 18:29:04 adamdunkels Exp $ * */ /* @@ -130,10 +130,10 @@ _upper_layer_chksum_call: ld a, h or a, l - jr nz, _upper_layer_htons + jr nz, _upper_layer_uip_htons ld hl, #0xffff jr _upper_layer_ret -_upper_layer_htons: +_upper_layer_uip_htons: ld a, l ld l, h ld h, a diff --git a/cpu/msp430/loader-arch.c b/cpu/msp430/loader-arch.c index fb3f0bc36..224d8d28b 100644 --- a/cpu/msp430/loader-arch.c +++ b/cpu/msp430/loader-arch.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: loader-arch.c,v 1.1 2006/06/17 22:41:21 adamdunkels Exp $ + * @(#)$Id: loader-arch.c,v 1.2 2010/10/19 18:29:04 adamdunkels Exp $ */ #include "contiki.h" @@ -68,13 +68,13 @@ loader_arch_load(unsigned short startaddr) /* Read the magic word and version number from the first four bytes in EEPROM. */ eeprom_read(startaddr, (char *)&tmp, 2); - if(tmp != HTONS(LOADER_ARCH_MAGIC)) { + if(tmp != UIP_HTONS(LOADER_ARCH_MAGIC)) { beep_beep(60000); return; } eeprom_read(startaddr + 2, (char *)&tmp, 2); - if(tmp != HTONS(LOADER_ARCH_VERSION)) { + if(tmp != UIP_HTONS(LOADER_ARCH_VERSION)) { return; } @@ -83,7 +83,7 @@ loader_arch_load(unsigned short startaddr) /* Read the total lenghth that the checksum covers. */ eeprom_read(startaddr, (char *)&sumlen, 2); - sumlen = htons(sumlen); + sumlen = uip_htons(sumlen); sum = 0; @@ -153,7 +153,7 @@ loader_arch_load(unsigned short startaddr) /* Read the size of the code segment from the next two bytes in EEPROM. */ eeprom_read(startaddr, (char *)&codelen, 2); /* Convert from network byte order to host byte order. */ - codelen = htons(codelen); + codelen = uip_htons(codelen); /* Flash program code into ROM. We use the available space in the @@ -193,7 +193,7 @@ loader_arch_load(unsigned short startaddr) eeprom_read(startaddr + 2 + codelen, (char *)&datalen, 2); /* Convert from network byte order to host byte order. */ - datalen = htons(datalen); + datalen = uip_htons(datalen); if(datalen > 0) { /* Read the contents of the data memory into RAM. */ diff --git a/cpu/native/net/tapdev-drv.c b/cpu/native/net/tapdev-drv.c index 916f0845f..44fe64d28 100644 --- a/cpu/native/net/tapdev-drv.c +++ b/cpu/native/net/tapdev-drv.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: tapdev-drv.c,v 1.5 2008/10/14 14:38:10 julienabeille Exp $ + * @(#)$Id: tapdev-drv.c,v 1.6 2010/10/19 18:29:04 adamdunkels Exp $ */ #include "contiki-net.h" @@ -65,14 +65,14 @@ pollhandler(void) if(uip_len > 0) { #if UIP_CONF_IPV6 - if(BUF->type == htons(UIP_ETHTYPE_IPV6)) { + if(BUF->type == uip_htons(UIP_ETHTYPE_IPV6)) { tcpip_input(); } else #endif /* UIP_CONF_IPV6 */ - if(BUF->type == htons(UIP_ETHTYPE_IP)) { + if(BUF->type == uip_htons(UIP_ETHTYPE_IP)) { uip_len -= sizeof(struct uip_eth_hdr); tcpip_input(); - } else if(BUF->type == htons(UIP_ETHTYPE_ARP)) { + } else if(BUF->type == uip_htons(UIP_ETHTYPE_ARP)) { #if !UIP_CONF_IPV6 //math uip_arp_arpin(); /* If the above function invocation resulted in data that diff --git a/cpu/native/net/tapdev6.c b/cpu/native/net/tapdev6.c index d3268c0d5..6334bbe9a 100644 --- a/cpu/native/net/tapdev6.c +++ b/cpu/native/net/tapdev6.c @@ -31,7 +31,7 @@ * * Author: Adam Dunkels * - * $Id: tapdev6.c,v 1.3 2008/10/14 16:50:11 julienabeille Exp $ + * $Id: tapdev6.c,v 1.4 2010/10/19 18:29:04 adamdunkels Exp $ */ @@ -211,7 +211,7 @@ u8_t tapdev_send(uip_lladdr_t *lladdr) memcpy(&BUF->dest, lladdr, UIP_LLADDR_LEN); } memcpy(&BUF->src, &uip_lladdr, UIP_LLADDR_LEN); - BUF->type = HTONS(UIP_ETHTYPE_IPV6); //math tmp + BUF->type = UIP_HTONS(UIP_ETHTYPE_IPV6); //math tmp uip_len += sizeof(struct uip_eth_hdr); do_send(); diff --git a/cpu/native/net/wpcap-drv.c b/cpu/native/net/wpcap-drv.c index dc9fcace8..3c6e5e4e5 100644 --- a/cpu/native/net/wpcap-drv.c +++ b/cpu/native/net/wpcap-drv.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: wpcap-drv.c,v 1.6 2009/08/11 16:06:17 dak664 Exp $ + * @(#)$Id: wpcap-drv.c,v 1.7 2010/10/19 18:29:04 adamdunkels Exp $ */ #include "contiki-net.h" @@ -62,15 +62,15 @@ pollhandler(void) if(uip_len > 0) { #if UIP_CONF_IPV6 - if(BUF->type == htons(UIP_ETHTYPE_IPV6)) { + if(BUF->type == uip_htons(UIP_ETHTYPE_IPV6)) { tcpip_input(); } else #endif /* UIP_CONF_IPV6 */ - if(BUF->type == htons(UIP_ETHTYPE_IP)) { + if(BUF->type == uip_htons(UIP_ETHTYPE_IP)) { uip_len -= sizeof(struct uip_eth_hdr); tcpip_input(); #if !UIP_CONF_IPV6 - } else if(BUF->type == htons(UIP_ETHTYPE_ARP)) { + } else if(BUF->type == uip_htons(UIP_ETHTYPE_ARP)) { uip_arp_arpin(); //math /* If the above function invocation resulted in data that should be sent out on the network, the global variable diff --git a/cpu/native/net/wpcap.c b/cpu/native/net/wpcap.c index 810d94682..2a18f8188 100644 --- a/cpu/native/net/wpcap.c +++ b/cpu/native/net/wpcap.c @@ -30,7 +30,7 @@ * * Author: Oliver Schmidt * - * $Id: wpcap.c,v 1.18 2009/08/13 18:41:00 dak664 Exp $ + * $Id: wpcap.c,v 1.19 2010/10/19 18:29:04 adamdunkels Exp $ */ #define WIN32_LEAN_AND_MEAN @@ -55,8 +55,8 @@ #endif /* Avoid 'conflicting types' errors. */ -#define htonl -#define htons +#define uip_htonl +#define uip_htons #include "contiki-net.h" #include "sys/log.h" @@ -317,7 +317,7 @@ wpcap_send(uip_lladdr_t *lladdr) PRINTF("Src= %02x %02x %02x %02x %02x %02x",(&BUF->src)->addr[0],(&BUF->src)->addr[1],(&BUF->src)->addr[2],(&BUF->src)->addr[3],(&BUF->src)->addr[4],(&BUF->src)->addr[5]); PRINTF(" Dst= %02x %02x %02x %02x %02x %02x",(&BUF->dest)->addr[0],(&BUF->dest)->addr[1],(&BUF->dest)->addr[2],(&BUF->dest)->addr[3],(&BUF->dest)->addr[4],(&BUF->dest)->addr[5]); PRINTF(" Type=%04x\n",BUF->type); - BUF->type = HTONS(UIP_ETHTYPE_IPV6); + BUF->type = UIP_HTONS(UIP_ETHTYPE_IPV6); uip_len += sizeof(struct uip_eth_hdr); if(pcap_sendpacket(pcap, uip_buf, uip_len) == -1) { error_exit("error on send\n"); diff --git a/cpu/z80/uip_arch.c b/cpu/z80/uip_arch.c index adf310ba7..fde5b9a14 100644 --- a/cpu/z80/uip_arch.c +++ b/cpu/z80/uip_arch.c @@ -27,7 +27,7 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: uip_arch.c,v 1.2 2007/09/29 03:57:39 matsutsuka Exp $ + * $Id: uip_arch.c,v 1.3 2010/10/19 18:29:04 adamdunkels Exp $ * */ /* @@ -130,10 +130,10 @@ _upper_layer_chksum_call: ld a, h or a, l - jr nz, _upper_layer_htons + jr nz, _upper_layer_uip_htons ld hl, #0xffff jr _upper_layer_ret -_upper_layer_htons: +_upper_layer_uip_htons: ld a, l ld l, h ld h, a diff --git a/doc/example-program.c b/doc/example-program.c index 19f03d45c..c4f8f6f0f 100644 --- a/doc/example-program.c +++ b/doc/example-program.c @@ -46,7 +46,7 @@ PROCESS_THREAD(example_program_process, ev, data) * attach any special data to the connection, so we pass it a NULL * parameter. */ - c = udp_broadcast_new(HTONS(4321), NULL); + c = udp_broadcast_new(UIP_HTONS(4321), NULL); /* * Loop for ever. diff --git a/doc/example-psock-client.c b/doc/example-psock-client.c index 5557cc1d0..c2a5a56f4 100644 --- a/doc/example-psock-client.c +++ b/doc/example-psock-client.c @@ -33,7 +33,7 @@ PROCESS_THREAD(example_psock_client_process, ev, data) PROCESS_BEGIN(); uip_ipaddr(addr, 192,168,2,1); - tcp_connect(addr, HTONS(80), NULL); + tcp_connect(addr, UIP_HTONS(80), NULL); printf("Connecting...\n"); PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event); diff --git a/doc/example-psock-server.c b/doc/example-psock-server.c index f297a43e0..45db462da 100644 --- a/doc/example-psock-server.c +++ b/doc/example-psock-server.c @@ -106,10 +106,10 @@ PROCESS_THREAD(example_psock_server_process, ev, data) /* * We start with setting up a listening TCP port. Note how we're - * using the HTONS() macro to convert the port number (1010) to + * using the UIP_HTONS() macro to convert the port number (1010) to * network byte order as required by the tcp_listen() function. */ - tcp_listen(HTONS(1010)); + tcp_listen(UIP_HTONS(1010)); /* * We loop for ever, accepting new connections. diff --git a/examples/ipv6/rpl-border-router/httpd-simple.c b/examples/ipv6/rpl-border-router/httpd-simple.c index 80f6939bc..af05386d0 100644 --- a/examples/ipv6/rpl-border-router/httpd-simple.c +++ b/examples/ipv6/rpl-border-router/httpd-simple.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: httpd-simple.c,v 1.4 2010/08/31 20:05:44 joxe Exp $ + * $Id: httpd-simple.c,v 1.5 2010/10/19 18:29:04 adamdunkels Exp $ */ /** @@ -249,7 +249,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(); diff --git a/examples/ipv6/rpl-udp/udp-client.c b/examples/ipv6/rpl-udp/udp-client.c index df92ad987..f539b41aa 100644 --- a/examples/ipv6/rpl-udp/udp-client.c +++ b/examples/ipv6/rpl-udp/udp-client.c @@ -81,7 +81,7 @@ send_packet(void *ptr) client_conn->ripaddr.u8[15], seq_id); sprintf(buf, "Hello %d from the client", seq_id); uip_udp_packet_sendto(client_conn, buf, strlen(buf), - &server_ipaddr, HTONS(UDP_SERVER_PORT)); + &server_ipaddr, UIP_HTONS(UDP_SERVER_PORT)); } /*---------------------------------------------------------------------------*/ static void @@ -135,13 +135,13 @@ PROCESS_THREAD(udp_client_process, ev, data) print_local_addresses(); /* new connection with remote host */ - client_conn = udp_new(NULL, HTONS(UDP_SERVER_PORT), NULL); - udp_bind(client_conn, HTONS(UDP_CLIENT_PORT)); + client_conn = udp_new(NULL, UIP_HTONS(UDP_SERVER_PORT), NULL); + udp_bind(client_conn, UIP_HTONS(UDP_CLIENT_PORT)); PRINTF("Created a connection with the server "); PRINT6ADDR(&client_conn->ripaddr); PRINTF(" local/remote port %u/%u\n", - HTONS(client_conn->lport), HTONS(client_conn->rport)); + UIP_HTONS(client_conn->lport), UIP_HTONS(client_conn->rport)); etimer_set(&periodic, SEND_INTERVAL); while(1) { diff --git a/examples/ipv6/rpl-udp/udp-server.c b/examples/ipv6/rpl-udp/udp-server.c index ee4cb76e8..e9e98d346 100644 --- a/examples/ipv6/rpl-udp/udp-server.c +++ b/examples/ipv6/rpl-udp/udp-server.c @@ -130,13 +130,13 @@ PROCESS_THREAD(udp_server_process, ev, data) packet reception rates. */ NETSTACK_MAC.off(1); - server_conn = udp_new(NULL, HTONS(UDP_CLIENT_PORT), NULL); - udp_bind(server_conn, HTONS(UDP_SERVER_PORT)); + server_conn = udp_new(NULL, UIP_HTONS(UDP_CLIENT_PORT), NULL); + udp_bind(server_conn, UIP_HTONS(UDP_SERVER_PORT)); PRINTF("Created a server connection with remote address "); PRINT6ADDR(&server_conn->ripaddr); - PRINTF(" local/remote port %u/%u\n", HTONS(server_conn->lport), - HTONS(server_conn->rport)); + PRINTF(" local/remote port %u/%u\n", UIP_HTONS(server_conn->lport), + UIP_HTONS(server_conn->rport)); while(1) { PROCESS_YIELD(); diff --git a/examples/ravenusbstick/fakeuip.c b/examples/ravenusbstick/fakeuip.c index 4a03bcd57..bd9e609a9 100644 --- a/examples/ravenusbstick/fakeuip.c +++ b/examples/ravenusbstick/fakeuip.c @@ -37,7 +37,7 @@ void tcpip_set_outputfunc(u8_t (* f)(uip_lladdr_t *)) { output = f; } -u16_t htons(u16_t val) { return HTONS(val);} +u16_t uip_htons(u16_t val) { return UIP_HTONS(val);} #if THEOLDWAY @@ -123,7 +123,7 @@ upper_layer_chksum(u8_t proto) sum = chksum(sum, &uip_buf[UIP_IPH_LEN + UIP_LLH_LEN], upper_layer_len); - return (sum == 0) ? 0xffff : htons(sum); + return (sum == 0) ? 0xffff : uip_htons(sum); } /*---------------------------------------------------------------------------*/ diff --git a/examples/sky/tcprudolph0.c b/examples/sky/tcprudolph0.c index 3a57333ed..c23444c32 100644 --- a/examples/sky/tcprudolph0.c +++ b/examples/sky/tcprudolph0.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: tcprudolph0.c,v 1.12 2009/02/27 14:28:02 nvt-se Exp $ + * @(#)$Id: tcprudolph0.c,v 1.13 2010/10/19 18:29:05 adamdunkels Exp $ */ #include @@ -118,7 +118,7 @@ PT_THREAD(recv_tcpthread(struct pt *pt)) rudolph0_stop(&rudolph0); /* elfloader_unload();*/ - 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); @@ -261,11 +261,11 @@ PROCESS_THREAD(tcp_loader_process, ev, data) rudolph0_open(&rudolph0, 20, &rudolph0_call); - 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); diff --git a/examples/test-ipv6/testv6.c b/examples/test-ipv6/testv6.c index 3ffc43dd2..6d55ef132 100644 --- a/examples/test-ipv6/testv6.c +++ b/examples/test-ipv6/testv6.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: testv6.c,v 1.3 2010/02/05 19:13:06 oliverschmidt Exp $ + * $Id: testv6.c,v 1.4 2010/10/19 18:29:05 adamdunkels Exp $ */ #include "contiki-net.h" @@ -54,7 +54,7 @@ PROCESS_THREAD(test_process, ev, data) uip_ip6addr(&ip6addr, 0xfc00,0,0,0,0,0,0,0x231); - tcp_connect(&ip6addr, HTONS(7), NULL); + tcp_connect(&ip6addr, UIP_HTONS(7), NULL); while(1) { PROCESS_WAIT_EVENT(); @@ -67,7 +67,7 @@ PROCESS_THREAD(test_tcpip_process, ev, data) { PROCESS_BEGIN(); - tcp_listen(HTONS(800)); + tcp_listen(UIP_HTONS(800)); while(1) { PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event); diff --git a/examples/udp-ipv6/udp-client.c b/examples/udp-ipv6/udp-client.c index 9978e1524..da7cef859 100644 --- a/examples/udp-ipv6/udp-client.c +++ b/examples/udp-ipv6/udp-client.c @@ -135,13 +135,13 @@ PROCESS_THREAD(udp_client_process, ev, data) set_connection_address(&ipaddr); /* new connection with remote host */ - client_conn = udp_new(&ipaddr, HTONS(3000), NULL); - udp_bind(client_conn, HTONS(3001)); + client_conn = udp_new(&ipaddr, UIP_HTONS(3000), NULL); + udp_bind(client_conn, UIP_HTONS(3001)); PRINTF("Created a connection with the server "); PRINT6ADDR(&client_conn->ripaddr); PRINTF(" local/remote port %u/%u\n", - HTONS(client_conn->lport), HTONS(client_conn->rport)); + UIP_HTONS(client_conn->lport), UIP_HTONS(client_conn->rport)); etimer_set(&et, SEND_INTERVAL); while(1) { diff --git a/examples/udp-ipv6/udp-server.c b/examples/udp-ipv6/udp-server.c index 9929ac886..1dc9279a5 100644 --- a/examples/udp-ipv6/udp-server.c +++ b/examples/udp-ipv6/udp-server.c @@ -102,8 +102,8 @@ PROCESS_THREAD(udp_server_process, ev, data) print_local_addresses(); - server_conn = udp_new(NULL, HTONS(3001), NULL); - udp_bind(server_conn, HTONS(3000)); + server_conn = udp_new(NULL, UIP_HTONS(3001), NULL); + udp_bind(server_conn, UIP_HTONS(3000)); while(1) { PROCESS_YIELD(); diff --git a/platform/avr-raven/apps/raven-ipso/raven-ipso.c b/platform/avr-raven/apps/raven-ipso/raven-ipso.c index 5b677882c..4e6161caa 100644 --- a/platform/avr-raven/apps/raven-ipso/raven-ipso.c +++ b/platform/avr-raven/apps/raven-ipso/raven-ipso.c @@ -254,9 +254,9 @@ PROCESS_THREAD(raven_lcd_process, ev, data) uip_ip6addr(&udp_addr,0x2001,0x420,0x5FFF,0x7D,0x2D0,0xB7FF,0xFE23,0xE6DB); /* set destination parameters*/ - udp_conn = udp_new(&udp_addr, HTONS(0xF0B0), NULL); + udp_conn = udp_new(&udp_addr, UIP_HTONS(0xF0B0), NULL); /*set local port */ - udp_bind(udp_conn, HTONS(0xF0B0+1)); + udp_bind(udp_conn, UIP_HTONS(0xF0B0+1)); if((error = icmp6_new(NULL)) == 0) { while(1) { diff --git a/platform/avr-raven/apps/raven-webserver/httpd-cfs.c b/platform/avr-raven/apps/raven-webserver/httpd-cfs.c index 2461b505b..df46826d1 100644 --- a/platform/avr-raven/apps/raven-webserver/httpd-cfs.c +++ b/platform/avr-raven/apps/raven-webserver/httpd-cfs.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: httpd-cfs.c,v 1.1 2009/03/12 19:15:25 adamdunkels Exp $ + * $Id: httpd-cfs.c,v 1.2 2010/10/19 18:29:05 adamdunkels Exp $ */ #include @@ -238,7 +238,7 @@ httpd_appcall(void *state) void httpd_init(void) { - tcp_listen(HTONS(80)); + tcp_listen(UIP_HTONS(80)); memb_init(&conns); } /*---------------------------------------------------------------------------*/ diff --git a/platform/avr-raven/apps/raven-webserver/httpd-cgi.c b/platform/avr-raven/apps/raven-webserver/httpd-cgi.c index f27fb18ee..089866287 100644 --- a/platform/avr-raven/apps/raven-webserver/httpd-cgi.c +++ b/platform/avr-raven/apps/raven-webserver/httpd-cgi.c @@ -28,7 +28,7 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: httpd-cgi.c,v 1.7 2010/02/26 21:38:58 dak664 Exp $ + * $Id: httpd-cgi.c,v 1.8 2010/10/19 18:29:05 adamdunkels Exp $ * */ @@ -227,12 +227,12 @@ make_tcp_stats(void *arg) conn = &uip_conns[s->u.count]; - numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(), httpd_cgi_tcpstat1, htons(conn->lport)); + numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(), httpd_cgi_tcpstat1, uip_htons(conn->lport)); numprinted += httpd_cgi_sprint_ip6(conn->ripaddr, uip_appdata + numprinted); httpd_strcpy(tstate,states[conn->tcpstateflags & UIP_TS_MASK]); numprinted += httpd_snprintf((char *)uip_appdata + numprinted, uip_mss() - numprinted, httpd_cgi_tcpstat2, - htons(conn->rport), + uip_htons(conn->rport), tstate, conn->nrtx, conn->timer, @@ -431,7 +431,7 @@ uint8_t httpd_cgi_sprint_ip6(uip_ip6addr_t addr, char * result) //Normal address, just print it else { - result += sprintf(result, "%x", (unsigned int)(ntohs(addr.u16[i]))); + result += sprintf(result, "%x", (unsigned int)(uip_ntohs(addr.u16[i]))); i++; numprinted++; } diff --git a/platform/avr-raven/apps/raven-webserver/httpd.c b/platform/avr-raven/apps/raven-webserver/httpd.c index a2148aeb2..64a9f2f1d 100644 --- a/platform/avr-raven/apps/raven-webserver/httpd.c +++ b/platform/avr-raven/apps/raven-webserver/httpd.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: httpd.c,v 1.4 2009/07/24 15:41:52 dak664 Exp $ + * $Id: httpd.c,v 1.5 2010/10/19 18:29:05 adamdunkels Exp $ */ #include @@ -484,7 +484,7 @@ httpd_appcall(void *state) void httpd_init(void) { - tcp_listen(HTONS(80)); + tcp_listen(UIP_HTONS(80)); memb_init(&conns); httpd_cgi_init(); } diff --git a/platform/avr-ravenlcd/uart.c b/platform/avr-ravenlcd/uart.c index ef2a74470..fd232a946 100644 --- a/platform/avr-ravenlcd/uart.c +++ b/platform/avr-ravenlcd/uart.c @@ -156,7 +156,7 @@ uart_circ_buf_has_char(tcirc_buf *cbuf) * \return val Converted hex value */ uint8_t -ntohex(uint8_t val) +uip_ntohex(uint8_t val) { /* Convert nibble to hex */ if (val > 9){ @@ -178,8 +178,8 @@ ntohex(uint8_t val) void itohex(uint8_t val,char *str) { - *str++ = ntohex(val >> 8); - *str = ntohex(val & 0x0f); + *str++ = uip_ntohex(val >> 8); + *str = uip_ntohex(val & 0x0f); } /*---------------------------------------------------------------------------*/ diff --git a/platform/avr-ravenusb/httpd-simple-avr.c b/platform/avr-ravenusb/httpd-simple-avr.c index 4a21c44d7..d1d89fb9b 100644 --- a/platform/avr-ravenusb/httpd-simple-avr.c +++ b/platform/avr-ravenusb/httpd-simple-avr.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: httpd-simple-avr.c,v 1.1 2010/08/26 18:55:43 dak664 Exp $ + * $Id: httpd-simple-avr.c,v 1.2 2010/10/19 18:29:05 adamdunkels Exp $ */ /** @@ -202,7 +202,7 @@ bomb void httpd_init(void) { - tcp_listen(HTONS(80)); + tcp_listen(UIP_HTONS(80)); memb_init(&conns); } diff --git a/platform/avr-ravenusb/sicslow_ethernet.c b/platform/avr-ravenusb/sicslow_ethernet.c index 06e688e43..a1f297d26 100644 --- a/platform/avr-ravenusb/sicslow_ethernet.c +++ b/platform/avr-ravenusb/sicslow_ethernet.c @@ -327,7 +327,7 @@ void mac_ethernetToLowpan(uint8_t * ethHeader) uip_lladdr_t destAddr; uip_lladdr_t *destAddrPtr = NULL; - PRINTF("Packet type: 0x%04x\n\r", ntohs(((struct uip_eth_hdr *) ethHeader)->type)); + PRINTF("Packet type: 0x%04x\n\r", uip_ntohs(((struct uip_eth_hdr *) ethHeader)->type)); //RUM doesn't support sending data #if UIP_CONF_USE_RUM @@ -342,8 +342,8 @@ void mac_ethernetToLowpan(uint8_t * ethHeader) //If not IPv6 we don't do anything - if (((struct uip_eth_hdr *) ethHeader)->type != HTONS(UIP_ETHTYPE_IPV6)) { - PRINTF("eth2low: Dropping packet w/type=0x%04x\n",ntohs(((struct uip_eth_hdr *) ethHeader)->type)); + if (((struct uip_eth_hdr *) ethHeader)->type != UIP_HTONS(UIP_ETHTYPE_IPV6)) { + PRINTF("eth2low: Dropping packet w/type=0x%04x\n",uip_ntohs(((struct uip_eth_hdr *) ethHeader)->type)); // printf("!ipv6"); #if !RF230BB usb_eth_stat.txbad++; @@ -448,7 +448,7 @@ void mac_LowpanToEthernet(void) //printf("in lowpantoethernet\n\r"); //Setup generic ethernet stuff - ETHBUF(uip_buf)->type = htons(UIP_ETHTYPE_IPV6); + ETHBUF(uip_buf)->type = uip_htons(UIP_ETHTYPE_IPV6); //Check for broadcast message @@ -924,7 +924,7 @@ mac_log_802_15_4_tx(const uint8_t* buffer, size_t total_len) { sendlen = total_len; /* Setup generic ethernet stuff */ - ETHBUF(raw_buf)->type = htons(0x809A); //UIP_ETHTYPE_802154 0x809A + ETHBUF(raw_buf)->type = uip_htons(0x809A); //UIP_ETHTYPE_802154 0x809A /* Check for broadcast message */ if(rimeaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &rimeaddr_null)) { @@ -965,7 +965,7 @@ mac_log_802_15_4_rx(const uint8_t* buf, size_t len) { sendlen = len; /* Setup generic ethernet stuff */ - ETHBUF(raw_buf)->type = htons(0x809A); //UIP_ETHTYPE_802154 0x809A + ETHBUF(raw_buf)->type = uip_htons(0x809A); //UIP_ETHTYPE_802154 0x809A /* Check for broadcast message */ if(rimeaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &rimeaddr_null)) { diff --git a/platform/cc2420dbk/gateway.c b/platform/cc2420dbk/gateway.c index ad5ed18e6..7eb2ffab8 100644 --- a/platform/cc2420dbk/gateway.c +++ b/platform/cc2420dbk/gateway.c @@ -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.3 2007/05/21 14:14:16 bg- Exp $ + * @(#)$Id: gateway.c,v 1.4 2010/10/19 18:29:05 adamdunkels Exp $ */ /* @@ -78,7 +78,7 @@ static struct uip_fw_netif slipif = {UIP_FW_NETIF(0,0,0,0, 255,255,255,255, slip_send)}; /* Radio stuff in network byte order. */ -static u16_t panId = HTONS(0x2024); +static u16_t panId = UIP_HTONS(0x2024); #ifndef RF_CHANNEL #define RF_CHANNEL 15 @@ -110,7 +110,7 @@ main(int argc, char **argv) leds_toggle(LEDS_ALL); slip_arch_init(BAUD2UBR(38400)); /* Must come before first printf */ printf("Starting %s " - "($Id: gateway.c,v 1.3 2007/05/21 14:14:16 bg- Exp $)\n", __FILE__); + "($Id: gateway.c,v 1.4 2010/10/19 18:29:05 adamdunkels Exp $)\n", __FILE__); ds2411_init(); cc2420_init(); xmem_init(); diff --git a/platform/cooja/net/radio-uip-uaodv.c b/platform/cooja/net/radio-uip-uaodv.c index 0805ecbd5..c4ca21491 100644 --- a/platform/cooja/net/radio-uip-uaodv.c +++ b/platform/cooja/net/radio-uip-uaodv.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: radio-uip-uaodv.c,v 1.9 2007/12/13 16:57:31 fros4943 Exp $ + * @(#)$Id: radio-uip-uaodv.c,v 1.10 2010/10/19 18:29:05 adamdunkels Exp $ */ #include "radio-uip-uaodv.h" @@ -209,7 +209,7 @@ radio_uip_uaodv_send(void) /* Transmit uAODV packets with headers but without using route table */ if (((struct uip_udpip_hdr *)&uip_buf[UIP_LLH_LEN])->proto == UIP_PROTO_UDP - && radio_uip_uaodv_dest_port(&uip_buf[UIP_LLH_LEN], uip_len) == HTONS(UAODV_UDPPORT)) { + && radio_uip_uaodv_dest_port(&uip_buf[UIP_LLH_LEN], uip_len) == UIP_HTONS(UAODV_UDPPORT)) { uip_ipaddr_t nexthop; memcpy(&nexthop, &((struct uip_udpip_hdr *)&uip_buf[UIP_LLH_LEN])->destipaddr, 4); diff --git a/platform/cooja/testapps/testuaodv.c b/platform/cooja/testapps/testuaodv.c index 47ff1a23f..edd4593db 100644 --- a/platform/cooja/testapps/testuaodv.c +++ b/platform/cooja/testapps/testuaodv.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: testuaodv.c,v 1.3 2010/01/14 19:19:50 nifi Exp $ + * $Id: testuaodv.c,v 1.4 2010/10/19 18:29:05 adamdunkels Exp $ */ #include @@ -56,11 +56,11 @@ PROCESS_THREAD(test_uaodv_process, ev, data) printf("uIP uAODV test process started\n"); uip_ipaddr(&addr, 0,0,0,0); - in_conn = udp_new(&addr, HTONS(0), NULL); - uip_udp_bind(in_conn, HTONS(COOJA_PORT)); + in_conn = udp_new(&addr, UIP_HTONS(0), NULL); + uip_udp_bind(in_conn, UIP_HTONS(COOJA_PORT)); uip_ipaddr(&addr, 10,10,10,4); - out_conn = udp_new(&addr, HTONS(COOJA_PORT), NULL); + out_conn = udp_new(&addr, UIP_HTONS(COOJA_PORT), NULL); button_sensor.configure(SENSORS_ACTIVE, 1); diff --git a/platform/esb/apps/pinger.c b/platform/esb/apps/pinger.c index 992c8995b..f2402d4f6 100644 --- a/platform/esb/apps/pinger.c +++ b/platform/esb/apps/pinger.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: pinger.c,v 1.2 2010/01/15 10:37:04 nifi Exp $ + * @(#)$Id: pinger.c,v 1.3 2010/10/19 18:29:05 adamdunkels Exp $ */ #include "contiki-esb.h" @@ -77,11 +77,11 @@ udp_appcall(void *arg) leds_toggle(LEDS_YELLOW); /* beep();*/ - /* if(htons(d->seqno) != last_seqno + 1) { + /* if(uip_htons(d->seqno) != last_seqno + 1) { leds_toggle(LEDS_RED); beep_quick(2); }*/ - /* last_seqno = htons(d->seqno);*/ + /* last_seqno = uip_htons(d->seqno);*/ /* uip_udp_send(sizeof(struct data));*/ /* snprintf(buf, sizeof(buf), "Packet received id %d signal %u\n", d->id, tr1001_sstrength()); @@ -91,7 +91,7 @@ udp_appcall(void *arg) d->pingpong = PONG; } else { d->pingpong = PING; - d->seqno = htons(htons(d->seqno) + 1); + d->seqno = uip_htons(uip_htons(d->seqno) + 1); }*/ /* uip_udp_send(sizeof(struct data)); timer_restart(&timer);*/ @@ -100,7 +100,7 @@ udp_appcall(void *arg) --packet_count; d->id = place_id; d->pingpong = PING; - d->seqno = htons(sent_seqno); + d->seqno = uip_htons(sent_seqno); ++sent_seqno; uip_udp_send(sizeof(struct data)); etimer_reset(&etimer); @@ -167,7 +167,7 @@ PROCESS_THREAD(pinger, ev, data) pingeron = 0; - conn = udp_broadcast_new(HTONS(PORT), NULL); + conn = udp_broadcast_new(UIP_HTONS(PORT), NULL); PT_INIT(&config_pt); diff --git a/platform/esb/apps/radio-test.c b/platform/esb/apps/radio-test.c index 3db22a5c8..32eecddeb 100644 --- a/platform/esb/apps/radio-test.c +++ b/platform/esb/apps/radio-test.c @@ -26,14 +26,14 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: radio-test.c,v 1.2 2006/10/09 11:55:30 adamdunkels Exp $ + * $Id: radio-test.c,v 1.3 2010/10/19 18:29:05 adamdunkels Exp $ * * ----------------------------------------------------------------- * * Author : Adam Dunkels, Joakim Eriksson, Niclas Finne * Created : 2006-03-07 - * Updated : $Date: 2006/10/09 11:55:30 $ - * $Revision: 1.2 $ + * Updated : $Date: 2010/10/19 18:29:05 $ + * $Revision: 1.3 $ * * Simple application to indicate connectivity between two nodes: * @@ -96,7 +96,7 @@ PROCESS_THREAD(radio_test_process, ev, data) other.led = LEDS_GREEN; flash.led = LEDS_RED; - conn = udp_broadcast_new(HTONS(PORT), NULL); + conn = udp_broadcast_new(UIP_HTONS(PORT), NULL); etimer_set(&send_timer, CLOCK_SECOND); while(1) { diff --git a/platform/esb/apps/test-receiver.c b/platform/esb/apps/test-receiver.c index 669329732..d8d921c00 100644 --- a/platform/esb/apps/test-receiver.c +++ b/platform/esb/apps/test-receiver.c @@ -26,14 +26,14 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: test-receiver.c,v 1.1 2006/06/18 07:48:48 adamdunkels Exp $ + * $Id: test-receiver.c,v 1.2 2010/10/19 18:29:05 adamdunkels Exp $ * * ----------------------------------------------------------------- * * Author : Adam Dunkels, Joakim Eriksson, Niclas Finne * Created : 2006-03-07 - * Updated : $Date: 2006/06/18 07:48:48 $ - * $Revision: 1.1 $ + * Updated : $Date: 2010/10/19 18:29:05 $ + * $Revision: 1.2 $ */ #include "contiki-esb.h" @@ -50,7 +50,7 @@ PROCESS_THREAD(test_receiver_process, ev, data) PROCESS_BEGIN(); - conn = udp_broadcast_new(HTONS(PORT), NULL); + conn = udp_broadcast_new(UIP_HTONS(PORT), NULL); while(1) { PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event && uip_newdata()); diff --git a/platform/esb/apps/test-sender.c b/platform/esb/apps/test-sender.c index cfa7e34ba..57fa0c2e9 100644 --- a/platform/esb/apps/test-sender.c +++ b/platform/esb/apps/test-sender.c @@ -26,14 +26,14 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: test-sender.c,v 1.1 2006/06/18 07:48:48 adamdunkels Exp $ + * $Id: test-sender.c,v 1.2 2010/10/19 18:29:05 adamdunkels Exp $ * * ----------------------------------------------------------------- * * Author : Adam Dunkels, Joakim Eriksson, Niclas Finne * Created : 2006-03-07 - * Updated : $Date: 2006/06/18 07:48:48 $ - * $Revision: 1.1 $ + * Updated : $Date: 2010/10/19 18:29:05 $ + * $Revision: 1.2 $ */ #include "contiki-esb.h" @@ -50,7 +50,7 @@ PROCESS_THREAD(test_sender_process, ev, data) PROCESS_BEGIN(); - conn = udp_broadcast_new(HTONS(PORT), NULL); + conn = udp_broadcast_new(UIP_HTONS(PORT), NULL); etimer_set(&timer, CLOCK_SECOND * 2); while(1) { diff --git a/platform/minimal-net/contiki-main.c b/platform/minimal-net/contiki-main.c index 67846f5ca..652c31270 100644 --- a/platform/minimal-net/contiki-main.c +++ b/platform/minimal-net/contiki-main.c @@ -29,7 +29,7 @@ * * This file is part of the Contiki OS * - * $Id: contiki-main.c,v 1.24 2010/03/18 20:11:54 dak664 Exp $ + * $Id: contiki-main.c,v 1.25 2010/10/19 18:29:05 adamdunkels Exp $ * */ @@ -80,7 +80,7 @@ sprint_ip6(uip_ip6addr_t addr) 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++; } diff --git a/platform/netsim/ether.c b/platform/netsim/ether.c index f1ccb45b4..f332a00ee 100644 --- a/platform/netsim/ether.c +++ b/platform/netsim/ether.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: ether.c,v 1.16 2010/02/23 18:44:08 adamdunkels Exp $ + * $Id: ether.c,v 1.17 2010/10/19 18:29:05 adamdunkels Exp $ */ /** * \file @@ -191,9 +191,9 @@ ether_server_init(void) memset((char *)&sa, 0, sizeof(sa)); sa.sin_family = AF_INET; - sa.sin_addr.s_addr = inet_addr("127.0.0.1");/*htonl(INADDR_ANY);*/ + sa.sin_addr.s_addr = inet_addr("127.0.0.1");/*uip_htonl(INADDR_ANY);*/ - sa.sin_port = htons(ETHER_PORT); + sa.sin_port = uip_htons(ETHER_PORT); /* printf("Binding to port %d\n", ETHER_PORT);*/ @@ -219,9 +219,9 @@ ether_client_init(int port) memset((char *)&sa, 0, sizeof(sa)); sa.sin_family = AF_INET; - sa.sin_addr.s_addr = inet_addr("127.0.0.1");/*htonl(INADDR_ANY);*/ + sa.sin_addr.s_addr = inet_addr("127.0.0.1");/*uip_htonl(INADDR_ANY);*/ - sa.sin_port = htons(port); + sa.sin_port = uip_htons(port); /* printf("ether_client_init: binding to port %d\n", port);*/ if(bind(sc, (struct sockaddr *)&sa, sizeof(sa)) < 0) { @@ -403,7 +403,7 @@ send_packet(char *data, int len, int port) memset((char *)&sa, 0, sizeof(sa)); sa.sin_family = AF_INET; sa.sin_addr.s_addr = inet_addr("127.0.0.1"); - sa.sin_port = htons(port); + sa.sin_port = uip_htons(port); if(sendto(s, data, len, 0, (struct sockaddr *)&sa, sizeof(sa)) == -1) { perror("ether: send_packet: sendto"); @@ -526,7 +526,7 @@ node_send_packet(char *data, int len) memset((char *)&sa, 0, sizeof(sa)); sa.sin_family = AF_INET; sa.sin_addr.s_addr = inet_addr("127.0.0.1"); - sa.sin_port = htons(ETHER_PORT); + sa.sin_port = uip_htons(ETHER_PORT); if(sendto(sc, data, len, 0, (struct sockaddr *)&sa, sizeof(sa)) == -1) { diff --git a/platform/pc-6001/apps/webserver-mini/httpd-cfs.c b/platform/pc-6001/apps/webserver-mini/httpd-cfs.c index bdc5d5bcd..18fe4aeb7 100644 --- a/platform/pc-6001/apps/webserver-mini/httpd-cfs.c +++ b/platform/pc-6001/apps/webserver-mini/httpd-cfs.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: httpd-cfs.c,v 1.1 2007/11/28 09:40:13 matsutsuka Exp $ + * $Id: httpd-cfs.c,v 1.2 2010/10/19 18:29:05 adamdunkels Exp $ */ #include @@ -212,7 +212,7 @@ httpd_appcall(void *state) void httpd_init(void) { - tcp_listen(HTONS(80)); + tcp_listen(UIP_HTONS(80)); memb_init(&conns); } /*---------------------------------------------------------------------------*/ diff --git a/platform/pc-6001/apps/webserver-mini/httpd-cgi.c b/platform/pc-6001/apps/webserver-mini/httpd-cgi.c index bffdcf830..fe1dc0706 100644 --- a/platform/pc-6001/apps/webserver-mini/httpd-cgi.c +++ b/platform/pc-6001/apps/webserver-mini/httpd-cgi.c @@ -28,7 +28,7 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: httpd-cgi.c,v 1.1 2007/11/28 09:40:13 matsutsuka Exp $ + * $Id: httpd-cgi.c,v 1.2 2010/10/19 18:29:05 adamdunkels Exp $ * */ @@ -164,12 +164,12 @@ make_tcp_stats(void *arg) conn = &uip_conns[s->u.count]; return sprintf((char *)uip_appdata, "%d%u.%u.%u.%u:%u%s%u%u%c %c\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, diff --git a/platform/pc-6001/apps/webserver-mini/httpd.c b/platform/pc-6001/apps/webserver-mini/httpd.c index 577990a2f..20d6b464c 100644 --- a/platform/pc-6001/apps/webserver-mini/httpd.c +++ b/platform/pc-6001/apps/webserver-mini/httpd.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: httpd.c,v 1.1 2007/11/28 09:40:13 matsutsuka Exp $ + * $Id: httpd.c,v 1.2 2010/10/19 18:29:05 adamdunkels Exp $ */ #include @@ -335,7 +335,7 @@ httpd_appcall(void *state) void httpd_init(void) { - tcp_listen(HTONS(80)); + tcp_listen(UIP_HTONS(80)); memb_init(&conns); #if HTTPD_CONF_CGI httpd_cgi_init(); diff --git a/platform/stepper-robot/stepper-process.c b/platform/stepper-robot/stepper-process.c index 7e5c22729..b371bf834 100644 --- a/platform/stepper-robot/stepper-process.c +++ b/platform/stepper-robot/stepper-process.c @@ -389,9 +389,9 @@ PROCESS_THREAD(udp_stepper_process, ev, data) printf("udp_stepper_process starting\n"); uip_ipaddr(&any, 0,0,0,0); - conn = udp_new(&any, HTONS(0), NULL); + conn = udp_new(&any, UIP_HTONS(0), NULL); if (!conn) goto exit; - uip_udp_bind(conn, HTONS(1010)); + uip_udp_bind(conn, UIP_HTONS(1010)); etimer_set(&timer, CLOCK_SECOND*2); while(1) { PROCESS_YIELD(); @@ -417,7 +417,7 @@ PROCESS_THREAD(udp_stepper_process, ev, data) uip_udp_remove(conn); conn = udp_new(&header->srcipaddr, header->srcport, &conn); if (!conn) goto exit; - uip_udp_bind(conn, HTONS(1010)); + uip_udp_bind(conn, UIP_HTONS(1010)); listening = 0; } etimer_reset(&timer); @@ -430,9 +430,9 @@ PROCESS_THREAD(udp_stepper_process, ev, data) } } else if (ev == PROCESS_EVENT_TIMER) { uip_udp_remove(conn); - conn = udp_new(&any, HTONS(0), NULL); + conn = udp_new(&any, UIP_HTONS(0), NULL); if (!conn) goto exit; - uip_udp_bind(conn, HTONS(1010)); + uip_udp_bind(conn, UIP_HTONS(1010)); listening = 1; } } @@ -490,7 +490,7 @@ PROCESS_THREAD(stepper_process, ev, data) PROCESS_EXITHANDLER(goto exit); PROCESS_BEGIN(); robot_stepper_init(); - tcp_listen(HTONS(1010)); + tcp_listen(UIP_HTONS(1010)); process_start(&udp_stepper_process, NULL); printf("Stepper starting\n"); diff --git a/platform/win32/contiki-main.c b/platform/win32/contiki-main.c index 6d9433d1a..213e12cce 100644 --- a/platform/win32/contiki-main.c +++ b/platform/win32/contiki-main.c @@ -30,7 +30,7 @@ * * Author: Oliver Schmidt * - * $Id: contiki-main.c,v 1.18 2010/10/15 21:14:18 oliverschmidt Exp $ + * $Id: contiki-main.c,v 1.19 2010/10/19 18:29:05 adamdunkels Exp $ */ #define WIN32_LEAN_AND_MEAN @@ -39,8 +39,8 @@ #include /* Avoid 'conflicting types' errors. */ -#define htonl -#define htons +#define uip_htonl +#define uip_htons #include "contiki-net.h" diff --git a/tools/codeprop.c b/tools/codeprop.c index 7d7191389..a3bf9da33 100644 --- a/tools/codeprop.c +++ b/tools/codeprop.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: codeprop.c,v 1.4 2007/04/26 12:56:28 bg- Exp $ + * @(#)$Id: codeprop.c,v 1.5 2010/10/19 18:29:05 adamdunkels Exp $ */ #include #include @@ -76,7 +76,7 @@ main(int argc, char **argv) { bzero((char *) &sa, sizeof(sa)); sa.sin_family = AF_INET; sa.sin_addr.s_addr = inet_addr(ip_addr); - sa.sin_port = htons(port); + sa.sin_port = uip_htons(port); /* Connect the socket to the remote host. */ if(connect(s, (struct sockaddr *)&sa, sizeof(sa)) < 0) { diff --git a/tools/sky/uip6-bridge/dev/slip.c b/tools/sky/uip6-bridge/dev/slip.c index 931cf50d0..72ffbf611 100644 --- a/tools/sky/uip6-bridge/dev/slip.c +++ b/tools/sky/uip6-bridge/dev/slip.c @@ -29,7 +29,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: slip.c,v 1.1 2009/05/08 12:49:36 joxe Exp $ + * @(#)$Id: slip.c,v 1.2 2010/10/19 18:29:05 adamdunkels Exp $ */ @@ -282,7 +282,7 @@ PROCESS_THREAD(slip_process, ev, data) uint16_t nid = ip_id++; BUF->ipid[0] = nid >> 8; BUF->ipid[1] = nid; - nid = htons(nid); + nid = uip_htons(nid); nid = ~nid; /* negate */ BUF->ipchksum += nid; /* add */ if(BUF->ipchksum < nid) { /* 1-complement overflow? */ diff --git a/tools/sky/uip6-bridge/fakeuip.c b/tools/sky/uip6-bridge/fakeuip.c index 8c39fe0d4..c79ae74ae 100644 --- a/tools/sky/uip6-bridge/fakeuip.c +++ b/tools/sky/uip6-bridge/fakeuip.c @@ -18,7 +18,7 @@ struct uip_stats uip_stat; uip_lladdr_t uip_lladdr; -u16_t htons(u16_t val) { return HTONS(val);} +u16_t uip_htons(u16_t val) { return UIP_HTONS(val);} uip_ds6_netif_t uip_ds6_if; @@ -118,7 +118,7 @@ upper_layer_chksum(u8_t proto) sum = chksum(sum, &uip_buf[UIP_IPH_LEN + UIP_LLH_LEN], upper_layer_len); - return (sum == 0) ? 0xffff : htons(sum); + return (sum == 0) ? 0xffff : uip_htons(sum); } /*---------------------------------------------------------------------------*/ diff --git a/tools/sky/uip6-bridge/sicslow_ethernet.c b/tools/sky/uip6-bridge/sicslow_ethernet.c index ef6e746b7..458468a2d 100644 --- a/tools/sky/uip6-bridge/sicslow_ethernet.c +++ b/tools/sky/uip6-bridge/sicslow_ethernet.c @@ -235,7 +235,7 @@ void mac_ethernetToLowpan(uint8_t * ethHeader) #endif //If not IPv6 we don't do anything - if (((struct uip_eth_hdr *) ethHeader)->type != HTONS(UIP_ETHTYPE_IPV6)) { + if (((struct uip_eth_hdr *) ethHeader)->type != UIP_HTONS(UIP_ETHTYPE_IPV6)) { PRINTF("eth2low: Packet is not IPv6, dropping\n"); /* rndis_stat.txbad++; */ uip_len = 0; @@ -309,7 +309,7 @@ void mac_LowpanToEthernet(void) /* parsed_frame = sicslowmac_get_frame(); */ //Setup generic ethernet stuff - ETHBUF(uip_buf)->type = htons(UIP_ETHTYPE_IPV6); + ETHBUF(uip_buf)->type = uip_htons(UIP_ETHTYPE_IPV6); //Check for broadcast message if(rimeaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER), &rimeaddr_null)) { @@ -782,7 +782,7 @@ void mac_logTXtoEthernet(frame_create_params_t *p,frame_result_t *frame_result) sendlen = frame_result->length; //Setup generic ethernet stuff - ETHBUF(raw_buf)->type = htons(UIP_ETHTYPE_802154); + ETHBUF(raw_buf)->type = uip_htons(UIP_ETHTYPE_802154); uint64_t tempaddr; @@ -845,7 +845,7 @@ void mac_802154raw(const struct mac_driver *r) sendlen = radio_frame_length(); //Setup generic ethernet stuff - ETHBUF(raw_buf)->type = htons(UIP_ETHTYPE_802154); + ETHBUF(raw_buf)->type = uip_htons(UIP_ETHTYPE_802154); //Check for broadcast message diff --git a/tools/tunslip.c b/tools/tunslip.c index 06a9992a1..69b4620db 100644 --- a/tools/tunslip.c +++ b/tools/tunslip.c @@ -28,7 +28,7 @@ * * This file is part of the uIP TCP/IP stack. * - * $Id: tunslip.c,v 1.15 2008/02/24 21:13:36 adamdunkels Exp $ + * $Id: tunslip.c,v 1.16 2010/10/19 18:29:05 adamdunkels Exp $ * */ @@ -172,7 +172,7 @@ relay_dhcp_to_server(struct ip *ip, int len) return; } - inm->flags = ntohs(BOOTP_BROADCAST); + inm->flags = uip_ntohs(BOOTP_BROADCAST); memcpy(&m, inm, DHCP_BASE_LEN); memset(&m.sname, 0x0, DHCP_HOLE_LEN); @@ -301,29 +301,29 @@ relay_dhcp_to_client(int slipfd) pkt.ip.ip_vhl = 0x45; /* IPv4 and hdrlen=5*4 */ pkt.ip.ip_tos = 0; - pkt.ip.ip_len = htons(ip_len); - pkt.ip.ip_id = htons(ip_id++); + pkt.ip.ip_len = uip_htons(ip_len); + pkt.ip.ip_id = uip_htons(ip_id++); pkt.ip.ip_off = 0; pkt.ip.ip_ttl = 64; pkt.ip.ip_p = 17; /* proto UDP */ pkt.ip.ip_sum = 0; pkt.ip.ip_src = giaddr; - if (inm.flags & htons(BOOTP_BROADCAST)) /* check bcast bit */ + if (inm.flags & uip_htons(BOOTP_BROADCAST)) /* check bcast bit */ pkt.ip.ip_dst = 0xffffffff; /* 255.255.255.255 */ else pkt.ip.ip_dst = yiaddr.s_addr; - pkt.ip.uh_sport = htons(BOOTPS); - pkt.ip.uh_dport = htons(BOOTPC); - pkt.ip.uh_ulen = htons(udp_len); + pkt.ip.uh_sport = uip_htons(BOOTPS); + pkt.ip.uh_dport = uip_htons(BOOTPC); + pkt.ip.uh_ulen = uip_htons(udp_len); pkt.ip.uh_sum = 0; - pkt.ip.ip_sum = ~htons(ip4sum(0, &pkt.ip, 20)); + pkt.ip.ip_sum = ~uip_htons(ip4sum(0, &pkt.ip, 20)); sum = 17 + udp_len; sum = ip4sum(sum, &pkt.ip.ip_src, 8); sum = ip4sum(sum, &pkt.ip.uh_sport, udp_len); if (sum != 0xffff) - pkt.ip.uh_sum = ~htons(sum); + pkt.ip.uh_sum = ~uip_htons(sum); else pkt.ip.uh_sum = 0xffff; @@ -370,10 +370,10 @@ check_ip(const struct ip *ip, unsigned ip_len) if((ip->ip_vhl & IP_V) != IP_V4) return -1; - if(ntohs(ip->ip_len) > ip_len) + if(uip_ntohs(ip->ip_len) > ip_len) return -2; - if(ntohs(ip->ip_len) < ip_len) + if(uip_ntohs(ip->ip_len) < ip_len) return -3; /* Check IP header. */ @@ -547,7 +547,7 @@ serial_to_tun(FILE *inslip, int outfd) if(dhsock != -1) { struct ip *ip = (void *)uip.inbuf; if(ip->ip_p == 17 && ip->ip_dst == 0xffffffff /* UDP and broadcast */ - && ip->uh_sport == ntohs(BOOTPC) && ip->uh_dport == ntohs(BOOTPS)) { + && ip->uh_sport == uip_ntohs(BOOTPC) && ip->uh_dport == uip_ntohs(BOOTPS)) { relay_dhcp_to_server(ip, inbufptr); inbufptr = 0; } @@ -641,7 +641,7 @@ write_to_serial(int outfd, void *inbuf, int len) } if(iphdr->ip_id == 0 && iphdr->ip_off & IP_DF) { - uint16_t nid = htons(ip_id++); + uint16_t nid = uip_htons(ip_id++); iphdr->ip_id = nid; nid = ~nid; /* negate */ iphdr->ip_sum += nid; /* add */ @@ -971,7 +971,7 @@ main(int argc, char **argv) dhaddr.sin_len = sizeof(dhaddr); #endif dhaddr.sin_family = AF_INET; - dhaddr.sin_port = htons(dhport); + dhaddr.sin_port = uip_htons(dhport); dhaddr.sin_addr.s_addr = a; dhsock = socket(AF_INET, SOCK_DGRAM, 0); @@ -984,7 +984,7 @@ main(int argc, char **argv) #endif myaddr.sin_family = AF_INET; myaddr.sin_addr.s_addr = INADDR_ANY; - myaddr.sin_port = htons(myport); + myaddr.sin_port = uip_htons(myport); if(bind(dhsock, (struct sockaddr *)&myaddr, sizeof(myaddr)) < 0) { err(1, "bind dhcp-relay"); } @@ -1010,7 +1010,7 @@ main(int argc, char **argv) } myaddr.sin_family = AF_INET; myaddr.sin_addr.s_addr = INADDR_ANY; - myaddr.sin_port = htons(myport); + myaddr.sin_port = uip_htons(myport); if(bind(dhsock, (struct sockaddr *)&myaddr, sizeof(myaddr)) < 0) { err(1, "bind dhcp-relay"); } diff --git a/tools/wpcapslip/wpcap.c b/tools/wpcapslip/wpcap.c index 28fa2468f..4949786ae 100644 --- a/tools/wpcapslip/wpcap.c +++ b/tools/wpcapslip/wpcap.c @@ -30,7 +30,7 @@ * * Author: Oliver Schmidt * - * $Id: wpcap.c,v 1.4 2009/04/29 11:56:14 adamdunkels Exp $ + * $Id: wpcap.c,v 1.5 2010/10/19 18:29:05 adamdunkels Exp $ */ @@ -67,8 +67,8 @@ #include /* Avoid 'conflicting types' errors. */ -#define htonl -#define htons +#define uip_htonl +#define uip_htons #define PROGRESS(x) @@ -449,12 +449,12 @@ arp_out(struct ethip_hdr *iphdr, int len) uip_ipaddr_copy(&arphdr->dipaddr, &ipaddr); uip_ipaddr_copy(&arphdr->sipaddr, &netaddr); - arphdr->opcode = HTONS(ARP_REQUEST); /* ARP request. */ - arphdr->hwtype = HTONS(ARP_HWTYPE_ETH); - arphdr->protocol = HTONS(UIP_ETHTYPE_IP); + arphdr->opcode = UIP_HTONS(ARP_REQUEST); /* ARP request. */ + arphdr->hwtype = UIP_HTONS(ARP_HWTYPE_ETH); + arphdr->protocol = UIP_HTONS(UIP_ETHTYPE_IP); arphdr->hwlen = 6; arphdr->protolen = 4; - arphdr->ethhdr.type = HTONS(UIP_ETHTYPE_ARP); + arphdr->ethhdr.type = UIP_HTONS(UIP_ETHTYPE_ARP); /* uip_appdata = &uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN];*/ @@ -467,7 +467,7 @@ arp_out(struct ethip_hdr *iphdr, int len) #endif /* 0 */ memcpy(iphdr->ethhdr.src.addr, uip_ethaddr.addr, 6); - iphdr->ethhdr.type = HTONS(UIP_ETHTYPE_IP); + iphdr->ethhdr.type = UIP_HTONS(UIP_ETHTYPE_IP); return len + sizeof(struct uip_eth_hdr); } @@ -478,8 +478,8 @@ do_arp(void *buf, int len) struct arp_hdr *hdr; hdr = (struct arp_hdr *)buf; - if(hdr->ethhdr.type == HTONS(UIP_ETHTYPE_ARP)) { - if(hdr->opcode == HTONS(ARP_REQUEST)) { + if(hdr->ethhdr.type == UIP_HTONS(UIP_ETHTYPE_ARP)) { + if(hdr->opcode == UIP_HTONS(ARP_REQUEST)) { /* Check if the ARP is for our network */ /* printf("ARP for %d.%d.%d.%d we are %d.%d.%d.%d/%d.%d.%d.%d\n", uip_ipaddr_to_quad(&hdr->dipaddr), @@ -491,7 +491,7 @@ do_arp(void *buf, int len) /* printf("ARP for us.\n");*/ uip_arp_update(&hdr->sipaddr, &hdr->shwaddr); - hdr->opcode = HTONS(ARP_REPLY); + hdr->opcode = UIP_HTONS(ARP_REPLY); memcpy(&hdr->dhwaddr.addr, &hdr->shwaddr.addr, 6); memcpy(&hdr->shwaddr.addr, &uip_ethaddr.addr, 6); @@ -502,11 +502,11 @@ do_arp(void *buf, int len) uip_ipaddr_copy(&hdr->dipaddr, &hdr->sipaddr); uip_ipaddr_copy(&hdr->sipaddr, &tmpaddr); - hdr->ethhdr.type = HTONS(UIP_ETHTYPE_ARP); + hdr->ethhdr.type = UIP_HTONS(UIP_ETHTYPE_ARP); raw_send(hdr, sizeof(struct arp_hdr)); return NULL; } - } else if(hdr->opcode == HTONS(ARP_REPLY)) { + } else if(hdr->opcode == UIP_HTONS(ARP_REPLY)) { /* ARP reply. We insert or update the ARP table if it was meant for us. */ if(uip_ipaddr_maskcmp(&hdr->dipaddr, &netaddr, &netmask)) { @@ -514,7 +514,7 @@ do_arp(void *buf, int len) } } } - if(hdr->ethhdr.type == HTONS(UIP_ETHTYPE_IP)) { + if(hdr->ethhdr.type == UIP_HTONS(UIP_ETHTYPE_IP)) { return &((struct ethip_hdr *)hdr)->vhl; } return NULL; diff --git a/tools/wpcapslip/wpcapslip.c b/tools/wpcapslip/wpcapslip.c index eb465ac08..8d21e9ef7 100644 --- a/tools/wpcapslip/wpcapslip.c +++ b/tools/wpcapslip/wpcapslip.c @@ -30,7 +30,7 @@ * * Author: Oliver Schmidt * - * $Id: wpcapslip.c,v 1.3 2008/06/19 07:52:28 adamdunkels Exp $ + * $Id: wpcapslip.c,v 1.4 2010/10/19 18:29:05 adamdunkels Exp $ */ @@ -182,7 +182,7 @@ static uint16_t chksum(const void *p, uint16_t len) { uint16_t sum = ip4sum(0, p, len); - return (sum == 0) ? 0xffff : htons(sum); + return (sum == 0) ? 0xffff : uip_htons(sum); } int @@ -195,11 +195,11 @@ check_ip(const struct ip *ip, unsigned ip_len) return -1; } - if(ntohs(ip->ip_len) > ip_len) { + if(uip_ntohs(ip->ip_len) > ip_len) { return -2; } - if(ntohs(ip->ip_len) < ip_len) { + if(uip_ntohs(ip->ip_len) < ip_len) { return -3; } @@ -348,7 +348,7 @@ serial_to_wpcap(FILE *inslip) if(dhsock != -1) { struct ip *ip = (void *)uip.inbuf; if(ip->ip_p == 17 && ip->ip_dst == 0xffffffff /* UDP and broadcast */ - && ip->uh_sport == ntohs(BOOTPC) && ip->uh_dport == ntohs(BOOTPS)) { + && ip->uh_sport == uip_ntohs(BOOTPC) && ip->uh_dport == uip_ntohs(BOOTPS)) { relay_dhcp_to_server(ip, inbufptr); inbufptr = 0; } @@ -448,7 +448,7 @@ write_to_serial(int outfd, void *inbuf, int len) } if(iphdr->ip_id == 0 && iphdr->ip_off & IP_DF) { - uint16_t nid = htons(ip_id++); + uint16_t nid = uip_htons(ip_id++); iphdr->ip_id = nid; nid = ~nid; /* negate */ iphdr->ip_sum += nid; /* add */ @@ -463,7 +463,7 @@ write_to_serial(int outfd, void *inbuf, int len) } - iphdr->ip_ttl = htons(htons(iphdr->ip_ttl) + 1); + iphdr->ip_ttl = uip_htons(uip_htons(iphdr->ip_ttl) + 1); if(iphdr->ip_ttl == 0) { fprintf(stderr, "Packet with ttl %d dropped\n", iphdr->ip_ttl); return; @@ -772,7 +772,7 @@ main(int argc, char **argv) dhaddr.sin_len = sizeof(dhaddr); #endif dhaddr.sin_family = AF_INET; - dhaddr.sin_port = htons(dhport); + dhaddr.sin_port = uip_htons(dhport); dhaddr.sin_addr.s_addr = a; dhsock = socket(AF_INET, SOCK_DGRAM, 0); @@ -785,7 +785,7 @@ main(int argc, char **argv) #endif myaddr.sin_family = AF_INET; myaddr.sin_addr.s_addr = INADDR_ANY; - myaddr.sin_port = htons(myport); + myaddr.sin_port = uip_htons(myport); if(bind(dhsock, (struct sockaddr *)&myaddr, sizeof(myaddr)) < 0) { err(1, "bind dhcp-relay"); } @@ -811,7 +811,7 @@ main(int argc, char **argv) } myaddr.sin_family = AF_INET; myaddr.sin_addr.s_addr = INADDR_ANY; - myaddr.sin_port = htons(myport); + myaddr.sin_port = uip_htons(myport); if(bind(dhsock, (struct sockaddr *)&myaddr, sizeof(myaddr)) < 0) { err(1, "bind dhcp-relay"); }