src/internet-stack/ip-conntrack-info.h
author Qasim Javed <qasimj@gmail.com>
Thu Aug 06 01:55:49 2009 +0600 (2009-08-06)
changeset 4638 19aa5f9b4bdf
parent 4636 be76844f7b75
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 IP_CONNTRACK_INFO
qasimj@4634
    21
#define IP_CONNTRACK_INFO
qasimj@4634
    22
qasimj@4634
    23
#include <stdint.h>
qasimj@4634
    24
qasimj@4634
    25
qasimj@4634
    26
namespace ns3 {
qasimj@4634
    27
    typedef enum {
qasimj@4634
    28
      IP_CT_ESTABLISHED,
qasimj@4634
    29
      IP_CT_RELATED,
qasimj@4634
    30
      IP_CT_NEW,
qasimj@4634
    31
      IP_CT_IS_REPLY,
qasimj@4634
    32
      IP_CT_NUMBER = IP_CT_IS_REPLY * 2 - 1
qasimj@4634
    33
    } ConntrackInfo_t;
qasimj@4634
    34
    
qasimj@4634
    35
    typedef enum {
qasimj@4634
    36
      IP_CT_DIR_ORIGINAL,
qasimj@4634
    37
      IP_CT_DIR_REPLY,
qasimj@4634
    38
      IP_CT_DIR_MAX,
qasimj@4634
    39
    } ConntrackDirection_t;
qasimj@4634
    40
    
qasimj@4634
    41
    typedef enum {
qasimj@4634
    42
      IPS_EXPECTED_BIT=0,
qasimj@4634
    43
      IPS_EXPECTED = (1 << IPS_EXPECTED_BIT),
qasimj@4634
    44
qasimj@4634
    45
      IPS_SEEN_REPLY_BIT = 1,
qasimj@4634
    46
      IPS_SEEN_REPLY = (1 << IPS_SEEN_REPLY_BIT),
qasimj@4634
    47
qasimj@4634
    48
      IPS_ASSURED_BIT = 2,
qasimj@4634
    49
      IPS_ASSURED = (1 << IPS_ASSURED_BIT),
qasimj@4634
    50
qasimj@4634
    51
      IPS_CONFIRMED_BIT = 3,
qasimj@4634
    52
      IPS_CONFIRMED = (1 << IPS_CONFIRMED_BIT),
qasimj@4634
    53
qasimj@4634
    54
      IPS_SRC_NAT_BIT = 4,
qasimj@4634
    55
      IPS_SRC_NAT = (1 << IPS_SRC_NAT_BIT),
qasimj@4634
    56
qasimj@4634
    57
      IPS_DST_NAT_BIT = 5,
qasimj@4634
    58
      IPS_DST_NAT = (1 << IPS_DST_NAT_BIT),
qasimj@4634
    59
qasimj@4634
    60
      IPS_NAT_MASK = (IPS_DST_NAT | IPS_SRC_NAT),
qasimj@4634
    61
qasimj@4634
    62
      IPS_SEQ_ADJUST_BIT = 6,
qasimj@4634
    63
      IPS_SEQ_ADJUST = (1 << IPS_SEQ_ADJUST_BIT),
qasimj@4634
    64
qasimj@4634
    65
      IPS_SRC_NAT_DONE_BIT = 7,
qasimj@4634
    66
      IPS_SRC_NAT_DONE = (1 << IPS_SRC_NAT_DONE_BIT),
qasimj@4634
    67
qasimj@4634
    68
      IPS_DST_NAT_DONE_BIT = 8,
qasimj@4634
    69
      IPS_DST_NAT_DONE = (1 << IPS_DST_NAT_DONE_BIT),
qasimj@4634
    70
qasimj@4634
    71
      IPS_NAT_DONE_MASK = (IPS_DST_NAT_DONE | IPS_SRC_NAT_DONE),
qasimj@4634
    72
qasimj@4634
    73
      IPS_DYING_BIT = 9,
qasimj@4634
    74
      IPS_DYING = (1 << IPS_DYING_BIT),
qasimj@4634
    75
qasimj@4634
    76
    } ConntrackStatus_t;
qasimj@4634
    77
qasimj@4634
    78
class IpConntrackInfo {
qasimj@4634
    79
  public:
qasimj@4636
    80
    IpConntrackInfo ();
qasimj@4636
    81
    IpConntrackInfo (uint32_t);
qasimj@4636
    82
    void SetStatus (uint32_t status);
qasimj@4636
    83
    uint32_t GetStatus ();
qasimj@4636
    84
    bool IsConfirmed ();
qasimj@4636
    85
    void SetConfirmed ();
qasimj@4636
    86
    bool IsDying ();
qasimj@4636
    87
    void SetDying ();
qasimj@4634
    88
qasimj@4638
    89
    void SetInfo (uint8_t info);
qasimj@4638
    90
    uint8_t GetInfo ();
qasimj@4638
    91
qasimj@4636
    92
    ConntrackDirection_t ConntrackInfoToDirection (ConntrackInfo_t ctinfo);
qasimj@4634
    93
qasimj@4634
    94
  private:
qasimj@4634
    95
    uint32_t m_status;
qasimj@4638
    96
    uint8_t m_info;
qasimj@4634
    97
};
qasimj@4634
    98
qasimj@4634
    99
}
qasimj@4634
   100
qasimj@4634
   101
#endif /* IP_CONNTRACK_INFO */