RINASim  October 2016
Documentation of framework for OMNeT++
EnrollmentStateTableEntry.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 
32 
33 const int VAL_NOCONRETRY = 0;
34 
36  Source(APNamingInfo()), Destination(APNamingInfo()),
37  conStatus(this->CON_NIL),
38  enrollStatus(this->ENROLL_NIL), connectRetries(VAL_NOCONRETRY),
39  immediateEnrollment(false)
40 {
41 }
42 
44  Source(src), Destination(dst),
45  conStatus(status),
46  enrollStatus(ENROLL_NIL), connectRetries(VAL_NOCONRETRY)
47 {
48 }
49 
51  APNamingInfo dst,
54  Source(src), Destination(dst),
55  conStatus(status),
56  enrollStatus(enrstat), connectRetries(VAL_NOCONRETRY)
57 {
58 }
59 
60 /*
61 EnrollmentStateTableEntry::EnrollmentStateTableEntry(Flow* flow) :
62  EnrollmentStateTableEntry(flow->getSrcApni(), flow->getDstApni(),
63  CON_CONNECTPENDING, false)
64 {
65  this->flow = flow;
66 }
67 
68 EnrollmentStateTableEntry::EnrollmentStateTableEntry(Flow* flow, EnrollmentStateTableEntry::CACEConnectionStatus status, bool isInitiator) :
69  EnrollmentStateTableEntry(flow->getSrcApni(), flow->getDstApni(),
70  status, isInitiator)
71 {
72  this->flow = flow;
73 }
74 */
75 
77  //this->flow = NULL;
78  Source = APNamingInfo();
83 }
84 /*
85 Flow* EnrollmentStateTableEntry::getFlow() {
86  return flow;
87 }
88 */
89 
91  return connectRetries;
92 }
93 
95  return immediateEnrollment;
96 }
97 
99  this->immediateEnrollment = immediate;
100 }
101 
103  return conStatus;
104 }
105 
107  connectRetries++;
108 }
109 
111  conStatus = status;
112 }
113 
115  enrollStatus = status;
116 }
117 
119  return enrollStatus;
120 }
121 
123  switch(this->conStatus) {
124  case CON_ERROR: return "error";
125  case CON_NIL: return "nil";
126  case CON_FLOWPENDING: return "flow pending";
127  case CON_CONNECTPENDING: return "connect pending";
128  case CON_AUTHENTICATING: return "authenticating";
129  case CON_ESTABLISHED: return "established";
130  case CON_RELEASING: return "releasing";
131 
132  default: return "UNKNOWN";
133  }
134 }
135 
137  switch(this->enrollStatus) {
138  case ENROLL_ERROR: return "error";
139  case ENROLL_NIL: return "nil";
140  case ENROLL_WAIT_START_ENROLLMENT: return "wait start enrollment";
141  case ENROLL_WAIT_START_RESPONSE_ENROLLMENT: return "wait start response enrollment";
142  case ENROLL_WAIT_STOP_ENROLLMENT: return "wait stop enrollment";
143  case ENROLL_WAIT_STOP_RESPONSE_ENROLLMENT: return "wait stop response enrollment";
144  case ENROLL_WAIT_READ_RESPONSE: return "wait read response";
145  case ENROLL_WAIT_START_OPERATION: return "wait start operation";
146  case ENROLL_CREATING_OBJ: return "creating obj";
147  case ENROLL_ENROLLED: return "enrolled";
148 
149  default: return "UNKNOWN";
150  }
151 }
152 
153 std::string EnrollmentStateTableEntry::info() const {
154  std::ostringstream os;
155  if ( !(Source == Destination) ) {
156  os << "Local> " << Source << endl
157  << "Remote> " << Destination << endl;
158  }
159  else {
160  os << Source << " is self-enrolled" << endl;
161  }
162  os << "CACEConnectionStatus: " << this->getCACEConnectionStatusString() << endl;
163  os << "EnrollmentStatus: " << this->getEnrollmentStatusString() << endl;
164  //os << flow->info() << endl;
165  return os.str();
166 }
167 
168 
169 
170 std::ostream& operator <<(std::ostream& os, const EnrollmentStateTableEntry& este) {
171  return os << este.info();
172 }
173 
175  return Source;
176 }
177 
179  Source = local;
180 }
181 
183  return Destination;
184 }
185 
187  Destination = remote;
188 }
189 
Enrollment state table entry .
EnrollmentStatus enrollStatus
void setEnrollmentStatus(EnrollmentStateTableEntry::EnrollmentStatus status)
int getCurrentConnectRetries()
CACEConnectionStatus
void setRemote(const APNamingInfo &remote)
std::string getCACEConnectionStatusString() const
const int VAL_NOCONRETRY
EnrollmentStatus
CACEConnectionStatus conStatus
virtual ~EnrollmentStateTableEntry()
int connectRetries
void increaseCurrentConnectRetries()
void setIsImmediateEnrollment(bool immediate)
const APNamingInfo & getLocal() const
std::string info() const
APNamingInfo holds complete naming info for particular application process.
Definition: APNamingInfo.h:43
void setLocal(const APNamingInfo &local)
const APNamingInfo & getRemote() const
EnrollmentStateTableEntry()
void setCACEConStatus(EnrollmentStateTableEntry::CACEConnectionStatus status)
bool immediateEnrollment
APNamingInfo Destination
bool getIsImmediateEnrollment()
EnrollmentStateTableEntry::CACEConnectionStatus getCACEConStatus() const
std::ostream & operator<<(std::ostream &os, const EnrollmentStateTableEntry &este)
std::string getEnrollmentStatusString() const
APNamingInfo Source
EnrollmentStateTableEntry::EnrollmentStatus getEnrollmentStatus() const