Alexander Afanasyev | 7e71c75 | 2012-01-25 21:40:39 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2011 UCLA |
| 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 19 | */ |
| 20 | |
| 21 | #include "ipv4-l3-tracer.h" |
| 22 | #include "ns3/node.h" |
Alexander Afanasyev | 7e71c75 | 2012-01-25 21:40:39 -0800 | [diff] [blame] | 23 | #include "ns3/config.h" |
| 24 | #include "ns3/names.h" |
| 25 | #include "ns3/callback.h" |
Alexander Afanasyev | 5352af3 | 2013-07-15 09:51:28 -0700 | [diff] [blame] | 26 | #include "ns3/ipv4-l3-protocol.h" |
Alexander Afanasyev | 7e71c75 | 2012-01-25 21:40:39 -0800 | [diff] [blame] | 27 | |
| 28 | #include <boost/lexical_cast.hpp> |
| 29 | |
| 30 | using namespace std; |
| 31 | |
| 32 | namespace ns3 { |
Alexander Afanasyev | 4916586 | 2013-01-31 00:38:20 -0800 | [diff] [blame] | 33 | |
Alexander Afanasyev | 7e71c75 | 2012-01-25 21:40:39 -0800 | [diff] [blame] | 34 | Ipv4L3Tracer::Ipv4L3Tracer (Ptr<Node> node) |
| 35 | : m_nodePtr (node) |
| 36 | { |
| 37 | m_node = boost::lexical_cast<string> (m_nodePtr->GetId ()); |
| 38 | |
| 39 | Connect (); |
| 40 | |
| 41 | string name = Names::FindName (node); |
| 42 | if (!name.empty ()) |
| 43 | { |
| 44 | m_node = name; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | void |
| 49 | Ipv4L3Tracer::Connect () |
| 50 | { |
Alexander Afanasyev | 5352af3 | 2013-07-15 09:51:28 -0700 | [diff] [blame] | 51 | Ptr<Ipv4L3Protocol> ip = m_nodePtr->GetObject<Ipv4L3Protocol> (); |
| 52 | ip->TraceConnectWithoutContext ("Tx", MakeCallback (&Ipv4L3Tracer::Tx, this)); |
| 53 | ip->TraceConnectWithoutContext ("Rx", MakeCallback (&Ipv4L3Tracer::Rx, this)); |
| 54 | ip->TraceConnectWithoutContext ("Drop", MakeCallback (&Ipv4L3Tracer::Drop, this)); |
Alexander Afanasyev | 7e71c75 | 2012-01-25 21:40:39 -0800 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | } // namespace ns3 |