RINASim  October 2016
Documentation of framework for OMNeT++
SDU.h
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 
23 #ifndef SDU_H_
24 #define SDU_H_
25 
26 #include <omnetpp.h>
27 #include <vector>
28 #include "EFCP_defs.h"
29 #include "CDAPMessage_m.h"
30 #include "SDU_m.h"
31 
32 
33 
34 #define SDU_SEQ_NUM_PRESENT 0x08
35 #define SDU_NO_LENGTH 0x04
36 #define SDU_NO_L_MID_FRAG 0x00
37 #define SDU_NO_L_FIRST_FRAG 0x01
38 #define SDU_NO_L_LAST_FRAG 0x02
39 #define SDU_NO_L_ONE_SDU 0x03
40 
41 #define SDU_L_COMP_SDU 0x00 /* It may express ZERO or more complete SDUs*/
42 #define SDU_L_SDU_FIRST_FRAG 0x01
43 #define SDU_L_LAST_FRAG_SDU 0x02
44 #define SDU_L_LAST_SDU_FIRST_FRAG 0x03 /* Last fragment, ZERO or more SDUs followed by first fragment */
45 
46 typedef std::vector<cPacket*> mUserDataType;
47 class SDU : public SDU_Base
48 {
49 
50  private:
51 // unsigned char * userData; //Deprecated
52 // unsigned int size;
53 // unsigned int offset;
55 
56  void copy(const SDU& other);
57 
58 public:
59 // SDU();
60  virtual ~SDU();
61 
62  SDU(const char *name=NULL, int kind=0);
63  SDU(const SDU& other); // : SDU_Base(other) {copy(other);}
64  SDU& operator=(const SDU& other)
65  {
66  if (this == &other)
67  return *this;
68  SDU_Base::operator=(other);
69  copy(other);
70  return *this;
71  }
72  virtual SDU *dup() const {return new SDU(*this);}
73 
74 
75  unsigned int getSize() const;
76  unsigned int getAbsoluteSize() const;
77  unsigned int getRestSize() const;
78 
79  bool addUserData(cPacket* msg);
80  cPacket* getUserData();
81 
82  std::vector<SDU*>fragment(unsigned int size);
83  SDU* genFragment(unsigned int size, unsigned int fSeqNum, unsigned int fOffset);
84  void setFragment(unsigned int size, unsigned int fSeqNum, unsigned int fOffset);
85 
86 
87 };
88 
89 #endif /* SDU_H_ */
void setFragment(unsigned int size, unsigned int fSeqNum, unsigned int fOffset)
Definition: SDU.cc:174
virtual SDU * dup() const
Definition: SDU.h:72
std::vector< cPacket * > mUserDataType
Definition: SDU.h:46
Definition: SDU_m.h:88
bool addUserData(cPacket *msg)
Definition: SDU.cc:120
unsigned int getAbsoluteSize() const
Definition: SDU.cc:71
virtual ~SDU()
Definition: SDU.cc:188
SDU_Base & operator=(const SDU_Base &other)
Definition: SDU_m.cc:195
void copy(const SDU &other)
Definition: SDU.cc:41
SDU(const char *name=NULL, int kind=0)
Definition: SDU.cc:31
unsigned int fSeqNum
Definition: SDU_m.h:96
unsigned int getSize() const
Definition: SDU.cc:55
cPacket * getUserData()
Definition: SDU.cc:134
unsigned int size
Definition: SDU_m.h:91
mUserDataType mUserData_var
Definition: SDU.h:54
SDU * genFragment(unsigned int size, unsigned int fSeqNum, unsigned int fOffset)
Definition: SDU.cc:166
Definition: SDU.h:47
std::vector< SDU * > fragment(unsigned int size)
Definition: SDU.cc:154
SDU & operator=(const SDU &other)
Definition: SDU.h:64
unsigned int fOffset
Definition: SDU_m.h:94
unsigned int getRestSize() const
Definition: SDU.cc:77