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>
20 #ifndef NETFILTER_CONNTRACK_TUPLE_H
21 #define NETFILTER_CONNTRACK_TUPLE_H
24 #include "ns3/ipv4-address.h"
25 #include "ns3/ref-count-base.h"
26 #include "ns3/object.h"
27 #include "ip-conntrack-info.h"
36 class NetfilterConntrackTuple : public RefCountBase {
38 NetfilterConntrackTuple ();
39 NetfilterConntrackTuple (Ipv4Address src, uint16_t srcPort, Ipv4Address dst, uint16_t dstPort);
40 bool operator== (const NetfilterConntrackTuple t) const;
41 bool SourceEqual (NetfilterConntrackTuple t1, NetfilterConntrackTuple t2);
42 bool DestinationEqual (NetfilterConntrackTuple t1, NetfilterConntrackTuple t2);
43 NetfilterConntrackTuple Invert ();
45 Ipv4Address GetSource () const;
46 Ipv4Address GetDestination () const;
47 uint16_t GetSourcePort () const;
48 uint16_t GetDestinationPort () const;
49 char * ToString () const;
50 uint16_t GetDestinationProtocol () const;
51 uint8_t GetDirection () const;
52 uint16_t GetProtocol ();
54 void SetSource (Ipv4Address source);
55 void SetSourcePort (uint16_t source);
56 void SetDestination (Ipv4Address destination);
57 void SetDestinationPort (uint16_t destination);
58 void SetProtocol (uint16_t protocol);
59 void SetDirection (ConntrackDirection_t direction);
61 void Print (std::ostream &os) const;
63 NetfilterConntrackTuple& operator= (const NetfilterConntrackTuple& tuple);
64 friend std::ostream& operator << (std::ostream& os, NetfilterConntrackTuple const& tuple);
67 Ipv4Address m_l3Source;
68 uint16_t m_l3Protocol;
71 Ipv4Address m_l3Destination;
72 uint16_t m_l4Destination;
73 uint8_t m_protocolNumber;
78 class ConntrackTupleHash : public std::unary_function<NetfilterConntrackTuple, size_t> {
80 size_t operator()(const NetfilterConntrackTuple &x) const;
84 #endif /* NETFILTER_CONNTRACK_TUPLE_H */