Made netsim gateway ip addr on Windows/Cygwin configurable at the command line.

This commit is contained in:
oliverschmidt 2008-01-04 23:23:29 +00:00
parent 5bff4631e4
commit 74fc3b4576
2 changed files with 27 additions and 7 deletions

View File

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: main.c,v 1.8 2007/11/28 12:54:42 adamdunkels Exp $
* $Id: main.c,v 1.9 2008/01/04 23:23:29 oliverschmidt Exp $
*/
/**
@ -59,6 +59,9 @@
#include <stdlib.h>
#include <stdio.h>
#include <sys/wait.h>
#include <arpa/inet.h>
in_addr_t gwaddr;
void netsim_init(void);
@ -158,6 +161,16 @@ main_add_base(int x, int y)
int
main(int argc, char **argv)
{
#ifdef __CYGWIN__
if(argc < 3 || inet_addr(argv[1]) == INADDR_NONE ||
inet_addr(argv[2]) == INADDR_NONE) {
printf("usage: <program> <ip addr of ethernet card to share> "
"<ip addr of netsim gateway>\n");
exit(1);
}
gwaddr = inet_addr(argv[2]);
#endif /* __CYGWIN__ */
/* system("ifconfig tap0 inet 192.168.250.1");*/
/* system("route delete 172.16.0.0/16");
system("route add 172.16.0.0/16 192.168.250.2");*/
@ -179,7 +192,12 @@ main(int argc, char **argv)
usleep(100);
}
#endif /* 0 */
#ifdef __CYGWIN__
if(argc > 3 && strcmp(argv[3], "-q") == 0) {
#else /* __CYGWIN__ */
if(argc > 1 && strcmp(argv[1], "-q") == 0) {
#endif /* __CYGWIN__ */
display_init(idle, 50, 0);
} else {
display_init(idle, 50, 1);
@ -188,14 +206,12 @@ main(int argc, char **argv)
signal(SIGCHLD, sigchld_handler);
display_run();
return 0;
argv = argv;
argc = argc;
}
/*-----------------------------------------------------------------------------------*/
char *arg_alloc(char size) {return NULL;}

View File

@ -30,7 +30,7 @@
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: node.c,v 1.9 2007/11/28 13:01:02 nvt-se Exp $
* $Id: node.c,v 1.10 2008/01/04 23:23:29 oliverschmidt Exp $
*/
#include "node.h"
#include "contiki.h"
@ -38,6 +38,9 @@
#include "net/rime.h"
#include <string.h>
#include <stdlib.h>
#include <arpa/inet.h>
extern in_addr_t gwaddr;
static clock_time_t drift, timer;
@ -59,10 +62,13 @@ node_init(int id, int posx, int posy, int b)
/* node.type = NODE_TYPE_NORMAL;*/
if(b) {
#ifdef __CYGWIN__
addr = *(uip_ipaddr_t *)&gwaddr;
#else /* __CYGWIN__ */
uip_ipaddr(&addr, 192,168,1,2);
#endif /* __CYGWIN__ */
} else {
uip_ipaddr(&addr, 172,16,posx,posy);
}
uip_sethostaddr(&addr);
@ -74,8 +80,6 @@ node_init(int id, int posx, int posy, int b)
rimeaddr_set_node_addr(&nodeaddr);
}
drift = rand() % 95726272;
init_node_log();