s/free_interface/interface_free/
[project/netifd.git] / main.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <getopt.h>
5
6 #include "netifd.h"
7 #include "ubus.h"
8
9 int avl_strcmp(const void *k1, const void *k2, void *ptr)
10 {
11         return strcmp(k1, k2);
12 }
13
14 static int usage(const char *progname)
15 {
16         fprintf(stderr, "Usage: %s [options]\n"
17                 "Options:\n"
18                 " -s <path>:            Path to the ubus socket\n"
19                 "\n", progname);
20
21         return 1;
22 }
23
24 int main(int argc, char **argv)
25 {
26         const char *socket = NULL;
27         int ch;
28
29         while ((ch = getopt(argc, argv, "s:")) != -1) {
30                 switch(ch) {
31                 case 's':
32                         socket = optarg;
33                         break;
34                 default:
35                         return usage(argv[0]);
36                 }
37         }
38
39         if (netifd_ubus_init(NULL) < 0) {
40                 fprintf(stderr, "Failed to connect to ubus\n");
41                 return 1;
42         }
43
44         config_init_interfaces(NULL);
45
46         uloop_run();
47
48         netifd_ubus_done();
49
50         return 0;
51 }