CPDebuggerInterface.h
Go to the documentation of this file.
1 /*
2  * PFPSim: Library for the Programmable Forwarding Plane Simulation Framework
3  *
4  * Copyright (C) 2016 Concordia Univ., Montreal
5  * Samar Abdi
6  * Umair Aftab
7  * Gordon Bailey
8  * Faras Dewal
9  * Shafigh Parsazad
10  * Eric Tremblay
11  *
12  * Copyright (C) 2016 Ericsson
13  * Bochra Boughzala
14  *
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * as published by the Free Software Foundation; either version 2
18  * of the License, or (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with this program; if not, write to the Free Software
27  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
28  * 02110-1301, USA.
29  */
30 
39 #ifndef CORE_DEBUGGER_CPDEBUGGERINTERFACE_H_
40 #define CORE_DEBUGGER_CPDEBUGGERINTERFACE_H_
41 
42 #include <string>
43 #include <vector>
44 #include <map>
45 #include <iostream>
46 
47 namespace pfp {
48 namespace core {
49 namespace db {
50 
58  public:
59  enum TableEntryStatus {
60  OK,
61  INSERTING,
62  DELETING,
63  MODIFYING,
64  NONE
65  };
66 
70  class TableEntry {
71  public:
72  TableEntry() {}
73  TableEntry(std::string table_name, std::string match_key,
74  std::string action_name, std::vector<std::string> action_data,
75  uint64_t handle, CPDebuggerInterface::TableEntryStatus status = NONE)
76  : table_name(table_name), match_key(match_key),
77  action_name(action_name), action_data(action_data),
78  handle(handle), status(status) {}
79 
81  std::string table_name;
83  std::string match_key;
85  std::string action_name;
87  std::vector<std::string> action_data;
89  uint64_t handle;
90  CPDebuggerInterface::TableEntryStatus status;
91  };
92 
93  virtual void do_command(std::string command) = 0;
94 
103  void updateHandle(std::string table_name, std::string match_key,
104  std::string action_name, uint64_t handle);
105 
113  void addTableEntry(std::string table_name, std::string match_key,
114  std::string action_name, std::vector<std::string> action_data,
115  uint64_t handle = -1);
116 
120  void printTableEntries();
121 
129  void updateTableEntry(std::string table_name, uint64_t handle,
130  std::string action_name, std::vector<std::string> action_data);
131 
137  void deleteTableEntry(std::string table_name, uint64_t handle);
138 
139  // confirm an update/modify
140  void confirmUpdateEntry(std::string table_name, uint64_t handle);
141 
142  // confirm a update / delete
143  void confirmDeleteEntry(std::string table_name, uint64_t handle);
144 
148  std::vector<CPDebuggerInterface::TableEntry> getAllTableEntries();
149 
150  protected:
152  std::map<std::string, std::map<std::string,
153  std::vector<TableEntry>>> table_entries;
154 };
155 
156 }; // namespace db
157 }; // namespace core
158 }; // namespace pfp
159 
160 #endif // CORE_DEBUGGER_CPDEBUGGERINTERFACE_H_
void printTableEntries()
Print the internal list of entries to stdout.
Definition: CPDebuggerInterface.cpp:83
std::string action_name
Name of the action that is used if this entry is hit.
Definition: CPDebuggerInterface.h:85
void updateTableEntry(std::string table_name, uint64_t handle, std::string action_name, std::vector< std::string > action_data)
Update or modify an entry that has already been added to the internal list of entries.
Definition: CPDebuggerInterface.cpp:104
Interface for Control Plane module that is necessary for it to work with pfpdb.
Definition: CPDebuggerInterface.h:57
std::vector< CPDebuggerInterface::TableEntry > getAllTableEntries()
Get internal list of table entries.
Definition: CPDebuggerInterface.cpp:133
void addTableEntry(std::string table_name, std::string match_key, std::string action_name, std::vector< std::string > action_data, uint64_t handle=-1)
Add a table entry to internal list of entries.
Definition: CPDebuggerInterface.cpp:57
void updateHandle(std::string table_name, std::string match_key, std::string action_name, uint64_t handle)
Update the handle of an entry in internal list of entries.
Definition: CPDebuggerInterface.cpp:40
Data Structure used to represent table entries so that they can be stored.
Definition: CPDebuggerInterface.h:70
void deleteTableEntry(std::string table_name, uint64_t handle)
Delete an entry from the internal list of entries.
Definition: CPDebuggerInterface.cpp:117
std::vector< std::string > action_data
Data inserted into the action if this entry is hit.
Definition: CPDebuggerInterface.h:87
std::string match_key
Key used to perform the match.
Definition: CPDebuggerInterface.h:83
std::string table_name
Name of table in which the entry is found.
Definition: CPDebuggerInterface.h:81
uint64_t handle
Handle (or unique identifier) corresponding to this entry.
Definition: CPDebuggerInterface.h:89
std::map< std::string, std::map< std::string, std::vector< TableEntry > > > table_entries
List of table entries (in a more convenient data structure)
Definition: CPDebuggerInterface.h:153
PacketBase.h.
Definition: ConfigurationParameters.cpp:36