aboutsummaryrefslogtreecommitdiffstats
path: root/glougloud/glougloud.c
blob: 45fca1797dab70f9d9d777fc7938f5e225fd20fc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <sys/ioctl.h>

#include <net/if.h>
#include <netinet/in.h>

#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <err.h>
#include <errno.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>

#include <libglouglou.h>

struct gg_server *ggserv_probes;
struct gg_server *ggserv_clients;
struct event_base *ev_base;

#if defined(__OPENBSD__)
void __dead
#else
void
#endif
usage(void)
{
	extern char     *__progname;

	 fprintf(stderr, "usage: %s [-vi]",
	 	 __progname);
	 exit(1);
}

static void
sig_handler(int sig, short why, void *data)
{
	//log_info("got signal %d", sig);
	if (sig == SIGINT || sig == SIGTERM)
		event_base_loopexit(ev_base, NULL);
}

int
main(int argc, char **argv)
{
	int		loglevel = 0;
	int op;

	while ((op = getopt(argc, argv, "hv")) != -1) {
		switch (op) {
			case 'h':
				usage();
				/* NOTREACHED */
			case 'v':
				loglevel++;
				break;
			default:
				usage();
				/* NOTREACHED */
		}
	}

	ev_base = event_base_new();

	ggserv_probes = gg_server_start(ev_base, "127.0.0.1", 4430, NULL, NULL, NULL);
	ggserv_clients = gg_server_start(ev_base, "127.0.0.1", 4431, NULL, NULL, NULL);

	event_base_dispatch(ev_base);

  return 0;
}