A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
qos-blocked-destinations.cc
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005, 2009 INRIA
4  * Copyright (c) 2009 MIRKO BANCHI
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Author: Mirko Banchi <mk.banchi@gmail.com>
20  */
21 #include "qos-blocked-destinations.h"
22 
23 namespace ns3 {
24 
25 QosBlockedDestinations::QosBlockedDestinations ()
26 {
27 }
28 
29 QosBlockedDestinations::~QosBlockedDestinations ()
30 {
31 }
32 
33 bool
34 QosBlockedDestinations::IsBlocked (Mac48Address dest, uint8_t tid) const
35 {
36  for (BlockedPacketsCI i = m_blockedQosPackets.begin (); i != m_blockedQosPackets.end (); i++)
37  {
38  if (i->first == dest && i->second == tid)
39  {
40  return true;
41  }
42  }
43  return false;
44 }
45 
46 void
47 QosBlockedDestinations::Block (Mac48Address dest, uint8_t tid)
48 {
49  if (!IsBlocked (dest, tid))
50  {
51  m_blockedQosPackets.push_back (std::make_pair (dest, tid));
52  }
53 }
54 
55 void
56 QosBlockedDestinations::Unblock (Mac48Address dest, uint8_t tid)
57 {
58  for (BlockedPacketsI i = m_blockedQosPackets.begin (); i != m_blockedQosPackets.end (); i++)
59  {
60  if (i->first == dest && i->second == tid)
61  {
62  m_blockedQosPackets.erase (i);
63  break;
64  }
65  }
66 }
67 
68 } // namespace ns3