![]() |
User Manual, Developers Guide and API Documentation |
![]() |
00001 /******************************************************************************* 00002 * This file is part of openWNS (open Wireless Network Simulator) 00003 * _____________________________________________________________________________ 00004 * 00005 * Copyright (C) 2004-2007 00006 * Chair of Communication Networks (ComNets) 00007 * Kopernikusstr. 16, D-52074 Aachen, Germany 00008 * phone: ++49-241-80-27910, 00009 * fax: ++49-241-80-22242 00010 * email: info@openwns.org 00011 * www: http://www.openwns.org 00012 * _____________________________________________________________________________ 00013 * 00014 * openWNS is free software; you can redistribute it and/or modify it under the 00015 * terms of the GNU Lesser General Public License version 2 as published by the 00016 * Free Software Foundation; 00017 * 00018 * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY 00019 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 00020 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00021 * details. 00022 * 00023 * You should have received a copy of the GNU Lesser General Public License 00024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00025 * 00026 ******************************************************************************/ 00027 00028 #ifndef TCP_CONNECTIONCONTROL_HPP 00029 #define TCP_CONNECTIONCONTROL_HPP 00030 00031 #include <WNS/fsm/FSM.hpp> 00032 00033 00034 namespace tcp { 00035 00040 class ConnectionControlSignals 00041 { 00042 public: 00043 virtual ConnectionControlSignals* 00044 syn() = 0; 00045 00046 virtual ConnectionControlSignals* 00047 syn_ack() = 0; 00048 00049 virtual ConnectionControlSignals* 00050 ack() = 0; 00051 00052 virtual ConnectionControlSignals* 00053 fin() = 0; 00054 00055 virtual ConnectionControlSignals* 00056 rst() = 0; 00057 00058 virtual ConnectionControlSignals* 00059 fin_ack() = 0; 00060 00061 virtual 00062 ~ConnectionControlSignals(){} 00063 00064 protected: 00068 ConnectionControlSignals(){} 00069 00070 private: 00071 // disallow copy contructor 00072 ConnectionControlSignals(const ConnectionControlSignals&); 00073 }; 00074 00075 struct ConnectionVariables 00076 { 00077 ConnectionVariables() : activeOpen(false), 00078 urg(false), 00079 ack(false), 00080 psh(false), 00081 rst(false), 00082 syn(false), 00083 fin(false) 00084 {} 00085 00093 bool activeOpen; 00094 bool urg; 00095 bool ack; 00096 bool psh; 00097 bool rst; 00098 bool syn; 00099 bool fin; 00100 00101 void resetTCPFlags() 00102 { 00103 urg = false; 00104 ack = false; 00105 psh = false; 00106 rst = false; 00107 syn = false; 00108 fin = false; 00109 } 00110 }; 00111 00112 typedef wns::fsm::FSM<ConnectionControlSignals, ConnectionVariables> ConnectionControlInterface; 00113 00114 class Closed : 00115 public ConnectionControlInterface::StateInterface 00116 { 00117 public: 00118 Closed(ConnectionControlInterface* cci) : ConnectionControlInterface::StateInterface(cci, "tcp_fsm_closed") 00119 {} 00120 00121 virtual StateInterface* 00122 syn(); 00123 00124 virtual StateInterface* 00125 syn_ack(); 00126 00127 virtual StateInterface* 00128 ack(); 00129 00130 virtual StateInterface* 00131 fin(); 00132 00133 virtual StateInterface* 00134 rst(); 00135 00136 virtual StateInterface* 00137 fin_ack(); 00138 }; 00139 00140 class Listen : 00141 public ConnectionControlInterface::StateInterface 00142 { 00143 public: 00144 Listen(ConnectionControlInterface* cci) : ConnectionControlInterface::StateInterface(cci, "tcp_fsm_listen") 00145 {} 00146 00147 virtual StateInterface* 00148 syn(); 00149 00150 virtual StateInterface* 00151 syn_ack(); 00152 00153 virtual StateInterface* 00154 ack(); 00155 00156 virtual StateInterface* 00157 fin(); 00158 00159 virtual StateInterface* 00160 rst(); 00161 00162 virtual StateInterface* 00163 fin_ack(); 00164 }; 00165 00166 class Syn_rcvd : 00167 public ConnectionControlInterface::StateInterface 00168 { 00169 public: 00170 Syn_rcvd(ConnectionControlInterface* cci) : ConnectionControlInterface::StateInterface(cci, "tcp_fsm_syn_rcvd") 00171 {} 00172 00173 virtual StateInterface* 00174 syn(); 00175 00176 virtual StateInterface* 00177 syn_ack(); 00178 00179 virtual StateInterface* 00180 ack(); 00181 00182 virtual StateInterface* 00183 fin(); 00184 00185 virtual StateInterface* 00186 rst(); 00187 00188 virtual StateInterface* 00189 fin_ack(); 00190 }; 00191 00192 class Syn_sent : 00193 public ConnectionControlInterface::StateInterface 00194 { 00195 public: 00196 Syn_sent(ConnectionControlInterface* cci) : ConnectionControlInterface::StateInterface(cci, "tcp_fsm_syn_sent") 00197 {} 00198 00199 virtual StateInterface* 00200 syn(); 00201 00202 virtual StateInterface* 00203 syn_ack(); 00204 00205 virtual StateInterface* 00206 ack(); 00207 00208 virtual StateInterface* 00209 fin(); 00210 00211 virtual StateInterface* 00212 rst(); 00213 00214 virtual StateInterface* 00215 fin_ack(); 00216 }; 00217 00218 class Established : public ConnectionControlInterface::StateInterface 00219 { 00220 public: 00221 Established(ConnectionControlInterface* cci) : ConnectionControlInterface::StateInterface(cci, "tcp_fsm_established") 00222 {} 00223 00224 virtual StateInterface* 00225 syn(); 00226 00227 virtual StateInterface* 00228 syn_ack(); 00229 00230 virtual StateInterface* 00231 ack(); 00232 00233 virtual StateInterface* 00234 fin(); 00235 00236 virtual StateInterface* 00237 rst(); 00238 00239 virtual StateInterface* 00240 fin_ack(); 00241 }; 00242 00243 class Close_wait : public ConnectionControlInterface::StateInterface 00244 { 00245 public: 00246 Close_wait(ConnectionControlInterface* cci) : ConnectionControlInterface::StateInterface(cci, "tcp_fsm_close_wait") 00247 {} 00248 00249 virtual StateInterface* 00250 syn(); 00251 00252 virtual StateInterface* 00253 syn_ack(); 00254 00255 virtual StateInterface* 00256 ack(); 00257 00258 virtual StateInterface* 00259 fin(); 00260 00261 virtual StateInterface* 00262 rst(); 00263 00264 virtual StateInterface* 00265 fin_ack(); 00266 }; 00267 00268 class Last_ack : public ConnectionControlInterface::StateInterface 00269 { 00270 public: 00271 Last_ack(ConnectionControlInterface* cci) : ConnectionControlInterface::StateInterface(cci, "tcp_fsm_last_ack") 00272 {} 00273 00274 virtual StateInterface* 00275 syn(); 00276 00277 virtual StateInterface* 00278 syn_ack(); 00279 00280 virtual StateInterface* 00281 ack(); 00282 00283 virtual StateInterface* 00284 fin(); 00285 00286 virtual StateInterface* 00287 rst(); 00288 00289 virtual StateInterface* 00290 fin_ack(); 00291 }; 00292 00293 class Fin_wait_1 : public ConnectionControlInterface::StateInterface 00294 { 00295 public: 00296 Fin_wait_1(ConnectionControlInterface* cci) : ConnectionControlInterface::StateInterface(cci, "tcp_fsm_fin_wait_1") 00297 {} 00298 00299 virtual StateInterface* 00300 syn(); 00301 00302 virtual StateInterface* 00303 syn_ack(); 00304 00305 virtual StateInterface* 00306 ack(); 00307 00308 virtual StateInterface* 00309 fin(); 00310 00311 virtual StateInterface* 00312 rst(); 00313 00314 virtual StateInterface* 00315 fin_ack(); 00316 }; 00317 00318 class Closing : public ConnectionControlInterface::StateInterface 00319 { 00320 public: 00321 Closing(ConnectionControlInterface* cci) : ConnectionControlInterface::StateInterface(cci, "tcp_fsm_closing") 00322 {} 00323 00324 virtual StateInterface* 00325 syn(); 00326 00327 virtual StateInterface* 00328 syn_ack(); 00329 00330 virtual StateInterface* 00331 ack(); 00332 00333 virtual StateInterface* 00334 fin(); 00335 00336 virtual StateInterface* 00337 rst(); 00338 00339 virtual StateInterface* 00340 fin_ack(); 00341 }; 00342 00343 class Fin_wait_2 : public ConnectionControlInterface::StateInterface 00344 { 00345 public: 00346 Fin_wait_2(ConnectionControlInterface* cci) : ConnectionControlInterface::StateInterface(cci, "tcp_fsm_fin_wait_2") 00347 {} 00348 00349 virtual StateInterface* 00350 syn(); 00351 00352 virtual StateInterface* 00353 syn_ack(); 00354 00355 virtual StateInterface* 00356 ack(); 00357 00358 virtual StateInterface* 00359 fin(); 00360 00361 virtual StateInterface* 00362 rst(); 00363 00364 virtual StateInterface* 00365 fin_ack(); 00366 }; 00367 00368 class Time_wait : public ConnectionControlInterface::StateInterface 00369 { 00370 public: 00371 Time_wait(ConnectionControlInterface* cci) : ConnectionControlInterface::StateInterface(cci, "tcp_fsm_time_wait") 00372 {} 00373 00374 virtual StateInterface* 00375 syn(); 00376 00377 virtual StateInterface* 00378 syn_ack(); 00379 00380 virtual StateInterface* 00381 ack(); 00382 00383 virtual StateInterface* 00384 fin(); 00385 00386 virtual StateInterface* 00387 rst(); 00388 00389 virtual StateInterface* 00390 fin_ack(); 00391 }; 00392 } // namespace tcp 00393 00394 00395 #endif // NOT defined TCP_CONNECTIONCONTROL_HPP
1.5.5