RINASim
October 2016
Documentation of framework for OMNeT++
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
PDU.cc
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.
30
#include <
PDU.h
>
31
32
Register_Class
(
PDU
);
33
34
//void PDU::addUserData(const unsigned char* userData, unsigned int size, bool *fragment){
35
//
36
// if(userData_arraysize == 0){
37
// userData_var= new unsigned char[size];
38
// memcpy(userData_var, userData, size);
39
// *fragment = false;
40
//
41
//
42
// }else{
43
//
44
// if(*fragment){
46
// //allocate new space
47
// unsigned char * tmp = new unsigned char[userData_arraysize + SDU_FRAG_LEN];
48
// //put size of the exising segment/SDU in the PDU
49
// tmp[0] = userData_arraysize & 0xFF;
50
// tmp[1] = (userData_arraysize << 8) & 0xFF;
51
// //update size of the userData array
52
// userData_arraysize += SDU_FRAG_LEN;
53
// //copy existing data
54
// memcpy(&tmp[SDU_FRAG_LEN], userData_var, userData_arraysize);
55
//
56
// delete [] userData_var;
57
// //assign pointer
58
// userData_var = tmp;
59
//
60
// *fragment = true;
61
// }
62
//
63
// //allocate new space
64
// unsigned char * tmp = new unsigned char [size + this->userData_arraysize + SDU_FRAG_LEN];
65
// //put size of the exising segment/SDU in the PDU
66
// tmp[this->userData_arraysize] = size & 0xFF;
67
// tmp[this->userData_arraysize +1 ] = (size << 8) & 0xFF;
68
// this->userData_arraysize += SDU_FRAG_LEN;
69
// //copy existing data
70
// memcpy(tmp, this->userData_var, this->userData_arraysize);
71
// //copy new data
72
// memcpy(&tmp[this->userData_arraysize], userData, size);
73
// delete [] this->userData_var;
74
// this->userData_var = tmp;
75
//
76
// }
77
//
78
// this->userData_arraysize += size;
79
//
80
// pduLen_var = PDU_HEADER_LEN + userData_arraysize;
81
//
82
//}
83
/*
84
* @param sduSeqNum is unused for the moment because its usage is not clear to me (yet)
85
*/
86
//void PDU::putDelimitFlags(int delimitFlags, bool fragment, int sduSeqNum){
87
// //TODO B2 Incorporate size of the delimiter flag field into process of delimiting SDUs/PDUs
88
// if(sduSeqNum != -1){
89
// //SDU Sequence Number present
90
//
91
// //TODO B2 add support for SDU Seq Number
92
// }
93
//
94
// flags_var |= 0x08 & (sduSeqNum == -1) ? 0x00: 0xFF;
95
// flags_var |= delimitFlags;
96
//
97
//
98
// unsigned char * tmp = new unsigned char[userData_arraysize + SDU_DELIMITER_FLAG_LEN];
99
// //put size of the exising segment/SDU in the PDU
100
// tmp[0] = 0x08 & (sduSeqNum == -1) ? 0x00: 0xFF;
101
// tmp[0] |= delimitFlags;
102
//
103
// //update size of the userData array
104
// userData_arraysize += SDU_DELIMITER_FLAG_LEN;
105
// //copy existing data
106
// memcpy(&tmp[SDU_DELIMITER_FLAG_LEN], userData_var, userData_arraysize);
107
//
108
// delete [] userData_var;
109
// //assign pointer
110
// userData_var = tmp;
111
//}
112
113
unsigned
int
PDU::getHeaderSize
(){
114
return
PDU_HEADER_LEN
;
115
}
116
117
unsigned
int
PDU::getSize
(){
118
return
getPduLen
() +
getHeaderSize
();
119
}
120
121
//std::string PDU::info() const {
122
// std::stringstream os;
123
// os << "srcAddr: " << srcAddr_var;
124
// return os.str();
125
//}
126
127
PDU::getHeaderSize
unsigned int getHeaderSize()
Definition:
PDU.cc:113
PDU::getSize
unsigned int getSize()
Definition:
PDU.cc:117
PDU
Definition:
PDU.h:42
PDU_Base::getPduLen
virtual unsigned int getPduLen() const
Definition:
PDU_m.cc:366
PDU.h
Register_Class
Register_Class(PDU)
PDU_HEADER_LEN
#define PDU_HEADER_LEN
Definition:
PDU_m.h:19
src
Common
PDU.cc
Generated on Tue Oct 25 2016 21:08:58 for RINASim by
1.8.10