465398f219ac606effdfe3afb5a8cb4cb4d13b9d
11 #include "interface.h"
13 unsigned int debug_mask
= 0;
14 const char *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 "\n", progname
, main_path
);
54 int main(int argc
, char **argv
)
56 const char *socket
= NULL
;
61 while ((ch
= getopt(argc
, argv
, "d:s:")) != -1) {
64 debug_mask
= strtoul(optarg
, NULL
, 0);
73 return usage(argv
[0]);
77 if (netifd_ubus_init(socket
) < 0) {
78 fprintf(stderr
, "Failed to connect to ubus\n");
83 fprintf(stderr
, "Failed to initialize system control\n");
87 config_init_interfaces(NULL
);