RINASim  October 2016
Documentation of framework for OMNeT++
CACEGeneric.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 <CACEGeneric.h>
17 
19 
20 }
21 
23 }
24 
26  this->outerClass = outerClass;
27  this->StateTable = check_and_cast<DAFEnrollmentStateTable*>(this->outerClass->getModuleByPath("^.^.^.enrollment.enrollmentStateTable"));
28 }
29 
31  //Enter_Method("authenticate()");
32 
33  //check and validate expected auth type
34  if (msg->getAuth().authType == this->outerClass->authType) {
35  //none auth option
36  if (msg->getAuth().authType == AUTH_NONE) {
37  processConResPosi(entry, msg);
38  return;
39 
40  }
41  //passwd auth option
42  else if (msg->getAuth().authType == AUTH_PASSWD) {
43  //correct passwd
44  if (!strcmp(msg->getAuth().authValue.authPassword.c_str(), this->outerClass->authPassword.c_str())) {
45  processConResPosi(entry, msg);
46  return;
47  }
48  }
49  //TODO: support for other options
50  }
51 
52  //not valid auth send negative response
53  processConResNega(entry, msg);
54 }
55 
57  //Enter_Method("startCACE()");
58 
60  StateTable->insert(entryr);
61 
62 
63  auto entry = StateTable->findEntryByDstAPNI(flow->getDstApni());
64 
66 
67  authValue_t aValue;
68  aValue.authName = this->outerClass->authName;
69  aValue.authPassword = this->outerClass->authPassword;
70  aValue.authOther = this->outerClass->authOther;
71 
72  auth_t auth;
73  auth.authType = this->outerClass->authType;
74  auth.authValue = aValue;
75 
76  msg->setAuth(auth);
77  msg->setAbsSyntax(GPB);
78 
79  APNamingInfo src = APNamingInfo(entry->getLocal().getApn(),
80  entry->getLocal().getApinstance(),
81  entry->getLocal().getAename(),
82  entry->getLocal().getAeinstance());
83 
84  APNamingInfo dst = APNamingInfo(entry->getRemote().getApn(),
85  entry->getRemote().getApinstance(),
86  entry->getRemote().getAename(),
87  entry->getRemote().getAeinstance());
88  /*
89  * XXX: Vesely@Jerabek> Removing unnecessary *.msg ADT when there exists
90  * exactly the same ADT in RINASim source codes.
91  naming_t dst;
92  dst.AEInst = entry.getRemote().getAeinstance();
93  dst.AEName = entry.getRemote().getAename();
94  dst.ApInst = entry.getRemote().getApinstance();
95  dst.ApName = entry.getRemote().getApn().getName();
96 
97  naming_t src;
98  src.AEInst = entry.getLocal().getAeinstance();
99  src.AEName = entry.getLocal().getAename();
100  src.ApInst = entry.getLocal().getApinstance();
101  src.ApName = entry.getLocal().getApn().getName();
102  */
103 
104  msg->setSrc(src);
105  msg->setDst(dst);
106 
107  msg->setSrcAddr(Address(entry->getLocal().getApn()));
108  msg->setDstAddr(Address(entry->getRemote().getApn()));
109 
110  //send data to ribd to send
112 }
113 
115  //Enter_Method("insertStateTableEntry()");
116  //insert only first flow created (management flow)
117  if(StateTable->findEntryByDstAPNI(flow->getDstApni()) != NULL) {
118  return;
119  }
121 }
122 
124  //Enter_Method("receivePositiveConnectResponse()");
125 
126  //signalizeEnrolled();
127 
128  /* this is commented only for testing ---> refactoring of adress is need to be done*/
129  CDAP_M_Connect_R* cmsg = check_and_cast<CDAP_M_Connect_R*>(msg);
131  cmsg->getSrc().getApn(),
132  cmsg->getSrc().getApinstance(),
133  cmsg->getSrc().getAename(),
134  cmsg->getSrc().getAeinstance()));
135 
136  //check appropriate state
137  if (entry->getCACEConStatus() != DAFEnrollmentStateTableEntry::CON_AUTHENTICATING) {
138  //TODO: send M_Release and invoke deallocate
139  return;
140  }
141 
143 
145 }
146 
148  //Enter_Method("receiveNegativeConnectResponse()");
149 
150  CDAP_M_Connect_R* cmsg = check_and_cast<CDAP_M_Connect_R*>(msg);
152  cmsg->getSrc().getApn(),
153  cmsg->getSrc().getApinstance(),
154  cmsg->getSrc().getAename(),
155  cmsg->getSrc().getAeinstance()));
156 
157  //check appropriate state
158  if (entry->getCACEConStatus() != DAFEnrollmentStateTableEntry::CON_AUTHENTICATING) {
159  //TODO: send M_Release and invoke deallocate
160  return;
161  }
162 
163  if (this->outerClass->maxConRetries <= entry->getCurrentConnectRetries()) {
165  //TODO: send release and deallocate
166  return;
167  }
168 
169 
170  entry->setCACEConStatus(DAFEnrollmentStateTableEntry::CON_CONNECTPENDING);
171  entry->increaseCurrentConnectRetries();
172  //create and send new connect retry
173  processNewConReq(entry);
174 }
175 
177  //Enter_Method("receiveConnectRequest()");
178 
179  CDAP_M_Connect* cmsg = check_and_cast<CDAP_M_Connect*>(msg);
180 
181  auto ent = DAFEnrollmentStateTableEntry(
183  StateTable->insert(ent);
184 
186  cmsg->getSrc().getApn(),
187  cmsg->getSrc().getApinstance(),
188  cmsg->getSrc().getAename(),
189  cmsg->getSrc().getAeinstance()));
190 
191  if (!entry) {
192  EV << "DAFEnrollment status not found for "
193  << cmsg->getSrc().getApn() << endl;
194  return;
195  }
196 
197  //check appropriate state
199  //TODO: send M_Release and invoke deallocate
200  return;
201  }
202 
203  //check if message is valid
204  if (cmsg->getAbsSyntax() != GPB) {
205  this->processConResNega(entry, cmsg);
206  return;
207  }
208 
210 
211  authenticate(entry, cmsg);
212 }
213 
216  CDAP_M_Connect* cmsg1 = check_and_cast<CDAP_M_Connect*>(cmsg);
217 
218  APNamingInfo src = APNamingInfo(entry->getLocal().getApn(),
219  entry->getLocal().getApinstance(),
220  entry->getLocal().getAename(),
221  entry->getLocal().getAeinstance());
222 
223  APNamingInfo dst = APNamingInfo(entry->getRemote().getApn(),
224  entry->getRemote().getApinstance(),
225  entry->getRemote().getAename(),
226  entry->getRemote().getAeinstance());
227 
228  result_t result;
229  result.resultValue = R_SUCCESS;
230 
231  auth_t auth;
232  auth.authType = cmsg1->getAuth().authType;
233  auth.authValue = cmsg1->getAuth().authValue;
234 
235  msg->setAbsSyntax(GPB);
236  msg->setResult(result);
237  msg->setAuth(auth);
238 
239  msg->setSrc(src);
240  msg->setDst(dst);
241 
242  msg->setSrcAddr(Address(entry->getLocal().getApn()));
243  msg->setDstAddr(Address(entry->getRemote().getApn()));
244 
245  //send data to ribd to send
247 
249  //entry->setDAFEnrollmentStatus(DAFEnrollmentStateTableEntry::ENROLL_WAIT_START_ENROLLMENT);
250 }
251 
254  CDAP_M_Connect* cmsg1 = check_and_cast<CDAP_M_Connect*>(cmsg);
255 
256  APNamingInfo src = APNamingInfo(entry->getLocal().getApn(),
257  entry->getLocal().getApinstance(),
258  entry->getLocal().getAename(),
259  entry->getLocal().getAeinstance());
260 
261  APNamingInfo dst = APNamingInfo(entry->getRemote().getApn(),
262  entry->getRemote().getApinstance(),
263  entry->getRemote().getAename(),
264  entry->getRemote().getAeinstance());
265 
266  result_t result;
267  result.resultValue = R_FAIL;
268 
269  auth_t auth;
270  auth.authType = cmsg1->getAuth().authType;
271  auth.authValue = cmsg1->getAuth().authValue;
272 
273  msg->setAbsSyntax(GPB);
274  msg->setResult(result);
275  msg->setAuth(auth);
276 
277  msg->setSrc(src);
278  msg->setDst(dst);
279 
280  msg->setSrcAddr(Address(entry->getLocal().getApn()));
281  msg->setDstAddr(Address(entry->getRemote().getApn()));
282 
283  //send data to send to ribd
285 
287 
288  //increase number of connects
290 }
291 
293  //Enter_Method("processNewConReq()");
294 
295  //TODO: probably change values, this is retry
296 
298 
299  authValue_t aValue;
300  aValue.authName = this->outerClass->authName;
301  aValue.authPassword = this->outerClass->authPassword;
302  aValue.authOther = this->outerClass->authOther;
303 
304  auth_t auth;
305  auth.authType = this->outerClass->authType;
306  auth.authValue = aValue;
307 
308  msg->setAuth(auth);
309  msg->setAbsSyntax(GPB);
310 
311  APNamingInfo src = APNamingInfo(entry->getLocal().getApn(),
312  entry->getLocal().getApinstance(),
313  entry->getLocal().getAename(),
314  entry->getLocal().getAeinstance());
315 
316  APNamingInfo dst = APNamingInfo(entry->getRemote().getApn(),
317  entry->getRemote().getApinstance(),
318  entry->getRemote().getAename(),
319  entry->getRemote().getAeinstance());
320 
321  msg->setSrc(src);
322  msg->setDst(dst);
323 
324  msg->setSrcAddr(Address(entry->getLocal().getApn()));
325  msg->setDstAddr(Address(entry->getRemote().getApn()));
326 
327  //send data to ribd to send
329 
330  //change state to auth after send retry
332 }
void processConResPosi(DAFEnrollmentStateTableEntry *entry, CDAPMessage *cmsg)
Definition: CACEGeneric.cc:214
virtual int32_t getAbsSyntax() const
const APNamingInfo & getRemote() const
void authenticate(DAFEnrollmentStateTableEntry *entry, CDAP_M_Connect *msg)
Definition: CACEGeneric.cc:30
Class representing flow object with attributes from specs.
Definition: Flow.h:45
const APNamingInfo & getSrcApni() const
Gets read-only source APNamingInfo.
Definition: Flow.cc:134
void receivePositiveConnectResponse(CDAPMessage *msg)
Definition: CACEGeneric.cc:123
virtual void setAuth(const auth_t &auth)
DAFEnrollmentStateTableEntry * findEntryByDstAPNI(const APNamingInfo &apni)
virtual void setAuth(const auth_t &auth)
void CACEFinished()
Definition: AE.cc:214
Definition: AE.h:44
AE * outerClass
Definition: CACEGeneric.h:47
virtual APNamingInfo & getDst()
int maxConRetries
Definition: AEBase.h:102
virtual void setSrcAddr(const Address &srcAddr)
void processConResNega(DAFEnrollmentStateTableEntry *entry, CDAPMessage *cmsg)
Definition: CACEGeneric.cc:252
virtual void setAbsSyntax(int32_t absSyntax)
void signalizeSendData(cMessage *msg)
Definition: AE.cc:563
virtual void setDst(const APNamingInfo &dst)
virtual void setAbsSyntax(int32_t absSyntax)
void increaseCurrentConnectRetries()
::omnetpp::opp_string authName
authValue_t authValue
const char * DAF_MSG_CONREQRETRY
Definition: CACEBase.cc:19
std::string authName
Definition: AEBase.h:99
const std::string & getAename() const
Getter of AE name.
Definition: APNamingInfo.h:110
void startCACE(Flow *flow)
Definition: CACEGeneric.cc:56
const char * DAF_MSG_CONRESPOS
Definition: CACEBase.cc:20
const APN & getApn() const
Getter of APN.
Definition: APNamingInfo.h:142
unsigned char authType
void insert(DAFEnrollmentStateTableEntry entry)
virtual void setDst(const APNamingInfo &dst)
const char * DAF_MSG_CONREQ
Definition: CACEBase.cc:18
APNamingInfo holds complete naming info for particular application process.
Definition: APNamingInfo.h:43
void receiveConnectRequest(CDAPMessage *msg)
Definition: CACEGeneric.cc:176
virtual ~CACEGeneric()
Definition: CACEGeneric.cc:22
virtual auth_t & getAuth()
DAFEnrollmentStateTable * StateTable
Definition: CACEBase.h:52
void processNewConReq(DAFEnrollmentStateTableEntry *entry)
Definition: CACEGeneric.cc:292
std::string authOther
Definition: AEBase.h:101
std::string authPassword
Definition: AEBase.h:100
const APNamingInfo & getLocal() const
const std::string & getAeinstance() const
Getter of AE-instance attribute.
Definition: APNamingInfo.h:94
const std::string & getApinstance() const
Getter of AP-instance id.
Definition: APNamingInfo.h:126
DAFEnrollmentStateTableEntry::CACEConnectionStatus getCACEConStatus() const
virtual APNamingInfo & getSrc()
void insertStateTableEntry(Flow *flow)
Definition: CACEGeneric.cc:114
void setCACEConStatus(DAFEnrollmentStateTableEntry::CACEConnectionStatus status)
virtual void setDstAddr(const Address &dstAddr)
int authType
Definition: AEBase.h:98
virtual void setSrc(const APNamingInfo &src)
virtual void setSrc(const APNamingInfo &src)
::omnetpp::opp_string authPassword
int32_t resultValue
::omnetpp::opp_string authOther
virtual APNamingInfo & getSrc()
virtual void setResult(const result_t &result)
Address class holds IPC Process identification.
Definition: Address.h:42
void receiveNegativeConnectResponse(CDAPMessage *msg)
Definition: CACEGeneric.cc:147
const APNamingInfo & getDstApni() const
Gets read-only destination APNamingInfo.
Definition: Flow.cc:102
const char * DAF_MSG_CONRESNEG
Definition: CACEBase.cc:21