RINASim  October 2016
Documentation of framework for OMNeT++
FANotifier.cc
Go to the documentation of this file.
1 //
2 // This program is free software: you can redistribute it and/or modify
3 // it under the terms of the GNU Lesser General Public License as published by
4 // the Free Software Foundation, either version 3 of the License, or
5 // (at your option) any later version.
6 //
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public License
13 // along with this program. If not, see http://www.gnu.org/licenses/.
14 //
15 
16 #include <FANotifier.h>
17 
18 const char* MSG_FLO = "Flow";
19 const char* MSG_FLOPOSI = "Flow+";
20 const char* MSG_FLONEGA = "Flow-";
21 //FIXME: Vesely: Unused variable commented
22 //const int VAL_FLOWPOSI = 1;
23 //FIXME: Vesely: Unused variable commented
24 //const int VAL_FLOWNEGA = 0;
25 const char* VAL_FLREQ = "Request ";
26 const char* VAL_FLREQPOSI = "Response+ ";
27 const char* VAL_FLREQNEGA = "Response- ";
28 
30 
32  cModule* catcher2 = this->getModuleByPath("^.^");
33  cModule* catcher3 = this->getModuleByPath("^.^.^");
34 
35  //Signals that this module is emitting
36  //sigRIBDSendData = registerSignal(SIG_RIBD_DataSend);
42  sigRIBDCreFlow = registerSignal(SIG_RIBD_CreateFlow);
45 
48  lisRIBDCreReq = new LisRIBDCreReq(this);
49  catcher2->subscribe(SIG_FAI_CreateFlowRequest, lisRIBDCreReq);
50 
51  lisRIBDDelReq = new LisRIBDDelReq(this);
52  catcher2->subscribe(SIG_FAI_DeleteFlowRequest, lisRIBDDelReq);
53  lisRIBDDelRes = new LisRIBDDelRes(this);
54  catcher2->subscribe(SIG_FAI_DeleteFlowResponse, lisRIBDDelRes);
55 
60 
65 
67  catcher2->subscribe(SIG_RA_CreateFlowPositive, lisRIBDCreFloPosi);
69  catcher2->subscribe(SIG_RA_CreateFlowNegative, lisRIBDCreFloNega);
70 
72  catcher3->subscribe(SIG_FAI_AllocateRequest, lisRIBDAllReqFromFai);
73 }
74 
76  Enter_Method("receiveAllocationRequestFromFai()");
77  if (flow->isManagementFlowLocalToIPCP())
78  {
80  }
81  else {
82  //Execute flow allocate
83  signalizeCreateFlow(flow);
84  }
85 }
86 
89 }
90 
93 }
94 
96  Enter_Method("sendCreateRequestFlow()");
97 
98  //Prepare M_CREATE Flow
99  CDAP_M_Create* mcref = new CDAP_M_Create(MSG_FLO);
100 
101  //Prepare object
102  std::ostringstream os;
103  os << flow->getFlowName();
104  object_t flowobj;
105  flowobj.objectClass = flow->getClassName();
106  flowobj.objectName = os.str();
107  flowobj.objectVal = flow;
108  //TODO: Vesely - Assign appropriate values
110  mcref->setObjectItem(flowobj);
111 
112  //Append src/dst address for RMT "routing"
113  mcref->setSrcAddr(flow->getSrcNeighbor());
114  mcref->setDstAddr(flow->getDstNeighbor());
115 
116  //Generate InvokeId
117  if (!flow->getAllocInvokeId())
119  mcref->setInvokeID(flow->getAllocInvokeId());
120 
121  //Send it
122  signalizeMessage(mcref);
123 }
124 
126  Enter_Method("sendDeleteRequestFlow()");
127 
128  //Prepare M_CREATE Flow
129  CDAP_M_Delete* mdereqf = new CDAP_M_Delete(MSG_FLO);
130 
131  //Prepare object
132  std::ostringstream os;
133  os << flow->getFlowName();
134  object_t flowobj;
135  flowobj.objectClass = flow->getClassName();
136  flowobj.objectName = os.str();
137  flowobj.objectVal = flow;
138  //TODO: Vesely - Assign appropriate values
140  mdereqf->setObjectItem(flowobj);
141 
142  //Append src/dst address for RMT "routing"
143  mdereqf->setSrcAddr(flow->getSrcNeighbor());
144  mdereqf->setDstAddr(flow->getDstAddr());
145 
146  //Generate InvokeId
147  if (!flow->getDeallocInvokeId())
149  mdereqf->setInvokeID(flow->getDeallocInvokeId());
150 
151  //Send it
152  signalizeMessage(mdereqf);
153 }
154 
156  Enter_Method("sendCreateResponseFlowNegative()");
157 
158  //Prepare M_CREATE_R Flow-
160 
161  //Prepare object
162  std::ostringstream os;
163  os << flow->getFlowName();
164  object_t flowobj;
165  flowobj.objectClass = flow->getClassName();
166  flowobj.objectName = os.str();
167  flowobj.objectVal = flow;
168  //TODO: Vesely - Assign appropriate values
170  mcref->setObjectItem(flowobj);
171 
172  //Prepare result object
173  result_t resultobj;
174  resultobj.resultValue = R_FAIL;
175  mcref->setResult(resultobj);
176 
177  //Generate InvokeId
178  mcref->setInvokeID(flow->getAllocInvokeId());
179 
180  //Append src/dst address for RMT "routing"
181  mcref->setSrcAddr(flow->getSrcNeighbor());
182  mcref->setDstAddr(flow->getDstAddr());
183 
184  //Send it
185  signalizeMessage(mcref);
186 }
187 
189  Enter_Method("sendCreateResponseFlowPositive()");
190 
191  //Prepare M_CREATE_R Flow+
193 
194  //Prepare object
195  std::ostringstream os;
196  os << flow->getFlowName();
197  object_t flowobj;
198  flowobj.objectClass = flow->getClassName();
199  flowobj.objectName = os.str();
200  flowobj.objectVal = flow;
201  //TODO: Vesely - Assign appropriate values
203  mcref->setObjectItem(flowobj);
204 
205  //Prepare result object
206  result_t resultobj;
207  resultobj.resultValue = R_SUCCESS;
208  mcref->setResult(resultobj);
209 
210  //Generate InvokeId
211  mcref->setInvokeID(flow->getAllocInvokeId());
212 
213  //Append src/dst address for RMT "routing"
214  mcref->setSrcAddr(flow->getSrcNeighbor());
215  mcref->setDstAddr(flow->getDstAddr());
216 
217  //Send it
218  signalizeMessage(mcref);
219 }
220 
222  Enter_Method("sendDeleteResponseFlow()");
223 
224  //Prepare M_CREATE_R Flow+
226 
227  //Prepare object
228  std::ostringstream os;
229  os << flow->getFlowName();
230  object_t flowobj;
231  flowobj.objectClass = flow->getClassName();
232  flowobj.objectName = os.str();
233  flowobj.objectVal = flow;
234  //TODO: Vesely - Assign appropriate values
236  mderesf->setObjectItem(flowobj);
237 
238  //Prepare result object
239  result_t resultobj;
240  resultobj.resultValue = R_SUCCESS;
241  mderesf->setResult(resultobj);
242 
243  //Generate InvokeId
244  mderesf->setInvokeID(flow->getDeallocInvokeId());
245 
246  //Append src/dst address for RMT "routing"
247  mderesf->setSrcAddr(flow->getSrcNeighbor());
248  mderesf->setDstAddr(flow->getDstAddr());
249 
250  //Send it
251  signalizeMessage(mderesf);
252 }
253 
255  EV << "Emits AllocateResponsePositive signal for flow" << endl;
256  emit(sigRIBDAllocResPosi, flow);
257 }
258 
260  EV << "Emits CreateRequestFlow signal for flow" << endl;
261  emit(sigRIBDCreReqFlo, flow);
262 }
263 
265  EV << "Emits CreateResponsetFlowPositive signal for flow" << endl;
266  emit(sigRIBDCreResFloPosi, flow);
267 }
268 
270  RIBd = check_and_cast<RIBdBase*>( getModuleByPath("^.ribd") );
271 }
272 
274  EV << "Emits CreateResponsetFlowNegative signal for flow" << endl;
275  emit(sigRIBDCreResFloNega, flow);
276 }
277 
279  EV << "Emits CreateFlow signal for flow" << endl;
280  emit(sigRIBDCreFlow, flow);
281 }
282 
284  EV << "Emits DeleteRequestFlow signal for flow" << endl;
285  emit(sigRIBDDelReqFlo, flow);
286 }
287 
289  EV << "Emits AllocateResponseNegative signal for flow" << endl;
290  emit(sigRIBDAllocResNega, flow);
291 }
292 
294  EV << "Emits DeleteResponseFlow signal for flow" << endl;
295  emit(sigRIBDDelResFlo, flow);
296 }
297 
299 // EV << "Received M_Create";
300  object_t object = msg->getObjectItem();
301 // EV << " with object '" << object.objectClass << "'" << endl;
302  if (dynamic_cast<Flow*>(object.objectVal)) {
303  Flow* fl = (check_and_cast<Flow*>(object.objectVal))->dup();
304  //EV << fl->info();
305  fl->swapFlow();
306  //EV << "\n===========\n" << fl->info();
308  }
309 }
310 
312 // EV << "Received M_Create_R";
313  object_t object = msg->getObjectItem();
314 // EV << " with object '" << object.objectClass << "'" << endl;
315  //CreateResponseFlow
316  if (dynamic_cast<Flow*>(object.objectVal)) {
317  Flow* flow = (check_and_cast<Flow*>(object.objectVal))->dup();
318  flow->swapFlow();
319  //Positive response
320  if (!msg->getResult().resultValue) {
322  }
323  //Negative response
324  else
326  }
327 }
328 
330 // EV << "Received M_Delete";
331  object_t object = msg->getObjectItem();
332 // EV << " with object '" << object.objectClass << "'" << endl;
333  //DeleteRequest Flow
334  if (dynamic_cast<Flow*>(object.objectVal)) {
335  Flow* fl = (check_and_cast<Flow*>(object.objectVal))->dup();
336  fl->swapFlow();
338  }
339 }
340 
342 // EV << "Received M_Delete_R";
343  object_t object = msg->getObjectItem();
344 // EV << " with object '" << object.objectClass << "'" << endl;
345  //DeleteResponseFlow
346  if (dynamic_cast<Flow*>(object.objectVal)) {
347  Flow* flow = (check_and_cast<Flow*>(object.objectVal))->dup();
348  flow->swapFlow();
350  }
351 }
352 
354  initMyAddress();
356  initPointers();
357 }
358 
360  RIBd->signalizeSendData(msg);
361 }
362 
364  return RIBd->getNewInvokeId();
365 }
366 
Class representing flow object with attributes from specs.
Definition: Flow.h:45
const char * SIG_RIBD_CreateFlow
Definition: RINASignals.cc:49
simsignal_t sigRIBDAllocResNega
Definition: FANotifier.h:46
simsignal_t sigRIBDDelReqFlo
Definition: FANotifier.h:41
void initPointers()
Definition: FANotifier.cc:269
::omnetpp::opp_string objectClass
const int VAL_DEFINSTANCE
virtual result_t & getResult()
LisRIBDCreResPosi * lisRIBDCreResPosi
Definition: FANotifier.h:55
Definition: RIBd.h:54
const char * SIG_FA_CreateFlowRequestForward
Definition: RINASignals.cc:96
int objectInstance
const char * VAL_FLREQ
Definition: FANotifier.cc:25
const char * SIG_AERIBD_AllocateResponsePositive
Definition: RINASignals.cc:91
const char * SIG_FAI_CreateFlowRequest
Definition: RINASignals.cc:110
virtual object_t & getObjectItem()
virtual void signalizeSendData(CDAPMessage *msg)
Definition: RIBd.cc:444
const char * SIG_RIBD_DeleteRequestFlow
Definition: RINASignals.cc:47
virtual void setSrcAddr(const Address &srcAddr)
virtual object_t & getObjectItem()
LisRIBDCreReq * lisRIBDCreReq
Definition: FANotifier.h:50
const char * SIG_RIBD_DeleteResponseFlow
Definition: RINASignals.cc:48
void signalizeAllocateResponseNegative(Flow *flow)
Definition: FANotifier.cc:288
void setAllocInvokeId(long allocInvokeId)
Sets allocation InvokeId.
Definition: Flow.cc:281
const char * SIG_FAI_CreateFlowResponseNegative
Definition: RINASignals.cc:113
virtual void signalizeMessage(CDAPMessage *msg)
Function asks for notifies about CDAP message ready to be sent.
Definition: FANotifier.cc:359
virtual void setObjectItem(const object_t &objectItem)
long getAllocInvokeId() const
Gets allocation InvokeId Used inside M_CREATE(_R)(flow) messages.
Definition: Flow.cc:277
const Address & getSrcNeighbor() const
Gets neighbor source Address, which is the address of (interim) hop-by-hop source Used during flow al...
Definition: Flow.cc:348
LisRIBDDelRes * lisRIBDDelRes
Definition: FANotifier.h:58
void initSignalsAndListeners()
Definition: FANotifier.cc:31
LisRIBDAllReqFromFai * lisRIBDAllReqFromFai
Definition: FANotifier.h:52
LisRIBDCreFloNega * lisRIBDCreFloNega
Definition: FANotifier.h:60
LisRIBDCreResNega * lisRIBDCreResNegaFromFa
Definition: FANotifier.h:54
virtual void processMDeleteR(CDAP_M_Delete_R *msg)
Function crunching supported M_DELETE_R message.
Definition: FANotifier.cc:341
const char * SIG_FAI_DeleteFlowRequest
Definition: RINASignals.cc:111
virtual void processMCreateR(CDAP_M_Create_R *msg)
Function crunching supported M_CREATE_R message.
Definition: FANotifier.cc:311
virtual void setObjectItem(const object_t &objectItem)
virtual void sendCreateRequestFlow(Flow *flow)
Definition: FANotifier.cc:95
virtual void sendCreateResponseNegative(Flow *flow)
Definition: FANotifier.cc:155
long getNewInvokeId()
Definition: FANotifier.cc:363
virtual void setResult(const result_t &result)
virtual void sendDeleteRequestFlow(Flow *flow)
Definition: FANotifier.cc:125
const char * MSG_FLONEGA
Definition: FANotifier.cc:20
LisRIBDCreReq * lisRIBDCreReqByForward
Definition: FANotifier.h:51
std::string getFlowName() const
Prints flow name consisting of source and destination APNI Primary use is for OMNeT++ cMessage proper...
Definition: Flow.cc:203
const char * SIG_FAI_DeleteFlowResponse
Definition: RINASignals.cc:114
const char * VAL_FLREQNEGA
Definition: FANotifier.cc:27
const char * SIG_FA_CreateFlowResponseNegative
Definition: RINASignals.cc:94
const Address & getDstNeighbor() const
Gets neighbor destination Address, which is the address of (interim) hop-by-hop destination Used duri...
Definition: Flow.cc:340
void signalizeCreateFlow(Flow *flow)
Definition: FANotifier.cc:278
LisRIBDDelReq * lisRIBDDelReq
Definition: FANotifier.h:57
const char * MSG_FLOPOSI
Definition: FANotifier.cc:19
simsignal_t sigRIBDCreReqFlo
Definition: FANotifier.h:40
const char * SIG_FAI_CreateFlowResponsePositive
Definition: RINASignals.cc:112
const char * SIG_RIBD_CreateRequestFlow
Definition: RINASignals.cc:46
long getNewInvokeId()
Definition: RIBdBase.cc:48
virtual void receiveCreateFlowNegativeFromRa(Flow *flow)
Definition: FANotifier.cc:91
LisRIBDCreResNega * lisRIBDCreResNega
Definition: FANotifier.h:53
virtual void setInvokeID(int32_t invokeID)
void signalizeDeleteResponseFlow(Flow *flow)
Definition: FANotifier.cc:293
virtual void sendDeleteResponseFlow(Flow *flow)
Definition: FANotifier.cc:221
virtual object_t & getObjectItem()
virtual void sendCreateResponsePostive(Flow *flow)
Definition: FANotifier.cc:188
const char * SIG_RA_CreateFlowNegative
Definition: RINASignals.cc:117
simsignal_t sigRIBDCreResFloNega
Definition: FANotifier.h:44
virtual void setResult(const result_t &result)
LisRIBDCreFloPosi * lisRIBDCreFloPosi
Definition: FANotifier.h:59
const char * SIG_AERIBD_AllocateResponseNegative
Definition: RINASignals.cc:92
virtual void processMDelete(CDAP_M_Delete *msg)
Function crunching supported M_DELETE message.
Definition: FANotifier.cc:329
virtual void receiveCreateFlowPositiveFromRa(Flow *flow)
Definition: FANotifier.cc:87
ObjectPtr objectVal
const char * SIG_RIBD_CreateFlowResponsePositive
Definition: RINASignals.cc:51
virtual void setDstAddr(const Address &dstAddr)
LisRIBDCreResPosi * lisRIBDCreResPosiForward
Definition: FANotifier.h:56
simsignal_t sigRIBDCreResFloPosi
Definition: FANotifier.h:43
virtual void setObjectItem(const object_t &objectItem)
virtual void processMCreate(CDAP_M_Create *msg)
Function crunching supported M_CREATE message.
Definition: FANotifier.cc:298
void signalizeAllocateResponsePositive(Flow *flow)
Definition: FANotifier.cc:254
const char * VAL_FLREQPOSI
Definition: FANotifier.cc:26
const Address & getDstAddr() const
Gets source Address, which is the address of communication end-point.
Definition: Flow.cc:150
int32_t resultValue
simsignal_t sigRIBDCreFlow
Definition: FANotifier.h:47
::omnetpp::opp_string objectName
void signalizeCreateResponseFlowNegative(Flow *flow)
Definition: FANotifier.cc:273
bool isManagementFlowLocalToIPCP() const
Definition: Flow.cc:370
virtual Flow * dup() const
Flow object duplication method that creates copy with.
Definition: Flow.cc:182
void signalizeCreateResponseFlowPositive(Flow *flow)
Definition: FANotifier.cc:264
const char * MSG_FLO
Definition: FANotifier.cc:18
virtual void receiveAllocationRequestFromFai(Flow *flow)
Definition: FANotifier.cc:75
void signalizeDeleteRequestFlow(Flow *flow)
Definition: FANotifier.cc:283
const char * SIG_RA_CreateFlowPositive
Definition: RINASignals.cc:116
simsignal_t sigRIBDDelResFlo
Definition: FANotifier.h:42
const char * SIG_FAI_AllocateRequest
Definition: RINASignals.cc:105
Flow & swapFlow()
Function that swaps relevant source and destination Flow parameters It is being used mainly for count...
Definition: Flow.cc:311
Define_Module(FANotifier)
const char * SIG_RIBD_CreateFlowResponseNegative
Definition: RINASignals.cc:50
void signalizeCreateRequestFlow(Flow *flow)
Definition: FANotifier.cc:259
virtual void setObjectItem(const object_t &objectItem)
virtual object_t & getObjectItem()
virtual void initialize()
Definition: FANotifier.cc:353
void setDeallocInvokeId(long deallocInvokeId)
Sets deallocation InvokeId.
Definition: Flow.cc:289
const char * SIG_FA_CreateFlowResponseForward
Definition: RINASignals.cc:97
simsignal_t sigRIBDAllocResPosi
Definition: FANotifier.h:45
long getDeallocInvokeId() const
Gets deallocation InvokeId Used inside M_DELETE(_R)(flow) messages.
Definition: Flow.cc:285