A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
wifi-information-element.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2010 Dean Armstrong
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  * Authors: Dean Armstrong <deanarm@gmail.com>
19  */
20 
21 #include "ns3/wifi-information-element.h"
22 
23 namespace ns3 {
24 
26 {
27 }
28 
29 void
30 WifiInformationElement::Print (std::ostream &os) const
31 {
32 }
33 
34 uint16_t
36 {
37  return (2 + GetInformationFieldSize ());
38 }
39 
42 {
43  i.WriteU8 (ElementId ());
47  return i;
48 }
49 
52 {
54  i = DeserializeIfPresent (i);
55  // This IE was not optional, so confirm that we did actually
56  // deserialise something.
57  NS_ASSERT (i.GetDistanceFrom (start) != 0);
58  return i;
59 }
60 
63 {
65  uint8_t elementId = i.ReadU8 ();
66 
67  // If the element here isn't the one we're after then we immediately
68  // return the iterator we were passed indicating that we haven't
69  // taken anything from the buffer.
70  if (elementId != ElementId ())
71  {
72  return start;
73  }
74 
75  uint8_t length = i.ReadU8 ();
76 
77  DeserializeInformationField (i, length);
78  i.Next (length);
79 
80  return i;
81 }
82 
83 
84 bool
86 {
87  return (ElementId () < a.ElementId ());
88 }
89 
90 bool
92 {
93  if (ElementId () != a.ElementId ())
94  {
95  return false;
96  }
97 
99  {
100  return false;
101  }
102 
103  uint32_t ieSize = GetInformationFieldSize ();
104 
105  Buffer myIe, hisIe;
106  myIe.AddAtEnd (ieSize);
107  hisIe.AddAtEnd (ieSize);
108 
110  a.SerializeInformationField (hisIe.Begin ());
111 
112  return (memcmp (myIe.PeekData (), hisIe.PeekData (), ieSize) == 0);
113 }
114 
115 }