src/internet-stack/ip-conntrack-info.cc
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 #include "ip-conntrack-info.h"
    21 
    22 namespace ns3 {
    23 
    24 IpConntrackInfo::IpConntrackInfo ()
    25 {
    26   m_status = 0;
    27 }
    28 
    29 IpConntrackInfo::IpConntrackInfo (uint32_t status)
    30 {
    31   m_status = status;
    32 }
    33 
    34 void 
    35 IpConntrackInfo::SetStatus (uint32_t status) 
    36 {
    37   m_status |= status;
    38 }
    39 
    40 uint32_t 
    41 IpConntrackInfo::GetStatus ()
    42 {
    43   return m_status;
    44 }
    45 
    46 void 
    47 IpConntrackInfo::SetInfo (uint8_t info) 
    48 {
    49   m_info = info;
    50 }
    51 
    52 uint8_t 
    53 IpConntrackInfo::GetInfo ()
    54 {
    55   return m_info;
    56 }
    57 
    58 bool
    59 IpConntrackInfo::IsConfirmed ()
    60 {
    61   if ( m_status & IPS_CONFIRMED )
    62     return true;
    63   else
    64     return false;
    65 }
    66 
    67 void
    68 IpConntrackInfo::SetConfirmed ()
    69 {
    70   m_status |= IPS_CONFIRMED;
    71 }
    72 
    73 bool
    74 IpConntrackInfo::IsDying ()
    75 {
    76   if ( m_status & IPS_DYING )
    77     return true;
    78   else
    79     return false;
    80 }
    81 
    82 void 
    83 IpConntrackInfo::SetDying ()
    84 {
    85   m_status |= IPS_DYING;
    86 }
    87 
    88 ConntrackDirection_t 
    89 ConntrackInfoToDirection (ConntrackInfo_t ctinfo)
    90 {
    91   return ctinfo >= IP_CT_IS_REPLY ? IP_CT_DIR_REPLY : IP_CT_DIR_ORIGINAL;
    92 }
    93 
    94 }