Added uip-over-mesh, bugfixes, printing of statistics, renamed init() function to netsim_init()

This commit is contained in:
adamdunkels 2007-03-22 18:59:34 +00:00
parent eea7f463d7
commit 1b762247fa
12 changed files with 128 additions and 148 deletions

View file

@ -1,37 +1,37 @@
/*
* Copyright (c) 2001, 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:
* 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.
* 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.
* 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.
* 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.
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: tapdev.c,v 1.1 2006/06/17 22:41:36 adamdunkels Exp $
* $Id: tapdev.c,v 1.2 2007/03/22 18:59:34 adamdunkels Exp $
*/
@ -94,12 +94,12 @@ tapdev_poll(void)
ret = select(fd + 1, &fdset, NULL, NULL, &tv);
if(ret == 0) {
return 0;
}
ret = read(fd, uip_buf, UIP_BUFSIZE);
}
ret = read(fd, uip_buf, UIP_BUFSIZE);
if(ret == -1) {
perror("tapdev_poll: read");
}
return ret;
return ret;
}
/*---------------------------------------------------------------------------*/
void
@ -125,9 +125,11 @@ tapdev_init(void)
}
#endif /* Linux */
snprintf(buf, sizeof(buf), "ifconfig tap0 inet 192.168.2.1");
snprintf(buf, sizeof(buf), "ifconfig tap0 inet 192.168.1.1");
system(buf);
printf("%s\n", buf);
snprintf(buf, sizeof(buf), "route add -net 172.16.0.0 192.168.1.2");
system(buf);
printf("%s\n", buf);
lasttime = 0;
@ -136,8 +138,8 @@ tapdev_init(void)
}
/*---------------------------------------------------------------------------*/
static void
do_send(void)
static void
do_send(void)
{
int ret;
char tmpbuf[UIP_BUFSIZE];
@ -172,7 +174,7 @@ do_send(void)
perror("tap_dev: tapdev_send: writev");
exit(1);
}
}
}
/*---------------------------------------------------------------------------*/
u8_t
tapdev_send(void)