src/devices/mesh/dot11s/dot11s-mac-header.cc
author Kirill Andreev <andreev@iitp.ru>
Mon, 24 Aug 2009 18:05:31 +0400
changeset 5157 ace422ad12df
parent 5132 aee541a30256
child 5162 35963e5411c0
permissions -rw-r--r--
Cosmetics: '\n' was replaced with std::endl, Camel case for attributes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     2
/*
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     3
 * Copyright (c) 2009 IITP RAS
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     4
 *
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     8
 *
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    12
 * GNU General Public License for more details.
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    13
 *
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    17
 *
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    18
 * Author: Kirill Andreev <andreev@iitp.ru>
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    19
 */
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    20
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    21
#include "ns3/assert.h"
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    22
#include "ns3/address-utils.h"
4956
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
    23
#include "dot11s-mac-header.h"
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
    24
#include "ns3/packet.h"
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
    25
#include "ns3/test.h"
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    26
5132
aee541a30256 Restored newline at namespace
Kirill Andreev <andreev@iitp.ru>
parents: 5129
diff changeset
    27
namespace ns3 {
aee541a30256 Restored newline at namespace
Kirill Andreev <andreev@iitp.ru>
parents: 5129
diff changeset
    28
namespace dot11s {
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    29
/***********************************************************
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    30
 *  Here Mesh Mac Header functionality is defined.
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    31
 ***********************************************************/
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    32
TypeId
4994
2c25f9c66604 Dot11sMacHeader renamed to MeshHeader to correspond standard
Pavel Boyko <boyko@iitp.ru>
parents: 4984
diff changeset
    33
MeshHeader::GetTypeId ()
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    34
{
4956
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
    35
  static TypeId tid = TypeId ("ns3::Dot11sMacHeader")
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    36
  .SetParent<Header> ()
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    37
  .AddConstructor<MeshHeader> ();
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    38
  return tid;
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    39
}
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    40
MeshHeader::MeshHeader () :
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    41
  m_meshFlags (0), m_meshTtl (0), m_meshSeqno (0), m_addr4 (Mac48Address ()), m_addr5 (Mac48Address ()),
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
    42
      m_addr6 (Mac48Address ())
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    43
{
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    44
}
4994
2c25f9c66604 Dot11sMacHeader renamed to MeshHeader to correspond standard
Pavel Boyko <boyko@iitp.ru>
parents: 4984
diff changeset
    45
MeshHeader::~MeshHeader ()
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    46
{
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    47
}
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    48
TypeId
4994
2c25f9c66604 Dot11sMacHeader renamed to MeshHeader to correspond standard
Pavel Boyko <boyko@iitp.ru>
parents: 4984
diff changeset
    49
MeshHeader::GetInstanceTypeId () const
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    50
{
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    51
  return GetTypeId ();
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    52
}
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    53
void
4994
2c25f9c66604 Dot11sMacHeader renamed to MeshHeader to correspond standard
Pavel Boyko <boyko@iitp.ru>
parents: 4984
diff changeset
    54
MeshHeader::SetAddr4 (Mac48Address address)
4889
279b07de3327 Fixrd bugs with address extensions, broadcast frames can go through L2Routing
Kirill Andreev <andreev@iitp.ru>
parents: 4883
diff changeset
    55
{
279b07de3327 Fixrd bugs with address extensions, broadcast frames can go through L2Routing
Kirill Andreev <andreev@iitp.ru>
parents: 4883
diff changeset
    56
  m_addr4 = address;
279b07de3327 Fixrd bugs with address extensions, broadcast frames can go through L2Routing
Kirill Andreev <andreev@iitp.ru>
parents: 4883
diff changeset
    57
}
279b07de3327 Fixrd bugs with address extensions, broadcast frames can go through L2Routing
Kirill Andreev <andreev@iitp.ru>
parents: 4883
diff changeset
    58
void
4994
2c25f9c66604 Dot11sMacHeader renamed to MeshHeader to correspond standard
Pavel Boyko <boyko@iitp.ru>
parents: 4984
diff changeset
    59
MeshHeader::SetAddr5 (Mac48Address address)
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    60
{
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    61
  m_addr5 = address;
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    62
}
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    63
void
4994
2c25f9c66604 Dot11sMacHeader renamed to MeshHeader to correspond standard
Pavel Boyko <boyko@iitp.ru>
parents: 4984
diff changeset
    64
MeshHeader::SetAddr6 (Mac48Address address)
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    65
{
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    66
  m_addr6 = address;
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    67
}
4889
279b07de3327 Fixrd bugs with address extensions, broadcast frames can go through L2Routing
Kirill Andreev <andreev@iitp.ru>
parents: 4883
diff changeset
    68
Mac48Address
4994
2c25f9c66604 Dot11sMacHeader renamed to MeshHeader to correspond standard
Pavel Boyko <boyko@iitp.ru>
parents: 4984
diff changeset
    69
MeshHeader::GetAddr4 () const
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    70
{
4889
279b07de3327 Fixrd bugs with address extensions, broadcast frames can go through L2Routing
Kirill Andreev <andreev@iitp.ru>
parents: 4883
diff changeset
    71
  return m_addr4;
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    72
}
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    73
Mac48Address
4994
2c25f9c66604 Dot11sMacHeader renamed to MeshHeader to correspond standard
Pavel Boyko <boyko@iitp.ru>
parents: 4984
diff changeset
    74
MeshHeader::GetAddr5 () const
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    75
{
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    76
  return m_addr5;
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    77
}
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    78
Mac48Address
4994
2c25f9c66604 Dot11sMacHeader renamed to MeshHeader to correspond standard
Pavel Boyko <boyko@iitp.ru>
parents: 4984
diff changeset
    79
MeshHeader::GetAddr6 () const
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    80
{
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    81
  return m_addr6;
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    82
}
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    83
void
4994
2c25f9c66604 Dot11sMacHeader renamed to MeshHeader to correspond standard
Pavel Boyko <boyko@iitp.ru>
parents: 4984
diff changeset
    84
MeshHeader::SetMeshSeqno (uint32_t seqno)
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    85
{
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    86
  m_meshSeqno = seqno;
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    87
}
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    88
uint32_t
4994
2c25f9c66604 Dot11sMacHeader renamed to MeshHeader to correspond standard
Pavel Boyko <boyko@iitp.ru>
parents: 4984
diff changeset
    89
MeshHeader::GetMeshSeqno () const
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    90
{
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    91
  return m_meshSeqno;
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    92
}
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    93
void
4994
2c25f9c66604 Dot11sMacHeader renamed to MeshHeader to correspond standard
Pavel Boyko <boyko@iitp.ru>
parents: 4984
diff changeset
    94
MeshHeader::SetMeshTtl (uint8_t TTL)
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    95
{
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    96
  m_meshTtl = TTL;
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    97
}
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
    98
uint8_t
4994
2c25f9c66604 Dot11sMacHeader renamed to MeshHeader to correspond standard
Pavel Boyko <boyko@iitp.ru>
parents: 4984
diff changeset
    99
MeshHeader::GetMeshTtl () const
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   100
{
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   101
  return m_meshTtl;
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   102
}
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   103
void
4994
2c25f9c66604 Dot11sMacHeader renamed to MeshHeader to correspond standard
Pavel Boyko <boyko@iitp.ru>
parents: 4984
diff changeset
   104
MeshHeader::SetAddressExt (uint8_t num_of_addresses)
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   105
{
5063
97b947e83640 Faker's code review response
Pavel Boyko <boyko@iitp.ru>
parents: 5027
diff changeset
   106
  NS_ASSERT (num_of_addresses <= 3);
5027
2f926202a5bf Moving to IEEE 802.11s Draft 3.0 (Mesh Control Field, Beacon Timing Element):
Andrey Mazo <mazo@iitp.ru>
parents: 4994
diff changeset
   107
  m_meshFlags |= 0x03 & num_of_addresses;
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   108
}
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   109
uint8_t
4994
2c25f9c66604 Dot11sMacHeader renamed to MeshHeader to correspond standard
Pavel Boyko <boyko@iitp.ru>
parents: 4984
diff changeset
   110
MeshHeader::GetAddressExt () const
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   111
{
5027
2f926202a5bf Moving to IEEE 802.11s Draft 3.0 (Mesh Control Field, Beacon Timing Element):
Andrey Mazo <mazo@iitp.ru>
parents: 4994
diff changeset
   112
  return (0x03 & m_meshFlags);
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   113
}
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   114
uint32_t
4994
2c25f9c66604 Dot11sMacHeader renamed to MeshHeader to correspond standard
Pavel Boyko <boyko@iitp.ru>
parents: 4984
diff changeset
   115
MeshHeader::GetSerializedSize () const
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   116
{
4889
279b07de3327 Fixrd bugs with address extensions, broadcast frames can go through L2Routing
Kirill Andreev <andreev@iitp.ru>
parents: 4883
diff changeset
   117
  return 6 + GetAddressExt () * 6;
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   118
}
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   119
void
4994
2c25f9c66604 Dot11sMacHeader renamed to MeshHeader to correspond standard
Pavel Boyko <boyko@iitp.ru>
parents: 4984
diff changeset
   120
MeshHeader::Serialize (Buffer::Iterator start) const
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   121
{
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   122
  Buffer::Iterator i = start;
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   123
  i.WriteU8 (m_meshFlags);
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   124
  i.WriteU8 (m_meshTtl);
5027
2f926202a5bf Moving to IEEE 802.11s Draft 3.0 (Mesh Control Field, Beacon Timing Element):
Andrey Mazo <mazo@iitp.ru>
parents: 4994
diff changeset
   125
  i.WriteHtolsbU32 (m_meshSeqno);
4889
279b07de3327 Fixrd bugs with address extensions, broadcast frames can go through L2Routing
Kirill Andreev <andreev@iitp.ru>
parents: 4883
diff changeset
   126
  uint8_t addresses_to_add = GetAddressExt ();
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   127
  //Writing Address extensions:
4956
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
   128
  if ((addresses_to_add == 1) || (addresses_to_add == 3))
5124
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   129
    {
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   130
      WriteTo (i, m_addr4);
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   131
    }
4889
279b07de3327 Fixrd bugs with address extensions, broadcast frames can go through L2Routing
Kirill Andreev <andreev@iitp.ru>
parents: 4883
diff changeset
   132
  if (addresses_to_add > 1)
5124
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   133
    {
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   134
      WriteTo (i, m_addr5);
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   135
    }
4956
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
   136
  if (addresses_to_add > 1)
5124
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   137
    {
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   138
      WriteTo (i, m_addr6);
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   139
    }
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   140
}
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   141
uint32_t
4994
2c25f9c66604 Dot11sMacHeader renamed to MeshHeader to correspond standard
Pavel Boyko <boyko@iitp.ru>
parents: 4984
diff changeset
   142
MeshHeader::Deserialize (Buffer::Iterator start)
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   143
{
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   144
  Buffer::Iterator i = start;
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   145
  uint8_t addresses_to_read = 0;
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   146
  m_meshFlags = i.ReadU8 ();
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   147
  m_meshTtl = i.ReadU8 ();
5027
2f926202a5bf Moving to IEEE 802.11s Draft 3.0 (Mesh Control Field, Beacon Timing Element):
Andrey Mazo <mazo@iitp.ru>
parents: 4994
diff changeset
   148
  m_meshSeqno = i.ReadLsbtohU32 ();
2f926202a5bf Moving to IEEE 802.11s Draft 3.0 (Mesh Control Field, Beacon Timing Element):
Andrey Mazo <mazo@iitp.ru>
parents: 4994
diff changeset
   149
  addresses_to_read = m_meshFlags & 0x03;
4956
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
   150
  if ((addresses_to_read == 1) || (addresses_to_read == 3))
5124
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   151
    {
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   152
      ReadFrom (i, m_addr4);
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   153
    }
4889
279b07de3327 Fixrd bugs with address extensions, broadcast frames can go through L2Routing
Kirill Andreev <andreev@iitp.ru>
parents: 4883
diff changeset
   154
  if (addresses_to_read > 1)
5124
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   155
    {
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   156
      ReadFrom (i, m_addr5);
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   157
    }
4956
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
   158
  if (addresses_to_read > 1)
5124
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   159
    {
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   160
      ReadFrom (i, m_addr6);
e206046b2e44 removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents: 5112
diff changeset
   161
    }
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   162
  return i.GetDistanceFrom (start);
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   163
}
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   164
void
4994
2c25f9c66604 Dot11sMacHeader renamed to MeshHeader to correspond standard
Pavel Boyko <boyko@iitp.ru>
parents: 4984
diff changeset
   165
MeshHeader::Print (std::ostream &os) const
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   166
{
5157
ace422ad12df Cosmetics: '\n' was replaced with std::endl, Camel case for attributes
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
   167
  os << "flags = " << (uint16_t) m_meshFlags << std::endl << "ttl = " << (uint16_t) m_meshTtl 
ace422ad12df Cosmetics: '\n' was replaced with std::endl, Camel case for attributes
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
   168
    << std::endl << "seqno = " << m_meshSeqno << std::endl<< "addr4 = " << m_addr4 << std::endl
ace422ad12df Cosmetics: '\n' was replaced with std::endl, Camel case for attributes
Kirill Andreev <andreev@iitp.ru>
parents: 5132
diff changeset
   169
    << "addr5 = " << m_addr5 << std::endl << "addr6 = " << m_addr6 << std::endl;
4956
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
   170
}
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   171
bool
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   172
operator== (const MeshHeader & a, const MeshHeader & b)
4956
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
   173
{
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   174
  return ((a.m_meshFlags == b.m_meshFlags) && (a.m_meshTtl == b.m_meshTtl)
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   175
      && (a.m_meshSeqno == b.m_meshSeqno) && (a.m_addr4 == b.m_addr4) && (a.m_addr5 == b.m_addr5)
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   176
      && (a.m_addr6 == b.m_addr6));
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   177
}
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   178
/**********************************************************
4984
77ab6e01a1c3 Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents: 4968
diff changeset
   179
 *   ActionFrame
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   180
 **********************************************************/
4984
77ab6e01a1c3 Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents: 4968
diff changeset
   181
WifiMeshActionHeader::WifiMeshActionHeader ()
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   182
{
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   183
}
4984
77ab6e01a1c3 Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents: 4968
diff changeset
   184
WifiMeshActionHeader::~WifiMeshActionHeader ()
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   185
{
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   186
}
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   187
void
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   188
WifiMeshActionHeader::SetAction (WifiMeshActionHeader::CategoryValue type,
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   189
    WifiMeshActionHeader::ActionValue action)
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   190
{
4968
ff5a2162d492 MulthopAction -> Action management frames in 802.11s according to std
Pavel Boyko <boyko@iitp.ru>
parents: 4956
diff changeset
   191
  m_category = type;
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   192
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   193
  switch (type)
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   194
    {
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   195
  case MESH_PEERING_MGT:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   196
    {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   197
      m_actionValue = action.peerLink;
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   198
      break;
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   199
    }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   200
  case MESH_PATH_SELECTION:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   201
    {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   202
      m_actionValue = action.pathSelection;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   203
      break;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   204
    }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   205
  case MESH_LINK_METRIC:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   206
  case MESH_INTERWORKING:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   207
  case MESH_RESOURCE_COORDINATION:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   208
  case MESH_PROXY_FORWARDING:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   209
    break;
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   210
    };
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   211
}
4984
77ab6e01a1c3 Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents: 4968
diff changeset
   212
WifiMeshActionHeader::CategoryValue
77ab6e01a1c3 Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents: 4968
diff changeset
   213
WifiMeshActionHeader::GetCategory ()
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   214
{
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   215
  switch (m_category)
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   216
    {
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   217
  case MESH_PEERING_MGT:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   218
    return MESH_PEERING_MGT;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   219
  case MESH_LINK_METRIC:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   220
    return MESH_LINK_METRIC;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   221
  case MESH_PATH_SELECTION:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   222
    return MESH_PATH_SELECTION;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   223
  case MESH_INTERWORKING:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   224
    return MESH_INTERWORKING;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   225
  case MESH_RESOURCE_COORDINATION:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   226
    return MESH_RESOURCE_COORDINATION;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   227
  case MESH_PROXY_FORWARDING:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   228
    return MESH_PROXY_FORWARDING;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   229
  default:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   230
    NS_FATAL_ERROR ("Unknown action value");
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   231
    return MESH_PEERING_MGT;
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   232
    }
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   233
}
4984
77ab6e01a1c3 Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents: 4968
diff changeset
   234
WifiMeshActionHeader::ActionValue
77ab6e01a1c3 Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents: 4968
diff changeset
   235
WifiMeshActionHeader::GetAction ()
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   236
{
4968
ff5a2162d492 MulthopAction -> Action management frames in 802.11s according to std
Pavel Boyko <boyko@iitp.ru>
parents: 4956
diff changeset
   237
  ActionValue retval;
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   238
  switch (m_category)
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   239
    {
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   240
  case MESH_PEERING_MGT:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   241
    switch (m_actionValue)
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   242
      {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   243
    case PEER_LINK_OPEN:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   244
      retval.peerLink = PEER_LINK_OPEN;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   245
      return retval;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   246
    case PEER_LINK_CONFIRM:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   247
      retval.peerLink = PEER_LINK_CONFIRM;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   248
      return retval;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   249
    case PEER_LINK_CLOSE:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   250
      retval.peerLink = PEER_LINK_CLOSE;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   251
      return retval;
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   252
    default:
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   253
      NS_FATAL_ERROR ("Unknown mesh peering management action code");
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   254
      return retval;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   255
      }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   256
  case MESH_PATH_SELECTION:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   257
    switch (m_actionValue)
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   258
      {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   259
    case PATH_SELECTION:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   260
      retval.pathSelection = PATH_SELECTION;
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   261
      return retval;
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   262
    default:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   263
      NS_FATAL_ERROR ("Unknown mesh path selection action code");
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   264
      return retval;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   265
      }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   266
  case MESH_LINK_METRIC:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   267
    // not yet supported
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   268
  case MESH_INTERWORKING:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   269
    // not yet supported
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   270
  case MESH_RESOURCE_COORDINATION:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   271
    // not yet supported
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   272
  default:
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   273
    NS_FATAL_ERROR ("Unsupported mesh action");
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   274
    return retval;
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   275
    }
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   276
}
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   277
TypeId
4984
77ab6e01a1c3 Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents: 4968
diff changeset
   278
WifiMeshActionHeader::GetTypeId ()
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   279
{
4984
77ab6e01a1c3 Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents: 4968
diff changeset
   280
  static TypeId tid = TypeId ("ns3::WifiMeshActionHeader")
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   281
  .SetParent<Header> ()
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   282
  .AddConstructor<WifiMeshActionHeader> ();
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   283
  return tid;
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   284
}
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   285
TypeId
4984
77ab6e01a1c3 Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents: 4968
diff changeset
   286
WifiMeshActionHeader::GetInstanceTypeId () const
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   287
{
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   288
  return GetTypeId ();
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   289
}
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   290
void
4984
77ab6e01a1c3 Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents: 4968
diff changeset
   291
WifiMeshActionHeader::Print (std::ostream &os) const
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   292
{
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   293
}
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   294
uint32_t
4984
77ab6e01a1c3 Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents: 4968
diff changeset
   295
WifiMeshActionHeader::GetSerializedSize () const
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   296
{
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   297
  return 2;
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   298
}
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   299
void
4984
77ab6e01a1c3 Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents: 4968
diff changeset
   300
WifiMeshActionHeader::Serialize (Buffer::Iterator start) const
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   301
{
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   302
  start.WriteU8 (m_category);
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   303
  start.WriteU8 (m_actionValue);
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   304
}
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   305
uint32_t
4984
77ab6e01a1c3 Outgoing data packets are dropped if there is no active link, MultihopAction
Kirill Andreev <andreev@iitp.ru>
parents: 4968
diff changeset
   306
WifiMeshActionHeader::Deserialize (Buffer::Iterator start)
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   307
{
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   308
  Buffer::Iterator i = start;
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   309
  m_category = i.ReadU8 ();
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   310
  m_actionValue = i.ReadU8 ();
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   311
  return i.GetDistanceFrom (start);
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   312
}
4956
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
   313
#ifdef RUN_SELF_TESTS
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
   314
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
   315
/// Built-in self test for Dot11sMacHeader
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   316
struct Dot11sMacHeaderBist : public Test
4956
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
   317
{
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   318
  Dot11sMacHeaderBist () :
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   319
    Test ("Mesh/802.11s/MeshHeader")
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   320
  {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   321
  }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   322
  virtual bool
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   323
  RunTests ();
4956
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
   324
};
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
   325
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
   326
/// Test instance
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
   327
static Dot11sMacHeaderBist g_Dot11sMacHeaderBist;
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
   328
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   329
bool
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   330
Dot11sMacHeaderBist::RunTests ()
4956
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
   331
{
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
   332
  bool result (true);
5129
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   333
    {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   334
      MeshHeader a;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   335
      a.SetAddressExt (3);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   336
      a.SetAddr4 (Mac48Address ("11:22:33:44:55:66"));
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   337
      a.SetAddr5 (Mac48Address ("11:00:33:00:55:00"));
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   338
      a.SetAddr6 (Mac48Address ("00:22:00:44:00:66"));
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   339
      a.SetMeshTtl (122);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   340
      a.SetMeshSeqno (321);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   341
      Ptr<Packet> packet = Create<Packet> ();
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   342
      packet->AddHeader (a);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   343
      MeshHeader b;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   344
      packet->RemoveHeader (b);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   345
      NS_TEST_ASSERT_EQUAL (a, b);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   346
    }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   347
    {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   348
      MeshHeader a;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   349
      a.SetAddressExt (2);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   350
      a.SetAddr5 (Mac48Address ("11:00:33:00:55:00"));
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   351
      a.SetAddr6 (Mac48Address ("00:22:00:44:00:66"));
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   352
      a.SetMeshTtl (122);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   353
      a.SetMeshSeqno (321);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   354
      Ptr<Packet> packet = Create<Packet> ();
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   355
      packet->AddHeader (a);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   356
      MeshHeader b;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   357
      packet->RemoveHeader (b);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   358
      NS_TEST_ASSERT_EQUAL (a, b);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   359
    }
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   360
    {
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   361
      MeshHeader a;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   362
      a.SetAddressExt (1);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   363
      a.SetAddr4 (Mac48Address ("11:22:33:44:55:66"));
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   364
      a.SetMeshTtl (122);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   365
      a.SetMeshSeqno (321);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   366
      Ptr<Packet> packet = Create<Packet> ();
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   367
      packet->AddHeader (a);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   368
      MeshHeader b;
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   369
      packet->RemoveHeader (b);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   370
      NS_TEST_ASSERT_EQUAL (a, b);
5688b8da4526 Fixed coding style
Kirill Andreev <andreev@iitp.ru>
parents: 5124
diff changeset
   371
    }
4956
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
   372
  return result;
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
   373
}
aba7cae978ac MeshWifiMacHeader moved to Dot11sMacHeader. test to it is written
Kirill Andreev <andreev@iitp.ru>
parents: 4949
diff changeset
   374
#endif
4949
c376fb558264 Added docs to peer link frame cleass, mesh-wifi-mac-header has been moved to
Kirill Andreev <andreev@iitp.ru>
parents: 4890
diff changeset
   375
} //namespace dot11s
4883
27921b45078e Restored mesh-wifi-mac-header
Kirill Andreev <andreev@iitp.ru>
parents:
diff changeset
   376
} // namespace ns3