00001 // 00002 // Copyright (C) 2006 Sam Jansen, Andras Varga, 2009 Zoltan Bojthe 00003 // 00004 // This program is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU General Public License 00006 // as published by the Free Software Foundation; either version 2 00007 // of the License, or (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 // 00018 00019 00020 #ifndef __TCP_NSC_CONNECTION_H 00021 #define __TCP_NSC_CONNECTION_H 00022 00023 #include <omnetpp.h> 00024 #include "IPvXAddress.h" 00025 00026 // forward declarations: 00027 class TCP_NSC; 00028 class TCPConnectInfo; 00029 class TCP_NSC_ReceiveQueue; 00030 class TCP_NSC_SendQueue; 00031 class INetStack; 00032 class INetStreamSocket; 00033 00037 class INET_API TCP_NSC_Connection 00038 { 00039 public: 00040 class SockAddr 00041 { 00042 public: 00043 SockAddr() : ipAddrM(),portM(-1) {} 00044 IPvXAddress ipAddrM; 00045 unsigned short portM; 00046 00047 inline bool operator<(const SockAddr& b) const 00048 { 00049 if (ipAddrM == b.ipAddrM) 00050 return portM < b.portM; 00051 return ipAddrM < b.ipAddrM; 00052 } 00053 00054 inline bool operator==(const SockAddr& b) const 00055 { 00056 return (ipAddrM == b.ipAddrM) && (portM == b.portM); 00057 } 00058 }; 00059 00060 class SockPair 00061 { 00062 public: 00063 SockAddr remoteM; 00064 SockAddr localM; 00065 00066 inline bool operator<(const SockPair& b) const 00067 { 00068 if (remoteM == b.remoteM) 00069 return localM < b.localM; 00070 return remoteM < b.remoteM; 00071 } 00072 00073 inline bool operator==(const SockPair& b) const 00074 { 00075 return (remoteM == b.remoteM) && (localM == b.localM); 00076 } 00077 }; 00078 00079 public: 00080 TCP_NSC_Connection(); 00081 cMessage* createEstablishedMsg(); 00082 void listen(INetStack &stackP, SockPair &inetSockPairP, SockPair &nscSockPairP); 00083 void connect(INetStack &stackP, SockPair &inetSockPairP, SockPair &nscSockPairP); 00084 void close(); 00085 void abort(); 00086 void send(cPacket *msgP); 00087 void do_SEND(); 00088 INetStreamSocket* getSocket(); 00089 void do_checkedclose(); 00090 00091 public: 00092 int connIdM; 00093 int appGateIndexM; 00094 SockPair inetSockPairM; 00095 SockPair nscSockPairM; 00096 INetStreamSocket *pNscSocketM; 00097 00098 bool sentEstablishedM; 00099 bool onCloseM; 00100 bool isListenerM; 00101 00102 // TCP Windows Size 00103 int tcpWinSizeM; 00104 00105 TCP_NSC *tcpNscM; 00106 TCP_NSC_ReceiveQueue * receiveQueueM; 00107 TCP_NSC_SendQueue * sendQueueM; 00108 }; 00109 00110 #endif