src/internet-node/ipv4-end-point.h
author Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
Wed, 13 Feb 2008 17:37:43 +0000
changeset 2326 eec07777d1a2
parent 1866 e7dbcc4df546
child 2365 89da0ca7c55e
permissions -rw-r--r--
Fix broadcast packet reception for locally bound sockets (bug #136)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
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
 * All rights reserved.
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 *
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * 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
     7
 * 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
     8
 * published by the Free Software Foundation;
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 *
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * 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
    11
 * 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
    12
 * 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
    13
 * GNU General Public License for more details.
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 *
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * 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
    16
 * 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
    17
 * 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
    18
 *
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
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
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
#ifndef IPV4_END_POINT_H
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
#define IPV4_END_POINT_H
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    25
#include <stdint.h>
524
082ffdd8fbd7 move code around
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 495
diff changeset
    26
#include "ns3/ipv4-address.h"
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
    27
#include "ns3/callback.h"
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    28
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
namespace ns3 {
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
class Header;
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
    32
class Packet;
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
class Ipv4EndPoint {
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
public:
2326
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1866
diff changeset
    36
  Ipv4EndPoint (Ipv4Address address, uint16_t port, Ipv4Address localInterface);
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    37
  ~Ipv4EndPoint ();
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    38
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    39
  Ipv4Address GetLocalAddress (void);
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
    40
  void SetLocalAddress (Ipv4Address address);
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    41
  uint16_t GetLocalPort (void);
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    42
  Ipv4Address GetPeerAddress (void);
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    43
  uint16_t GetPeerPort (void);
2326
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1866
diff changeset
    44
  Ipv4Address GetLocalInterface (void) const;
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1866
diff changeset
    45
  void SetLocalInterface (Ipv4Address localInterface);
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    46
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    47
  void SetPeer (Ipv4Address address, uint16_t port);
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    48
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1317
diff changeset
    49
  void SetRxCallback (Callback<void,Ptr<Packet>, Ipv4Address, uint16_t> callback);
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
    50
  void 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
    51
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1317
diff changeset
    52
  void ForwardUp (Ptr<Packet> p, Ipv4Address saddr, uint16_t sport);
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
    53
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    54
private:
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    55
  Ipv4Address m_localAddr;
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    56
  uint16_t m_localPort;
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    57
  Ipv4Address m_peerAddr;
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    58
  uint16_t m_peerPort;
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1317
diff changeset
    59
  Callback<void,Ptr<Packet>, Ipv4Address, uint16_t> m_rxCallback;
495
a839408950b9 rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 238
diff changeset
    60
  Callback<void> m_destroyCallback;
2326
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1866
diff changeset
    61
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1866
diff changeset
    62
  // If the corresponding socket is bound to a specific local
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1866
diff changeset
    63
  // interface, m_localInterface contains that interface's ipv4
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1866
diff changeset
    64
  // address, else it contains the value Ipv4Address::GetAny ().
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1866
diff changeset
    65
  Ipv4Address m_localInterface;
238
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    66
};
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    67
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    68
}; // namespace ns3
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
2f09fd9cf32e add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    71
#endif /* IPV4_END_POINT_H */