1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
3 * Copyright (c) 2009 University of Texas at Dallas
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;
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.
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
18 * Author: Qasim Javed <qasim@utdallas.edu>
21 #include "ns3/ipv4-header.h"
22 #include "ns3/callback.h"
23 #include "ns3/conntrack-tag.h"
24 #include "ipv4-conntrack-l3-protocol.h"
26 NS_LOG_COMPONENT_DEFINE ("Ipv4ConntrackL3Protocol");
30 Ipv4ConntrackL3Protocol::Ipv4ConntrackL3Protocol ()
35 Ipv4ConntrackL3Protocol::Ipv4Confirm (Hooks_t hookNumber, Ptr<Packet> packet, Ptr<NetDevice> in,
36 Ptr<NetDevice> out, ContinueCallback& ccb)
38 NS_LOG_DEBUG (":: Executing hook function Ipv4Confirm ::");
39 /*ConntrackTag ctinfo;
40 bool tagFound = packet->PeekPacketTag (ctinfo);
42 if (!tagFound || ctinfo.GetConntrack () == IP_CT_RELATED + IP_CT_IS_REPLY)
44 NS_LOG_DEBUG ("Conntrack tag not found");
48 // Call conntrack helper here
50 NS_ASSERT (!ccb.IsNull ());
51 // NetfilterConntrackConfirm
52 NS_LOG_DEBUG ("Invoking the ContinueCallback");
59 Ipv4ConntrackL3Protocol::Ipv4ConntrackPreRoutingHook (Hooks_t hookNumber, Ptr<Packet> p, Ptr<NetDevice> in, Ptr<NetDevice> out, ContinueCallback& ccb)
65 Ipv4ConntrackL3Protocol::Ipv4ConntrackInHook (Hooks_t hookNumber, Ptr<Packet> p, Ptr<NetDevice> in, Ptr<NetDevice> out, ContinueCallback& ccb)
71 Ipv4ConntrackL3Protocol::Ipv4ConntrackOutHook (Hooks_t hookNumber, Ptr<Packet> p, Ptr<NetDevice> in, Ptr<NetDevice> out, ContinueCallback& ccb)
77 Ipv4ConntrackL3Protocol::Ipv4ConntrackPostRoutingHook (Hooks_t hookNumber, Ptr<Packet> p, Ptr<NetDevice> in, Ptr<NetDevice> out, ContinueCallback& ccb)
83 Ipv4ConntrackL3Protocol::RegisterPreRoutingHook ()
89 Ipv4ConntrackL3Protocol::RegisterInHook ()
95 Ipv4ConntrackL3Protocol::RegisterOutHook ()
101 Ipv4ConntrackL3Protocol::RegisterPostRoutingHook ()
107 Ipv4ConntrackL3Protocol::PacketToTuple (Ptr<Packet> packet, NetfilterConntrackTuple& tuple)
111 packet->PeekHeader (ipHeader);
113 tuple.SetSource (ipHeader.GetSource ());
114 tuple.SetDestination (ipHeader.GetDestination ());
116 NS_LOG_DEBUG ("Ipv4 Packet To Tuple: " << "( " << tuple.GetSource () << "," << tuple.GetSourcePort () << "," << tuple.GetDestination () << "," << tuple.GetDestinationPort () << ")" );
122 Ipv4ConntrackL3Protocol::InvertTuple (NetfilterConntrackTuple& inverse, NetfilterConntrackTuple& orig)
124 inverse.SetSource (orig.GetDestination () );
125 inverse.SetDestination (orig.GetSource () );