Made netsim gateway ip addr on Windows/Cygwin configurable at the command line.
This commit is contained in:
parent
5bff4631e4
commit
74fc3b4576
2 changed files with 27 additions and 7 deletions
|
@ -30,7 +30,7 @@
|
||||||
*
|
*
|
||||||
* Author: Adam Dunkels <adam@sics.se>
|
* 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 <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
in_addr_t gwaddr;
|
||||||
|
|
||||||
void netsim_init(void);
|
void netsim_init(void);
|
||||||
|
|
||||||
|
@ -158,6 +161,16 @@ main_add_base(int x, int y)
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
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("ifconfig tap0 inet 192.168.250.1");*/
|
||||||
/* system("route delete 172.16.0.0/16");
|
/* system("route delete 172.16.0.0/16");
|
||||||
system("route add 172.16.0.0/16 192.168.250.2");*/
|
system("route add 172.16.0.0/16 192.168.250.2");*/
|
||||||
|
@ -179,7 +192,12 @@ main(int argc, char **argv)
|
||||||
usleep(100);
|
usleep(100);
|
||||||
}
|
}
|
||||||
#endif /* 0 */
|
#endif /* 0 */
|
||||||
|
|
||||||
|
#ifdef __CYGWIN__
|
||||||
|
if(argc > 3 && strcmp(argv[3], "-q") == 0) {
|
||||||
|
#else /* __CYGWIN__ */
|
||||||
if(argc > 1 && strcmp(argv[1], "-q") == 0) {
|
if(argc > 1 && strcmp(argv[1], "-q") == 0) {
|
||||||
|
#endif /* __CYGWIN__ */
|
||||||
display_init(idle, 50, 0);
|
display_init(idle, 50, 0);
|
||||||
} else {
|
} else {
|
||||||
display_init(idle, 50, 1);
|
display_init(idle, 50, 1);
|
||||||
|
@ -188,14 +206,12 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
signal(SIGCHLD, sigchld_handler);
|
signal(SIGCHLD, sigchld_handler);
|
||||||
|
|
||||||
|
|
||||||
display_run();
|
display_run();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
argv = argv;
|
argv = argv;
|
||||||
argc = argc;
|
argc = argc;
|
||||||
|
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
char *arg_alloc(char size) {return NULL;}
|
char *arg_alloc(char size) {return NULL;}
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
*
|
*
|
||||||
* Author: Adam Dunkels <adam@sics.se>
|
* 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 "node.h"
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
|
@ -38,6 +38,9 @@
|
||||||
#include "net/rime.h"
|
#include "net/rime.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
extern in_addr_t gwaddr;
|
||||||
|
|
||||||
static clock_time_t drift, timer;
|
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;*/
|
/* node.type = NODE_TYPE_NORMAL;*/
|
||||||
|
|
||||||
if(b) {
|
if(b) {
|
||||||
|
#ifdef __CYGWIN__
|
||||||
|
addr = *(uip_ipaddr_t *)&gwaddr;
|
||||||
|
#else /* __CYGWIN__ */
|
||||||
uip_ipaddr(&addr, 192,168,1,2);
|
uip_ipaddr(&addr, 192,168,1,2);
|
||||||
|
#endif /* __CYGWIN__ */
|
||||||
} else {
|
} else {
|
||||||
uip_ipaddr(&addr, 172,16,posx,posy);
|
uip_ipaddr(&addr, 172,16,posx,posy);
|
||||||
|
|
||||||
}
|
}
|
||||||
uip_sethostaddr(&addr);
|
uip_sethostaddr(&addr);
|
||||||
|
|
||||||
|
@ -74,8 +80,6 @@ node_init(int id, int posx, int posy, int b)
|
||||||
rimeaddr_set_node_addr(&nodeaddr);
|
rimeaddr_set_node_addr(&nodeaddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
drift = rand() % 95726272;
|
drift = rand() % 95726272;
|
||||||
|
|
||||||
init_node_log();
|
init_node_log();
|
||||||
|
|
Loading…
Reference in a new issue