1 /* 2 * Copyright (c) 2015 PLUMgrid, Inc. 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 #pragma once 18 19 #include <map> 20 #include <memory> 21 #include <string> 22 23 #include "table_storage.h" 24 25 namespace llvm { 26 class Module; 27 } 28 29 namespace ebpf { 30 31 namespace cc { 32 class Parser; 33 class CodegenLLVM; 34 } 35 36 class BLoader { 37 public: 38 explicit BLoader(unsigned flags); 39 ~BLoader(); 40 int parse(llvm::Module *mod, const std::string &filename, const std::string &proto_filename, 41 TableStorage &ts, const std::string &id, const std::string &maps_ns); 42 43 private: 44 unsigned flags_; 45 std::unique_ptr<cc::Parser> parser_; 46 std::unique_ptr<cc::Parser> proto_parser_; 47 std::unique_ptr<cc::CodegenLLVM> codegen_; 48 }; 49 50 } // namespace ebpf 51