1*387f9dfdSAndroid Build Coastguard Worker /*
2*387f9dfdSAndroid Build Coastguard Worker * Copyright (c) 2017 VMware, Inc.
3*387f9dfdSAndroid Build Coastguard Worker *
4*387f9dfdSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*387f9dfdSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*387f9dfdSAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*387f9dfdSAndroid Build Coastguard Worker *
8*387f9dfdSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
9*387f9dfdSAndroid Build Coastguard Worker *
10*387f9dfdSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*387f9dfdSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*387f9dfdSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*387f9dfdSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*387f9dfdSAndroid Build Coastguard Worker * limitations under the License.
15*387f9dfdSAndroid Build Coastguard Worker */
16*387f9dfdSAndroid Build Coastguard Worker
17*387f9dfdSAndroid Build Coastguard Worker #include "common.h"
18*387f9dfdSAndroid Build Coastguard Worker #include "table_storage_impl.h"
19*387f9dfdSAndroid Build Coastguard Worker
20*387f9dfdSAndroid Build Coastguard Worker namespace ebpf {
21*387f9dfdSAndroid Build Coastguard Worker
22*387f9dfdSAndroid Build Coastguard Worker using std::string;
23*387f9dfdSAndroid Build Coastguard Worker using std::unique_ptr;
24*387f9dfdSAndroid Build Coastguard Worker
25*387f9dfdSAndroid Build Coastguard Worker /// A filesystem backed table storage
26*387f9dfdSAndroid Build Coastguard Worker class BpfFsTableStorage : public TableStorageImpl {
27*387f9dfdSAndroid Build Coastguard Worker public:
28*387f9dfdSAndroid Build Coastguard Worker class iterator : public TableStorageIteratorImpl {
29*387f9dfdSAndroid Build Coastguard Worker public:
~iterator()30*387f9dfdSAndroid Build Coastguard Worker virtual ~iterator() {}
31*387f9dfdSAndroid Build Coastguard Worker virtual unique_ptr<self_type> clone() const override;
32*387f9dfdSAndroid Build Coastguard Worker virtual self_type &operator++() override;
33*387f9dfdSAndroid Build Coastguard Worker virtual value_type &operator*() const override;
34*387f9dfdSAndroid Build Coastguard Worker virtual pointer operator->() const override;
35*387f9dfdSAndroid Build Coastguard Worker };
~BpfFsTableStorage()36*387f9dfdSAndroid Build Coastguard Worker virtual ~BpfFsTableStorage() {}
37*387f9dfdSAndroid Build Coastguard Worker virtual bool Find(const string &name, TableStorage::iterator &result) const override;
38*387f9dfdSAndroid Build Coastguard Worker virtual bool Insert(const string &name, TableDesc &&desc) override;
39*387f9dfdSAndroid Build Coastguard Worker virtual bool Delete(const string &name) override;
40*387f9dfdSAndroid Build Coastguard Worker virtual unique_ptr<TableStorageIteratorImpl> begin() override;
41*387f9dfdSAndroid Build Coastguard Worker virtual unique_ptr<TableStorageIteratorImpl> end() override;
42*387f9dfdSAndroid Build Coastguard Worker virtual unique_ptr<TableStorageIteratorImpl> lower_bound(const string &k) override;
43*387f9dfdSAndroid Build Coastguard Worker virtual unique_ptr<TableStorageIteratorImpl> upper_bound(const string &k) override;
44*387f9dfdSAndroid Build Coastguard Worker virtual unique_ptr<TableStorageIteratorImpl> erase(const TableStorageIteratorImpl &it) override;
45*387f9dfdSAndroid Build Coastguard Worker
46*387f9dfdSAndroid Build Coastguard Worker private:
47*387f9dfdSAndroid Build Coastguard Worker };
48*387f9dfdSAndroid Build Coastguard Worker
Find(const string & name,TableStorage::iterator & result) const49*387f9dfdSAndroid Build Coastguard Worker bool BpfFsTableStorage::Find(const string &name, TableStorage::iterator &result) const {
50*387f9dfdSAndroid Build Coastguard Worker return false;
51*387f9dfdSAndroid Build Coastguard Worker }
52*387f9dfdSAndroid Build Coastguard Worker
Insert(const string & name,TableDesc && desc)53*387f9dfdSAndroid Build Coastguard Worker bool BpfFsTableStorage::Insert(const string &name, TableDesc &&desc) { return false; }
54*387f9dfdSAndroid Build Coastguard Worker
Delete(const string & name)55*387f9dfdSAndroid Build Coastguard Worker bool BpfFsTableStorage::Delete(const string &name) { return false; }
56*387f9dfdSAndroid Build Coastguard Worker
begin()57*387f9dfdSAndroid Build Coastguard Worker unique_ptr<TableStorageIteratorImpl> BpfFsTableStorage::begin() { return unique_ptr<iterator>(); }
end()58*387f9dfdSAndroid Build Coastguard Worker unique_ptr<TableStorageIteratorImpl> BpfFsTableStorage::end() { return unique_ptr<iterator>(); }
lower_bound(const string & k)59*387f9dfdSAndroid Build Coastguard Worker unique_ptr<TableStorageIteratorImpl> BpfFsTableStorage::lower_bound(const string &k) {
60*387f9dfdSAndroid Build Coastguard Worker return unique_ptr<iterator>();
61*387f9dfdSAndroid Build Coastguard Worker }
upper_bound(const string & k)62*387f9dfdSAndroid Build Coastguard Worker unique_ptr<TableStorageIteratorImpl> BpfFsTableStorage::upper_bound(const string &k) {
63*387f9dfdSAndroid Build Coastguard Worker return unique_ptr<iterator>();
64*387f9dfdSAndroid Build Coastguard Worker }
erase(const TableStorageIteratorImpl & it)65*387f9dfdSAndroid Build Coastguard Worker unique_ptr<TableStorageIteratorImpl> BpfFsTableStorage::erase(const TableStorageIteratorImpl &it) {
66*387f9dfdSAndroid Build Coastguard Worker return unique_ptr<iterator>();
67*387f9dfdSAndroid Build Coastguard Worker }
68*387f9dfdSAndroid Build Coastguard Worker
createBpfFsTableStorage()69*387f9dfdSAndroid Build Coastguard Worker unique_ptr<TableStorage> createBpfFsTableStorage() {
70*387f9dfdSAndroid Build Coastguard Worker auto t = make_unique<TableStorage>();
71*387f9dfdSAndroid Build Coastguard Worker t->Init(make_unique<BpfFsTableStorage>());
72*387f9dfdSAndroid Build Coastguard Worker return t;
73*387f9dfdSAndroid Build Coastguard Worker }
74*387f9dfdSAndroid Build Coastguard Worker
75*387f9dfdSAndroid Build Coastguard Worker } // namespace ebpf
76