RINASim  October 2016
Documentation of framework for OMNeT++
IntRouting.cc
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 #include "IntRouting.h"
24 
26 
27  cModule* catcher = this->getParentModule();
28  catcher->unsubscribe(SIG_RIBD_RoutingUpdateReceived, listener);
29  delete listener;
30 }
31 
33 
34  // IPCProcess module.
35  cModule * ipcModule = getParentModule();
36 
38  ipcModule->par("ipcAddress").stringValue(),
39  ipcModule->par("difName").stringValue());
40 
41  getRINAModule<cObject *>(this, 1, {MOD_RESALLOC, MOD_PDUFWDGEN});
42 
43  //Set FWDGenerator
44  fwdg = getRINAModule<IntPDUFG *>(this, 1, {MOD_RESALLOC, MOD_PDUFWDGEN});
45 
46  // Display active policy name.
48 
49  cModule* catcher = this->getParentModule();
50 
51  // Signal emitters; there will be part of our outputs.
52  sigRoutingUpdate = registerSignal(SIG_RIBD_RoutingUpdate);
53 
54  // Signal receivers; there will be part of our inputs.
55  listener = new LisRoutingRecv(this);
56  catcher->subscribe(SIG_RIBD_RoutingUpdateReceived, listener);
57 
58  onPolicyInit();
59 
60 }
61 
63  update->setSource(myAddress);
64  emit(sigRoutingUpdate, update);
65 }
66 
68  if(processUpdate(update)) {
70  }
71 }
72 
73 
75  module = _module;
76 }
77 
78 void LisRoutingRecv::receiveSignal(cComponent *src, simsignal_t id, cObject *obj, cObject *details){
79  EV << "RoutingUpdate initiated by " << src->getFullPath()
80  << " and processed by " << module->getFullPath() << endl;
81 
82  IntRoutingUpdate * update = dynamic_cast<IntRoutingUpdate *>(obj);
83 
84  if (update) {
85  module->receiveUpdate(update);
86  } else {
87  EV << "RoutingUpdate received unknown object!" << endl;
88  }
89 
90  delete update;
91 }
const char * MOD_RESALLOC
Definition: ExternConsts.cc:58
const char * SIG_RIBD_RoutingUpdateReceived
Definition: RINASignals.cc:53
IntPDUFG * fwdg
Definition: IntRouting.h:62
virtual void routingUpdated()=0
IntRouting * module
Definition: IntRouting.h:71
const char * MOD_PDUFWDGEN
Definition: ExternConsts.cc:54
virtual bool processUpdate(IntRoutingUpdate *update)=0
virtual void finish()
Definition: IntRouting.cc:25
Address myAddress
Definition: IntRouting.h:49
virtual void onPolicyInit()=0
simsignal_t sigRoutingUpdate
Definition: IntRouting.h:61
void setPolicyDisplayString(cModule *mod, const char *str)
Definition: Utils.cc:69
const char * SIG_RIBD_RoutingUpdate
Definition: RINASignals.cc:140
void receiveUpdate(IntRoutingUpdate *update)
Definition: IntRouting.cc:67
LisRoutingRecv(IntRouting *_module)
Definition: IntRouting.cc:74
void sendUpdate(IntRoutingUpdate *update)
Definition: IntRouting.cc:62
void receiveSignal(cComponent *src, simsignal_t id, cObject *obj, cObject *details)
Definition: IntRouting.cc:78
void setSource(Address src)
Address class holds IPC Process identification.
Definition: Address.h:42
void initialize()
Definition: IntRouting.cc:32
LisRoutingRecv * listener
Definition: IntRouting.h:60