src/devices/mesh/dot11s/ie-dot11s-preq.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu Nov 12 13:01:01 2009 +0100 (2009-11-12)
changeset 5505 c0ac392289c3
parent 5162 35963e5411c0
child 6273 8d70de29d514
permissions -rw-r--r--
replace RefCountBase with SimpleRefCount<> to avoid duplicate refcounting implementations.
mazo@4793
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
mazo@4793
     2
/*
mazo@4793
     3
 * Copyright (c) 2008,2009 IITP RAS
mazo@4793
     4
 *
mazo@4793
     5
 * This program is free software; you can redistribute it and/or modify
mazo@4812
     6
 * it under the terms of the GNU General Public License version 2 as
mazo@4793
     7
 * published by the Free Software Foundation;
mazo@4793
     8
 *
mazo@4793
     9
 * This program is distributed in the hope that it will be useful,
mazo@4793
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
mazo@4793
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
mazo@4793
    12
 * GNU General Public License for more details.
mazo@4793
    13
 *
mazo@4793
    14
 * You should have received a copy of the GNU General Public License
mazo@4793
    15
 * along with this program; if not, write to the Free Software
mazo@4793
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
mazo@4793
    17
 *
mazo@4811
    18
 * Author: Kirill Andreev <andreev@iitp.ru>
mazo@4793
    19
 */
mazo@4793
    20
mazo@4793
    21
#ifndef WIFI_PREQ_INFORMATION_ELEMENT_H
mazo@4793
    22
#define WIFI_PREQ_INFORMATION_ELEMENT_H
mazo@4793
    23
boyko@4813
    24
#include <vector>
boyko@4813
    25
mazo@4812
    26
#include "ns3/mac48-address.h"
andreev@5161
    27
#include "ns3/wifi-information-element-vector.h"
boyko@4813
    28
andreev@5132
    29
namespace ns3 {
andreev@5132
    30
namespace dot11s {
boyko@4807
    31
/**
boyko@4851
    32
 * \ingroup dot11s
andreev@4850
    33
 * \brief Describes an address unit in PREQ information element
andreev@4850
    34
 * See 7.3.2.96 for more details
boyko@4807
    35
 */
mathieu@5505
    36
class DestinationAddressUnit : public SimpleRefCount<DestinationAddressUnit>
mazo@4793
    37
{
mazo@4812
    38
public:
mazo@4852
    39
  DestinationAddressUnit ();
andreev@4955
    40
  void SetFlags (bool doFlag, bool rfFlag, bool usnFlag);
mazo@4852
    41
  void SetDestinationAddress (Mac48Address dest_address);
mazo@4852
    42
  void SetDestSeqNumber (uint32_t dest_seq_number);
mazo@4852
    43
  bool IsDo ();
mazo@4852
    44
  bool IsRf ();
andreev@4955
    45
  bool IsUsn ();
mazo@4852
    46
  Mac48Address GetDestinationAddress () const;
mazo@4852
    47
  uint32_t GetDestSeqNumber () const;
mazo@4812
    48
private:
mazo@4812
    49
  bool m_do;
mazo@4812
    50
  bool m_rf;
andreev@4955
    51
  bool m_usn;
mazo@4812
    52
  Mac48Address m_destinationAddress;
mazo@4812
    53
  uint32_t m_destSeqNumber;
andreev@5129
    54
boyko@4904
    55
  friend bool operator== (const DestinationAddressUnit & a, const DestinationAddressUnit & b);
mazo@4812
    56
};
boyko@4807
    57
/**
boyko@4851
    58
 * \ingroup dot11s
andreev@4850
    59
 * \brief See 7.3.2.96 of 802.11s draft 2.07
boyko@4807
    60
 */
andreev@4876
    61
class IePreq : public WifiInformationElement
mazo@4793
    62
{
mazo@4812
    63
public:
andreev@4876
    64
  IePreq ();
andreev@4876
    65
  ~IePreq ();
andreev@5107
    66
  /**
andreev@5107
    67
   * Add a destination address unit: flags, destination and sequence
andreev@5107
    68
   * number
andreev@5107
    69
   */
mazo@4852
    70
  void AddDestinationAddressElement (
mazo@4812
    71
    bool doFlag,
mazo@4812
    72
    bool rfFlag,
mazo@4812
    73
    Mac48Address dest_address,
mazo@4812
    74
    uint32_t dest_seq_number
mazo@4812
    75
  );
andreev@5107
    76
  /// Delete a destination address unit by destination
mazo@4852
    77
  void DelDestinationAddressElement (Mac48Address dest_address);
andreev@5107
    78
  /// Clear PREQ: remove all destinations
andreev@5107
    79
  void ClearDestinationAddressElements ();
andreev@5107
    80
  /// Get all destinations, which are stored in PREQ:
mazo@4812
    81
  std::vector<Ptr<DestinationAddressUnit> > GetDestinationList ();
andreev@5107
    82
  /// SetProper flags which indicate that PREQ is unicast
mazo@4852
    83
  void SetUnicastPreq ();
mazo@4812
    84
  /*
mazo@4812
    85
   * \brief In proactive case: need we send PREP
mazo@4812
    86
   */
mazo@4852
    87
  void SetNeedNotPrep ();
andreev@5107
    88
  ///\name Setters for fields:
andreev@5107
    89
  ///\{
mazo@4852
    90
  void SetHopcount (uint8_t hopcount);
mazo@4852
    91
  void SetTTL (uint8_t ttl);
mazo@4852
    92
  void SetPreqID (uint32_t id);
mazo@4852
    93
  void SetOriginatorAddress (Mac48Address originator_address);
mazo@4852
    94
  void SetOriginatorSeqNumber (uint32_t originator_seq_number);
mazo@4852
    95
  void SetLifetime (uint32_t lifetime);
mazo@4852
    96
  void SetMetric (uint32_t metric);
mazo@4852
    97
  void SetDestCount (uint8_t dest_count);
andreev@5107
    98
  ///\}
andreev@5107
    99
  ///\name Getters for fields:
andreev@5107
   100
  ///\{
mazo@4852
   101
  bool  IsUnicastPreq () const;
mazo@4852
   102
  bool  IsNeedNotPrep () const;
mazo@4852
   103
  uint8_t  GetHopCount () const;
mazo@4852
   104
  uint8_t  GetTtl ()const ;
mazo@4852
   105
  uint32_t GetPreqID () const;
mazo@4852
   106
  Mac48Address GetOriginatorAddress () const;
mazo@4852
   107
  uint32_t GetOriginatorSeqNumber () const;
mazo@4852
   108
  uint32_t GetLifetime () const;
mazo@4852
   109
  uint32_t GetMetric () const;
mazo@4852
   110
  uint8_t  GetDestCount () const;
andreev@5107
   111
  ///\}
andreev@5107
   112
  /// Handle TTL and Metric:
mazo@4852
   113
  void  DecrementTtl ();
mazo@4852
   114
  void  IncrementMetric (uint32_t metric);
andreev@4965
   115
  /*
andreev@4965
   116
   * \brief Checks that preq's originator address equals to originator, and
andreev@4965
   117
   * this preq is not proactive
andreev@4965
   118
   */
andreev@5130
   119
  bool MayAddAddress (Mac48Address originator);
andreev@5113
   120
  bool IsFull () const;
andreev@5159
   121
  /**
andreev@5159
   122
   * \name Inherited from WifiInformationElement
andreev@5159
   123
   * \{
andreev@5159
   124
   */
andreev@5162
   125
  virtual WifiElementId ElementId () const;
andreev@5162
   126
  virtual void SerializeInformation (Buffer::Iterator i) const;
andreev@5162
   127
  virtual uint8_t DeserializeInformation (Buffer::Iterator i, uint8_t length);
andreev@5162
   128
  virtual uint8_t GetInformationSize () const;
andreev@5162
   129
  virtual void Print (std::ostream& os) const;
andreev@5159
   130
  ///\}
andreev@5159
   131
private:
andreev@4847
   132
  /**
andreev@4847
   133
   * how many destinations we support
andreev@4847
   134
   */
mazo@4812
   135
  uint8_t m_maxSize; //TODO: make as an attrubute
andreev@4847
   136
  /**
andreev@4847
   137
   * Fields of information element:
andreev@4847
   138
   */
mazo@4812
   139
  uint8_t m_flags;
mazo@4812
   140
  uint8_t m_hopCount;
mazo@4812
   141
  uint8_t m_ttl;
mazo@4812
   142
  uint32_t m_preqId;
mazo@4812
   143
  Mac48Address m_originatorAddress;
mazo@4812
   144
  uint32_t m_originatorSeqNumber;
mazo@4812
   145
  uint32_t m_lifetime;
mazo@4812
   146
  uint32_t m_metric;
mazo@4812
   147
  uint8_t  m_destCount;
mazo@4853
   148
  std::vector<Ptr<DestinationAddressUnit> >  m_destinations;
andreev@5129
   149
boyko@4904
   150
  friend bool operator== (const IePreq & a, const IePreq & b);
mazo@4793
   151
};
boyko@4904
   152
boyko@4904
   153
bool operator== (const DestinationAddressUnit & a, const DestinationAddressUnit & b);
boyko@4904
   154
bool operator== (const IePreq & a, const IePreq & b);
andreev@5162
   155
std::ostream &operator << (std::ostream &os, const IePreq &preq);
boyko@4904
   156
andreev@4872
   157
} // namespace dot11s
mazo@4793
   158
} //namespace ns3
mazo@4793
   159
#endif
mazo@4793
   160