00001 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 2008 INRIA 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation; 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> 00019 */ 00020 #include "flow-id-tag.h" 00021 00022 namespace ns3 { 00023 00024 TypeId 00025 FlowIdTag::GetTypeId (void) 00026 { 00027 static TypeId tid = TypeId ("ns3::FlowIdTag") 00028 .SetParent<Tag> () 00029 .AddConstructor<FlowIdTag> () 00030 ; 00031 return tid; 00032 } 00033 TypeId 00034 FlowIdTag::GetInstanceTypeId (void) const 00035 { 00036 return GetTypeId (); 00037 } 00038 uint32_t 00039 FlowIdTag::GetSerializedSize (void) const 00040 { 00041 return 4; 00042 } 00043 void 00044 FlowIdTag::Serialize (TagBuffer buf) const 00045 { 00046 buf.WriteU32 (m_flowId); 00047 } 00048 void 00049 FlowIdTag::Deserialize (TagBuffer buf) 00050 { 00051 m_flowId = buf.ReadU32 (); 00052 } 00053 void 00054 FlowIdTag::Print (std::ostream &os) const 00055 { 00056 os << "FlowId=" << m_flowId; 00057 } 00058 FlowIdTag::FlowIdTag () 00059 : Tag () 00060 {} 00061 00062 FlowIdTag::FlowIdTag (uint32_t id) 00063 : Tag (), 00064 m_flowId (id) 00065 {} 00066 00067 void 00068 FlowIdTag::SetFlowId (uint32_t id) 00069 { 00070 m_flowId = id; 00071 } 00072 uint32_t 00073 FlowIdTag::GetFlowId (void) const 00074 { 00075 return m_flowId; 00076 } 00077 00078 uint32_t 00079 FlowIdTag::AllocateFlowId (void) 00080 { 00081 static uint32_t nextFlowId = 1; 00082 uint32_t flowId = nextFlowId; 00083 nextFlowId++; 00084 return flowId; 00085 } 00086 00087 } // namespace ns3 00088