| // Copyright 2024 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| library fuchsia.net.routes; |
| |
| using fuchsia.net.matchers; |
| |
| /// The priority of the rule set, all rule sets are linearized based on this. |
| /// |
| /// Rules of a `RuleSet` with a smaller [`RuleSetPriority`] are executed before |
| /// rules of a `RuleSet` with a larger [`RuleSetPriority`]. That is, `RuleSet` |
| /// with priority 0 has the top priority. |
| @available(added=HEAD) |
| alias RuleSetPriority = uint32; |
| |
| /// A reserved rule set priority for the netstack. |
| /// |
| /// This is used by the network stack for installing default rules. |
| @available(added=HEAD) |
| const DEFAULT_RULE_SET_PRIORITY RuleSetPriority = 0xffffffff; |
| |
| /// The index of a rule within a provided rule set. |
| /// |
| /// Rules within the same `RuleSet` are oredered based on the index. Rule at |
| /// index 0 is evaluated first among the entire set. |
| @available(added=HEAD) |
| alias RuleIndex = uint32; |
| |
| /// Actions of a rule if the matcher matches. |
| @available(added=HEAD) |
| type RuleAction = flexible union { |
| /// Look for a route in the indicated route table. If there is no matching |
| /// route in the target table, the lookup will continue to consider the |
| /// next rule. |
| 1: lookup TableId; |
| /// Return network is unreachable. This is contrary to if a `lookup` table |
| /// is empty or no matching routes, this decision is terminal and stops |
| /// the lookup process from continuing. |
| 2: unreachable struct {}; |
| }; |
| |
| /// The common matcher that can be matched to both IPv4 and IPv6 packets. |
| /// |
| /// A matcher matches a packet if all of the present fields match the |
| /// corresponding properties. |
| @available(added=HEAD) |
| type BaseMatcher = table { |
| /// Matches the packet iff the packet was locally generated. |
| 1: locally_generated bool; |
| |
| /// Matches on the originating interface of the outgoing packet. |
| 2: bound_device fuchsia.net.matchers.BoundInterface; |
| |
| /// Matches the MARK_1 domain. |
| 3: mark_1 fuchsia.net.matchers.Mark; |
| |
| /// Matches for the MARK_2 domain. |
| 4: mark_2 fuchsia.net.matchers.Mark; |
| }; |