]> git.proxmox.com Git - mirror_frr.git/blob - lib/pbr.h
Merge pull request #2367 from qlyoung/docuser
[mirror_frr.git] / lib / pbr.h
1 /* Policy Based Routing (PBR) main header
2 * Copyright (C) 2018 6WIND
3 *
4 * FRR is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2, or (at your option) any
7 * later version.
8 *
9 * FRR is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with FRR; see the file COPYING. If not, write to the Free
16 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17 * 02111-1307, USA.
18 */
19
20 #ifndef _PBR_H
21 #define _PBR_H
22
23 /*
24 * A PBR filter
25 *
26 * The filter or match criteria in a PBR rule.
27 * For simplicity, all supported filters are grouped into a structure rather
28 * than delineating further. A bitmask denotes which filters are actually
29 * specified.
30 */
31 struct pbr_filter {
32 uint32_t filter_bm; /* not encoded by zapi
33 */
34 #define PBR_FILTER_SRC_IP (1 << 0)
35 #define PBR_FILTER_DST_IP (1 << 1)
36 #define PBR_FILTER_SRC_PORT (1 << 2)
37 #define PBR_FILTER_DST_PORT (1 << 3)
38 #define PBR_FILTER_FWMARK (1 << 4)
39 #define PBR_FILTER_PROTO (1 << 5)
40 #define PBR_FILTER_SRC_PORT_RANGE (1 << 6)
41 #define PBR_FILTER_DST_PORT_RANGE (1 << 7)
42
43 /* Source and Destination IP address with masks. */
44 struct prefix src_ip;
45 struct prefix dst_ip;
46
47 /* Source and Destination higher-layer (TCP/UDP) port numbers. */
48 uint16_t src_port;
49 uint16_t dst_port;
50
51 /* Filter with fwmark */
52 uint32_t fwmark;
53 };
54
55 /*
56 * A PBR action
57 *
58 * The action corresponding to a PBR rule.
59 * While the user specifies the action in a particular way, the forwarding
60 * plane implementation (Linux only) requires that to be encoded into a
61 * route table and the rule then point to that route table; in some cases,
62 * the user criteria may directly point to a table too.
63 */
64 struct pbr_action {
65 uint32_t table;
66 };
67
68 /*
69 * A PBR rule
70 *
71 * This is a combination of the filter criteria and corresponding action.
72 * Rules also have a user-defined sequence number which defines the relative
73 * order amongst rules.
74 */
75 struct pbr_rule {
76 vrf_id_t vrf_id;
77
78 uint32_t seq;
79 uint32_t priority;
80 uint32_t unique;
81 struct pbr_filter filter;
82 struct pbr_action action;
83 uint32_t ifindex;
84 };
85
86 extern int zapi_pbr_rule_encode(uint8_t cmd, struct stream *s,
87 struct pbr_rule *zrule);
88
89 #endif /* _PBR_H */