-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.c
58 lines (43 loc) · 863 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2022 Felix Fietkau <nbd@nbd.name>
*/
#include "bridger.h"
int debug_level = 0;
const char *format_macaddr(const uint8_t *mac)
{
static char str[sizeof("ff:ff:ff:ff:ff:ff ")];
snprintf(str, sizeof(str), "%02x:%02x:%02x:%02x:%02x:%02x",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
return str;
}
int main(int argc, char **argv)
{
int ch;
while ((ch = getopt(argc, argv, "d")) != -1) {
switch (ch) {
case 'd':
debug_level++;
break;
default:
break;
}
}
uloop_init();
if (bridger_bpf_init()) {
perror("bridger_bpf_init");
return 1;
}
if (bridger_nl_init()) {
perror("bridger_nl_init");
return 1;
}
bridger_device_init();
bridger_flow_init();
bridger_ubus_init();
uloop_run();
bridger_ubus_stop();
bridger_device_stop();
uloop_done();
return 0;
}