blob: 036541b43feda4eb180927a10220d2663f216660 [file] [log] [blame]
// Copyright 2018 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.filter;
/// Status codes for commands.
enum Status {
OK = 0;
ERR_INTERNAL = 1;
ERR_GENERATION_MISMATCH = 2;
ERR_BAD_RULE = 3;
};
/// The maximum number of rules.
const uint32 MAX_RULES = 128;
[Discoverable]
protocol Filter {
/// Enable enables the filter if true is passed.
/// It disables the filter if false is passed.
Enable(bool enabled) -> (Status status);
/// IsEnabled returns true if the filter is enabled.
IsEnabled() -> (bool enabled);
/// GetRules gets the current rules. They do not include NAT or RDR rules.
/// (use GetNatRules or GetRdrRules instead).
///
/// GetRules also returns a generation number associated with the current
/// rules.
GetRules() -> (vector<Rule>:MAX_RULES rules, uint32 generation, Status status);
/// UpdateRules updates the current rules. It does not update NAT or RDR rules
/// (use UpdateNatRules or UpdateRdrRules instead).
///
/// UpdateRules takes a generation number that is previously returned from
/// GetRules. To successfully update the current rules, the generation number
/// passed to UpdateRules needs to be up-to-date.
///
/// If somebody else has updated the rules since the previous GetRules, the
/// generation number won't match and err_generation_mismatch will be returned.
UpdateRules(vector<Rule>:MAX_RULES rules, uint32 generation) -> (Status status);
/// GetNatRules gets the current NAT rules.
///
/// It also returns a generation number that can be passed to UpdateNatRules.
///
GetNatRules() -> (vector<Nat>:MAX_RULES rules, uint32 generation, Status status);
/// UpdateNatRules updates the current NAT rules.
///
/// It takes a generation number that is returned from GetNatRules. To
/// successfully update the current rules, the generation number passed to
/// UpdateNatRules needs to be up-to-date.
UpdateNatRules(vector<Nat>:MAX_RULES rules, uint32 generation) -> (Status status);
/// GetRdrRules gets the current RDR rules.
///
/// It also returns a generation number that can be passed to UpdateRdrRules.
GetRdrRules() -> (vector<Rdr>:MAX_RULES rules, uint32 generation, Status status);
/// UpdateRdrRules updates the previous RDR rules with new rules.
///
/// It takes a generation number that is returned from GetRdrRules. To
/// successfully update the current rules, the generation number passed to
/// UpdateRdrRules needs to be up-to-date.
UpdateRdrRules(vector<Rdr>:MAX_RULES rules, uint32 generation) -> (Status status);
};