41 #include <arpa/inet.h>
43 extern in_addr_t gwaddr;
45 static clock_time_t drift,
timer;
51 static void init_node_log(
void);
55 node_init(
int id,
int posx,
int posy,
int b)
78 nodeaddr.u8[0] = posx;
79 nodeaddr.u8[1] = posy;
83 drift = rand() % 95726272;
95 gettimeofday(&tv,
NULL);
97 return tv.tv_sec * 1000 + tv.tv_usec / 1000;
105 gettimeofday(&tv,
NULL);
111 node_set_time(clock_time_t time)
136 fd = open(
"log", O_CREAT | O_WRONLY | O_APPEND, 0666);
140 node_log(
const char *fmt, ...)
146 len = sprintf(buf,
"Node %d (%d, %d): ", node.id, node.x, node.y);
148 vsprintf(&buf[len], fmt, ap);
149 write(fd, buf, strlen(buf));