Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | |
2 /* | |
3 * Copyright (c) 2013 Mohammed J.F. Alenazi | |
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: Mohammed J.F. Alenazi <malenazi@ittc.ku.edu> | |
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 by King Saud University and | |
27 * the ITTC at The University of Kansas. | |
28 */ | |
29 | |
30 #include "epidemic-packet.h" | |
31 #include "epidemic-tag.h" | |
32 #include "ns3/address-utils.h" | |
33 #include "ns3/log.h" | |
34 #include "ns3/packet.h" | |
35 | |
36 namespace ns3 { | |
37 namespace Epidemic { | |
38 | |
39 NS_OBJECT_ENSURE_REGISTERED (EpidemicTag); | |
40 | |
41 /// Get TypeId | |
42 TypeId EpidemicTag::GetTypeId () | |
43 { | |
44 static TypeId tid = TypeId ("ns3::epidemic::EpidemicTag").SetParent<Tag> () | |
Peter Barnes
2015/02/03 01:25:48
"ns3::Epidemic::…"
mjf.alenazi
2015/04/26 22:56:09
Done.
| |
45 .SetParent<Tag> () | |
46 .AddConstructor<EpidemicTag> () | |
47 ; | |
48 return tid; | |
49 } | |
50 | |
51 | |
52 /// Get instanceTypeId | |
53 TypeId EpidemicTag::GetInstanceTypeId () const | |
54 { | |
55 return GetTypeId (); | |
56 } | |
57 | |
58 /// Get epidemic tag | |
59 EpidemicTag::TagType EpidemicTag::GetTagType () const | |
60 { | |
61 return m_tag; | |
62 } | |
63 | |
64 bool | |
65 EpidemicTag::IsTagType (const TagType type) const | |
66 { | |
67 return m_tag == type; | |
68 } | |
69 | |
70 /// Set epidemic tag | |
71 void | |
72 EpidemicTag::SetTagType (const TagType tag) | |
73 { | |
74 m_tag = tag; | |
75 } | |
76 | |
77 /// Get size | |
78 uint32_t EpidemicTag::GetSerializedSize () const | |
79 { | |
80 return sizeof(uint8_t); | |
81 } | |
82 | |
83 | |
84 /// Serialize | |
85 void EpidemicTag::Serialize (TagBuffer i) const | |
86 { | |
87 i.WriteU8 ((uint8_t) m_tag); | |
88 } | |
89 | |
90 | |
91 | |
92 ///Deserialize | |
93 void EpidemicTag::Deserialize (TagBuffer i) | |
94 { | |
95 uint8_t type = i.ReadU8 (); | |
96 switch (type) | |
97 { | |
98 case CONTROL: | |
99 case NOT_SET: | |
100 { | |
101 m_tag = (TagType) type; | |
102 break; | |
103 } | |
104 default: | |
105 break; | |
106 } | |
107 | |
108 } | |
109 /// Print | |
110 void EpidemicTag::Print (std::ostream &os) const | |
111 { | |
112 os << "EpidemicTag:" << m_tag; | |
113 } | |
114 | |
115 } //end namespace epidemic | |
116 } //end namespace ns3 | |
OLD | NEW |