IPv6: Remove local ULA if there is an external one
[project/netifd.git] / iprule.h
1 /*
2 * netifd - network interface daemon
3 * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
4 * Copyright (C) 2013 Jo-Philipp Wich <jow@openwrt.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2
8 * as published by the Free Software Foundation
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15 #ifndef __IPRULE_H
16 #define __IPRULE_H
17
18 #include "interface-ip.h"
19
20 enum iprule_flags {
21 /* address family for rule */
22 IPRULE_INET4 = (0 << 0),
23 IPRULE_INET6 = (1 << 0),
24 IPRULE_FAMILY = IPRULE_INET4 | IPRULE_INET6,
25
26 /* rule specifies input device */
27 IPRULE_IN = (1 << 2),
28
29 /* rule specifies output device */
30 IPRULE_OUT = (1 << 3),
31
32 /* rule specifies src */
33 IPRULE_SRC = (1 << 4),
34
35 /* rule specifies dest */
36 IPRULE_DEST = (1 << 5),
37
38 /* rule specifies priority */
39 IPRULE_PRIORITY = (1 << 6),
40
41 /* rule specifies diffserv/tos */
42 IPRULE_TOS = (1 << 7),
43
44 /* rule specifies fwmark */
45 IPRULE_FWMARK = (1 << 8),
46
47 /* rule specifies fwmask */
48 IPRULE_FWMASK = (1 << 9),
49
50 /* rule performs table lookup */
51 IPRULE_LOOKUP = (1 << 10),
52
53 /* rule performs routing action */
54 IPRULE_ACTION = (1 << 11),
55
56 /* rule is a goto */
57 IPRULE_GOTO = (1 << 12),
58 };
59
60 struct iprule {
61 struct vlist_node node;
62 unsigned int order;
63
64 /* everything below is used as avl tree key */
65 enum iprule_flags flags;
66
67 bool invert;
68
69 char in_dev[IFNAMSIZ + 1];
70 char out_dev[IFNAMSIZ + 1];
71
72 unsigned int src_mask;
73 union if_addr src_addr;
74
75 unsigned int dest_mask;
76 union if_addr dest_addr;
77
78 unsigned int priority;
79 unsigned int tos;
80
81 unsigned int fwmark;
82 unsigned int fwmask;
83
84 unsigned int lookup;
85 unsigned int action;
86 unsigned int gotoid;
87 };
88
89 extern struct vlist_tree iprules;
90 extern const struct config_param_list rule_attr_list;
91
92 void iprule_add(struct blob_attr *attr, bool v6);
93 void iprule_update_start(void);
94 void iprule_update_complete(void);
95
96 #endif