Android-cuttlefish cvd tool
nftables.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2026 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ALLOCD_NET_NFTABLES_H_
18#define ALLOCD_NET_NFTABLES_H_
19
20#include <stdint.h>
21
22#include <string_view>
23
25
26namespace cuttlefish {
27
28class Nftables {
29 public:
30 virtual ~Nftables() = default;
31
32 virtual Result<void> EnsureTable(std::string_view family,
33 std::string_view table) = 0;
34 virtual Result<void> DeleteTable(std::string_view family,
35 std::string_view table) = 0;
36 virtual Result<void> EnsureChain(std::string_view family,
37 std::string_view table,
38 std::string_view chain,
39 std::string_view content) = 0;
40 virtual Result<uint64_t> AddRule(std::string_view family,
41 std::string_view table,
42 std::string_view chain,
43 std::string_view content,
44 std::string_view comment) = 0;
45 virtual Result<void> DeleteRule(std::string_view family,
46 std::string_view table,
47 std::string_view chain, uint64_t handle) = 0;
48 virtual Result<void> DeleteRulesByComment(std::string_view family,
49 std::string_view table,
50 std::string_view chain,
51 std::string_view comment) = 0;
52};
53
54} // namespace cuttlefish
55
56#endif // ALLOCD_NET_NFTABLES_H_
Definition: nftables.h:28
virtual Result< void > EnsureChain(std::string_view family, std::string_view table, std::string_view chain, std::string_view content)=0
virtual Result< void > DeleteRule(std::string_view family, std::string_view table, std::string_view chain, uint64_t handle)=0
virtual Result< void > DeleteTable(std::string_view family, std::string_view table)=0
virtual Result< uint64_t > AddRule(std::string_view family, std::string_view table, std::string_view chain, std::string_view content, std::string_view comment)=0
virtual ~Nftables()=default
virtual Result< void > DeleteRulesByComment(std::string_view family, std::string_view table, std::string_view chain, std::string_view comment)=0
virtual Result< void > EnsureTable(std::string_view family, std::string_view table)=0
Definition: alloc_driver.h:20
tl::expected< T, StackTraceError > Result
Definition: result_type.h:30