projects
/
project
/
netifd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
bring all interfaces down on restart
[project/netifd.git]
/
main.c
diff --git
a/main.c
b/main.c
index
4f6a4f6
..
7d7bfcb
100644
(file)
--- a/
main.c
+++ b/
main.c
@@
-5,10
+5,25
@@
#include "netifd.h"
#include "ubus.h"
#include "netifd.h"
#include "ubus.h"
+#include "config.h"
+#include "interface.h"
-int avl_strcmp(const void *k1, const void *k2, void *ptr)
+const char *main_path = ".";
+static char **global_argv;
+
+static void netifd_do_restart(struct uloop_timeout *timeout)
{
{
- return strcmp(k1, k2);
+ execvp(global_argv[0], global_argv);
+}
+
+static struct uloop_timeout restart_timer = {
+ .cb = netifd_do_restart,
+};
+
+void netifd_restart(void)
+{
+ interface_set_down(NULL);
+ uloop_timeout_set(&restart_timer, 1000);
}
static int usage(const char *progname)
}
static int usage(const char *progname)
@@
-16,7
+31,8
@@
static int usage(const char *progname)
fprintf(stderr, "Usage: %s [options]\n"
"Options:\n"
" -s <path>: Path to the ubus socket\n"
fprintf(stderr, "Usage: %s [options]\n"
"Options:\n"
" -s <path>: Path to the ubus socket\n"
- "\n", progname);
+ " -p <path>: Path to netifd addons (default: %s)\n"
+ "\n", progname, main_path);
return 1;
}
return 1;
}
@@
-26,11
+42,16
@@
int main(int argc, char **argv)
const char *socket = NULL;
int ch;
const char *socket = NULL;
int ch;
+ global_argv = argv;
+
while ((ch = getopt(argc, argv, "s:")) != -1) {
switch(ch) {
case 's':
socket = optarg;
break;
while ((ch = getopt(argc, argv, "s:")) != -1) {
switch(ch) {
case 's':
socket = optarg;
break;
+ case 'p':
+ main_path = optarg;
+ break;
default:
return usage(argv[0]);
}
default:
return usage(argv[0]);
}