summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2011-02-19 15:21:52 +0100
committerFelix Fietkau <nbd@openwrt.org>2011-03-27 01:42:33 +0100
commit5d1fff7af6f77c9bf0d46572c7af563cd9fc55b3 (patch)
tree76d080e6b59f9235cd47b0e047f662c1f0a6ce00 /main.c
downloadnetifd-5d1fff7af6f77c9bf0d46572c7af563cd9fc55b3.tar.gz
Initial import
Diffstat (limited to 'main.c')
-rw-r--r--main.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..69aa5cd
--- /dev/null
+++ b/main.c
@@ -0,0 +1,46 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <getopt.h>
+
+#include "netifd.h"
+#include "ubus.h"
+
+static int usage(const char *progname)
+{
+ fprintf(stderr, "Usage: %s [options]\n"
+ "Options:\n"
+ " -s <path>: Path to the ubus socket\n"
+ "\n", progname);
+
+ return 1;
+}
+
+int main(int argc, char **argv)
+{
+ const char *socket = NULL;
+ int ch;
+
+ while ((ch = getopt(argc, argv, "s:")) != -1) {
+ switch(ch) {
+ case 's':
+ socket = optarg;
+ break;
+ default:
+ return usage(argv[0]);
+ }
+ }
+
+ if (netifd_ubus_init(NULL) < 0) {
+ fprintf(stderr, "Failed to connect to ubus\n");
+ return 1;
+ }
+
+ config_init_interfaces(NULL);
+
+ uloop_run();
+
+ netifd_ubus_done();
+
+ return 0;
+}