OLD | NEW |
(Empty) | |
| 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2009 University of Washington |
| 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: Leonard Tracy <lentracy@gmail.com> |
| 19 */ |
| 20 |
| 21 #include "uan-header-common.h" |
| 22 #include "uan-address.h" |
| 23 |
| 24 namespace ns3 { |
| 25 |
| 26 UanHeaderCommon::UanHeaderCommon () |
| 27 { |
| 28 } |
| 29 |
| 30 UanHeaderCommon::UanHeaderCommon (const UanAddress src, const UanAddress dest, u
int8_t type) |
| 31 : Header (), |
| 32 m_dest (dest), |
| 33 m_src (src), |
| 34 m_type (type) |
| 35 { |
| 36 |
| 37 } |
| 38 |
| 39 TypeId |
| 40 UanHeaderCommon::GetTypeId (void) |
| 41 { |
| 42 static TypeId tid = TypeId ("ns3::UanHeaderCommon") |
| 43 .SetParent<Header> () |
| 44 .AddConstructor<UanHeaderCommon> () |
| 45 ; |
| 46 return tid; |
| 47 } |
| 48 |
| 49 TypeId |
| 50 UanHeaderCommon::GetInstanceTypeId (void) const |
| 51 { |
| 52 return GetTypeId (); |
| 53 } |
| 54 UanHeaderCommon::~UanHeaderCommon () |
| 55 { |
| 56 } |
| 57 |
| 58 |
| 59 void |
| 60 UanHeaderCommon::SetDest (UanAddress dest) |
| 61 { |
| 62 m_dest = dest; |
| 63 } |
| 64 void |
| 65 UanHeaderCommon::SetSrc (UanAddress src) |
| 66 { |
| 67 m_src = src; |
| 68 } |
| 69 |
| 70 void |
| 71 UanHeaderCommon::SetType (uint8_t type) |
| 72 { |
| 73 m_type = type; |
| 74 } |
| 75 |
| 76 UanAddress |
| 77 UanHeaderCommon::GetDest (void) const |
| 78 { |
| 79 return m_dest; |
| 80 } |
| 81 UanAddress |
| 82 UanHeaderCommon::GetSrc (void) const |
| 83 { |
| 84 return m_src; |
| 85 } |
| 86 uint8_t |
| 87 UanHeaderCommon::GetType (void) const |
| 88 { |
| 89 return m_type; |
| 90 } |
| 91 |
| 92 // Inherrited methods |
| 93 |
| 94 uint32_t |
| 95 UanHeaderCommon::GetSerializedSize (void) const |
| 96 { |
| 97 return 1 + 1 + 1; |
| 98 } |
| 99 |
| 100 void |
| 101 UanHeaderCommon::Serialize (Buffer::Iterator start) const |
| 102 { |
| 103 start.WriteU8 (m_src.GetAsInt ()); |
| 104 start.WriteU8 (m_dest.GetAsInt ()); |
| 105 start.WriteU8 (m_type); |
| 106 } |
| 107 |
| 108 uint32_t |
| 109 UanHeaderCommon::Deserialize (Buffer::Iterator start) |
| 110 { |
| 111 Buffer::Iterator rbuf = start; |
| 112 |
| 113 m_src = UanAddress (rbuf.ReadU8 ()); |
| 114 m_dest = UanAddress (rbuf.ReadU8 ()); |
| 115 m_type = rbuf.ReadU8 (); |
| 116 |
| 117 return rbuf.GetDistanceFrom (start); |
| 118 } |
| 119 |
| 120 void |
| 121 UanHeaderCommon::Print (std::ostream &os) const |
| 122 { |
| 123 os << "UAN src=" << m_src << " dest=" << m_dest << " type=" << (uint32_t) m_ty
pe; |
| 124 } |
| 125 |
| 126 |
| 127 |
| 128 |
| 129 } // namespace ns3 |
OLD | NEW |