blob: 7759ef7c7eeec321a82470ddf96a3461066a5f9b [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.
type Status = strict enum {
OK = 0;
ERR_INTERNAL = 1;
ERR_GENERATION_MISMATCH = 2;
ERR_BAD_RULE = 3;
ERR_NOT_SUPPORTED = 4;
};
/// The maximum number of rules.
const MAX_RULES uint32 = 128;
@discoverable
protocol Filter {
/// Enable enables the filter if true is passed.
/// It disables the filter if false is passed.
Enable(struct {
enabled bool;
}) -> (struct {
status Status;
});
/// IsEnabled returns true if the filter is enabled.
IsEnabled() -> (struct {
enabled bool;
});
/// 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() -> (struct {
rules vector<Rule>:MAX_RULES;
generation uint32;
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(struct {
rules vector<Rule>:MAX_RULES;
generation uint32;
}) -> (struct {
status Status;
});
/// GetNatRules gets the current NAT rules.
///
/// It also returns a generation number that can be passed to UpdateNatRules.
///
GetNatRules() -> (struct {
rules vector<Nat>:MAX_RULES;
generation uint32;
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(struct {
rules vector<Nat>:MAX_RULES;
generation uint32;
}) -> (struct {
status Status;
});
/// GetRdrRules gets the current RDR rules.
///
/// It also returns a generation number that can be passed to UpdateRdrRules.
GetRdrRules() -> (struct {
rules vector<Rdr>:MAX_RULES;
generation uint32;
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(struct {
rules vector<Rdr>:MAX_RULES;
generation uint32;
}) -> (struct {
status Status;
});
};