11 #include "interface.h"
13 unsigned int debug_mask = 0;
14 const char *main_path = DEFAULT_MAIN_PATH;
15 const char *resolv_conf = DEFAULT_RESOLV_CONF;
16 static char **global_argv;
18 static void netifd_do_restart(struct uloop_timeout *timeout)
20 execvp(global_argv[0], global_argv);
23 static void netifd_do_reload(struct uloop_timeout *timeout)
25 config_init_interfaces(NULL);
28 static struct uloop_timeout main_timer;
30 void netifd_reload(void)
32 main_timer.cb = netifd_do_reload;
33 uloop_timeout_set(&main_timer, 100);
36 void netifd_restart(void)
38 main_timer.cb = netifd_do_restart;
39 interface_set_down(NULL);
40 uloop_timeout_set(&main_timer, 1000);
43 static int usage(const char *progname)
45 fprintf(stderr, "Usage: %s [options]\n"
47 " -d <mask>: Mask for debug messages\n"
48 " -s <path>: Path to the ubus socket\n"
49 " -p <path>: Path to netifd addons (default: %s)\n"
50 " -h <path>: Path to the hotplug script\n"
51 " -r <path>: Path to resolv.conf\n"
52 " (default: "DEFAULT_HOTPLUG_PATH")\n"
53 "\n", progname, main_path);
58 int main(int argc, char **argv)
60 const char *socket = NULL;
65 while ((ch = getopt(argc, argv, "d:s:p:h:r:")) != -1) {
68 debug_mask = strtoul(optarg, NULL, 0);
77 hotplug_cmd_path = optarg;
83 return usage(argv[0]);
87 if (netifd_ubus_init(socket) < 0) {
88 fprintf(stderr, "Failed to connect to ubus\n");
93 fprintf(stderr, "Failed to initialize system control\n");
97 config_init_interfaces(NULL);