RINASim  October 2016
Documentation of framework for OMNeT++
DAFEnrollmentStateTableEntry.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 int VAL_NOCONRETRY = 0;
35 
37  Source(APNamingInfo()), Destination(APNamingInfo()),
38  conStatus(this->CON_NIL),
39  enrollStatus(this->ENROLL_NIL), connectRetries(VAL_NOCONRETRY),
40  immediateDAFEnrollment(false)
41 {
42 }
43 
45  Source(src), Destination(dst),
46  conStatus(status),
47  enrollStatus(ENROLL_NIL), connectRetries(VAL_NOCONRETRY)
48 {
49 }
50 
52  APNamingInfo dst,
55  Source(src), Destination(dst),
56  conStatus(status),
57  enrollStatus(enrstat), connectRetries(VAL_NOCONRETRY)
58 {
59 }
60 
61 /*
62 DAFEnrollmentStateTableEntry::DAFEnrollmentStateTableEntry(Flow* flow) :
63  DAFEnrollmentStateTableEntry(flow->getSrcApni(), flow->getDstApni(),
64  CON_CONNECTPENDING, false)
65 {
66  this->flow = flow;
67 }
68 
69 DAFEnrollmentStateTableEntry::DAFEnrollmentStateTableEntry(Flow* flow, DAFEnrollmentStateTableEntry::CACEConnectionStatus status, bool isInitiator) :
70  DAFEnrollmentStateTableEntry(flow->getSrcApni(), flow->getDstApni(),
71  status, isInitiator)
72 {
73  this->flow = flow;
74 }
75 */
76 
78  //this->flow = NULL;
79  Source = APNamingInfo();
84 }
85 /*
86 Flow* DAFEnrollmentStateTableEntry::getFlow() {
87  return flow;
88 }
89 */
90 
92  return connectRetries;
93 }
94 
97 }
98 
100  this->immediateDAFEnrollment = immediate;
101 }
102 
104  return conStatus;
105 }
106 
108  connectRetries++;
109 }
110 
112  conStatus = status;
113 }
114 
116  enrollStatus = status;
117 }
118 
120  return enrollStatus;
121 }
122 
124  switch(this->conStatus) {
125  case CON_ERROR: return "error";
126  case CON_NIL: return "nil";
127  case CON_FLOWPENDING: return "flow pending";
128  case CON_CONNECTPENDING: return "connect pending";
129  case CON_AUTHENTICATING: return "authenticating";
130  case CON_ESTABLISHED: return "established";
131  case CON_RELEASING: return "releasing";
132 
133  default: return "UNKNOWN";
134  }
135 }
136 
138  switch(this->enrollStatus) {
139  case ENROLL_ERROR: return "error";
140  case ENROLL_NIL: return "nil";
141  case ENROLL_WAIT_START_ENROLLMENT: return "wait start enrollment";
142  case ENROLL_WAIT_START_RESPONSE_ENROLLMENT: return "wait start response enrollment";
143  case ENROLL_WAIT_STOP_ENROLLMENT: return "wait stop enrollment";
144  case ENROLL_WAIT_STOP_RESPONSE_ENROLLMENT: return "wait stop response enrollment";
145  case ENROLL_WAIT_READ_RESPONSE: return "wait read response";
146  case ENROLL_WAIT_START_OPERATION: return "wait start operation";
147  case ENROLL_CREATING_OBJ: return "creating obj";
148  case ENROLL_ENROLLED: return "enrolled";
149 
150  default: return "UNKNOWN";
151  }
152 }
153 
155  std::ostringstream os;
156  if ( !(Source == Destination) ) {
157  os << "Local> " << Source << endl
158  << "Remote> " << Destination << endl;
159  }
160  else {
161  os << Source << " is self-enrolled" << endl;
162  }
163  os << "CACEConnectionStatus: " << this->getCACEConnectionStatusString() << endl;
164  os << "DAFEnrollmentStatus: " << this->getDAFEnrollmentStatusString() << endl;
165  //os << flow->info() << endl;
166  return os.str();
167 }
168 
169 
170 
171 std::ostream& operator <<(std::ostream& os, const DAFEnrollmentStateTableEntry& este) {
172  return os << este.info();
173 }
174 
176  return Source;
177 }
178 
180  Source = local;
181 }
182 
184  return Destination;
185 }
186 
188  Destination = remote;
189 }
190 
const APNamingInfo & getRemote() const
std::string getDAFEnrollmentStatusString() const
std::string getCACEConnectionStatusString() const
APNamingInfo Source
void increaseCurrentConnectRetries()
void setDAFEnrollmentStatus(DAFEnrollmentStateTableEntry::DAFEnrollmentStatus status)
int connectRetries
void setLocal(const APNamingInfo &local)
bool immediateDAFEnrollment
APNamingInfo holds complete naming info for particular application process.
Definition: APNamingInfo.h:43
void setRemote(const APNamingInfo &remote)
std::string info() const
CACEConnectionStatus
DAFEnrollment state table entry .
void setIsImmediateDAFEnrollment(bool immediate)
const APNamingInfo & getLocal() const
const int VAL_NOCONRETRY
DAFEnrollmentStateTableEntry::CACEConnectionStatus getCACEConStatus() const
APNamingInfo Destination
void setCACEConStatus(DAFEnrollmentStateTableEntry::CACEConnectionStatus status)
bool getIsImmediateDAFEnrollment()
DAFEnrollmentStateTableEntry()
DAFEnrollmentStatus
int getCurrentConnectRetries()
virtual ~DAFEnrollmentStateTableEntry()
DAFEnrollmentStatus enrollStatus
DAFEnrollmentStateTableEntry::DAFEnrollmentStatus getDAFEnrollmentStatus() const
std::ostream & operator<<(std::ostream &os, const DAFEnrollmentStateTableEntry &este)
CACEConnectionStatus conStatus