2 * OLSR ad-hoc routing table management protocol GUI front-end
3 * Copyright (C) 2003 Andreas Tønnesen (andreto@ifi.uio.no)
5 * This file is part of olsr.org.
7 * uolsrGUI is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * uolsrGUI is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with olsr.org; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 main (int argc, char *argv[])
32 struct sockaddr_in pin;
37 GtkWidget *main_window;
40 if (WSAStartup(0x0202, &WsaData))
42 fprintf(stderr, "Could not initialize WinSock.\n");
49 if ((hp = gethostbyname(argc > 1 ? argv[1] : "localhost")) == 0)
51 perror("Not a valid host");
55 in.s_addr=((struct in_addr *)(hp->h_addr))->s_addr;
56 printf("Address: %s\n", inet_ntoa(in));
58 /* fill in the socket structure with host information */
59 memset(&pin, 0, sizeof(pin));
60 pin.sin_family = AF_INET;
61 pin.sin_addr.s_addr = ((struct in_addr *)(hp->h_addr))->s_addr;
62 pin.sin_port = htons(IPC_PORT);
64 gtk_init (&argc, &argv);
71 /* "Failsafe" values */
73 ipsize = sizeof(struct in_addr);
75 main_window = create_main_window ();
76 gtk_widget_show (main_window);
78 printf("Done building GUI\n");
80 memset(&main_addr, 0, sizeof(union olsr_ip_addr));
81 memset(&null_addr, 0, sizeof(union olsr_ip_addr));
83 /* Terminate signal */
84 signal(SIGINT, shutdown_);
86 /* Init node timeout */
87 nodes_timeout = NEIGHB_HOLD_TIME_NW;
88 init_timer((olsr_u32_t) (nodes_timeout * 1000), &hold_time_nodes);
109 *Check socket for messages every IPC_INTERVAL
112 gtk_timeout_add(IPC_INTERVAL, ipc_timeout, NULL);
118 timeouts = 5; /* Wait 5 times befor starting timing out nodes */
119 gtk_timeout_add(TOP_HOLD_TIME, time_out_nodes, NULL);
127 gint ipc_timeout(gpointer data)
137 shutdown_(int signal)
139 printf("Cleaning up...\n");
142 printf("Could not close socket!\n");
144 printf("BYE-BYE!\n");