src/devices/mesh/wifi-information-element.cc
author Kirill Andreev <andreev@iitp.ru>
Fri, 31 Jul 2009 14:13:10 +0400
changeset 5139 87eb2f77f661
parent 5128 d6e168eba404
child 5157 ace422ad12df
permissions -rw-r--r--
Added wifi-information-element-vector
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4820
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
5128
d6e168eba404 Fixed coding style in helpers and mesh
Kirill Andreev <andreev@iitp.ru>
parents: 4903
diff changeset
     2
/*
4820
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
     3
 * Copyright (c) 2009 IITP RAS
5128
d6e168eba404 Fixed coding style in helpers and mesh
Kirill Andreev <andreev@iitp.ru>
parents: 4903
diff changeset
     4
 *
4820
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
     8
 *
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    12
 * GNU General Public License for more details.
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    13
 *
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
5128
d6e168eba404 Fixed coding style in helpers and mesh
Kirill Andreev <andreev@iitp.ru>
parents: 4903
diff changeset
    17
 *
4820
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    18
 * Author: Pavel Boyko <boyko@iitp.ru>
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    19
 */
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    20
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    21
#include "ns3/wifi-information-element.h"
4858
78437693dcc7 Peer manager restructure - unfinished
Kirill Andreev <andreev@iitp.ru>
parents: 4852
diff changeset
    22
#include "ns3/packet.h"
78437693dcc7 Peer manager restructure - unfinished
Kirill Andreev <andreev@iitp.ru>
parents: 4852
diff changeset
    23
#include "ns3/log.h"
4820
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    24
5128
d6e168eba404 Fixed coding style in helpers and mesh
Kirill Andreev <andreev@iitp.ru>
parents: 4903
diff changeset
    25
namespace ns3
d6e168eba404 Fixed coding style in helpers and mesh
Kirill Andreev <andreev@iitp.ru>
parents: 4903
diff changeset
    26
{
4820
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    27
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    28
TypeId
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4836
diff changeset
    29
WifiInformationElement::GetTypeId ()
4820
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    30
{
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    31
  static TypeId tid = TypeId ("ns3::WifiInformationElement")
5128
d6e168eba404 Fixed coding style in helpers and mesh
Kirill Andreev <andreev@iitp.ru>
parents: 4903
diff changeset
    32
    .SetParent<Header> ();
4820
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    33
  return tid;
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    34
}
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    35
4825
b407cc4bda3c Restructured mesh configuration element
Kirill Andreev <andreev@iitp.ru>
parents: 4824
diff changeset
    36
TypeId
b407cc4bda3c Restructured mesh configuration element
Kirill Andreev <andreev@iitp.ru>
parents: 4824
diff changeset
    37
WifiInformationElement::GetInstanceTypeId () const
b407cc4bda3c Restructured mesh configuration element
Kirill Andreev <andreev@iitp.ru>
parents: 4824
diff changeset
    38
{
b407cc4bda3c Restructured mesh configuration element
Kirill Andreev <andreev@iitp.ru>
parents: 4824
diff changeset
    39
  return GetTypeId ();
b407cc4bda3c Restructured mesh configuration element
Kirill Andreev <andreev@iitp.ru>
parents: 4824
diff changeset
    40
}
5128
d6e168eba404 Fixed coding style in helpers and mesh
Kirill Andreev <andreev@iitp.ru>
parents: 4903
diff changeset
    41
uint32_t
d6e168eba404 Fixed coding style in helpers and mesh
Kirill Andreev <andreev@iitp.ru>
parents: 4903
diff changeset
    42
WifiInformationElement::GetSerializedSize () const
4820
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    43
{
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4836
diff changeset
    44
  return (GetInformationSize () + 2);
4820
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    45
}
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    46
5128
d6e168eba404 Fixed coding style in helpers and mesh
Kirill Andreev <andreev@iitp.ru>
parents: 4903
diff changeset
    47
void
d6e168eba404 Fixed coding style in helpers and mesh
Kirill Andreev <andreev@iitp.ru>
parents: 4903
diff changeset
    48
WifiInformationElement::Serialize (Buffer::Iterator i) const
4820
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    49
{
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4836
diff changeset
    50
  i.WriteU8 (ElementId ());
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4836
diff changeset
    51
  i.WriteU8 (GetInformationSize ());
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4836
diff changeset
    52
  SerializeInformation (i);
4820
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    53
}
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    54
5128
d6e168eba404 Fixed coding style in helpers and mesh
Kirill Andreev <andreev@iitp.ru>
parents: 4903
diff changeset
    55
uint32_t
d6e168eba404 Fixed coding style in helpers and mesh
Kirill Andreev <andreev@iitp.ru>
parents: 4903
diff changeset
    56
WifiInformationElement::Deserialize (Buffer::Iterator i)
4820
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    57
{
5128
d6e168eba404 Fixed coding style in helpers and mesh
Kirill Andreev <andreev@iitp.ru>
parents: 4903
diff changeset
    58
  if (i.ReadU8 () != ElementId ())
d6e168eba404 Fixed coding style in helpers and mesh
Kirill Andreev <andreev@iitp.ru>
parents: 4903
diff changeset
    59
    {
d6e168eba404 Fixed coding style in helpers and mesh
Kirill Andreev <andreev@iitp.ru>
parents: 4903
diff changeset
    60
      return 0;
d6e168eba404 Fixed coding style in helpers and mesh
Kirill Andreev <andreev@iitp.ru>
parents: 4903
diff changeset
    61
    }
4820
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    62
  uint8_t length = i.ReadU8 ();
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4836
diff changeset
    63
  return (DeserializeInformation (i, length) + 2);
4820
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    64
}
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    65
5128
d6e168eba404 Fixed coding style in helpers and mesh
Kirill Andreev <andreev@iitp.ru>
parents: 4903
diff changeset
    66
void
d6e168eba404 Fixed coding style in helpers and mesh
Kirill Andreev <andreev@iitp.ru>
parents: 4903
diff changeset
    67
WifiInformationElement::Print (std::ostream &os) const
4820
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    68
{
4903
9a06b4979e1a RANN test cleanup
Pavel Boyko <boyko@iitp.ru>
parents: 4874
diff changeset
    69
  os << "\n<information_element id=" << ElementId () << ">\n";
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4836
diff changeset
    70
  PrintInformation (os);
4820
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    71
  os << "</information_element>\n";
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    72
}
5128
d6e168eba404 Fixed coding style in helpers and mesh
Kirill Andreev <andreev@iitp.ru>
parents: 4903
diff changeset
    73
bool
d6e168eba404 Fixed coding style in helpers and mesh
Kirill Andreev <andreev@iitp.ru>
parents: 4903
diff changeset
    74
operator< (WifiInformationElement const & a, WifiInformationElement const & b)
4822
55868bb52909 MeshWifiBeacon class created
Pavel Boyko <boyko@iitp.ru>
parents: 4820
diff changeset
    75
{
5128
d6e168eba404 Fixed coding style in helpers and mesh
Kirill Andreev <andreev@iitp.ru>
parents: 4903
diff changeset
    76
  return (a.ElementId () < b.ElementId ());
4820
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    77
}
8507b0cef8c0 WifiInformationElement class added as the base for all IEs
Pavel Boyko <boyko@iitp.ru>
parents:
diff changeset
    78
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4836
diff changeset
    79
}
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4836
diff changeset
    80