A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
eps-bearer-tag.cc
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011,2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
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: Marco Miozzo <marco.miozzo@cttc.es>
19  * Nicola Baldo <nbaldo@cttc.es>
20  */
21 
22 
23 #include "eps-bearer-tag.h"
24 #include "ns3/tag.h"
25 #include "ns3/uinteger.h"
26 
27 namespace ns3 {
28 
29 NS_OBJECT_ENSURE_REGISTERED (EpsBearerTag);
30 
31 TypeId
32 EpsBearerTag::GetTypeId (void)
33 {
34  static TypeId tid = TypeId ("ns3::EpsBearerTag")
35  .SetParent<Tag> ()
36  .AddConstructor<EpsBearerTag> ()
37  .AddAttribute ("rnti", "The rnti that indicates the UE which packet belongs",
38  UintegerValue (0),
39  MakeUintegerAccessor (&EpsBearerTag::GetRnti),
40  MakeUintegerChecker<uint16_t> ())
41  .AddAttribute ("bid", "The EPS bearer id within the UE to which the packet belongs",
42  UintegerValue (0),
43  MakeUintegerAccessor (&EpsBearerTag::GetBid),
44  MakeUintegerChecker<uint8_t> ())
45  ;
46  return tid;
47 }
48 
49 TypeId
51 {
52  return GetTypeId ();
53 }
54 
56  : m_rnti (0),
57  m_bid (0)
58 {
59 }
60 EpsBearerTag::EpsBearerTag (uint16_t rnti, uint8_t bid)
61  : m_rnti (rnti),
62  m_bid (bid)
63 {
64 }
65 
66 void
67 EpsBearerTag::SetRnti (uint16_t rnti)
68 {
69  m_rnti = rnti;
70 }
71 
72 void
73 EpsBearerTag::SetBid (uint8_t bid)
74 {
75  m_bid = bid;
76 }
77 
78 uint32_t
80 {
81  return 3;
82 }
83 
84 void
86 {
87  i.WriteU16 (m_rnti);
88  i.WriteU8 (m_bid);
89 }
90 
91 void
93 {
94  m_rnti = (uint16_t) i.ReadU16 ();
95  m_bid = (uint8_t) i.ReadU8 ();
96 }
97 
98 uint16_t
99 EpsBearerTag::GetRnti () const
100 {
101  return m_rnti;
102 }
103 
104 uint8_t
105 EpsBearerTag::GetBid () const
106 {
107  return m_bid;
108 }
109 
110 void
111 EpsBearerTag::Print (std::ostream &os) const
112 {
113  os << "rnti=" << m_rnti << ", bid=" << (uint16_t) m_bid;
114 }
115 
116 } // namespace ns3
void SetBid(uint8_t bid)
virtual TypeId GetInstanceTypeId(void) const
TAG_BUFFER_INLINE uint8_t ReadU8(void)
Definition: tag-buffer.h:179
TAG_BUFFER_INLINE void WriteU16(uint16_t v)
Definition: tag-buffer.h:164
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
Definition: tag-buffer.h:156
read and write tag data
Definition: tag-buffer.h:51
virtual void Serialize(TagBuffer i) const
virtual void Deserialize(TagBuffer i)
void SetRnti(uint16_t tid)
TAG_BUFFER_INLINE uint16_t ReadU16(void)
Definition: tag-buffer.h:189
virtual void Print(std::ostream &os) const
virtual uint32_t GetSerializedSize() const