author | Andrey Mazo <mazo@iitp.ru> |
Wed, 18 Mar 2009 22:36:12 +0300 | |
changeset 4852 | 123dc54d734e |
parent 4841 | 702fa974e205 |
permissions | -rw-r--r-- |
4793 | 1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2008,2009 IITP RAS |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
4793 | 7 |
* published by the Free Software Foundation; |
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 |
* |
|
4811
080b8f23fa4a
Added license information to some files.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
18 |
* Author: Kirill Andreev <andreev@iitp.ru> |
4793 | 19 |
*/ |
20 |
||
21 |
||
4833
9e10eae04db9
Restructured filenames in information elements
Kirill Andreev <andreev@iitp.ru>
parents:
4832
diff
changeset
|
22 |
#include "ns3/ie-dot11s-rann.h" |
4793 | 23 |
#include "ns3/assert.h" |
24 |
#include "ns3/address-utils.h" |
|
4841 | 25 |
#include "ns3/node.h" |
4793 | 26 |
|
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
27 |
namespace ns3 { |
4793 | 28 |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
29 |
IeDot11sRann::~IeDot11sRann () |
4793 | 30 |
{ |
31 |
} |
|
32 |
TypeId |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
33 |
IeDot11sRann::GetTypeId () |
4793 | 34 |
{ |
4835 | 35 |
static TypeId tid = TypeId ("ns3::IeDot11sRann").SetParent<Object> (); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
36 |
return tid; |
4793 | 37 |
} |
38 |
TypeId |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
39 |
IeDot11sRann::GetInstanceTypeId () const |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
40 |
{ |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
41 |
return GetTypeId (); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
42 |
} |
4793 | 43 |
void |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
44 |
IeDot11sRann::Print (std::ostream &os)const |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
45 |
{ |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
46 |
// FILL |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
47 |
} |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
48 |
IeDot11sRann::IeDot11sRann (): |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
49 |
m_flags (0), |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
50 |
m_hopcount (0), |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
51 |
m_ttl (0), |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
52 |
m_originatorAddress (Mac48Address::GetBroadcast()), |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
53 |
m_destSeqNumber (0), |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
54 |
m_metric (0) |
4805
1578b45ead40
Removed ELEMENT_ID, added proper methods, which returns element id
Kirill Andreev <andreev@iitp.ru>
parents:
4793
diff
changeset
|
55 |
{ |
4793 | 56 |
} |
57 |
void |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
58 |
IeDot11sRann::SetFlags (uint8_t flags) |
4793 | 59 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
60 |
m_flags = flags; |
4793 | 61 |
} |
62 |
void |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
63 |
IeDot11sRann::SetHopcount (uint8_t hopcount) |
4793 | 64 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
65 |
m_hopcount = hopcount; |
4793 | 66 |
} |
67 |
void |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
68 |
IeDot11sRann::SetTTL (uint8_t ttl) |
4793 | 69 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
70 |
m_ttl = ttl; |
4793 | 71 |
} |
72 |
void |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
73 |
IeDot11sRann::SetDestSeqNumber (uint32_t dest_seq_number) |
4793 | 74 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
75 |
m_destSeqNumber = dest_seq_number; |
4793 | 76 |
} |
77 |
void |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
78 |
IeDot11sRann::SetMetric (uint32_t metric) |
4793 | 79 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
80 |
m_metric = metric; |
4793 | 81 |
} |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
82 |
void |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
83 |
IeDot11sRann::SetOriginatorAddress (Mac48Address originator_address) |
4793 | 84 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
85 |
m_originatorAddress = originator_address; |
4793 | 86 |
} |
87 |
||
88 |
uint8_t |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
89 |
IeDot11sRann::GetFlags () |
4793 | 90 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
91 |
return m_flags; |
4793 | 92 |
} |
93 |
uint8_t |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
94 |
IeDot11sRann::GetHopcount () |
4793 | 95 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
96 |
return m_hopcount; |
4793 | 97 |
} |
98 |
uint8_t |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
99 |
IeDot11sRann::GetTTL () |
4793 | 100 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
101 |
return m_ttl; |
4793 | 102 |
} |
103 |
uint32_t |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
104 |
IeDot11sRann::GetDestSeqNumber () |
4793 | 105 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
106 |
return m_destSeqNumber; |
4793 | 107 |
} |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
108 |
uint32_t |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
109 |
IeDot11sRann::GetMetric () |
4793 | 110 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
111 |
return m_metric; |
4793 | 112 |
} |
113 |
Mac48Address |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
114 |
IeDot11sRann::GetOriginatorAddress () |
4793 | 115 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
116 |
return m_originatorAddress; |
4793 | 117 |
} |
118 |
void |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
119 |
IeDot11sRann::SerializeInformation (Buffer::Iterator i) const |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
120 |
{ |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
121 |
i.WriteU8 (m_flags); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
122 |
i.WriteU8 (m_hopcount); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
123 |
i.WriteU8 (m_ttl); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
124 |
WriteTo (i, m_originatorAddress); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
125 |
i.WriteHtonU32 (m_destSeqNumber); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
126 |
i.WriteHtonU32 (m_metric); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
127 |
} |
4838
ce31277d72ad
Finished restructuring information elements
Kirill Andreev <andreev@iitp.ru>
parents:
4835
diff
changeset
|
128 |
uint8_t |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
129 |
IeDot11sRann::DeserializeInformation (Buffer::Iterator start, uint8_t length) |
4793 | 130 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
131 |
Buffer::Iterator i = start; |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
132 |
m_flags = i.ReadU8 (); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
133 |
m_hopcount = i.ReadU8 (); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
134 |
m_ttl = i.ReadU8 (); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
135 |
ReadFrom (i, m_originatorAddress); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
136 |
m_destSeqNumber = i.ReadNtohU32 (); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
137 |
m_metric = i.ReadNtohU32 (); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
138 |
return i.GetDistanceFrom (start); |
4793 | 139 |
} |
4838
ce31277d72ad
Finished restructuring information elements
Kirill Andreev <andreev@iitp.ru>
parents:
4835
diff
changeset
|
140 |
uint8_t |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
141 |
IeDot11sRann::GetInformationSize () const |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
142 |
{ |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
143 |
uint8_t retval = |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
144 |
1 //Flags |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
145 |
+1 //Hopcount |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
146 |
+1 //TTL |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
147 |
+6 //OriginatorAddress |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
148 |
+4 //DestSeqNumber |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
149 |
+4;//Metric |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
150 |
return retval; |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
151 |
} |
4793 | 152 |
|
153 |
} |
|
154 |