02dd1e51c308db7728b8bd7499044ccd5710d14d
11 #include "interface.h"
13 unsigned int debug_mask
= 0;
14 const char *main_path
= DEFAULT_MAIN_PATH
;
15 static char **global_argv
;
17 static void netifd_do_restart(struct uloop_timeout
*timeout
)
19 execvp(global_argv
[0], global_argv
);
22 static void netifd_do_reload(struct uloop_timeout
*timeout
)
24 config_init_interfaces(NULL
);
27 static struct uloop_timeout main_timer
;
29 void netifd_reload(void)
31 main_timer
.cb
= netifd_do_reload
;
32 uloop_timeout_set(&main_timer
, 100);
35 void netifd_restart(void)
37 main_timer
.cb
= netifd_do_restart
;
38 interface_set_down(NULL
);
39 uloop_timeout_set(&main_timer
, 1000);
42 static int usage(const char *progname
)
44 fprintf(stderr
, "Usage: %s [options]\n"
46 " -d <mask>: Mask for debug messages\n"
47 " -s <path>: Path to the ubus socket\n"
48 " -p <path>: Path to netifd addons (default: %s)\n"
49 " -h <path>: Path to the hotplug script\n"
50 " (default: "DEFAULT_HOTPLUG_PATH
")\n"
51 "\n", progname
, main_path
);
56 int main(int argc
, char **argv
)
58 const char *socket
= NULL
;
63 while ((ch
= getopt(argc
, argv
, "d:s:")) != -1) {
66 debug_mask
= strtoul(optarg
, NULL
, 0);
75 hotplug_cmd_path
= optarg
;
78 return usage(argv
[0]);
82 if (netifd_ubus_init(socket
) < 0) {
83 fprintf(stderr
, "Failed to connect to ubus\n");
88 fprintf(stderr
, "Failed to initialize system control\n");
92 config_init_interfaces(NULL
);