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