INET Framework for OMNeT++/OMNEST
TCPSegment_m.h
Go to the documentation of this file.
00001 //
00002 // Generated file, do not edit! Created by opp_msgc 4.2 from transport/tcp/TCPSegment.msg.
00003 //
00004 
00005 #ifndef _TCPSEGMENT_M_H_
00006 #define _TCPSEGMENT_M_H_
00007 
00008 #include <omnetpp.h>
00009 
00010 // opp_msgc version check
00011 #define MSGC_VERSION 0x0402
00012 #if (MSGC_VERSION!=OMNETPP_VERSION)
00013 #    error Version mismatch! Probably this file was generated by an earlier version of opp_msgc: 'make clean' should help.
00014 #endif
00015 
00016 // cplusplus {{
00017 #include <iostream>
00018 #include "INETDefs.h"
00019 
00020     
00021     #define TCP_HEADER_OCTETS  20    
00022 
00023     
00024     const unsigned int TCP_MAX_HEADER_OCTETS = 60;
00025 
00026     
00027     const unsigned int MAX_SACK_ENTRIES = 4;
00028 
00029     typedef cPacket *cPacketPtr;
00030 
00031     inline std::ostream& operator<<(std::ostream& os, cPacketPtr msg)
00032     {
00033         return os << "(" << msg->getClassName() << ") " << msg->getName() << ": " << msg->info();
00034     }
00035 
00036     inline void doPacking(cCommBuffer *b, cPacketPtr& msg) {msg->parsimPack(b);}
00037     inline void doUnpacking(cCommBuffer *b, cPacketPtr& msg) {msg->parsimUnpack(b);}
00038 // }}
00039 
00040 
00041 
00083 enum TCPOptionNumbers {
00084     TCPOPTION_END_OF_OPTION_LIST = 0,
00085     TCPOPTION_NO_OPERATION = 1,
00086     TCPOPTION_MAXIMUM_SEGMENT_SIZE = 2,
00087     TCPOPTION_WINDOW_SCALE = 3,
00088     TCPOPTION_SACK_PERMITTED = 4,
00089     TCPOPTION_SACK = 5,
00090     TCPOPTION_TIMESTAMP = 8
00091 };
00092 
00096 struct TCPPayloadMessage
00097 {
00098     TCPPayloadMessage();
00099     unsigned int endSequenceNo;
00100     cPacketPtr msg;
00101 };
00102 
00103 void doPacking(cCommBuffer *b, TCPPayloadMessage& a);
00104 void doUnpacking(cCommBuffer *b, TCPPayloadMessage& a);
00105 
00116 class Sack : public ::cObject
00117 {
00118   protected:
00119     unsigned int start_var;
00120     unsigned int end_var;
00121 
00122   private:
00123     void copy(const Sack& other);
00124 
00125   protected:
00126     // protected and unimplemented operator==(), to prevent accidental usage
00127     bool operator==(const Sack&);
00128 
00129   public:
00130     Sack();
00131     Sack(const Sack& other);
00132     virtual ~Sack();
00133     Sack& operator=(const Sack& other);
00134     virtual Sack *dup() const {return new Sack(*this);}
00135     virtual void parsimPack(cCommBuffer *b);
00136     virtual void parsimUnpack(cCommBuffer *b);
00137 
00138     // field getter/setter methods
00139     virtual unsigned int getStart() const;
00140     virtual void setStart(unsigned int start);
00141     virtual unsigned int getEnd() const;
00142     virtual void setEnd(unsigned int end);
00143 };
00144 
00145 inline void doPacking(cCommBuffer *b, Sack& obj) {obj.parsimPack(b);}
00146 inline void doUnpacking(cCommBuffer *b, Sack& obj) {obj.parsimUnpack(b);}
00147 
00159 class TCPOption : public ::cObject
00160 {
00161   protected:
00162     unsigned short kind_var;
00163     unsigned short length_var;
00164     unsigned int *values_var; // array ptr
00165     unsigned int values_arraysize;
00166 
00167   private:
00168     void copy(const TCPOption& other);
00169 
00170   protected:
00171     // protected and unimplemented operator==(), to prevent accidental usage
00172     bool operator==(const TCPOption&);
00173 
00174   public:
00175     TCPOption();
00176     TCPOption(const TCPOption& other);
00177     virtual ~TCPOption();
00178     TCPOption& operator=(const TCPOption& other);
00179     virtual TCPOption *dup() const {return new TCPOption(*this);}
00180     virtual void parsimPack(cCommBuffer *b);
00181     virtual void parsimUnpack(cCommBuffer *b);
00182 
00183     // field getter/setter methods
00184     virtual unsigned short getKind() const;
00185     virtual void setKind(unsigned short kind);
00186     virtual unsigned short getLength() const;
00187     virtual void setLength(unsigned short length);
00188     virtual void setValuesArraySize(unsigned int size);
00189     virtual unsigned int getValuesArraySize() const;
00190     virtual unsigned int getValues(unsigned int k) const;
00191     virtual void setValues(unsigned int k, unsigned int values);
00192 };
00193 
00194 inline void doPacking(cCommBuffer *b, TCPOption& obj) {obj.parsimPack(b);}
00195 inline void doUnpacking(cCommBuffer *b, TCPOption& obj) {obj.parsimUnpack(b);}
00196 
00290 class TCPSegment_Base : public ::cPacket
00291 {
00292   protected:
00293     unsigned short srcPort_var;
00294     unsigned short destPort_var;
00295     unsigned int sequenceNo_var;
00296     unsigned int ackNo_var;
00297     unsigned short headerLength_var;
00298     bool urgBit_var;
00299     bool ackBit_var;
00300     bool pshBit_var;
00301     bool rstBit_var;
00302     bool synBit_var;
00303     bool finBit_var;
00304     unsigned short window_var;
00305     unsigned short urgentPointer_var;
00306     TCPOption *options_var; // array ptr
00307     unsigned int options_arraysize;
00308     unsigned long payloadLength_var;
00309 
00310   private:
00311     void copy(const TCPSegment_Base& other);
00312 
00313   protected:
00314     // protected and unimplemented operator==(), to prevent accidental usage
00315     bool operator==(const TCPSegment_Base&);
00316     // make constructors protected to avoid instantiation
00317     TCPSegment_Base(const char *name=NULL, int kind=0);
00318     TCPSegment_Base(const TCPSegment_Base& other);
00319     // make assignment operator protected to force the user override it
00320     TCPSegment_Base& operator=(const TCPSegment_Base& other);
00321 
00322   public:
00323     virtual ~TCPSegment_Base();
00324     virtual TCPSegment_Base *dup() const {throw cRuntimeError("You forgot to manually add a dup() function to class TCPSegment");}
00325     virtual void parsimPack(cCommBuffer *b);
00326     virtual void parsimUnpack(cCommBuffer *b);
00327 
00328     // field getter/setter methods
00329     virtual unsigned short getSrcPort() const;
00330     virtual void setSrcPort(unsigned short srcPort);
00331     virtual unsigned short getDestPort() const;
00332     virtual void setDestPort(unsigned short destPort);
00333     virtual unsigned int getSequenceNo() const;
00334     virtual void setSequenceNo(unsigned int sequenceNo);
00335     virtual unsigned int getAckNo() const;
00336     virtual void setAckNo(unsigned int ackNo);
00337     virtual unsigned short getHeaderLength() const;
00338     virtual void setHeaderLength(unsigned short headerLength);
00339     virtual bool getUrgBit() const;
00340     virtual void setUrgBit(bool urgBit);
00341     virtual bool getAckBit() const;
00342     virtual void setAckBit(bool ackBit);
00343     virtual bool getPshBit() const;
00344     virtual void setPshBit(bool pshBit);
00345     virtual bool getRstBit() const;
00346     virtual void setRstBit(bool rstBit);
00347     virtual bool getSynBit() const;
00348     virtual void setSynBit(bool synBit);
00349     virtual bool getFinBit() const;
00350     virtual void setFinBit(bool finBit);
00351     virtual unsigned short getWindow() const;
00352     virtual void setWindow(unsigned short window);
00353     virtual unsigned short getUrgentPointer() const;
00354     virtual void setUrgentPointer(unsigned short urgentPointer);
00355     virtual void setOptionsArraySize(unsigned int size);
00356     virtual unsigned int getOptionsArraySize() const;
00357     virtual TCPOption& getOptions(unsigned int k);
00358     virtual const TCPOption& getOptions(unsigned int k) const {return const_cast<TCPSegment_Base*>(this)->getOptions(k);}
00359     virtual void setOptions(unsigned int k, const TCPOption& options);
00360     virtual unsigned long getPayloadLength() const;
00361     virtual void setPayloadLength(unsigned long payloadLength);
00362     virtual void setPayloadArraySize(unsigned int size) = 0;
00363     virtual unsigned int getPayloadArraySize() const = 0;
00364     virtual TCPPayloadMessage& getPayload(unsigned int k) = 0;
00365     virtual const TCPPayloadMessage& getPayload(unsigned int k) const {return const_cast<TCPSegment_Base*>(this)->getPayload(k);}
00366     virtual void setPayload(unsigned int k, const TCPPayloadMessage& payload) = 0;
00367 };
00368 
00369 
00370 #endif // _TCPSEGMENT_M_H_