Parent: [180d2e] (diff)

Download this file

SDU.h    94 lines (77 with data), 3.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// The MIT License (MIT)
//
// Copyright (c) 2014-2016 Brno University of Technology, PRISTINE project
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#ifndef SDU_H_
#define SDU_H_
#include <omnetpp.h>
#include <cobject.h>
#include <vector>
#include "EFCP_defs.h"
#include "CDAPMessage_m.h"
#include "SDU_m.h"
#define SDU_SEQ_NUM_PRESENT 0x08
#define SDU_NO_LENGTH 0x04
#define SDU_NO_L_MID_FRAG 0x00
#define SDU_NO_L_FIRST_FRAG 0x01
#define SDU_NO_L_LAST_FRAG 0x02
#define SDU_NO_L_ONE_SDU 0x03
#define SDU_L_COMP_SDU 0x00 /* It may express ZERO or more complete SDUs*/
#define SDU_L_SDU_FIRST_FRAG 0x01
#define SDU_L_LAST_FRAG_SDU 0x02
#define SDU_L_LAST_SDU_FIRST_FRAG 0x03 /* Last fragment, ZERO or more SDUs followed by first fragment */
typedef std::vector<cPacket*> mUserDataType;
class SDU : public SDU_Base
{
private:
unsigned char * userData; //Deprecated
// unsigned int size;
// unsigned int offset;
mUserDataType mUserData_var;
void copy(const SDU& other);
public:
// SDU();
virtual ~SDU();
SDU(const char *name=NULL, int kind=0);
SDU(const SDU& other); // : SDU_Base(other) {copy(other);}
SDU& operator=(const SDU& other)
{
if (this == &other)
return *this;
SDU_Base::operator=(other);
copy(other);
return *this;
}
virtual SDU *dup() const {return new SDU(*this);}
// ADD CODE HERE to redefine and implement pure virtual functions from SDU_Base
unsigned int getSize() const;
unsigned int getAbsoluteSize() const;
unsigned int getRestSize() const;
void setSize(unsigned int size);
unsigned char* getUserData() const;
const unsigned char* getUserData(unsigned int offset);
void setUserData(unsigned char* userData, unsigned int size);
bool addUserData(cPacket* msg);
cPacket* getUserData();
std::vector<SDU*>fragment(unsigned int size);
SDU* genFragment(unsigned int size, unsigned int fSeqNum, unsigned int fOffset);
void setFragment(unsigned int size, unsigned int fSeqNum, unsigned int fOffset);
};
#endif /* SDU_H_ */