src/devices/wifi/amsdu-subframe-header.cc
changeset 4408 76a169b3db3d
equal deleted inserted replaced
4407:ef566eeff84f 4408:76a169b3db3d
       
     1 /* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
       
     2 /*
       
     3  * Copyright (c) 2009 MIRKO BANCHI
       
     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: Mirko Banchi <mk.banchi@gmail.com>
       
    19  */
       
    20 #include "amsdu-subframe-header.h"
       
    21 #include "ns3/address-utils.h"
       
    22 
       
    23 namespace ns3 {
       
    24 
       
    25 NS_OBJECT_ENSURE_REGISTERED (AmsduSubframeHeader);
       
    26 
       
    27 TypeId
       
    28 AmsduSubframeHeader::GetTypeId ()
       
    29 {
       
    30   static TypeId tid = TypeId ("ns3::AmsduSubframeHeader")
       
    31     .SetParent<Header> ()
       
    32     .AddConstructor<AmsduSubframeHeader> ()
       
    33     ;
       
    34   return tid; 
       
    35 }
       
    36 
       
    37 TypeId 
       
    38 AmsduSubframeHeader::GetInstanceTypeId (void) const
       
    39 {
       
    40   return GetTypeId ();
       
    41 }
       
    42 
       
    43 AmsduSubframeHeader::AmsduSubframeHeader ()
       
    44   : m_length (0)
       
    45 {}
       
    46 
       
    47 AmsduSubframeHeader::~AmsduSubframeHeader ()
       
    48 {}
       
    49 
       
    50 uint32_t
       
    51 AmsduSubframeHeader::GetSerializedSize () const
       
    52 {
       
    53   return (6 + 6 + 2);
       
    54 }
       
    55 
       
    56 void
       
    57 AmsduSubframeHeader::Serialize (Buffer::Iterator i) const
       
    58 {
       
    59   WriteTo (i, m_da);
       
    60   WriteTo (i, m_sa);
       
    61   i.WriteHtonU16 (m_length);
       
    62 }
       
    63 
       
    64 uint32_t
       
    65 AmsduSubframeHeader::Deserialize (Buffer::Iterator start)
       
    66 {
       
    67   Buffer::Iterator i = start;
       
    68   ReadFrom (i, m_da);
       
    69   ReadFrom (i, m_sa);
       
    70   m_length = i.ReadNtohU16 ();
       
    71   return i.GetDistanceFrom (start);
       
    72 }
       
    73 
       
    74 void
       
    75 AmsduSubframeHeader::Print (std::ostream &os) const
       
    76 {
       
    77   os << "DA = " << m_da << ", SA = " << m_sa << ", length = " << m_length;
       
    78 }
       
    79 
       
    80 void
       
    81 AmsduSubframeHeader::SetDestinationAddr (Mac48Address to)
       
    82 {
       
    83   m_da = to;
       
    84 }
       
    85 
       
    86 void
       
    87 AmsduSubframeHeader::SetSourceAddr (Mac48Address from)
       
    88 {
       
    89   m_sa = from;
       
    90 }
       
    91 
       
    92 void
       
    93 AmsduSubframeHeader::SetLength (uint16_t length)
       
    94 {
       
    95   m_length = length;
       
    96 }
       
    97 
       
    98 Mac48Address
       
    99 AmsduSubframeHeader::GetDestinationAddr (void) const
       
   100 {
       
   101   return m_da;
       
   102 }
       
   103 
       
   104 Mac48Address
       
   105 AmsduSubframeHeader::GetSourceAddr (void) const
       
   106 {
       
   107   return m_sa;
       
   108 }
       
   109   
       
   110 uint16_t
       
   111 AmsduSubframeHeader::GetLength (void) const
       
   112 {
       
   113   return m_length;
       
   114 }
       
   115 
       
   116 } //namespace ns3