OLD | NEW |
(Empty) | |
| 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2010 Hemanth Narra |
| 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: Hemanth Narra <hemanth@ittc.ku.com> |
| 19 * |
| 20 * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director |
| 21 * ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets |
| 22 * Information and Telecommunication Technology Center (ITTC) |
| 23 * and Department of Electrical Engineering and Computer Science |
| 24 * The University of Kansas Lawrence, KS USA. |
| 25 * |
| 26 * Work supported in part by NSF FIND (Future Internet Design) Program |
| 27 * under grant CNS-0626918 (Postmodern Internet Architecture), |
| 28 * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimenta
tion on GENI), |
| 29 * US Department of Defense (DoD), and ITTC at The University of Kansas. |
| 30 */ |
| 31 #include "dsdv6-packet.h" |
| 32 #include "ns3/address-utils.h" |
| 33 #include "ns3/packet.h" |
| 34 |
| 35 namespace ns3 { |
| 36 namespace dsdv6 { |
| 37 |
| 38 NS_OBJECT_ENSURE_REGISTERED (Dsdv6Header); |
| 39 |
| 40 Dsdv6Header::Dsdv6Header (Ipv6Address dst, uint32_t hopCount, uint32_t dstSeqNo) |
| 41 : m_dst (dst), |
| 42 m_hopCount (hopCount), |
| 43 m_dstSeqNo (dstSeqNo) |
| 44 { |
| 45 } |
| 46 |
| 47 Dsdv6Header::~Dsdv6Header () |
| 48 { |
| 49 } |
| 50 |
| 51 TypeId |
| 52 Dsdv6Header::GetTypeId (void) |
| 53 { |
| 54 static TypeId tid = TypeId ("ns3::dsdv6::Dsdv6Header") |
| 55 .SetParent<Header> () |
| 56 .SetGroupName ("Dsdv6") |
| 57 .AddConstructor<Dsdv6Header> (); |
| 58 return tid; |
| 59 } |
| 60 |
| 61 TypeId |
| 62 Dsdv6Header::GetInstanceTypeId () const |
| 63 { |
| 64 return GetTypeId (); |
| 65 } |
| 66 |
| 67 uint32_t |
| 68 Dsdv6Header::GetSerializedSize () const |
| 69 { |
| 70 return 24; |
| 71 } |
| 72 |
| 73 void |
| 74 Dsdv6Header::Serialize (Buffer::Iterator i) const |
| 75 { |
| 76 WriteTo (i, m_dst); |
| 77 i.WriteHtonU32 (m_hopCount); |
| 78 i.WriteHtonU32 (m_dstSeqNo); |
| 79 |
| 80 } |
| 81 |
| 82 uint32_t |
| 83 Dsdv6Header::Deserialize (Buffer::Iterator start) |
| 84 { |
| 85 Buffer::Iterator i = start; |
| 86 |
| 87 ReadFrom (i, m_dst); |
| 88 m_hopCount = i.ReadNtohU32 (); |
| 89 m_dstSeqNo = i.ReadNtohU32 (); |
| 90 |
| 91 uint32_t dist = i.GetDistanceFrom (start); |
| 92 NS_ASSERT (dist == GetSerializedSize ()); |
| 93 return dist; |
| 94 } |
| 95 |
| 96 void |
| 97 Dsdv6Header::Print (std::ostream &os) const |
| 98 { |
| 99 os << "DestinationIpv6: " << m_dst |
| 100 << " Hopcount: " << m_hopCount |
| 101 << " SequenceNumber: " << m_dstSeqNo; |
| 102 } |
| 103 } |
| 104 } |
OLD | NEW |