author | Kirill Andreev <andreev@iitp.ru> |
Sun, 22 Mar 2009 12:34:24 +0300 | |
changeset 4865 | e331ed5d3662 |
parent 4852 | 123dc54d734e |
child 4890 | 8ee0a72c0ae0 |
permissions | -rw-r--r-- |
4822 | 1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2009 IITP RAS |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License version 2 as |
|
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 |
* Author: Pavel Boyko <boyko@iitp.ru> |
|
19 |
*/ |
|
20 |
||
21 |
#include "ns3/mesh-wifi-beacon.h" |
|
22 |
#include <algorithm> |
|
23 |
||
24 |
namespace ns3 { |
|
25 |
||
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4843
diff
changeset
|
26 |
MeshWifiBeacon::MeshWifiBeacon (Ssid ssid, SupportedRates rates, uint64_t us) |
4822 | 27 |
{ |
28 |
m_header.SetSsid (ssid); |
|
29 |
m_header.SetSupportedRates (rates); |
|
30 |
m_header.SetBeaconIntervalUs (us); |
|
31 |
} |
|
32 |
||
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4843
diff
changeset
|
33 |
void MeshWifiBeacon::AddInformationElement (Ptr<WifiInformationElement> ie) |
4822 | 34 |
{ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4843
diff
changeset
|
35 |
m_elements.push_back (ie); |
4822 | 36 |
} |
37 |
||
4823
7c2d9ff2d4ab
Bugfix, sort by element ID not by pointer addresses
Pavel Boyko <boyko@iitp.ru>
parents:
4822
diff
changeset
|
38 |
namespace { |
4842
605a2680b56b
Use reference counting for WifiInformationElement
Pavel Boyko <boyko@iitp.ru>
parents:
4823
diff
changeset
|
39 |
/// aux sorter for Ptr<WifiInformationElement> |
605a2680b56b
Use reference counting for WifiInformationElement
Pavel Boyko <boyko@iitp.ru>
parents:
4823
diff
changeset
|
40 |
struct PIEComparator |
4823
7c2d9ff2d4ab
Bugfix, sort by element ID not by pointer addresses
Pavel Boyko <boyko@iitp.ru>
parents:
4822
diff
changeset
|
41 |
{ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4843
diff
changeset
|
42 |
bool operator () (Ptr<WifiInformationElement> a, Ptr<WifiInformationElement> b) const |
4823
7c2d9ff2d4ab
Bugfix, sort by element ID not by pointer addresses
Pavel Boyko <boyko@iitp.ru>
parents:
4822
diff
changeset
|
43 |
{ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4843
diff
changeset
|
44 |
return ((*PeekPointer (a)) < (*PeekPointer(b))); |
4823
7c2d9ff2d4ab
Bugfix, sort by element ID not by pointer addresses
Pavel Boyko <boyko@iitp.ru>
parents:
4822
diff
changeset
|
45 |
} |
7c2d9ff2d4ab
Bugfix, sort by element ID not by pointer addresses
Pavel Boyko <boyko@iitp.ru>
parents:
4822
diff
changeset
|
46 |
}; |
7c2d9ff2d4ab
Bugfix, sort by element ID not by pointer addresses
Pavel Boyko <boyko@iitp.ru>
parents:
4822
diff
changeset
|
47 |
} |
7c2d9ff2d4ab
Bugfix, sort by element ID not by pointer addresses
Pavel Boyko <boyko@iitp.ru>
parents:
4822
diff
changeset
|
48 |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4843
diff
changeset
|
49 |
Ptr<Packet> MeshWifiBeacon::CreatePacket () |
4822 | 50 |
{ |
51 |
Ptr<Packet> packet = Create<Packet> (); |
|
52 |
||
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4843
diff
changeset
|
53 |
std::sort (m_elements.begin(), m_elements.end(), PIEComparator()); |
4822 | 54 |
|
4842
605a2680b56b
Use reference counting for WifiInformationElement
Pavel Boyko <boyko@iitp.ru>
parents:
4823
diff
changeset
|
55 |
std::vector< Ptr<WifiInformationElement> >::const_reverse_iterator i; |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4843
diff
changeset
|
56 |
for (i = m_elements.rbegin(); i != m_elements.rend(); ++i) |
4822 | 57 |
{ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4843
diff
changeset
|
58 |
packet->AddHeader (**i); |
4822 | 59 |
} |
60 |
||
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4843
diff
changeset
|
61 |
packet->AddHeader (BeaconHeader()); |
4822 | 62 |
|
63 |
return packet; |
|
64 |
} |
|
4843
f65f22ef327e
MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4842
diff
changeset
|
65 |
|
f65f22ef327e
MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4842
diff
changeset
|
66 |
WifiMacHeader MeshWifiBeacon::CreateHeader (Mac48Address address) |
f65f22ef327e
MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4842
diff
changeset
|
67 |
{ |
f65f22ef327e
MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4842
diff
changeset
|
68 |
WifiMacHeader hdr; |
f65f22ef327e
MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4842
diff
changeset
|
69 |
|
f65f22ef327e
MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4842
diff
changeset
|
70 |
hdr.SetBeacon (); |
f65f22ef327e
MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4842
diff
changeset
|
71 |
hdr.SetAddr1 (Mac48Address::GetBroadcast ()); |
f65f22ef327e
MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4842
diff
changeset
|
72 |
hdr.SetAddr2 (address); |
f65f22ef327e
MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4842
diff
changeset
|
73 |
hdr.SetAddr3 (address); |
f65f22ef327e
MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4842
diff
changeset
|
74 |
hdr.SetDsNotFrom (); |
f65f22ef327e
MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4842
diff
changeset
|
75 |
hdr.SetDsNotTo (); |
f65f22ef327e
MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4842
diff
changeset
|
76 |
|
f65f22ef327e
MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4842
diff
changeset
|
77 |
return hdr; |
f65f22ef327e
MeshWifiInterfaceMac just added and beacon generation refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4842
diff
changeset
|
78 |
} |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4843
diff
changeset
|
79 |
|
4822 | 80 |
} // namespace |
81 |