RINASim  October 2016
Documentation of framework for OMNeT++
DAFEnrollmentStateTable.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 
33 
34 const char* DAF_DAF_ELEM_ENSTATETAB = "DAFEnrollmentStateTable";
35 const char* DAF_ELEM_ENSTATE = "State";
36 const char* DAF_ATTR_CACE = "cace";
37 const char* DAF_ATTR_ENROLL = "enroll";
38 
40 
42 {
43  //Parse XML config
44  parseConfig(par(PAR_CONFIGDATA).xmlValue());
45 
46  //Init watchers
47  WATCH_LIST(StateTable);
48 }
49 
51  return StateTable.empty();
52 }
53 
55  StateTable.push_back(entry);
56 }
57 
59  for(auto it = StateTable.begin(); it != StateTable.end(); ++it) {
61  if (est.getRemote().getApn() == apn &&
62  strstr(est.getRemote().getAename().c_str(), "mgmt")) {
63  return &(*it);
64  }
65  }
66  return NULL;
67 }
68 
70  for(auto it = StateTable.begin(); it != StateTable.end(); ++it) {
72 
73  if (est.getRemote().getApn() == apni.getApn() &&
74  est.getRemote().getAeinstance() == apni.getAeinstance() &&
75  est.getRemote().getAename() == apni.getAename() &&
76  est.getRemote().getApinstance() == apni.getApinstance()) {
77  return &(*it);
78  }
79  }
80  return NULL;
81 }
82 
84 {
85 
86 }
87 
89  for(auto it = StateTable.begin(); it != StateTable.end(); ++it) {
91  if (est.getLocal().getApn() == myApn
93  && strstr(est.getRemote().getAename().c_str(), "mgmt")) {
94  return true;
95  }
96  }
97  return false;
98 }
99 
100 void DAFEnrollmentStateTable::parseConfig(cXMLElement* config) {
101  cXMLElement* mainTag = NULL;
102  if (config != NULL && config->hasChildren() && config->getFirstChildWithTag(DAF_DAF_ELEM_ENSTATETAB))
103  mainTag = config->getFirstChildWithTag(DAF_DAF_ELEM_ENSTATETAB);
104  else {
105  EV << "configData parameter not initialized!" << endl;
106  return;
107  }
108 
109  cXMLElementList enrll = mainTag->getChildrenByTagName(DAF_ELEM_ENSTATE);
110  for (cXMLElementList::const_iterator it = enrll.begin(); it != enrll.end(); ++it) {
111  cXMLElement* m = *it;
112 
113  if (!(m->getAttribute(ATTR_SRC))
114  && !(m->getAttribute(ATTR_DST))
115  ) {
116  EV << "\nError when parsing DAFEnrollmentState record" << endl;
117  continue;
118  }
119 
120 
121  APNamingInfo src = APNamingInfo(APN(m->getAttribute(ATTR_SRC)));
122  APNamingInfo dst = APNamingInfo(APN(m->getAttribute(ATTR_DST)));
123 
124 
126  if ( m->getAttribute(DAF_ATTR_CACE) ) {
127  std::string statstr(m->getAttribute(DAF_ATTR_CACE));
128  if (!statstr.compare("CON_ERROR"))
130  else if (!statstr.compare("CON_NIL"))
132  else if (!statstr.compare("CON_FLOWPENDING"))
134  else if (!statstr.compare("CON_CONNECTPENDING"))
136  else if (!statstr.compare("CON_AUTHENTICATING"))
138  else if (!statstr.compare("CON_ESTABLISHED"))
140  else if (!statstr.compare("CON_RELEASING"))
142  }
143 
145  if ( m->getAttribute(DAF_ATTR_ENROLL) ) {
146  std::string enrlstr(m->getAttribute(DAF_ATTR_ENROLL));
147  if (!enrlstr.compare("ENROLL_ERROR"))
149  else if (!enrlstr.compare("ENROLL_NIL"))
151  else if (!enrlstr.compare("ENROLL_WAIT_START_ENROLLMENT"))
153  else if (!enrlstr.compare("ENROLL_WAIT_START_RESPONSE_ENROLLMENT"))
155  else if (!enrlstr.compare("ENROLL_WAIT_STOP_ENROLLMENT"))
157  else if (!enrlstr.compare("ENROLL_WAIT_STOP_RESPONSE_ENROLLMENT"))
159  else if (!enrlstr.compare("ENROLL_WAIT_READ_RESPONSE"))
161  else if (!enrlstr.compare("ENROLL_WAIT_START_OPERATION"))
163  else if (!enrlstr.compare("ENROLL_CREATING_OBJ"))
165  else if (!enrlstr.compare("ENROLL_ENROLLED"))
167  }
168 
169  insert(DAFEnrollmentStateTableEntry(src, dst, stat, enrl));
170  }
171 }
const APNamingInfo & getRemote() const
const char * DAF_ATTR_CACE
DAFEnrollmentStateTableEntry * findEntryByDstAPNI(const APNamingInfo &apni)
Define_Module(DAFEnrollmentStateTable)
Application Process Name class.
Definition: APN.h:36
DAFEnrollmentStateTableEntry * findEntryByDstAPN(const APN &apn)
const char * DAF_DAF_ELEM_ENSTATETAB
const char * ATTR_SRC
const char * DAF_ELEM_ENSTATE
const char * PAR_CONFIGDATA
const std::string & getAename() const
Getter of AE name.
Definition: APNamingInfo.h:110
const APN & getApn() const
Getter of APN.
Definition: APNamingInfo.h:142
void insert(DAFEnrollmentStateTableEntry entry)
bool isEnrolled(const APN &myApn)
APNamingInfo holds complete naming info for particular application process.
Definition: APNamingInfo.h:43
DAFEnrollStateTable StateTable
const char * DAF_ATTR_ENROLL
DAFEnrollment state table .
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
void parseConfig(cXMLElement *config)
virtual void handleMessage(cMessage *msg)
const char * ATTR_DST
DAFEnrollmentStateTableEntry::DAFEnrollmentStatus getDAFEnrollmentStatus() const