author | Pavel Boyko <boyko@iitp.ru> |
Mon, 30 Mar 2009 18:13:48 +0400 | |
changeset 4899 | 50591b95753a |
parent 4877 | f08902c42733 |
child 4951 | acaf07eb8542 |
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:
4809
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 |
* |
|
18 |
* Authors: Kirill Andreev <andreev@iitp.ru> |
|
19 |
* Aleksey Kovalenko <kovalenko@iitp.ru> |
|
20 |
*/ |
|
21 |
||
22 |
||
4877
f08902c42733
Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents:
4876
diff
changeset
|
23 |
#include "ie-dot11s-peer-management.h" |
4793 | 24 |
#include "ns3/assert.h" |
25 |
||
26 |
||
27 |
//NS_LOG_COMPONENT_DEFINE ("MeshPeerLinkManagementelement"); |
|
28 |
||
29 |
namespace ns3 { |
|
4872 | 30 |
namespace dot11s { |
4793 | 31 |
|
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
32 |
IePeerManagement::IePeerManagement (): |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
33 |
m_length (0), |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
34 |
m_subtype (PEER_OPEN), |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
35 |
m_localLinkId (0), |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
36 |
m_peerLinkId (0), |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
37 |
m_reasonCode (REASON11S_RESERVED) |
4793 | 38 |
{} |
39 |
||
40 |
||
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
41 |
void |
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
42 |
IePeerManagement::SetPeerOpen (uint16_t localLinkId) |
4793 | 43 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
44 |
m_length = 3; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
45 |
m_subtype = PEER_OPEN; |
4793 | 46 |
m_localLinkId = localLinkId; |
47 |
} |
|
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
48 |
void |
4899
50591b95753a
dot11s-codes.h removed. StatusCode enum is found to be unused and removed. ReadonCode enum is moved to dot11s/ie-dot11s-peer-management.h
Pavel Boyko <boyko@iitp.ru>
parents:
4877
diff
changeset
|
49 |
IePeerManagement::SetPeerClose (uint16_t localLinkId, uint16_t peerLinkId, PmpReasonCode reasonCode) |
4793 | 50 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
51 |
m_length = 7; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
52 |
m_subtype = PEER_CLOSE; |
4793 | 53 |
m_localLinkId = localLinkId; |
54 |
m_peerLinkId = peerLinkId; |
|
55 |
m_reasonCode = reasonCode; |
|
56 |
} |
|
57 |
||
58 |
void |
|
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
59 |
IePeerManagement::SetPeerConfirm (uint16_t localLinkId, uint16_t peerLinkId) |
4793 | 60 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
61 |
m_length = 5; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
62 |
m_subtype = PEER_CONFIRM; |
4793 | 63 |
m_localLinkId = localLinkId; |
64 |
m_peerLinkId = peerLinkId; |
|
65 |
} |
|
66 |
||
4899
50591b95753a
dot11s-codes.h removed. StatusCode enum is found to be unused and removed. ReadonCode enum is moved to dot11s/ie-dot11s-peer-management.h
Pavel Boyko <boyko@iitp.ru>
parents:
4877
diff
changeset
|
67 |
PmpReasonCode |
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
68 |
IePeerManagement::GetReasonCode () const |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
69 |
{ |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
70 |
return m_reasonCode; |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
71 |
} |
4793 | 72 |
|
73 |
uint16_t |
|
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
74 |
IePeerManagement::GetLocalLinkId () const |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
75 |
{ |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
76 |
return m_localLinkId; |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
77 |
} |
4793 | 78 |
|
79 |
uint16_t |
|
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
80 |
IePeerManagement::GetPeerLinkId () const |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
81 |
{ |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
82 |
return m_peerLinkId; |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
83 |
} |
4793 | 84 |
|
4838
ce31277d72ad
Finished restructuring information elements
Kirill Andreev <andreev@iitp.ru>
parents:
4813
diff
changeset
|
85 |
uint8_t |
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
86 |
IePeerManagement::GetInformationSize (void) const |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
87 |
{ |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
88 |
return m_length; |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
89 |
} |
4793 | 90 |
|
91 |
bool |
|
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
92 |
IePeerManagement::SubtypeIsOpen () const |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
93 |
{ |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
94 |
return (m_subtype == PEER_OPEN); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
95 |
} |
4793 | 96 |
bool |
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
97 |
IePeerManagement::SubtypeIsClose () const |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
98 |
{ |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
99 |
return (m_subtype == PEER_CLOSE); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
100 |
} |
4793 | 101 |
bool |
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
102 |
IePeerManagement::SubtypeIsConfirm () const |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
103 |
{ |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
104 |
return (m_subtype == PEER_CONFIRM); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
105 |
} |
4793 | 106 |
|
4838
ce31277d72ad
Finished restructuring information elements
Kirill Andreev <andreev@iitp.ru>
parents:
4813
diff
changeset
|
107 |
void |
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
108 |
IePeerManagement::SerializeInformation (Buffer::Iterator i) const |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
109 |
{ |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
110 |
i.WriteU8 (m_subtype); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
111 |
i.WriteHtonU16 (m_localLinkId); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
112 |
if (m_length > 3) |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
113 |
i.WriteHtonU16 (m_peerLinkId); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
114 |
if (m_length > 5) |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
115 |
i.WriteHtonU16 (m_reasonCode); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
116 |
} |
4838
ce31277d72ad
Finished restructuring information elements
Kirill Andreev <andreev@iitp.ru>
parents:
4813
diff
changeset
|
117 |
uint8_t |
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
118 |
IePeerManagement::DeserializeInformation (Buffer::Iterator start, uint8_t length) |
4793 | 119 |
{ |
4838
ce31277d72ad
Finished restructuring information elements
Kirill Andreev <andreev@iitp.ru>
parents:
4813
diff
changeset
|
120 |
Buffer::Iterator i = start; |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
121 |
m_subtype = i.ReadU8 (); |
4839 | 122 |
m_length = length; |
123 |
if (m_subtype == PEER_OPEN) |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
124 |
NS_ASSERT (length == 3); |
4839 | 125 |
if (m_subtype == PEER_CONFIRM) |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
126 |
NS_ASSERT (length == 5); |
4839 | 127 |
if (m_subtype == PEER_CLOSE) |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
128 |
NS_ASSERT (length == 7); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
129 |
m_localLinkId = i.ReadNtohU16 (); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
130 |
if (m_length > 3) |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
131 |
m_peerLinkId = i.ReadNtohU16 (); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
132 |
if (m_length > 5) |
4899
50591b95753a
dot11s-codes.h removed. StatusCode enum is found to be unused and removed. ReadonCode enum is moved to dot11s/ie-dot11s-peer-management.h
Pavel Boyko <boyko@iitp.ru>
parents:
4877
diff
changeset
|
133 |
m_reasonCode = (PmpReasonCode)i.ReadNtohU16 (); |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4839
diff
changeset
|
134 |
return i.GetDistanceFrom (start); |
4838
ce31277d72ad
Finished restructuring information elements
Kirill Andreev <andreev@iitp.ru>
parents:
4813
diff
changeset
|
135 |
} |
ce31277d72ad
Finished restructuring information elements
Kirill Andreev <andreev@iitp.ru>
parents:
4813
diff
changeset
|
136 |
void |
4876
d78f1b978dac
Rstructured file names: IeDot11s* no is Ie, because it is in namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents:
4872
diff
changeset
|
137 |
IePeerManagement::PrintInformation (std::ostream& os) const |
4838
ce31277d72ad
Finished restructuring information elements
Kirill Andreev <andreev@iitp.ru>
parents:
4813
diff
changeset
|
138 |
{ |
ce31277d72ad
Finished restructuring information elements
Kirill Andreev <andreev@iitp.ru>
parents:
4813
diff
changeset
|
139 |
//TODO |
4793 | 140 |
} |
4872 | 141 |
|
142 |
} // namespace dot11s |
|
143 |
} //namespace ns3 |
|
144 |