|
INET Framework for OMNeT++/OMNEST
|
00001 // 00002 // Copyright (C) 2004 Andras Varga 00003 // 00004 // This program is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser 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 Lesser General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU Lesser General Public License 00015 // along with this program; if not, see <http://www.gnu.org/licenses/>. 00016 // 00017 00018 00019 #ifndef __INET_TCPSEGMENT_H 00020 #define __INET_TCPSEGMENT_H 00021 00022 #include <list> 00023 #include "INETDefs.h" 00024 #include "TCPSegment_m.h" 00025 00026 00029 inline bool seqLess(uint32 a, uint32 b) {return a!=b && b-a<(1UL<<31);} 00030 inline bool seqLE(uint32 a, uint32 b) {return b-a<(1UL<<31);} 00031 inline bool seqGreater(uint32 a, uint32 b) {return a!=b && a-b<(1UL<<31);} 00032 inline bool seqGE(uint32 a, uint32 b) {return a-b<(1UL<<31);} 00034 00035 00040 class INET_API TCPSegment : public TCPSegment_Base 00041 { 00042 protected: 00043 std::list<TCPPayloadMessage> payloadList; 00044 00045 public: 00046 TCPSegment(const char *name=NULL, int kind=0) : TCPSegment_Base(name,kind) {} 00047 TCPSegment(const TCPSegment& other) : TCPSegment_Base(other.getName()) {operator=(other);} 00048 virtual ~TCPSegment(); 00049 TCPSegment& operator=(const TCPSegment& other); 00050 virtual TCPSegment *dup() const {return new TCPSegment(*this);} 00051 virtual void parsimPack(cCommBuffer *b); 00052 virtual void parsimUnpack(cCommBuffer *b); 00053 00055 virtual void setPayloadArraySize(unsigned int size); 00057 virtual void setPayload(unsigned int k, const TCPPayloadMessage& payload_var); 00058 00062 virtual unsigned int getPayloadArraySize() const; 00063 00067 virtual TCPPayloadMessage& getPayload(unsigned int k); 00068 00073 virtual void addPayloadMessage(cPacket *msg, uint32 endSequenceNo); 00074 00079 virtual cPacket *removeFirstPayloadMessage(uint32& outEndSequenceNo); 00080 00086 virtual void truncateSegment(uint32 firstSeqNo, uint32 endSeqNo); 00087 }; 00088 00089 #endif 00090 00091