src/internet/model/ipv4-end-point.cc
author Pedro Silva <pmms@inesctec.pt>
Wed, 29 Oct 2014 10:12:53 -0700
changeset 11040 cd2eda848730
parent 10968 2d29fee2b7b8
child 11470 0b3d6135a28b
permissions -rw-r--r--
bug 1791: TCP Endpoint never deallocates when closing
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7385
10beb0e53130 standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents: 7176
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
/*
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
 * Copyright (c) 2005 INRIA
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
 *
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
 *
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * GNU General Public License for more details.
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 *
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 *
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 */
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
#include "ipv4-end-point.h"
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1317
diff changeset
    22
#include "ns3/packet.h"
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3260
diff changeset
    23
#include "ns3/log.h"
4022
142c13a3975f Mathieu's patch: Avoid stack explosion (bug 417)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3820
diff changeset
    24
#include "ns3/simulator.h"
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3260
diff changeset
    25
10968
2d29fee2b7b8 [Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9710
diff changeset
    26
namespace ns3 {
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
10968
2d29fee2b7b8 [Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 9710
diff changeset
    28
NS_LOG_COMPONENT_DEFINE ("Ipv4EndPoint");
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
2365
89da0ca7c55e undoes 2326:eec07777d1a2 because localInterface is no longer needed (see bug 136)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2326
diff changeset
    30
Ipv4EndPoint::Ipv4EndPoint (Ipv4Address address, uint16_t port)
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
  : m_localAddr (address), 
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
    m_localPort (port),
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
    m_peerAddr (Ipv4Address::GetAny ()),
2365
89da0ca7c55e undoes 2326:eec07777d1a2 because localInterface is no longer needed (see bug 136)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 2326
diff changeset
    34
    m_peerPort (0)
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
    35
{
9710
df21b904fce3 Further work on cleaning up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 9217
diff changeset
    36
  NS_LOG_FUNCTION (this << address << port);
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
    37
}
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    38
Ipv4EndPoint::~Ipv4EndPoint ()
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
    39
{
9710
df21b904fce3 Further work on cleaning up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 9217
diff changeset
    40
  NS_LOG_FUNCTION (this);
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
    41
  if (!m_destroyCallback.IsNull ())
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
    42
    {
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
    43
      m_destroyCallback ();
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
    44
    }
7747
53a26ce38807 Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 7386
diff changeset
    45
  m_rxCallback.Nullify ();
53a26ce38807 Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 7386
diff changeset
    46
  m_icmpCallback.Nullify ();
53a26ce38807 Bug 1377: various memory leaks
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents: 7386
diff changeset
    47
  m_destroyCallback.Nullify ();
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
    48
}
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    49
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    50
Ipv4Address 
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    51
Ipv4EndPoint::GetLocalAddress (void)
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    52
{
9710
df21b904fce3 Further work on cleaning up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 9217
diff changeset
    53
  NS_LOG_FUNCTION (this);
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    54
  return m_localAddr;
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    55
}
1317
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
    56
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
    57
void 
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
    58
Ipv4EndPoint::SetLocalAddress (Ipv4Address address)
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
    59
{
9710
df21b904fce3 Further work on cleaning up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 9217
diff changeset
    60
  NS_LOG_FUNCTION (this << address);
1317
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
    61
  m_localAddr = address;
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
    62
}
82629189efff Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents: 1308
diff changeset
    63
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    64
uint16_t 
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    65
Ipv4EndPoint::GetLocalPort (void)
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    66
{
9710
df21b904fce3 Further work on cleaning up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 9217
diff changeset
    67
  NS_LOG_FUNCTION (this);
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    68
  return m_localPort;
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    69
}
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
Ipv4Address 
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    71
Ipv4EndPoint::GetPeerAddress (void)
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    72
{
9710
df21b904fce3 Further work on cleaning up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 9217
diff changeset
    73
  NS_LOG_FUNCTION (this);
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    74
  return m_peerAddr;
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    75
}
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    76
uint16_t 
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    77
Ipv4EndPoint::GetPeerPort (void)
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    78
{
9710
df21b904fce3 Further work on cleaning up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 9217
diff changeset
    79
  NS_LOG_FUNCTION (this);
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    80
  return m_peerPort;
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    81
}
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    82
void 
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    83
Ipv4EndPoint::SetPeer (Ipv4Address address, uint16_t port)
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    84
{
9710
df21b904fce3 Further work on cleaning up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 9217
diff changeset
    85
  NS_LOG_FUNCTION (this << address << port);
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    86
  m_peerAddr = address;
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    87
  m_peerPort = port;
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    88
}
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    89
5856
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 4022
diff changeset
    90
void
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 4022
diff changeset
    91
Ipv4EndPoint::BindToNetDevice (Ptr<NetDevice> netdevice)
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 4022
diff changeset
    92
{
9710
df21b904fce3 Further work on cleaning up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 9217
diff changeset
    93
  NS_LOG_FUNCTION (this << netdevice);
5856
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 4022
diff changeset
    94
  m_boundnetdevice = netdevice;
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 4022
diff changeset
    95
  return;
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 4022
diff changeset
    96
}
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 4022
diff changeset
    97
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 4022
diff changeset
    98
Ptr<NetDevice> 
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 4022
diff changeset
    99
Ipv4EndPoint::GetBoundNetDevice (void)
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 4022
diff changeset
   100
{
9710
df21b904fce3 Further work on cleaning up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 9217
diff changeset
   101
  NS_LOG_FUNCTION (this);
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
   102
  return m_boundnetdevice;
5856
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 4022
diff changeset
   103
}
7fd20c798a7d bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents: 4022
diff changeset
   104
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
   105
void 
6442
f380cf1aa4d8 Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 5971
diff changeset
   106
Ipv4EndPoint::SetRxCallback (Callback<void,Ptr<Packet>, Ipv4Header, uint16_t, Ptr<Ipv4Interface> > callback)
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
   107
{
9710
df21b904fce3 Further work on cleaning up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 9217
diff changeset
   108
  NS_LOG_FUNCTION (this << &callback);
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
   109
  m_rxCallback = callback;
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
   110
}
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3260
diff changeset
   111
void 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3260
diff changeset
   112
Ipv4EndPoint::SetIcmpCallback (Callback<void,Ipv4Address,uint8_t,uint8_t,uint8_t,uint32_t> callback)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3260
diff changeset
   113
{
9710
df21b904fce3 Further work on cleaning up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 9217
diff changeset
   114
  NS_LOG_FUNCTION (this << &callback);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3260
diff changeset
   115
  m_icmpCallback = callback;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3260
diff changeset
   116
}
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
   117
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
   118
void 
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
   119
Ipv4EndPoint::SetDestroyCallback (Callback<void> callback)
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
   120
{
9710
df21b904fce3 Further work on cleaning up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 9217
diff changeset
   121
  NS_LOG_FUNCTION (this << &callback);
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
   122
  m_destroyCallback = callback;
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
   123
}
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
   124
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
   125
void 
6442
f380cf1aa4d8 Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 5971
diff changeset
   126
Ipv4EndPoint::ForwardUp (Ptr<Packet> p, const Ipv4Header& header, uint16_t sport,
f380cf1aa4d8 Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 5971
diff changeset
   127
                         Ptr<Ipv4Interface> incomingInterface)
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
   128
{
9710
df21b904fce3 Further work on cleaning up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 9217
diff changeset
   129
  NS_LOG_FUNCTION (this << p << &header << sport << incomingInterface);
df21b904fce3 Further work on cleaning up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 9217
diff changeset
   130
  
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
   131
  if (!m_rxCallback.IsNull ())
4022
142c13a3975f Mathieu's patch: Avoid stack explosion (bug 417)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3820
diff changeset
   132
    {
6442
f380cf1aa4d8 Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 5971
diff changeset
   133
      Simulator::ScheduleNow (&Ipv4EndPoint::DoForwardUp, this, p, header, sport, 
f380cf1aa4d8 Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 5971
diff changeset
   134
                              incomingInterface);
4022
142c13a3975f Mathieu's patch: Avoid stack explosion (bug 417)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3820
diff changeset
   135
    }
142c13a3975f Mathieu's patch: Avoid stack explosion (bug 417)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3820
diff changeset
   136
}
142c13a3975f Mathieu's patch: Avoid stack explosion (bug 417)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3820
diff changeset
   137
void 
6442
f380cf1aa4d8 Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 5971
diff changeset
   138
Ipv4EndPoint::DoForwardUp (Ptr<Packet> p, const Ipv4Header& header, uint16_t sport,
f380cf1aa4d8 Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 5971
diff changeset
   139
                           Ptr<Ipv4Interface> incomingInterface)
4022
142c13a3975f Mathieu's patch: Avoid stack explosion (bug 417)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3820
diff changeset
   140
{
9710
df21b904fce3 Further work on cleaning up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 9217
diff changeset
   141
  NS_LOG_FUNCTION (this << p << &header << sport << incomingInterface);
df21b904fce3 Further work on cleaning up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 9217
diff changeset
   142
  
9217
55055ecdbd47 Ipv4Endpoint: Add 2 tests to verify the existence of the callback before calling it.
frederic.urbani@inria.fr
parents: 7747
diff changeset
   143
  if (!m_rxCallback.IsNull ())
55055ecdbd47 Ipv4Endpoint: Add 2 tests to verify the existence of the callback before calling it.
frederic.urbani@inria.fr
parents: 7747
diff changeset
   144
    {
55055ecdbd47 Ipv4Endpoint: Add 2 tests to verify the existence of the callback before calling it.
frederic.urbani@inria.fr
parents: 7747
diff changeset
   145
      m_rxCallback (p, header, sport, incomingInterface);
55055ecdbd47 Ipv4Endpoint: Add 2 tests to verify the existence of the callback before calling it.
frederic.urbani@inria.fr
parents: 7747
diff changeset
   146
    }
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
   147
}
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
   148
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3260
diff changeset
   149
void 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3260
diff changeset
   150
Ipv4EndPoint::ForwardIcmp (Ipv4Address icmpSource, uint8_t icmpTtl, 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3260
diff changeset
   151
                           uint8_t icmpType, uint8_t icmpCode,
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3260
diff changeset
   152
                           uint32_t icmpInfo)
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3260
diff changeset
   153
{
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3260
diff changeset
   154
  NS_LOG_FUNCTION (this << icmpSource << (uint32_t)icmpTtl << (uint32_t)icmpType <<
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3260
diff changeset
   155
                   (uint32_t)icmpCode << icmpInfo);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3260
diff changeset
   156
  if (!m_icmpCallback.IsNull ())
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3260
diff changeset
   157
    {
4022
142c13a3975f Mathieu's patch: Avoid stack explosion (bug 417)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3820
diff changeset
   158
      Simulator::ScheduleNow (&Ipv4EndPoint::DoForwardIcmp, this, 
142c13a3975f Mathieu's patch: Avoid stack explosion (bug 417)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3820
diff changeset
   159
                              icmpSource, icmpTtl, icmpType, icmpCode, icmpInfo);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3260
diff changeset
   160
    }
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3260
diff changeset
   161
}
4022
142c13a3975f Mathieu's patch: Avoid stack explosion (bug 417)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3820
diff changeset
   162
void 
142c13a3975f Mathieu's patch: Avoid stack explosion (bug 417)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3820
diff changeset
   163
Ipv4EndPoint::DoForwardIcmp (Ipv4Address icmpSource, uint8_t icmpTtl, 
142c13a3975f Mathieu's patch: Avoid stack explosion (bug 417)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3820
diff changeset
   164
                             uint8_t icmpType, uint8_t icmpCode,
142c13a3975f Mathieu's patch: Avoid stack explosion (bug 417)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3820
diff changeset
   165
                             uint32_t icmpInfo)
142c13a3975f Mathieu's patch: Avoid stack explosion (bug 417)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3820
diff changeset
   166
{
9710
df21b904fce3 Further work on cleaning up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 9217
diff changeset
   167
  NS_LOG_FUNCTION (this << icmpSource << static_cast<uint32_t> (icmpTtl) << static_cast<uint32_t> (icmpType) << static_cast<uint32_t> (icmpCode) << icmpInfo);
df21b904fce3 Further work on cleaning up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 9217
diff changeset
   168
  
9217
55055ecdbd47 Ipv4Endpoint: Add 2 tests to verify the existence of the callback before calling it.
frederic.urbani@inria.fr
parents: 7747
diff changeset
   169
  if (!m_icmpCallback.IsNull ())
55055ecdbd47 Ipv4Endpoint: Add 2 tests to verify the existence of the callback before calling it.
frederic.urbani@inria.fr
parents: 7747
diff changeset
   170
    {
55055ecdbd47 Ipv4Endpoint: Add 2 tests to verify the existence of the callback before calling it.
frederic.urbani@inria.fr
parents: 7747
diff changeset
   171
      m_icmpCallback (icmpSource,icmpTtl,icmpType,icmpCode,icmpInfo);
55055ecdbd47 Ipv4Endpoint: Add 2 tests to verify the existence of the callback before calling it.
frederic.urbani@inria.fr
parents: 7747
diff changeset
   172
    }
4022
142c13a3975f Mathieu's patch: Avoid stack explosion (bug 417)
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3820
diff changeset
   173
}
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   174
7386
2310ed220a61 standardize ns-3 namespace declaration format
Vedran Miletić <rivanvx@gmail.com>
parents: 7385
diff changeset
   175
} // namespace ns3