src/internet-stack/netfilter-conntrack-tuple.h
author Qasim Javed <qasimj@gmail.com>
Thu Aug 06 01:55:49 2009 +0600 (2009-08-06)
changeset 4638 19aa5f9b4bdf
parent 4637 0882bb6eac0b
permissions -rw-r--r--
Source NAT working! Run (examples/netfilter-example.cc)
qasimj@4634
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
qasimj@4634
     2
/* 
qasimj@4634
     3
 * Copyright (c) 2009 University of Texas at Dallas
qasimj@4634
     4
 * 
qasimj@4634
     5
 * This program is free software; you can redistribute it and/or modify
qasimj@4634
     6
 * it under the terms of the GNU General Public License version 2 as
qasimj@4634
     7
 * published by the Free Software Foundation;
qasimj@4634
     8
 *
qasimj@4634
     9
 * This program is distributed in the hope that it will be useful,
qasimj@4634
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
qasimj@4634
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
qasimj@4634
    12
 * GNU General Public License for more details.
qasimj@4634
    13
 *
qasimj@4634
    14
 * You should have received a copy of the GNU General Public License
qasimj@4634
    15
 * along with this program; if not, write to the Free Software
qasimj@4634
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
qasimj@4634
    17
 * 
qasimj@4634
    18
 * Author: Qasim Javed <qasim@utdallas.edu>
qasimj@4634
    19
 */
qasimj@4634
    20
#ifndef NETFILTER_CONNTRACK_TUPLE_H
qasimj@4634
    21
#define NETFILTER_CONNTRACK_TUPLE_H
qasimj@4634
    22
qasimj@4634
    23
#include "ns3/log.h"
qasimj@4634
    24
#include "ns3/ipv4-address.h"
qasimj@4634
    25
#include "ns3/ref-count-base.h"
qasimj@4634
    26
#include "ns3/object.h"
qasimj@4634
    27
#include "ip-conntrack-info.h"
qasimj@4634
    28
//#include "jhash.h"
qasimj@4634
    29
qasimj@4634
    30
qasimj@4634
    31
namespace ns3 {
qasimj@4634
    32
qasimj@4634
    33
class Object;
qasimj@4634
    34
class Ipv4Address;
qasimj@4634
    35
qasimj@4634
    36
class NetfilterConntrackTuple : public RefCountBase {
qasimj@4634
    37
  public:
qasimj@4636
    38
    NetfilterConntrackTuple ();
qasimj@4636
    39
    NetfilterConntrackTuple (Ipv4Address src, uint16_t srcPort, Ipv4Address dst, uint16_t dstPort);
qasimj@4636
    40
    bool operator== (const NetfilterConntrackTuple t) const;
qasimj@4636
    41
    bool SourceEqual (NetfilterConntrackTuple t1, NetfilterConntrackTuple t2);
qasimj@4636
    42
    bool DestinationEqual (NetfilterConntrackTuple t1, NetfilterConntrackTuple t2);
qasimj@4636
    43
    NetfilterConntrackTuple Invert ();
qasimj@4634
    44
qasimj@4636
    45
    Ipv4Address GetSource () const;
qasimj@4636
    46
    Ipv4Address GetDestination () const;
qasimj@4636
    47
    uint16_t GetSourcePort () const;
qasimj@4636
    48
    uint16_t GetDestinationPort () const;
qasimj@4636
    49
    char * ToString () const;
qasimj@4636
    50
    uint16_t GetDestinationProtocol () const;
qasimj@4636
    51
    uint8_t GetDirection () const;
qasimj@4636
    52
    uint16_t GetProtocol ();
qasimj@4634
    53
qasimj@4636
    54
    void SetSource (Ipv4Address source);
qasimj@4636
    55
    void SetSourcePort (uint16_t source);
qasimj@4636
    56
    void SetDestination (Ipv4Address destination);
qasimj@4636
    57
    void SetDestinationPort (uint16_t destination);
qasimj@4636
    58
    void SetProtocol (uint16_t protocol);
qasimj@4636
    59
    void SetDirection (ConntrackDirection_t direction);
qasimj@4634
    60
qasimj@4634
    61
    void Print (std::ostream &os) const;
qasimj@4634
    62
qasimj@4638
    63
    NetfilterConntrackTuple& operator= (const NetfilterConntrackTuple&  tuple);
qasimj@4638
    64
    friend std::ostream& operator << (std::ostream& os, NetfilterConntrackTuple const& tuple);
qasimj@4638
    65
qasimj@4634
    66
  private:
qasimj@4637
    67
    Ipv4Address m_l3Source;
qasimj@4637
    68
    uint16_t m_l3Protocol;
qasimj@4637
    69
    uint16_t m_l4Source;
qasimj@4634
    70
qasimj@4637
    71
    Ipv4Address m_l3Destination;
qasimj@4637
    72
    uint16_t m_l4Destination;
qasimj@4637
    73
    uint8_t m_protocolNumber;
qasimj@4634
    74
    uint8_t m_direction;
qasimj@4634
    75
};
qasimj@4634
    76
qasimj@4634
    77
qasimj@4634
    78
class ConntrackTupleHash : public std::unary_function<NetfilterConntrackTuple, size_t> {
qasimj@4634
    79
public:
qasimj@4634
    80
  size_t operator()(const NetfilterConntrackTuple &x) const;
qasimj@4634
    81
};
qasimj@4634
    82
qasimj@4634
    83
}
qasimj@4634
    84
#endif /* NETFILTER_CONNTRACK_TUPLE_H */