blob: 77afdecf96bd5c5a7d48560c3529b182ab6d8080 [file] [log] [blame]
Ilya Moiseenko59c62212011-08-04 19:04:24 -07001//
2// ndn_timeoutheader.cpp
3// Abstraction
4//
5// Created by Ilya Moiseenko on 04.08.11.
6// Copyright 2011 UCLA. All rights reserved.
7//
8
9#include "ndn_timeoutheader.h"
10
11namespace ns3
12{
13namespace NDNabstraction
14{
15 NS_OBJECT_ENSURE_REGISTERED (TimeoutHeader);
16
17 TimeoutHeader::TimeoutHeader()
18 {
19 m_value = 4000;
20 }
21
22 TimeoutHeader::TimeoutHeader (uint32_t timeout)
23 {
24 m_value = timeout;
25 }
26
27 TypeId
28 TimeoutHeader::GetTypeId ()
29 {
30 static TypeId tid = TypeId ("ns3::NDNabstraction::TimeoutHeader")
31 .SetParent<Header> ()
32 .AddConstructor<TimeoutHeader> ()
33 ;
34 return tid;
35 }
36
37 TypeId
38 TimeoutHeader::GetInstanceTypeId () const
39 {
40 return GetTypeId ();
41 }
42
43 uint32_t
44 TimeoutHeader::GetSerializedSize () const
45 {
46 return 4;
47 }
48
49 void
50 TimeoutHeader::Serialize (Buffer::Iterator i) const
51 {
52 i.WriteU32 ((uint32_t) m_value);
53 }
54
55 uint32_t
56 TimeoutHeader::Deserialize (Buffer::Iterator start)
57 {
58 Buffer::Iterator i = start;
59 m_value = i.ReadU32 ();
60
61 uint32_t dist = i.GetDistanceFrom (start);
62 NS_ASSERT (dist == GetSerializedSize ());
63 return dist;
64 }
65
66 void
67 TimeoutHeader::Print (std::ostream &os) const
68 {
69 os << m_value;
70 }
71
72 uint32_t
73 TimeoutHeader::GetValue()
74 {
75 return m_value;
76 }
77}
78}