RINASim  October 2016
Documentation of framework for OMNeT++
DomainTable.h
Go to the documentation of this file.
1 // The MIT License (MIT)
2 //
3 // Copyright (c) 2014-2016 Brno University of Technology, PRISTINE project
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 // THE SOFTWARE.
22 
23 #ifndef SimpleTable_H_
24 #define SimpleTable_H_
25 
26 #include <IntPDUForwarding.h>
27 
28 #include <map>
29 #include <string>
30 #include <vector>
31 
32 namespace DomainTable {
33 
34 using namespace std;
35 
36 typedef vector<string> sList;
37 typedef sList::iterator sListIt;
38 
39 typedef map<string, RMTPort*> s2Port;
40 struct domainSet {
41  unsigned short len;
42  s2Port entries;
43 
44  domainSet():len(0){}
45  domainSet(const unsigned short &_len):len(_len){}
46 };
47 typedef map<string, domainSet> FWDTable;
48 
49 typedef s2Port::iterator s2PortIt;
50 typedef FWDTable::iterator FWDTableIt;
51 
52 struct pAddr {
53  string domain;
54  string addr;
55  pAddr (const string &_domain, const string &_addr)
56  : domain(_domain), addr(_addr) {}
57 };
58 
60 
61 public:
62  // Lookup function, return a list of RMTPorts to forward a PDU/Address+qos.
63  vector<RMTPort * > lookup(const PDU * pdu);
64  vector<RMTPort * > lookup(const Address &dst, const std::string& qos);
65 
66  // Returns a representation of the Forwarding Knowledge
67  string toString();
68 
69  // Create Domain
70  void addDomain(const string &domain);
71  void removeDomain(const string &domain);
72 
73  //Insert/Remove an entry
74  void insert(const string &domain, const string &addr, RMTPort * port);
75  void remove(const string &domain, const string &addr);
76 
77  void finish();
78  pAddr parseAddr(const string &addr);
79 
80 protected:
81  sList domains;
82  FWDTable table;
83 
84  // Called after initialize
85  void onPolicyInit();
86 };
87 
88 }
89 
90 #endif /* SimpleTable_H_ */
domainSet(const unsigned short &_len)
Definition: DomainTable.h:45
pAddr(const string &_domain, const string &_addr)
Definition: DomainTable.h:55
s2Port::iterator s2PortIt
Definition: DomainTable.h:49
unsigned short len
Definition: DomainTable.h:41
FWDTable::iterator FWDTableIt
Definition: DomainTable.h:50
Definition: PDU.h:42
map< string, domainSet > FWDTable
Definition: DomainTable.h:47
map< string, RMTPort * > s2Port
Definition: DomainTable.h:39
sList::iterator sListIt
Definition: DomainTable.h:37
vector< string > sList
Definition: DomainTable.h:36
Address class holds IPC Process identification.
Definition: Address.h:42