diff --git a/core/cfs/cfs-eeprom.c b/core/cfs/cfs-eeprom.c index b75b15fda..77e1ecb71 100644 --- a/core/cfs/cfs-eeprom.c +++ b/core/cfs/cfs-eeprom.c @@ -1,36 +1,36 @@ /* * Copyright (c) 2004, Swedish Institute of Computer Science. - * All rights reserved. + * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. * * This file is part of the Contiki operating system. - * + * * Author: Adam Dunkels * - * $Id: cfs-eeprom.c,v 1.2 2007/05/19 21:05:48 oliverschmidt Exp $ + * $Id: cfs-eeprom.c,v 1.3 2007/11/17 18:01:00 adamdunkels Exp $ */ #include "contiki.h" @@ -72,7 +72,7 @@ cfs_close(int f) } /*---------------------------------------------------------------------------*/ int -cfs_read(int f, char *buf, unsigned int len) +cfs_read(int f, void *buf, unsigned int len) { if(f == 1) { eeprom_read(CFS_EEPROM_OFFSET + file.fileptr, buf, len); @@ -84,7 +84,7 @@ cfs_read(int f, char *buf, unsigned int len) } /*---------------------------------------------------------------------------*/ int -cfs_write(int f, char *buf, unsigned int len) +cfs_write(int f, void *buf, unsigned int len) { if(f == 1) { eeprom_write(CFS_EEPROM_OFFSET + file.fileptr, buf, len); diff --git a/core/cfs/cfs-posix.c b/core/cfs/cfs-posix.c index 7dfa5a2c6..509aa79de 100644 --- a/core/cfs/cfs-posix.c +++ b/core/cfs/cfs-posix.c @@ -1,36 +1,36 @@ /* * Copyright (c) 2004, Swedish Institute of Computer Science. - * All rights reserved. + * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. * * This file is part of the Contiki operating system. - * + * * Author: Adam Dunkels * - * $Id: cfs-posix.c,v 1.3 2007/05/19 21:05:49 oliverschmidt Exp $ + * $Id: cfs-posix.c,v 1.4 2007/11/17 18:01:00 adamdunkels Exp $ */ #include "contiki.h" @@ -76,13 +76,13 @@ cfs_close(int f) } /*---------------------------------------------------------------------------*/ int -cfs_read(int f, char *b, unsigned int l) +cfs_read(int f, void *b, unsigned int l) { return read(f, b, l); } /*---------------------------------------------------------------------------*/ int -cfs_write(int f, char *b, unsigned int l) +cfs_write(int f, void *b, unsigned int l) { return write(f, b, l); } diff --git a/core/cfs/cfs-ram.c b/core/cfs/cfs-ram.c index ce2a092a6..2c029732f 100644 --- a/core/cfs/cfs-ram.c +++ b/core/cfs/cfs-ram.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: cfs-ram.c,v 1.3 2007/05/19 21:05:49 oliverschmidt Exp $ + * $Id: cfs-ram.c,v 1.4 2007/11/17 18:01:00 adamdunkels Exp $ */ #include "contiki.h" @@ -77,7 +77,7 @@ cfs_close(int f) } /*---------------------------------------------------------------------------*/ int -cfs_read(int f, char *buf, unsigned int len) +cfs_read(int f, void *buf, unsigned int len) { if(file.fileptr + len > sizeof(filemem)) { len = sizeof(filemem) - file.fileptr; @@ -97,7 +97,7 @@ cfs_read(int f, char *buf, unsigned int len) } /*---------------------------------------------------------------------------*/ int -cfs_write(int f, char *buf, unsigned int len) +cfs_write(int f, void *buf, unsigned int len) { if(file.fileptr >= sizeof(filemem)) { return 0; diff --git a/core/cfs/cfs-xmem.c b/core/cfs/cfs-xmem.c index fc3e2bc0b..9b01d128b 100644 --- a/core/cfs/cfs-xmem.c +++ b/core/cfs/cfs-xmem.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: cfs-xmem.c,v 1.4 2007/05/19 21:05:49 oliverschmidt Exp $ + * $Id: cfs-xmem.c,v 1.5 2007/11/17 18:01:00 adamdunkels Exp $ */ #include "contiki.h" @@ -84,7 +84,7 @@ cfs_close(int f) } /*---------------------------------------------------------------------------*/ int -cfs_read(int f, char *buf, unsigned int len) +cfs_read(int f, void *buf, unsigned int len) { if(file.fileptr + len > CFS_XMEM_SIZE) { len = CFS_XMEM_SIZE - file.fileptr; @@ -104,7 +104,7 @@ cfs_read(int f, char *buf, unsigned int len) } /*---------------------------------------------------------------------------*/ int -cfs_write(int f, char *buf, unsigned int len) +cfs_write(int f, void *buf, unsigned int len) { if(file.fileptr >= CFS_XMEM_SIZE) { return 0; @@ -159,4 +159,3 @@ cfs_closedir(struct cfs_dir *p) return 1; } /*---------------------------------------------------------------------------*/ - diff --git a/core/cfs/cfs.h b/core/cfs/cfs.h index eaa9a111c..5bc73b86a 100644 --- a/core/cfs/cfs.h +++ b/core/cfs/cfs.h @@ -54,7 +54,7 @@ * * Author: Adam Dunkels * - * $Id: cfs.h,v 1.5 2007/05/19 21:05:49 oliverschmidt Exp $ + * $Id: cfs.h,v 1.6 2007/11/17 18:01:00 adamdunkels Exp $ */ #ifndef __CFS_H__ #define __CFS_H__ @@ -146,7 +146,7 @@ CCIF void cfs_close(int fd); * buffer. The file must have first been opened with * cfs_open() and the CFS_READ flag. */ -CCIF int cfs_read(int fd, char *buf, unsigned int len); +CCIF int cfs_read(int fd, void *buf, unsigned int len); /** * \brief Write data to an open file. @@ -159,7 +159,7 @@ CCIF int cfs_read(int fd, char *buf, unsigned int len); * an open file. The file must have been opened with * cfs_open() and the CFS_WRITE flag. */ -CCIF int cfs_write(int fd, char *buf, unsigned int len); +CCIF int cfs_write(int fd, void *buf, unsigned int len); /** * \brief Seek to a specified position in an open file. diff --git a/core/lib/sensors.h b/core/lib/sensors.h index 7722ed8d7..644662cd8 100644 --- a/core/lib/sensors.h +++ b/core/lib/sensors.h @@ -1,34 +1,34 @@ /* * Copyright (c) 2005, Swedish Institute of Computer Science - * All rights reserved. + * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. * * This file is part of the Contiki operating system. * - * @(#)$Id: sensors.h,v 1.1 2006/06/17 22:41:18 adamdunkels Exp $ + * @(#)$Id: sensors.h,v 1.2 2007/11/17 18:05:56 adamdunkels Exp $ */ #ifndef __SENSORS_H__ @@ -47,7 +47,7 @@ const struct sensors_sensor name = { type , \ #define SENSORS(...) \ const struct sensors_sensor *sensors[] = {__VA_ARGS__, NULL}; \ unsigned char sensors_flags[SENSORS_NUM]; \ -struct process *sensors_selecting_proc[SENSORS_NUM]; +struct process *sensors_selecting_proc[SENSORS_NUM] struct sensors_sensor { char * type; diff --git a/core/net/psock.c b/core/net/psock.c index 7828f3685..6e17ed2fa 100644 --- a/core/net/psock.c +++ b/core/net/psock.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: psock.c,v 1.4 2007/09/08 16:12:54 matsutsuka Exp $ + * $Id: psock.c,v 1.5 2007/11/17 18:05:21 adamdunkels Exp $ */ #include @@ -171,7 +171,7 @@ data_acked(CC_REGISTER_ARG struct psock *s) return 0; } /*---------------------------------------------------------------------------*/ -PT_THREAD(psock_send(CC_REGISTER_ARG struct psock *s, const char *buf, +PT_THREAD(psock_send(CC_REGISTER_ARG struct psock *s, const uint8_t *buf, unsigned int len)) { PT_BEGIN(&s->psockpt); @@ -322,7 +322,8 @@ PT_THREAD(psock_readbuf(CC_REGISTER_ARG struct psock *psock)) } /*---------------------------------------------------------------------------*/ void -psock_init(CC_REGISTER_ARG struct psock *psock, char *buffer, unsigned int buffersize) +psock_init(CC_REGISTER_ARG struct psock *psock, + uint8_t *buffer, unsigned int buffersize) { psock->state = STATE_NONE; psock->readlen = 0; diff --git a/core/net/psock.h b/core/net/psock.h index ebedcf5bb..a141916ff 100644 --- a/core/net/psock.h +++ b/core/net/psock.h @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: psock.h,v 1.3 2007/09/04 12:39:00 nvt-se Exp $ + * $Id: psock.h,v 1.4 2007/11/17 18:05:21 adamdunkels Exp $ */ /** @@ -117,7 +117,7 @@ struct psock { const u8_t *sendptr; /* Pointer to the next data to be sent. */ u8_t *readptr; /* Pointer to the next data to be read. */ - char *bufptr; /* Pointer to the buffer used for buffering + uint8_t *bufptr; /* Pointer to the buffer used for buffering incoming data. */ u16_t sendlen; /* The number of bytes left to be sent. */ @@ -130,7 +130,7 @@ struct psock { unsigned char state; /* The state of the protosocket. */ }; -void psock_init(struct psock *psock, char *buffer, unsigned int buffersize); +void psock_init(struct psock *psock, uint8_t *buffer, unsigned int buffersize); /** * Initialize a protosocket. * @@ -141,7 +141,7 @@ void psock_init(struct psock *psock, char *buffer, unsigned int buffersize); * \param psock (struct psock *) A pointer to the protosocket to be * initialized * - * \param buffer (char *) A pointer to the input buffer for the + * \param buffer (uint8_t *) A pointer to the input buffer for the * protosocket. * * \param buffersize (unsigned int) The size of the input buffer. @@ -164,7 +164,7 @@ void psock_init(struct psock *psock, char *buffer, unsigned int buffersize); */ #define PSOCK_BEGIN(psock) PT_BEGIN(&((psock)->pt)) -PT_THREAD(psock_send(struct psock *psock, const char *buf, unsigned int len)); +PT_THREAD(psock_send(struct psock *psock, const uint8_t *buf, unsigned int len)); /** * Send data. * @@ -175,7 +175,7 @@ PT_THREAD(psock_send(struct psock *psock, const char *buf, unsigned int len)); * \param psock (struct psock *) A pointer to the protosocket over which * data is to be sent. * - * \param data (char *) A pointer to the data that is to be sent. + * \param data (uint8_t *) A pointer to the data that is to be sent. * * \param datalen (unsigned int) The length of the data that is to be * sent. diff --git a/core/net/rawpacket-udp.c b/core/net/rawpacket-udp.c index 64da44217..9acae9b8c 100644 --- a/core/net/rawpacket-udp.c +++ b/core/net/rawpacket-udp.c @@ -1,4 +1,4 @@ -/* +c/* * Copyright (c) 2006, Swedish Institute of Computer Science. * All rights reserved. * @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: rawpacket-udp.c,v 1.2 2007/09/29 03:54:18 matsutsuka Exp $ + * $Id: rawpacket-udp.c,v 1.3 2007/11/17 18:05:21 adamdunkels Exp $ */ /** @@ -38,7 +38,7 @@ * Adam Dunkels */ -#if UIP_UDP +#include "contiki.h" #include "contiki-net.h" #include "net/rawpacket-udp.h" @@ -70,4 +70,3 @@ rawpacket_received(struct rawpacket_conn *c) return uip_newdata() && (struct uip_udp_conn *)c == uip_udp_conn; } /*---------------------------------------------------------------------------*/ -#endif /* UIP_UDP */ diff --git a/core/net/resolv.c b/core/net/resolv.c index bcad4a8b0..51a3d194f 100644 --- a/core/net/resolv.c +++ b/core/net/resolv.c @@ -23,25 +23,25 @@ * \file * DNS host name to IP address resolver. * \author Adam Dunkels - * + * * This file implements a DNS host name to IP address resolver. */ /* * Copyright (c) 2002-2003, Adam Dunkels. - * All rights reserved. + * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote * products derived from this software without specific prior - * written permission. + * written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED @@ -53,11 +53,11 @@ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of the uIP TCP/IP stack. * - * $Id: resolv.c,v 1.6 2007/09/29 03:54:18 matsutsuka Exp $ + * $Id: resolv.c,v 1.7 2007/11/17 18:05:21 adamdunkels Exp $ * */ @@ -184,7 +184,7 @@ check_entries(void) static u8_t n; register struct namemap *namemapptr; - for(i = 0; i < RESOLV_ENTRIES; ++i) { + for(i = 0; i < RESOLV_ENTRIES; ++i) { namemapptr = &names[i]; if(namemapptr->state == STATE_NEW || namemapptr->state == STATE_ASKING) { @@ -196,7 +196,7 @@ check_entries(void) resolv_found(namemapptr->name, NULL); continue; } - namemapptr->tmr = namemapptr->retries; + namemapptr->tmr = namemapptr->retries; } else { /* printf("Timer %d\n", namemapptr->tmr);*/ /* Its timer has not run out, so we move on to next @@ -246,7 +246,7 @@ check_entries(void) static void newdata(void) { - char *nameptr; + unsigned char *nameptr; struct dns_answer *ans; struct dns_hdr *hdr; static u8_t nquestions, nanswers; @@ -290,18 +290,18 @@ newdata(void) /* Skip the name in the question. XXX: This should really be checked agains the name in the question, to be sure that they match. */ - nameptr = parse_name((char *)uip_appdata + 12) + 4; + nameptr = parse_name((uint8_t *)uip_appdata + 12) + 4; while(nanswers > 0) { /* The first byte in the answer resource record determines if it is a compressed record or a normal one. */ - if(*nameptr & 0xc0) { + if(*nameptr & 0xc0) { /* Compressed name. */ nameptr +=2; /* printf("Compressed anwser\n");*/ } else { /* Not compressed name. */ - nameptr = parse_name((char *)nameptr); + nameptr = parse_name((uint8_t *)nameptr); } ans = (struct dns_answer *)nameptr; @@ -348,7 +348,7 @@ PROCESS_THREAD(resolv_process, ev, data) names[i].state = STATE_UNUSED; } resolv_conn = NULL; - resolv_event_found = process_alloc_event(); + resolv_event_found = process_alloc_event(); while(1) { @@ -372,7 +372,7 @@ PROCESS_THREAD(resolv_process, ev, data) } if(uip_newdata()) { newdata(); - } + } } } } @@ -445,12 +445,12 @@ resolv_lookup(char *name) for(i = 0; i < RESOLV_ENTRIES; ++i) { nameptr = &names[i]; if(nameptr->state == STATE_DONE && - strcmp(name, nameptr->name) == 0) { + strcmp(name, nameptr->name) == 0) { return nameptr->ipaddr; } } return NULL; -} +} /*-----------------------------------------------------------------------------------*/ /** * Obtain the currently configured DNS server. diff --git a/core/net/rime/queuebuf.c b/core/net/rime/queuebuf.c index 5ffe55678..3ff4f93b2 100644 --- a/core/net/rime/queuebuf.c +++ b/core/net/rime/queuebuf.c @@ -33,7 +33,7 @@ * * This file is part of the Contiki operating system. * - * $Id: queuebuf.c,v 1.9 2007/05/15 08:09:21 adamdunkels Exp $ + * $Id: queuebuf.c,v 1.10 2007/11/17 18:05:21 adamdunkels Exp $ */ /** @@ -110,9 +110,9 @@ queuebuf_new_from_rimebuf(void) #if QUEUEBUF_STATS ++queuebuf_ref_len; #if NETSIM - node_log("%d %d\n", + /* node_log("%d %d\n", queuebuf_len, - queuebuf_ref_len); + queuebuf_ref_len);*/ #endif /* NETSIM */ #endif /* QUEUEBUF_STATS */ rbuf->len = rimebuf_datalen(); @@ -133,9 +133,9 @@ queuebuf_new_from_rimebuf(void) return NULL; } #if NETSIM - node_log("%d %d\n", + /* node_log("%d %d\n", queuebuf_len, - queuebuf_ref_len); + queuebuf_ref_len);*/ #endif /* NETSIM */ #endif /* QUEUEBUF_STATS */ buf->len = rimebuf_copyto(buf->data); @@ -154,9 +154,9 @@ queuebuf_free(struct queuebuf *buf) #if QUEUEBUF_STATS --queuebuf_len; #if NETSIM - node_log("%d %d\n", + /* node_log("%d %d\n", queuebuf_len, - queuebuf_ref_len); + queuebuf_ref_len);*/ #endif /* NETSIM */ #endif /* QUEUEBUF_STATS */ } else if(memb_inmemb(&refbufmem, buf)) { @@ -164,9 +164,9 @@ queuebuf_free(struct queuebuf *buf) #if QUEUEBUF_STATS --queuebuf_ref_len; #if NETSIM - node_log("%d %d\n", + /* node_log("%d %d\n", queuebuf_len, - queuebuf_ref_len); + queuebuf_ref_len);*/ #endif /* NETSIM */ #endif /* QUEUEBUF_STATS */ } diff --git a/core/net/rime/rimebuf.c b/core/net/rime/rimebuf.c index 0643f358a..1aad1fb5a 100644 --- a/core/net/rime/rimebuf.c +++ b/core/net/rime/rimebuf.c @@ -33,7 +33,7 @@ * * This file is part of the Contiki operating system. * - * $Id: rimebuf.c,v 1.9 2007/10/25 12:48:46 adamdunkels Exp $ + * $Id: rimebuf.c,v 1.10 2007/11/17 18:05:21 adamdunkels Exp $ */ /** @@ -75,7 +75,7 @@ rimebuf_clear(void) } /*---------------------------------------------------------------------------*/ int -rimebuf_copyfrom(const u8_t *from, u16_t len) +rimebuf_copyfrom(const void *from, u16_t len) { u16_t l; @@ -117,7 +117,7 @@ rimebuf_copyto_hdr(u8_t *to) } /*---------------------------------------------------------------------------*/ int -rimebuf_copyto(u8_t *to) +rimebuf_copyto(void *to) { #if DEBUG_LEVEL > 0 { @@ -139,7 +139,7 @@ rimebuf_copyto(u8_t *to) } #endif /* DEBUG_LEVEL */ memcpy(to, rimebuf + hdrptr, RIMEBUF_HDR_SIZE - hdrptr); - memcpy(to + RIMEBUF_HDR_SIZE - hdrptr, rimebufptr + bufptr, + memcpy((u8_t *)to + RIMEBUF_HDR_SIZE - hdrptr, rimebufptr + bufptr, buflen); return RIMEBUF_HDR_SIZE - hdrptr + buflen; } diff --git a/core/net/rime/rimebuf.h b/core/net/rime/rimebuf.h index 08f49414a..9d76e11c0 100644 --- a/core/net/rime/rimebuf.h +++ b/core/net/rime/rimebuf.h @@ -40,7 +40,7 @@ * * This file is part of the Contiki operating system. * - * $Id: rimebuf.h,v 1.10 2007/10/25 12:48:46 adamdunkels Exp $ + * $Id: rimebuf.h,v 1.11 2007/11/17 18:05:21 adamdunkels Exp $ */ /** @@ -232,7 +232,7 @@ void rimebuf_compact(void); * copied into the rimbuf is returned. * */ -int rimebuf_copyfrom(const u8_t *from, u16_t len); +int rimebuf_copyfrom(const void *from, u16_t len); /** * \brief Copy the entire rimebuf to an external buffer @@ -252,7 +252,7 @@ int rimebuf_copyfrom(const u8_t *from, u16_t len); * returned. * */ -int rimebuf_copyto(u8_t *to); +int rimebuf_copyto(void *to); /** * \brief Copy the header portion of the rimebuf to an external buffer diff --git a/core/net/rime/rudolph0.h b/core/net/rime/rudolph0.h index c8bfddebb..d0cc05299 100644 --- a/core/net/rime/rudolph0.h +++ b/core/net/rime/rudolph0.h @@ -47,7 +47,7 @@ * * This file is part of the Contiki operating system. * - * $Id: rudolph0.h,v 1.5 2007/11/16 09:17:22 fros4943 Exp $ + * $Id: rudolph0.h,v 1.6 2007/11/17 18:05:21 adamdunkels Exp $ */ /** @@ -75,8 +75,8 @@ enum { struct rudolph0_callbacks { void (* write_chunk)(struct rudolph0_conn *c, int offset, int flag, - char *data, int len); - int (* read_chunk)(struct rudolph0_conn *c, int offset, char *to, + uint8_t *data, int len); + int (* read_chunk)(struct rudolph0_conn *c, int offset, uint8_t *to, int maxsize); }; diff --git a/core/net/rime/rudolph1.c b/core/net/rime/rudolph1.c index ec086f2e7..3f1aca41d 100644 --- a/core/net/rime/rudolph1.c +++ b/core/net/rime/rudolph1.c @@ -33,7 +33,7 @@ * * This file is part of the Contiki operating system. * - * $Id: rudolph1.c,v 1.9 2007/05/15 08:09:21 adamdunkels Exp $ + * $Id: rudolph1.c,v 1.10 2007/11/17 18:05:21 adamdunkels Exp $ */ /** @@ -86,7 +86,7 @@ enum { /*---------------------------------------------------------------------------*/ static int -read_data(struct rudolph1_conn *c, char *dataptr, int chunk) +read_data(struct rudolph1_conn *c, uint8_t *dataptr, int chunk) { int len = 0; diff --git a/core/net/rime/rudolph1.h b/core/net/rime/rudolph1.h index 51f3433d5..9065bee1d 100644 --- a/core/net/rime/rudolph1.h +++ b/core/net/rime/rudolph1.h @@ -47,7 +47,7 @@ * * This file is part of the Contiki operating system. * - * $Id: rudolph1.h,v 1.5 2007/05/15 08:09:21 adamdunkels Exp $ + * $Id: rudolph1.h,v 1.6 2007/11/17 18:05:21 adamdunkels Exp $ */ /** @@ -75,8 +75,8 @@ enum { struct rudolph1_callbacks { void (* write_chunk)(struct rudolph1_conn *c, int offset, int flag, - char *data, int len); - int (* read_chunk)(struct rudolph1_conn *c, int offset, char *to, + uint8_t *data, int len); + int (* read_chunk)(struct rudolph1_conn *c, int offset, uint8_t *to, int maxsize); }; diff --git a/core/net/rime/rudolph2.c b/core/net/rime/rudolph2.c index f82bba2db..eaf25ba7d 100644 --- a/core/net/rime/rudolph2.c +++ b/core/net/rime/rudolph2.c @@ -39,7 +39,7 @@ * * This file is part of the Contiki operating system. * - * $Id: rudolph2.c,v 1.2 2007/11/17 10:13:17 adamdunkels Exp $ + * $Id: rudolph2.c,v 1.3 2007/11/17 18:05:21 adamdunkels Exp $ */ /** @@ -94,7 +94,7 @@ enum { /*---------------------------------------------------------------------------*/ static int -read_data(struct rudolph2_conn *c, char *dataptr, int chunk) +read_data(struct rudolph2_conn *c, uint8_t *dataptr, int chunk) { int len = 0; @@ -117,7 +117,7 @@ format_data(struct rudolph2_conn *c, int chunk) hdr->hops_from_base = c->hops_from_base; hdr->version = c->version; hdr->chunk = chunk; - len = read_data(c, (char *)hdr + sizeof(struct rudolph2_hdr), chunk); + len = read_data(c, (uint8_t *)hdr + sizeof(struct rudolph2_hdr), chunk); rimebuf_set_datalen(sizeof(struct rudolph2_hdr) + len); return len; diff --git a/core/net/rime/rudolph2.h b/core/net/rime/rudolph2.h index 9631b5293..c94180584 100644 --- a/core/net/rime/rudolph2.h +++ b/core/net/rime/rudolph2.h @@ -47,7 +47,7 @@ * * This file is part of the Contiki operating system. * - * $Id: rudolph2.h,v 1.1 2007/05/15 08:07:46 adamdunkels Exp $ + * $Id: rudolph2.h,v 1.2 2007/11/17 18:05:21 adamdunkels Exp $ */ /** @@ -75,8 +75,8 @@ enum { struct rudolph2_callbacks { void (* write_chunk)(struct rudolph2_conn *c, int offset, int flag, - char *data, int len); - int (* read_chunk)(struct rudolph2_conn *c, int offset, char *to, + uint8_t *data, int len); + int (* read_chunk)(struct rudolph2_conn *c, int offset, uint8_t *to, int maxsize); }; diff --git a/core/net/rime/tree.c b/core/net/rime/tree.c index 4c62464ed..47051ff31 100644 --- a/core/net/rime/tree.c +++ b/core/net/rime/tree.c @@ -33,7 +33,7 @@ * * This file is part of the Contiki operating system. * - * $Id: tree.c,v 1.14 2007/11/17 10:32:54 adamdunkels Exp $ + * $Id: tree.c,v 1.15 2007/11/17 18:05:21 adamdunkels Exp $ */ /** @@ -139,7 +139,7 @@ update_rtmetric(struct tree_conn *tc) if(tc->local_rtmetric == RTMETRIC_MAX) { strcpy(buf, " "); } else { - snprintf(buf, sizeof(buf), "%d", tc->local_rtmetric); + sprintf(buf, "%d", tc->local_rtmetric); } ether_set_text(buf); } diff --git a/core/net/uaodv.c b/core/net/uaodv.c index 0ddfa3d29..e1da3b6d5 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.32 2007/09/29 03:54:18 matsutsuka Exp $ + * $Id: uaodv.c,v 1.33 2007/11/17 18:05:21 adamdunkels Exp $ */ /** @@ -38,7 +38,6 @@ * Adam Dunkels */ -#if UIP_UDP #include #include @@ -240,7 +239,7 @@ send_rerr(uip_ipaddr_t *addr, u32_t *seqno) { struct uaodv_msg_rerr *rm = (struct uaodv_msg_rerr *)uip_appdata; - print_debug("send RERR for %d.%d.%d.%d\n", uip_ipaddr_to_quad(addr)); + print_debug("send RERR for %d.%d.%d.%d\n", uip_ipaddr_to_quad(addr)); rm->type = UAODV_RERR_TYPE; rm->reserved = 0; @@ -358,7 +357,7 @@ handle_incoming_rreq(void) my_hseqno++; if(!(rm->flags & UAODV_RREQ_UNKSEQNO) - && SCMP32(my_hseqno, ntohl(rm->dest_seqno)) < 0) { + && SCMP32(my_hseqno, ntohl(rm->dest_seqno)) < 0) { print_debug("New my_hseqno %lu\n", my_hseqno); /* We have rebooted. */ my_hseqno = ntohl(rm->dest_seqno) + 1; } @@ -626,4 +625,3 @@ PROCESS_THREAD(uaodv_process, ev, data) PROCESS_END(); } /*---------------------------------------------------------------------------*/ -#endif /* UIP_UDP */ diff --git a/core/net/uip-udp-packet.c b/core/net/uip-udp-packet.c index 85c40ef10..8d8a5d135 100644 --- a/core/net/uip-udp-packet.c +++ b/core/net/uip-udp-packet.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: uip-udp-packet.c,v 1.4 2007/09/29 03:54:18 matsutsuka Exp $ + * $Id: uip-udp-packet.c,v 1.5 2007/11/17 18:05:21 adamdunkels Exp $ */ /** @@ -38,17 +38,19 @@ * Adam Dunkels */ -#if UIP_UDP +#include "contiki-conf.h" + +extern u16_t uip_slen; + #include "net/uip-udp-packet.h" #include -extern u16_t uip_slen; - /*---------------------------------------------------------------------------*/ void uip_udp_packet_send(struct uip_udp_conn *c, const void *data, int len) { +#if UIP_UDP uip_udp_conn = c; uip_slen = len; memcpy(&uip_buf[UIP_LLH_LEN + UIP_IPUDPH_LEN], data, len > UIP_BUFSIZE? UIP_BUFSIZE: len); @@ -57,6 +59,6 @@ uip_udp_packet_send(struct uip_udp_conn *c, const void *data, int len) tcpip_output(); } uip_slen = 0; +#endif /* UIP_UDP */ } /*---------------------------------------------------------------------------*/ -#endif /* UIP_UDP */ diff --git a/core/sys/profile-aggregates.c b/core/sys/profile-aggregates.c index cc75b4cbb..2d34a9f15 100644 --- a/core/sys/profile-aggregates.c +++ b/core/sys/profile-aggregates.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: profile-aggregates.c,v 1.2 2007/11/17 10:14:19 adamdunkels Exp $ + * $Id: profile-aggregates.c,v 1.3 2007/11/17 18:07:40 adamdunkels Exp $ */ /** @@ -44,7 +44,7 @@ #include struct aggregate { - const unsigned char *ptr; + const char *ptr; unsigned short episodes; unsigned long cycles; }; diff --git a/cpu/native/Makefile.native b/cpu/native/Makefile.native index b3198f91a..025f22c98 100644 --- a/cpu/native/Makefile.native +++ b/cpu/native/Makefile.native @@ -8,7 +8,7 @@ LD = gcc AS = as OBJCOPY = objcopy STRIP = strip -CFLAGSNO = -Wall -Werror -g -I/usr/local/include +CFLAGSNO = -pedantic -std=c99 -Wall -Werror -g -I/usr/local/include CFLAGS += $(CFLAGSNO) -O LDFLAGS = -Wl,-Map=contiki-$(TARGET).map,-export-dynamic diff --git a/cpu/native/net/wpcap.c b/cpu/native/net/wpcap.c index a3f289785..d1f3dee20 100644 --- a/cpu/native/net/wpcap.c +++ b/cpu/native/net/wpcap.c @@ -1,36 +1,36 @@ /* * Copyright (c) 2007, Swedish Institute of Computer Science. - * All rights reserved. + * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. * * This file is part of the Contiki operating system. - * + * * Author: Oliver Schmidt * - * $Id: wpcap.c,v 1.8 2007/05/22 22:01:03 oliverschmidt Exp $ + * $Id: wpcap.c,v 1.9 2007/11/17 18:08:15 adamdunkels Exp $ */ #define WIN32_LEAN_AND_MEAN @@ -42,9 +42,10 @@ #include #include #include +#include /* Avoid 'conflicting types' errors. */ -#define htonl +#define htonl #define htons #include "contiki-net.h" @@ -109,7 +110,7 @@ init_pcap(struct in_addr addr) while(interfaces != NULL) { log_message("init_pcap: found interface: ", interfaces->description); - if(interfaces->addresses != NULL && + if(interfaces->addresses != NULL && interfaces->addresses->addr != NULL && interfaces->addresses->addr->sa_family == AF_INET) { @@ -119,7 +120,7 @@ init_pcap(struct in_addr addr) if(interface_addr.s_addr == addr.s_addr) { break; - } + } } interfaces = interfaces->next; } @@ -207,10 +208,10 @@ wpcap_init(void) log_message("wpcap_init: cmdline address: ", inet_ntoa(addr)); wpcap = LoadLibrary("wpcap.dll"); - (FARPROC)pcap_findalldevs = GetProcAddress(wpcap, "pcap_findalldevs"); - (FARPROC)pcap_open_live = GetProcAddress(wpcap, "pcap_open_live"); - (FARPROC)pcap_next_ex = GetProcAddress(wpcap, "pcap_next_ex"); - (FARPROC)pcap_sendpacket = GetProcAddress(wpcap, "pcap_sendpacket"); + pcap_findalldevs = (int (*)(struct pcap_if **, char *))GetProcAddress(wpcap, "pcap_findalldevs"); + pcap_open_live = (struct pcap *(*)(char *, int, int, int, char *))GetProcAddress(wpcap, "pcap_open_live"); + pcap_next_ex = (int (*)(struct pcap *, struct pcap_pkthdr **, unsigned char **))GetProcAddress(wpcap, "pcap_next_ex"); + pcap_sendpacket = (int (*)(struct pcap *, unsigned char *, int))GetProcAddress(wpcap, "pcap_sendpacket"); if(pcap_findalldevs == NULL || pcap_open_live == NULL || pcap_next_ex == NULL || pcap_sendpacket == NULL) { @@ -228,7 +229,7 @@ wpcap_poll(void) unsigned char *packet; switch(pcap_next_ex(pcap, &packet_header, &packet)) { - case -1: + case -1: error_exit("error on poll\n"); case 0: return 0; diff --git a/examples/rime/test-rucb.c b/examples/rime/test-rucb.c index 6df642de9..fabeefe6f 100644 --- a/examples/rime/test-rucb.c +++ b/examples/rime/test-rucb.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: test-rucb.c,v 1.1 2007/09/27 22:21:27 adamdunkels Exp $ + * $Id: test-rucb.c,v 1.2 2007/11/17 18:09:56 adamdunkels Exp $ */ /** @@ -46,11 +46,16 @@ #include "dev/leds.h" #include "cfs/cfs.h" - +#include "lib/print-stats.h" #include "sys/profile.h" #include +#if NETSIM +#include "ether.h" +#include "node.h" +#endif /* NETSIM */ + #define FILESIZE 40000 static unsigned long bytecount; @@ -87,7 +92,7 @@ read_chunk(struct rucb_conn *c, int offset, char *to, int maxsize) bytecount += size; if(bytecount == FILESIZE) { - printf("Completion time %u / %u\n", clock_time() - start_time, CLOCK_SECOND); + printf("Completion time %lu / %u\n", (unsigned long)clock_time() - start_time, CLOCK_SECOND); /* profile_aggregates_print(); */ /* profile_print_stats(); */ print_stats(); @@ -104,7 +109,6 @@ static struct rucb_conn rucb; PROCESS_THREAD(test_rucb_process, ev, data) { - static int fd; PROCESS_EXITHANDLER(rucb_close(&rucb);) PROCESS_BEGIN(); @@ -116,11 +120,11 @@ PROCESS_THREAD(test_rucb_process, ev, data) PROCESS_PAUSE(); - if(rimeaddr_node_addr.u8[0] == 10 && + if(rimeaddr_node_addr.u8[0] == 51 && rimeaddr_node_addr.u8[1] == 0) { rimeaddr_t recv; - recv.u8[0] = 20; + recv.u8[0] = 52; recv.u8[1] = 0; start_time = clock_time(); rucb_send(&rucb, &recv); diff --git a/examples/rime/test-rudolph0.c b/examples/rime/test-rudolph0.c index f7fcece27..526f45b5b 100644 --- a/examples/rime/test-rudolph0.c +++ b/examples/rime/test-rudolph0.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: test-rudolph0.c,v 1.5 2007/05/22 21:04:19 adamdunkels Exp $ + * $Id: test-rudolph0.c,v 1.6 2007/11/17 18:09:56 adamdunkels Exp $ */ /** @@ -39,6 +39,7 @@ */ #include "contiki.h" +#include "cfs/cfs.h" #include "net/rime/rudolph0.h" #include "dev/button-sensor.h" @@ -55,7 +56,7 @@ AUTOSTART_PROCESSES(&test_rudolph0_process); /*---------------------------------------------------------------------------*/ static void write_chunk(struct rudolph0_conn *c, int offset, int flag, - char *data, int datalen) + uint8_t *data, int datalen) { int fd; @@ -94,7 +95,7 @@ write_chunk(struct rudolph0_conn *c, int offset, int flag, } } static int -read_chunk(struct rudolph0_conn *c, int offset, char *to, int maxsize) +read_chunk(struct rudolph0_conn *c, int offset, uint8_t *to, int maxsize) { int fd; int ret; diff --git a/examples/rime/test-rudolph1.c b/examples/rime/test-rudolph1.c index 32d39249b..2995ddb76 100644 --- a/examples/rime/test-rudolph1.c +++ b/examples/rime/test-rudolph1.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: test-rudolph1.c,v 1.7 2007/05/15 08:10:32 adamdunkels Exp $ + * $Id: test-rudolph1.c,v 1.8 2007/11/17 18:09:56 adamdunkels Exp $ */ /** @@ -51,6 +51,11 @@ #include +#if NETSIM +#include "ether.h" +#include "node.h" +#endif /* NETSIM */ + #define FILESIZE 2000 /*---------------------------------------------------------------------------*/ @@ -59,7 +64,7 @@ AUTOSTART_PROCESSES(&test_rudolph1_process); /*---------------------------------------------------------------------------*/ static void write_chunk(struct rudolph1_conn *c, int offset, int flag, - char *data, int datalen) + uint8_t *data, int datalen) { int fd; #if NETSIM @@ -111,7 +116,7 @@ write_chunk(struct rudolph1_conn *c, int offset, int flag, } } static int -read_chunk(struct rudolph1_conn *c, int offset, char *to, int maxsize) +read_chunk(struct rudolph1_conn *c, int offset, uint8_t *to, int maxsize) { int fd; int ret; diff --git a/examples/rime/test-rudolph2.c b/examples/rime/test-rudolph2.c index 586d5c0b0..f295ef807 100644 --- a/examples/rime/test-rudolph2.c +++ b/examples/rime/test-rudolph2.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: test-rudolph2.c,v 1.1 2007/05/15 08:10:32 adamdunkels Exp $ + * $Id: test-rudolph2.c,v 1.2 2007/11/17 18:09:56 adamdunkels Exp $ */ /** @@ -49,6 +49,11 @@ #include +#if NETSIM +#include "ether.h" +#include "node.h" +#endif /* NETSIM */ + #define FILESIZE 2000 /*---------------------------------------------------------------------------*/ @@ -57,7 +62,7 @@ AUTOSTART_PROCESSES(&test_rudolph2_process); /*---------------------------------------------------------------------------*/ static void write_chunk(struct rudolph2_conn *c, int offset, int flag, - char *data, int datalen) + uint8_t *data, int datalen) { int fd; #if NETSIM @@ -109,7 +114,7 @@ write_chunk(struct rudolph2_conn *c, int offset, int flag, } } static int -read_chunk(struct rudolph2_conn *c, int offset, char *to, int maxsize) +read_chunk(struct rudolph2_conn *c, int offset, uint8_t *to, int maxsize) { int fd; int ret; diff --git a/examples/sky/test-cfs.c b/examples/sky/test-cfs.c index d1688d8d6..de44cac41 100644 --- a/examples/sky/test-cfs.c +++ b/examples/sky/test-cfs.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: test-cfs.c,v 1.2 2007/05/19 21:07:07 oliverschmidt Exp $ + * $Id: test-cfs.c,v 1.3 2007/11/17 18:10:54 adamdunkels Exp $ */ /** @@ -41,6 +41,10 @@ #include "contiki.h" #include "cfs/cfs.h" +#include + +PROCESS(cfs_process, "Test CFS process"); +AUTOSTART_PROCESSES(&cfs_process); /*---------------------------------------------------------------------------*/ PROCESS_THREAD(cfs_process, ev, data) { diff --git a/platform/native/contiki-conf.h b/platform/native/contiki-conf.h index e07e7272d..21c7578fb 100644 --- a/platform/native/contiki-conf.h +++ b/platform/native/contiki-conf.h @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: contiki-conf.h,v 1.5 2007/05/12 21:01:20 oliverschmidt Exp $ + * @(#)$Id: contiki-conf.h,v 1.6 2007/11/17 18:08:56 adamdunkels Exp $ */ #ifndef __CONTIKI_CONF_H__ @@ -51,6 +51,7 @@ typedef uint32_t u32_t; typedef int32_t s32_t; typedef unsigned short uip_stats_t; +#define UIP_UDP 1 #define UIP_CONF_MAX_CONNECTIONS 40 #define UIP_CONF_MAX_LISTENPORTS 40 #define UIP_CONF_BUFFER_SIZE 420 diff --git a/platform/netsim/contiki-main.c b/platform/netsim/contiki-main.c index 79986f041..38443c4f7 100644 --- a/platform/netsim/contiki-main.c +++ b/platform/netsim/contiki-main.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: contiki-main.c,v 1.18 2007/11/15 13:11:42 nifi Exp $ + * $Id: contiki-main.c,v 1.19 2007/11/17 18:09:18 adamdunkels Exp $ */ #include "contiki.h" @@ -49,11 +49,13 @@ #include "net/ethernode.h" #include "net/uip-over-mesh.h" +#include "net/mac/nullmac.h" + #include "ether.h" -/*#include +#include #include -#include */ +#include #include "dev/button-sensor.h" #include "dev/pir-sensor.h" @@ -118,7 +120,7 @@ contiki_main(int flag) rtimer_init(); - autostart_start(autostart_processes); + autostart_start((struct process **)autostart_processes); while(1) { int n; diff --git a/platform/netsim/dev/eeprom.c b/platform/netsim/dev/eeprom.c index 225508a31..18c60edc8 100644 --- a/platform/netsim/dev/eeprom.c +++ b/platform/netsim/dev/eeprom.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: eeprom.c,v 1.1 2006/06/17 22:41:36 adamdunkels Exp $ + * $Id: eeprom.c,v 1.2 2007/11/17 18:09:18 adamdunkels Exp $ */ #include "dev/eeprom.h" #include "node.h" @@ -49,7 +49,7 @@ eeprom_write(eeprom_addr_t addr, unsigned char *buf, int size) int f; char name[400]; - snprintf(name, sizeof(name), "eeprom.%d.%d", node_x(), node_y()); + sprintf(name, "eeprom.%d.%d", node_x(), node_y()); f = open(name, O_WRONLY | O_APPEND | O_CREAT, 0644); lseek(f, addr, SEEK_SET); write(f, buf, size); diff --git a/platform/netsim/display.c b/platform/netsim/display.c index 438e866e9..31250bfb6 100644 --- a/platform/netsim/display.c +++ b/platform/netsim/display.c @@ -24,7 +24,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * - * $Id: display.c,v 1.5 2007/04/02 17:58:43 adamdunkels Exp $ + * $Id: display.c,v 1.6 2007/11/17 18:09:18 adamdunkels Exp $ * * Author: Adam Dunkels * @@ -41,6 +41,7 @@ #include +#include #include static GdkPixmap *pixmap = NULL; @@ -87,12 +88,10 @@ static struct nodes_node *marked_node; void display_redraw(void) { - int i, j; - struct nodes_node *n, *m; - char string[20]; + int i; + struct nodes_node *n; int x, y; struct dot *d; - GdkGC *color; if(!window_is_open) { return; @@ -503,7 +502,7 @@ display_init(void (* idlefunc)(void), int time, int with_gui) gtk_init(NULL, NULL); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_title(window, "Contiki simulation display"); + gtk_window_set_title(GTK_WINDOW(window), "Contiki simulation display"); vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER (window), vbox); diff --git a/platform/netsim/ether.c b/platform/netsim/ether.c index 3f6bafa01..8ee493eab 100644 --- a/platform/netsim/ether.c +++ b/platform/netsim/ether.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: ether.c,v 1.9 2007/11/14 11:17:30 nvt-se Exp $ + * $Id: ether.c,v 1.10 2007/11/17 18:09:18 adamdunkels Exp $ */ /** * \file @@ -117,7 +117,7 @@ static int num_drops = 0; static struct timeval t1; /*-----------------------------------------------------------------------------------*/ -int +void ether_print_stats(void) { unsigned long time; @@ -132,8 +132,6 @@ ether_print_stats(void) printf("Total collisions: %d\n", num_collisions); printf("Total packets receptions: %d\n", num_received); printf("Total randomly dropped packets: %d\n", num_drops); - - return 0; } /*-----------------------------------------------------------------------------------*/ void @@ -178,7 +176,7 @@ ether_server_init(void) perror("ether_server_init: socket"); } - bzero((char *)&sa, sizeof(sa)); + 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);*/ @@ -206,7 +204,7 @@ ether_client_init(int port) perror("socket"); } - bzero((char *)&sa, sizeof(sa)); + 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);*/ @@ -322,7 +320,7 @@ ether_server_poll(void) case PTYPE_DATA: PRINTF("ether_poll: read %d bytes from (%d, %d)\n", ret, hdr->srcx, hdr->srcy); - ether_put(rxbuffer, ret, hdr->srcx, hdr->srcy); + ether_put((char *)rxbuffer, ret, hdr->srcx, hdr->srcy); break; case PTYPE_LEDS: nodes_set_leds(hdr->srcx, hdr->srcy, hdr->leds); @@ -369,7 +367,7 @@ send_packet(char *data, int len, int port) { struct sockaddr_in sa; - bzero((char *)&sa , sizeof(sa)); + 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); @@ -492,7 +490,7 @@ node_send_packet(char *data, int len) { struct sockaddr_in sa; - bzero((char *)&sa , sizeof(sa)); + 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); diff --git a/platform/netsim/ether.h b/platform/netsim/ether.h index d2a2956ba..86ee237ff 100644 --- a/platform/netsim/ether.h +++ b/platform/netsim/ether.h @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: ether.h,v 1.5 2007/03/22 18:59:34 adamdunkels Exp $ + * $Id: ether.h,v 1.6 2007/11/17 18:09:18 adamdunkels Exp $ */ #ifndef __ETHER_H__ #define __ETHER_H__ @@ -67,6 +67,8 @@ void ether_put(char *packet, int len, int src_x, int src_y); void ether_send_sensor_data(struct sensor_data *d, int srcx, int srcy, int strength); +int ether_client_poll(void); + struct ether_packet * ether_packets(void); clock_time_t ether_time(void); @@ -78,6 +80,6 @@ void ether_set_strength(int s); void ether_set_collisions(int c); void ether_set_drop_probability(double p); -int ether_print_stats(void); +void ether_print_stats(void); #endif /* __ETHER_H__ */ diff --git a/platform/netsim/init.h b/platform/netsim/init.h index 52367c9bb..abf66d9e8 100644 --- a/platform/netsim/init.h +++ b/platform/netsim/init.h @@ -28,11 +28,13 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: init.h,v 1.2 2006/10/06 08:25:30 adamdunkels Exp $ + * @(#)$Id: init.h,v 1.3 2007/11/17 18:09:18 adamdunkels Exp $ */ #ifndef __INIT_H__ #define __INIT_H__ +#include "ether.h" + void init(void); int main_add_node(int x, int y); diff --git a/platform/netsim/main.c b/platform/netsim/main.c index 087cb3873..5282c2587 100644 --- a/platform/netsim/main.c +++ b/platform/netsim/main.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: main.c,v 1.5 2007/03/22 18:59:34 adamdunkels Exp $ + * $Id: main.c,v 1.6 2007/11/17 18:09:18 adamdunkels Exp $ */ /** @@ -60,6 +60,8 @@ #include #include +void netsim_init(void); + static int main_process = 0; /*---------------------------------------------------------------------------*/ @@ -118,7 +120,7 @@ start_node(int x, int y, int b) /* This is the sensor process. */ main_process = 0; - srandom(getpid()); + srand(getpid()); usleep(1000 * (rand() % 1000)); diff --git a/platform/netsim/net/ethernode.c b/platform/netsim/net/ethernode.c index 6bbe1bfca..c486d65ca 100644 --- a/platform/netsim/net/ethernode.c +++ b/platform/netsim/net/ethernode.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: ethernode.c,v 1.8 2007/05/22 21:09:19 adamdunkels Exp $ + * $Id: ethernode.c,v 1.9 2007/11/17 18:09:19 adamdunkels Exp $ */ /** * \file @@ -145,8 +145,8 @@ ethernode_poll(void) return ether_client_poll(); } /*-------------------------------------------------------------------------------*/ -u16_t -ethernode_read(u8_t *buf, u16_t bufsize) +int +ethernode_read(void *buf, unsigned short bufsize) { int len; u8_t tmpbuf[2048]; @@ -216,7 +216,7 @@ ethernode_send(void) } /*-------------------------------------------------------------------------------*/ int -ethernode_send_buf(const u8_t *buf, u16_t len) +ethernode_send_buf(const void *buf, unsigned short len) { char tmpbuf[2048]; struct hdr *hdr = (struct hdr *)tmpbuf; diff --git a/platform/netsim/net/ethernode.h b/platform/netsim/net/ethernode.h index 07ed15697..174863098 100644 --- a/platform/netsim/net/ethernode.h +++ b/platform/netsim/net/ethernode.h @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: ethernode.h,v 1.3 2007/05/22 21:09:19 adamdunkels Exp $ + * $Id: ethernode.h,v 1.4 2007/11/17 18:09:19 adamdunkels Exp $ */ #ifndef __ETHERNODE_H__ #define __ETHERNODE_H__ @@ -40,9 +40,9 @@ #include "dev/radio.h" void ethernode_init(int port); -u16_t ethernode_read(u8_t *buf, u16_t bufsize); +int ethernode_read(void *buf, unsigned short bufsize); u8_t ethernode_send(void); -int ethernode_send_buf(const u8_t *buf, u16_t len); +int ethernode_send_buf(const void *buf, unsigned short len); void ethernode_periodic(void); void ethernode_set_receiver(void (* recv)(const struct radio_driver *)); diff --git a/platform/netsim/node.c b/platform/netsim/node.c index 26e1f14cf..42cc597c2 100644 --- a/platform/netsim/node.c +++ b/platform/netsim/node.c @@ -30,7 +30,7 @@ * * Author: Adam Dunkels * - * $Id: node.c,v 1.7 2007/03/29 22:25:39 adamdunkels Exp $ + * $Id: node.c,v 1.8 2007/11/17 18:09:18 adamdunkels Exp $ */ #include "node.h" #include "contiki.h" @@ -76,7 +76,7 @@ node_init(int id, int posx, int posy, int b) - drift = random() % 95726272; + drift = rand() % 95726272; init_node_log(); } @@ -141,9 +141,9 @@ node_log(const char *fmt, ...) char buf[4096]; int len; - len = snprintf(buf, sizeof(buf), "Node %d (%d, %d): ", node.id, node.x, node.y); + len = sprintf(buf, "Node %d (%d, %d): ", node.id, node.x, node.y); va_start(ap, fmt); - vsnprintf(&buf[len], sizeof(buf) - len, fmt, ap); + vsprintf(&buf[len], fmt, ap); write(fd, buf, strlen(buf)); va_end(ap); } diff --git a/platform/netsim/nodes.c b/platform/netsim/nodes.c index 5c5723be6..258498897 100644 --- a/platform/netsim/nodes.c +++ b/platform/netsim/nodes.c @@ -30,11 +30,12 @@ * * Author: Adam Dunkels * - * $Id: nodes.c,v 1.4 2007/04/02 10:03:35 adamdunkels Exp $ + * $Id: nodes.c,v 1.5 2007/11/17 18:09:18 adamdunkels Exp $ */ #include #include #include +#include #include "nodes.h" diff --git a/platform/netsim/random.c b/platform/netsim/random.c index 22a50f925..76a2dce25 100644 --- a/platform/netsim/random.c +++ b/platform/netsim/random.c @@ -1,36 +1,36 @@ /* * Copyright (c) 2004, Swedish Institute of Computer Science. - * All rights reserved. + * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. * * This file is part of the Contiki operating system. - * + * * Author: Adam Dunkels * - * $Id: random.c,v 1.1 2006/06/17 22:41:35 adamdunkels Exp $ + * $Id: random.c,v 1.2 2007/11/17 18:09:18 adamdunkels Exp $ */ /*----------------------------------------------------------------------------*/ /* @@ -41,19 +41,20 @@ * */ /*----------------------------------------------------------------------------*/ - #include +#include +#include /*----------------------------------------------------------------------------*/ void random_init(void) { - srandom(getpid()); + srand(getpid()); } /*----------------------------------------------------------------------------*/ unsigned short random_rand(void) { - return (random() >> 4) & 0xffff; + return (rand() >> 4) & 0xffff; } /*----------------------------------------------------------------------------*/