RINASim  October 2016
Documentation of framework for OMNeT++
Routing.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 DomainRouting_H_
24 #define DomainRouting_H_
25 
26 #include <IntRouting.h>
27 
28 #include "Address.h"
29 
30 #include <vector>
31 #include <map>
32 #include <string>
33 
34 #include <DomainRouting/rModule.h>
35 
36 namespace DMRnms {
37 
38 enum ModuleAlgs { DV, LS };
39 
40 
41 
42 class RoutingSelf: public cMessage {
43 public:
44  RoutingSelf():cMessage("RoutingSelf"){}
45  std::string domain;
46  cMessage * subM;
47 };
48 
49 class Routing: public IntRouting {
50 public:
51 
52  //Finish and delete modules
53  ~Routing();
54 
55  void finish();
56 
57 
58  // Process a Routing Update, return true => inform FWDG of the update
59  bool processUpdate(IntRoutingUpdate * update);
60 
61  // Add/Remove a domain
62  void addDomain(const std::string &domain, const std::string &addr, const ModuleAlgs &alg);
63  void removeDomain(const std::string &domain);
64 
65  // Add/Remove flow to neighbour
66  void addFlow(const Address &nAddr, const std::string &domain, const std::string &addr, const unsigned short &metric);
67  void removeFlow(const Address &nAddr, const std::string &domain, const std::string &addr);
68 
69  // Add/Remove secondary addresses
70  void addAddr(const std::string &domain, const std::string &addr);
71  void removeAddr(const std::string &domain, const std::string &addr);
72 
73  // Set Infinite Metric
74  void setInfMetric(const std::string &domain, const unsigned short &inf);
75 
76  // Sends a Routing Update
77  void chSendUpdate(RoutingUpdate * update);
78 
79  // Get next hops
81  dmUpdateM getAll();
82 
83 
84  void chScheduleAt(const std::string domain, const double & time, cMessage *msg);
85  virtual void handleMessage(cMessage *msg);
86 
87 protected:
88  // Called after initialize
89  void onPolicyInit();
90  std::map<std::string, rModule*> rModules;
91  std::set<std::string> changedModules;
92 };
93 
94 }
95 
96 #endif /* DomainRouting_H_ */
void addDomain(const std::string &domain, const std::string &addr, const ModuleAlgs &alg)
Definition: Routing.cc:57
dmUpdateM getAll()
Definition: Routing.cc:126
virtual void handleMessage(cMessage *msg)
Definition: Routing.cc:146
std::set< std::string > changedModules
Definition: Routing.h:91
ModuleAlgs
Definition: Routing.h:38
void addFlow(const Address &nAddr, const std::string &domain, const std::string &addr, const unsigned short &metric)
Definition: Routing.cc:75
void finish()
Definition: Routing.cc:159
void chSendUpdate(RoutingUpdate *update)
Definition: Routing.cc:111
void removeAddr(const std::string &domain, const std::string &addr)
Definition: Routing.cc:96
dmUpdateM getChanges()
Definition: Routing.cc:117
void onPolicyInit()
Definition: Routing.cc:136
void removeDomain(const std::string &domain)
Definition: Routing.cc:67
std::string domain
Definition: Routing.h:45
void setInfMetric(const std::string &domain, const unsigned short &inf)
Definition: Routing.cc:104
std::map< std::string, rModule * > rModules
Definition: Routing.h:90
void removeFlow(const Address &nAddr, const std::string &domain, const std::string &addr)
Definition: Routing.cc:82
void chScheduleAt(const std::string domain, const double &time, cMessage *msg)
Definition: Routing.cc:139
void addAddr(const std::string &domain, const std::string &addr)
Definition: Routing.cc:90
std::vector< dmNxt > dmUpdateM
Definition: rModule.h:52
cMessage * subM
Definition: Routing.h:46
Address class holds IPC Process identification.
Definition: Address.h:42
bool processUpdate(IntRoutingUpdate *update)
Definition: Routing.cc:38