RINASim  October 2016
Documentation of framework for OMNeT++
MockEFCPI.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 "MockEFCPI.h"
24 
26 
28 {
29  northI = this->gateHalf("northIo", cGate::INPUT);
30  northO = this->gateHalf("northIo", cGate::OUTPUT);
31  southI = this->gateHalf("southIo", cGate::INPUT);
32  southO = this->gateHalf("southIo", cGate::OUTPUT);
33 
34  connID = new ConnectionId();
35  connID->setSrcCepId(0);
36  connID->setDstCepId(0);
38 
39  srcApn = APN(getModuleByPath(".^.^")->par("apName"));
41 
42 
43 
44 }
45 
46 void MockEFCPI::handleMessage(cMessage *msg)
47 {
48 
49  if (msg->arrivedOn(northI->getId()))
50  {
51 
52  CDAPMessage* cdap = (CDAPMessage*)msg;
53  ManagementPDU* pdu = new ManagementPDU();
54 
55  pdu->setConnId(*(connID->dup()));
56 
57  pdu->setSrcAddr(srcAddress);
58  pdu->setDstAddr(cdap->getDstAddr());
59  pdu->setSrcApn(srcApn);
60  pdu->setDstApn(cdap->getDstAddr().getApn());
61 
62  pdu->setSeqNum(0);
63 
64  pdu->encapsulate(cdap);
65 
66 
67 
68  send(pdu, southO);
69 
70 
71  }
72  else if (msg->arrivedOn(southI->getId()))
73  {
74 
75  cPacket* packet = (cPacket*)msg;
76  send(packet->decapsulate(), northO);
77  delete packet;
78 
79  }
80 
81 }
Application Process Name class.
Definition: APN.h:36
virtual Address & getDstAddr()
virtual void setDstApn(const APN &dstApn)
Definition: PDU_m.cc:331
cGate * southI
Definition: MockEFCPI.h:47
Connection identifier as defined in specifications.
Definition: ConnectionId.h:42
const std::string VAL_MGMTQOSID
Definition: QoSCube.cc:37
virtual void setSrcAddr(const Address &srcAddr)
Definition: PDU_m.cc:301
virtual void setDstAddr(const Address &dstAddr)
Definition: PDU_m.cc:311
virtual ConnectionId * dup() const
Duplicate overload creates exact copy of ConnectionId.
Definition: ConnectionId.cc:71
void setDstCepId(int destCepId)
Setter of destination Connection-Endpoint identifier.
Definition: ConnectionId.cc:39
virtual void setSeqNum(unsigned int seqNum)
Definition: PDU_m.cc:381
virtual void setSrcApn(const APN &srcApn)
Definition: PDU_m.cc:321
Address srcAddress
Definition: MockEFCPI.h:53
void setQoSId(std::string qoSId)
Setter of selected QoS-cube identifier.
Definition: ConnectionId.cc:49
APN srcApn
Definition: MockEFCPI.h:52
cGate * northO
Definition: MockEFCPI.h:44
const APN & getApn() const
Getter of unique APN which is initialized during object construction.
Definition: Address.cc:119
void setSrcCepId(int srcCepId)
Setter of source Connection-Endpoint identifier.
Definition: ConnectionId.cc:59
cGate * southO
Definition: MockEFCPI.h:48
Define_Module(MockEFCPI)
virtual void handleMessage(cMessage *msg)
Definition: MockEFCPI.cc:46
ConnectionId * connID
Definition: MockEFCPI.h:50
virtual void setConnId(const ConnectionId &connId)
Definition: PDU_m.cc:341
virtual void initialize()
Definition: MockEFCPI.cc:27
Address class holds IPC Process identification.
Definition: Address.h:42
cGate * northI
Definition: MockEFCPI.h:43