device: Don't process link events anymore in device user specific callback handlers
[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 #define IPRULE_PRIORITY_ADDR 10000
21 #define IPRULE_PRIORITY_NW 90000
22 #define IPRULE_PRIORITY_REJECT 4200000000
23
24 enum iprule_flags {
25 /* address family for rule */
26 IPRULE_INET4 = (0 << 0),
27 IPRULE_INET6 = (1 << 0),
28 IPRULE_FAMILY = IPRULE_INET4 | IPRULE_INET6,
29
30 /* rule specifies input device */
31 IPRULE_IN = (1 << 2),
32
33 /* rule specifies output device */
34 IPRULE_OUT = (1 << 3),
35
36 /* rule specifies src */
37 IPRULE_SRC = (1 << 4),
38
39 /* rule specifies dest */
40 IPRULE_DEST = (1 << 5),
41
42 /* rule specifies priority */
43 IPRULE_PRIORITY = (1 << 6),
44
45 /* rule specifies diffserv/tos */
46 IPRULE_TOS = (1 << 7),
47
48 /* rule specifies fwmark */
49 IPRULE_FWMARK = (1 << 8),
50
51 /* rule specifies fwmask */
52 IPRULE_FWMASK = (1 << 9),
53
54 /* rule performs table lookup */
55 IPRULE_LOOKUP = (1 << 10),
56
57 /* rule performs routing action */
58 IPRULE_ACTION = (1 << 11),
59
60 /* rule is a goto */
61 IPRULE_GOTO = (1 << 12),
62 };
63
64 struct iprule {
65 struct vlist_node node;
66 unsigned int order;
67
68 /* everything below is used as avl tree key */
69 enum iprule_flags flags;
70
71 bool invert;
72
73 char in_dev[IFNAMSIZ + 1];
74 char out_dev[IFNAMSIZ + 1];
75
76 unsigned int src_mask;
77 union if_addr src_addr;
78
79 unsigned int dest_mask;
80 union if_addr dest_addr;
81
82 unsigned int priority;
83 unsigned int tos;
84
85 unsigned int fwmark;
86 unsigned int fwmask;
87
88 unsigned int lookup;
89 unsigned int action;
90 unsigned int gotoid;
91 };
92
93 extern struct vlist_tree iprules;
94 extern const struct uci_blob_param_list rule_attr_list;
95
96 void iprule_add(struct blob_attr *attr, bool v6);
97 void iprule_update_start(void);
98 void iprule_update_complete(void);
99
100 #endif