1 //-------------------------------------------------------------------------- 2 // Copyright (C) 2016-2021 Cisco and/or its affiliates. All rights reserved. 3 // 4 // This program is free software; you can redistribute it and/or modify it 5 // under the terms of the GNU General Public License Version 2 as published 6 // by the Free Software Foundation. You may not use, modify or distribute 7 // this program under any other version of the GNU General Public License. 8 // 9 // This program is distributed in the hope that it will be useful, but 10 // WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 // General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License along 15 // with this program; if not, write to the Free Software Foundation, Inc., 16 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 //-------------------------------------------------------------------------- 18 19 // sfdaq_config.h author Michael Altizer <mialtize@cisco.com> 20 21 #ifndef SFDAQ_CONFIG_H 22 #define SFDAQ_CONFIG_H 23 24 #include <string> 25 #include <vector> 26 27 using DaqVar = std::pair<std::string, std::string>; 28 using DaqVarList = std::vector<DaqVar>; 29 30 /* Module configuration */ 31 struct SFDAQModuleConfig 32 { 33 enum SFDAQMode 34 { 35 SFDAQ_MODE_UNSET, 36 SFDAQ_MODE_PASSIVE, 37 SFDAQ_MODE_INLINE, 38 SFDAQ_MODE_READ_FILE, 39 }; 40 41 SFDAQModuleConfig() = default; 42 SFDAQModuleConfig(const SFDAQModuleConfig&); 43 void set_variable(const char* varkvp); 44 45 std::string name; 46 SFDAQMode mode = SFDAQ_MODE_UNSET; 47 DaqVarList variables; 48 }; 49 50 /* General/base configuration */ 51 struct SFDAQConfig 52 { 53 SFDAQConfig(); 54 ~SFDAQConfig(); 55 56 void add_input(const char*); 57 SFDAQModuleConfig* add_module_config(const char* module_name); 58 void add_module_dir(const char*); 59 void set_batch_size(uint32_t); 60 void set_mru_size(int); 61 get_batch_sizeSFDAQConfig62 uint32_t get_batch_size() const { return (batch_size == BATCH_SIZE_UNSET) ? BATCH_SIZE_DEFAULT : batch_size; } get_mru_sizeSFDAQConfig63 uint32_t get_mru_size() const { return (mru_size == SNAPLEN_UNSET) ? SNAPLEN_DEFAULT : mru_size; } 64 65 void overlay(const SFDAQConfig*); 66 67 /* General configuration */ 68 std::vector<std::string> module_dirs; 69 /* Instance configuration */ 70 std::vector<std::string> inputs; 71 uint32_t batch_size; 72 int mru_size; 73 unsigned int timeout; 74 std::vector<SFDAQModuleConfig*> module_configs; 75 76 /* Constants */ 77 static constexpr uint32_t BATCH_SIZE_UNSET = 0; 78 static constexpr int SNAPLEN_UNSET = -1; 79 static constexpr uint32_t BATCH_SIZE_DEFAULT = 64; 80 static constexpr int SNAPLEN_DEFAULT = 1518; 81 static constexpr unsigned TIMEOUT_DEFAULT = 1000; 82 }; 83 84 #endif 85