2 * Copyright (C) 2014 John Crispin <blogic@openwrt.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 2.1
6 * as published by the Free Software Foundation
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
15 #include <sys/types.h>
23 #include <sys/types.h>
24 #include <arpa/inet.h>
25 #include <sys/socket.h>
26 #include <netinet/in.h>
27 #include <arpa/nameser.h>
31 #include <libubox/uloop.h>
39 #include "interface.h"
42 int cfg_no_subnet
= 0;
44 static struct udebug ud
;
45 static struct udebug_buf udb
;
46 static bool udebug_enabled
;
49 umdns_udebug_vprintf(const char *format
, va_list ap
)
54 udebug_entry_init(&udb
);
55 udebug_entry_vprintf(&udb
, format
, ap
);
56 udebug_entry_add(&udb
);
59 void umdns_udebug_printf(const char *format
, ...)
64 umdns_udebug_vprintf(format
, ap
);
68 void umdns_udebug_set_enabled(bool val
)
70 static const struct udebug_buf_meta meta
= {
72 .format
= UDEBUG_FORMAT_STRING
,
75 if (udebug_enabled
== val
)
80 udebug_buf_free(&udb
);
86 udebug_auto_connect(&ud
, NULL
);
87 udebug_buf_init(&udb
, 1024, 64 * 1024);
88 udebug_buf_add(&ud
, &udb
, &meta
);
92 signal_shutdown(int signal
)
98 main(int argc
, char **argv
)
104 while ((ch
= getopt(argc
, argv
, "t:i:d46n")) != -1) {
111 fprintf(stderr
, "invalid ttl\n");
117 interface_add(optarg
);
134 signal(SIGPIPE
, SIG_IGN
);
135 signal(SIGTERM
, signal_shutdown
);
136 signal(SIGKILL
, signal_shutdown
);
148 interface_shutdown();
151 vlist_flush(&interfaces
);