RINASim  October 2016
Documentation of framework for OMNeT++
CDAPProcessingBase.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 <CDAPProcessingBase.h>
17 
19  //M_CONNECT_Request
20  if (dynamic_cast<CDAP_M_Connect*>(msg)) {
21  processMConnect(check_and_cast<CDAP_M_Connect*>(msg));
22  }
23  //M_CONNECT_Response
24  else if (dynamic_cast<CDAP_M_Connect_R*>(msg)) {
25  processMConnectR(check_and_cast<CDAP_M_Connect_R*>(msg));
26  }
27  //M_RELEASE_Request
28  else if (dynamic_cast<CDAP_M_Release*>(msg)) {
29  processMRelease(check_and_cast<CDAP_M_Release*>(msg));
30  }
31  //M_RELEASE_Response
32  else if (dynamic_cast<CDAP_M_Release_R*>(msg)) {
33  processMReleaseR(check_and_cast<CDAP_M_Release_R*>(msg));
34  }
35  //M_CREATE_Request
36  else if (dynamic_cast<CDAP_M_Create*>(msg)) {
37  processMCreate(check_and_cast<CDAP_M_Create*>(msg));
38  }
39  //M_CREATE_Response
40  else if (dynamic_cast<CDAP_M_Create_R*>(msg)) {
41  processMCreateR(check_and_cast<CDAP_M_Create_R*>(msg));
42  }
43  //M_DELETE_Request
44  else if (dynamic_cast<CDAP_M_Delete*>(msg)) {
45  processMDelete(check_and_cast<CDAP_M_Delete*>(msg));
46  }
47  //M_DELETE_Request
48  else if (dynamic_cast<CDAP_M_Delete_R*>(msg)) {
49  processMDeleteR(check_and_cast<CDAP_M_Delete_R*>(msg));
50  }
51  //M_WRITE_Request
52  else if (dynamic_cast<CDAP_M_Read*>(msg)) {
53  processMRead(check_and_cast<CDAP_M_Read*>(msg));
54  }
55  //M_WRITE_Response
56  else if (dynamic_cast<CDAP_M_Read_R*>(msg)) {
57  processMReadR(check_and_cast<CDAP_M_Read_R*>(msg));
58  }
59  //M_WRITE_Request
60  else if (dynamic_cast<CDAP_M_Write*>(msg)) {
61  processMWrite(check_and_cast<CDAP_M_Write*>(msg));
62  }
63  //M_WRITE_Response
64  else if (dynamic_cast<CDAP_M_Write_R*>(msg)) {
65  processMWriteR(check_and_cast<CDAP_M_Write_R*>(msg));
66  }
67  //M_START_Request
68  else if (dynamic_cast<CDAP_M_Start*>(msg)) {
69  processMStart(check_and_cast<CDAP_M_Start*>(msg));
70  }
71  //M_START_Response
72  else if (dynamic_cast<CDAP_M_Start_R*>(msg)) {
73  processMStartR(check_and_cast<CDAP_M_Start_R*>(msg));
74  }
75  //M_Stop_Request
76  else if (dynamic_cast<CDAP_M_Stop*>(msg)) {
77  processMStop(check_and_cast<CDAP_M_Stop*>(msg));
78  }
79  //M_Stop_Response
80  else if (dynamic_cast<CDAP_M_Stop_R*>(msg)) {
81  processMStopR(check_and_cast<CDAP_M_Stop_R*>(msg));
82  }
83  delete msg;
84 }
85 
87  infoMessage(msg);
88 }
89 
91  infoMessage(msg);
92 }
93 
95  infoMessage(msg);
96 }
97 
99  infoMessage(msg);
100 }
101 
103  infoMessage(msg);
104 }
105 
107 }
108 
110 }
111 
113  infoMessage(msg);
114 }
115 
117  infoMessage(msg);
118 }
119 
121  infoMessage(msg);
122 }
123 
125  infoMessage(msg);
126 }
127 
129  infoMessage(msg);
130 }
131 
133  infoMessage(msg);
134 }
135 
137  infoMessage(msg);
138 }
139 
141  infoMessage(msg);
142 }
143 
145  infoMessage(msg);
146 }
147 
149  std::ostringstream os;
150  os << "MESSAGE PROCESSING NOT DEFINED!" << endl
151  << "OpCode: " << msg->getOpCode();
152  std::string type;
153  switch (msg->getOpCode()) {
154  case 1: type = "M_CONNECT"; break;
155  case 2: type = "M_CONNECT_R"; break;
156  case 3: type = "M_RELEASE"; break;
157  case 4: type = "M_RELEASE_R"; break;
158  case 5: type = "M_CREATE"; break;
159  case 6: type = "M_CREATE_R"; break;
160  case 7: type = "M_DELETE"; break;
161  case 8: type = "M_DELETE_R"; break;
162  case 9: type = "M_READ"; break;
163  case 10: type = "M_READ_R"; break;
164  case 11: type = "M_CANCELREAD"; break;
165  case 12: type = "M_CANCELREAD_R";break;
166  case 13: type = "M_WRITE"; break;
167  case 14: type = "M_WRITE_R"; break;
168  case 15: type = "M_START"; break;
169  case 16: type = "M_START_R"; break;
170  case 17: type = "M_STOP"; break;
171  case 18: type = "M_STOP_R"; break;
172  case 0:
173  default: type = "UNKNOWNN";
174  }
175 
176  os << type << endl;
177  os << "SrcAddr: " << msg->getSrcAddr() << endl
178  << "DstAddr: " << msg->getDstAddr() << endl
179  << "InvokeId: " << msg->getInvokeID() << endl
180  << "Size: " << msg->getHeaderBitLength() << " bits" << endl;
181  EV << os.str();
182  return os.str();
183 }
184 
186  return false;
187 }
188 
190  std::ostringstream os;
191  os << "Object: '" << obj.objectClass << "'" << endl;
192  EV << os.str();
193  return os.str();
194 }
virtual void processMStart(CDAP_M_Start *msg)
Function crunching supported M_START message.
virtual void processMDelete(CDAP_M_Delete *msg)
Function crunching supported M_DELETE message.
::omnetpp::opp_string objectClass
virtual void processMStopR(CDAP_M_Stop_R *msg)
Function crunching supported M_STOP_R message.
virtual void processMWriteR(CDAP_M_Write_R *msg)
Function crunching supported M_WRITE_R message.
virtual unsigned int getHeaderBitLength() const
virtual Address & getDstAddr()
virtual int32_t getInvokeID() const
virtual void processMCreate(CDAP_M_Create *msg)
Function crunching supported M_CREATE message.
virtual void processMStartR(CDAP_M_Start_R *msg)
Function crunching supported M_START_R message.
virtual bool isMessageProcessable(CDAPMessage *msg)=0
Function checks whether CDAP message can be processed by notifier.
std::string infoMessage(CDAPMessage *msg)
virtual void processMConnect(CDAP_M_Connect *msg)
Function crunching supported M_CONNECT message.
virtual void processMReleaseR(CDAP_M_Release_R *msg)
Function crunching supported M_RELEASE_R message.
virtual void processMReadR(CDAP_M_Read_R *msg)
Function crunching supported M_READ_R message.
virtual int32_t getOpCode() const
std::string infoObject(object_t obj)
virtual void processMWrite(CDAP_M_Write *msg)
Function crunching supported M_WRITE message.
virtual void processMRelease(CDAP_M_Release *msg)
Function crunching supported M_RELEASE message.
virtual void processMDeleteR(CDAP_M_Delete_R *msg)
Function crunching supported M_DELETE_R message.
virtual Address & getSrcAddr()
virtual void processMCreateR(CDAP_M_Create_R *msg)
Function crunching supported M_CREATE_R message.
virtual void receiveMessage(CDAPMessage *msg)
Function checks the type of CDAP message and passes it to appropriate processing method.
virtual void processMConnectR(CDAP_M_Connect_R *msg)
Function crunching supported M_CONNECT_R message.
virtual void processMRead(CDAP_M_Read *msg)
Function crunching supported M_READ message.
virtual void processMStop(CDAP_M_Stop *msg)
Function crunching supported M_STOP message.