]>
Commit | Line | Data |
---|---|---|
0031a6bb PG |
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 | ||
40 | /* Source and Destination IP address with masks. */ | |
41 | struct prefix src_ip; | |
42 | struct prefix dst_ip; | |
43 | ||
44 | /* Source and Destination higher-layer (TCP/UDP) port numbers. */ | |
45 | uint16_t src_port; | |
46 | uint16_t dst_port; | |
47 | ||
48 | /* Filter with fwmark */ | |
49 | uint32_t fwmark; | |
50 | }; | |
51 | ||
52 | /* | |
53 | * A PBR action | |
54 | * | |
55 | * The action corresponding to a PBR rule. | |
56 | * While the user specifies the action in a particular way, the forwarding | |
57 | * plane implementation (Linux only) requires that to be encoded into a | |
58 | * route table and the rule then point to that route table; in some cases, | |
59 | * the user criteria may directly point to a table too. | |
60 | */ | |
61 | struct pbr_action { | |
62 | uint32_t table; | |
63 | }; | |
64 | ||
65 | /* | |
66 | * A PBR rule | |
67 | * | |
68 | * This is a combination of the filter criteria and corresponding action. | |
69 | * Rules also have a user-defined sequence number which defines the relative | |
70 | * order amongst rules. | |
71 | */ | |
72 | struct pbr_rule { | |
73 | vrf_id_t vrf_id; | |
74 | ||
75 | uint32_t seq; | |
76 | uint32_t priority; | |
77 | uint32_t unique; | |
78 | struct pbr_filter filter; | |
79 | struct pbr_action action; | |
80 | uint32_t ifindex; | |
81 | }; | |
82 | ||
83 | extern int zapi_pbr_rule_encode(uint8_t cmd, struct stream *s, | |
84 | struct pbr_rule *zrule); | |
85 | ||
86 | #endif /* _PBR_H */ |