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