src/virtual-net-device/model/virtual-net-device.h
author Mitch Watrous <watrous@u.washington.edu>
Wed, 18 May 2011 17:24:04 -0700
changeset 7241 0a7a16b599e8
parent 6852 8f1a53d3f6ca
child 7256 b04ba6772f8c
permissions -rw-r--r--
Make some more modules show up on doxygen modules page
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4536
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     2
/*
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     3
 * Copyright (c) 2008,2009 INESC Porto
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     4
 *
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     8
 *
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    12
 * GNU General Public License for more details.
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    13
 *
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    17
 *
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    18
 * Author: Gustavo J. A. M. Carneiro  <gjc@inescporto.pt>
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    19
 */
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    20
4541
e943b94bf523 Rename TapNetDevice to VirtualNetDevice
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4540
diff changeset
    21
#ifndef VIRTUAL_NET_DEVICE_H
e943b94bf523 Rename TapNetDevice to VirtualNetDevice
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4540
diff changeset
    22
#define VIRTUAL_NET_DEVICE_H
4536
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    23
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    24
#include "ns3/address.h"
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    25
#include "ns3/node.h"
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    26
#include "ns3/net-device.h"
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    27
#include "ns3/callback.h"
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    28
#include "ns3/packet.h"
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    29
#include "ns3/ptr.h"
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    30
#include "ns3/traced-callback.h"
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    31
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    32
namespace ns3 {
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    33
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    34
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    35
/**
7241
0a7a16b599e8 Make some more modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents: 6852
diff changeset
    36
 * \defgroup virtualdevice Virtual Device
0a7a16b599e8 Make some more modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents: 6852
diff changeset
    37
 *
0a7a16b599e8 Make some more modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents: 6852
diff changeset
    38
 */
0a7a16b599e8 Make some more modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents: 6852
diff changeset
    39
0a7a16b599e8 Make some more modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents: 6852
diff changeset
    40
/**
0a7a16b599e8 Make some more modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents: 6852
diff changeset
    41
 * \ingroup virtualdevice
0a7a16b599e8 Make some more modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents: 6852
diff changeset
    42
 *
4541
e943b94bf523 Rename TapNetDevice to VirtualNetDevice
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4540
diff changeset
    43
 * \class VirtualNetDevice
4543
f9509a42bc87 Make the value returned by VirtualNetDevice::IsPointToPoint configurable.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4541
diff changeset
    44
 * \brief A virtual device, similar to Linux TUN/TAP interfaces.
4536
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    45
 *
4541
e943b94bf523 Rename TapNetDevice to VirtualNetDevice
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4540
diff changeset
    46
 * A VirtualNetDevice is a "virtual" NetDevice implementation which
4545
8566a9f6725a VirtualNetDevice: Single Receive() (promisc. one); add trace sources to align better with CsmaNetDevice. Add SetAddress()
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4543
diff changeset
    47
 * delegates to a user callback (see method SetSendCallback()) the
4536
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    48
 * task of actually transmitting a packet.  It also allows the user
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    49
 * code to inject the packet as if it had been received by the
4541
e943b94bf523 Rename TapNetDevice to VirtualNetDevice
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4540
diff changeset
    50
 * VirtualNetDevice.  Together, these features allow one to build tunnels.
4536
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    51
 * For instance, by transmitting packets into a UDP socket we end up
4543
f9509a42bc87 Make the value returned by VirtualNetDevice::IsPointToPoint configurable.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4541
diff changeset
    52
 * building an IP-over-UDP-over-IP tunnel, or IP-over-IP tunnels.
4536
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    53
 *
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    54
 * The same thing could be accomplished by subclassing NetDevice
4541
e943b94bf523 Rename TapNetDevice to VirtualNetDevice
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4540
diff changeset
    55
 * directly.  However, VirtualNetDevice is usually much simpler to program
4536
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    56
 * than a NetDevice subclass.
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    57
 */
4541
e943b94bf523 Rename TapNetDevice to VirtualNetDevice
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4540
diff changeset
    58
class VirtualNetDevice : public NetDevice
4536
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    59
{
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    60
public:
4540
e8a12e172432 api docs fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4537
diff changeset
    61
  /**
4541
e943b94bf523 Rename TapNetDevice to VirtualNetDevice
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4540
diff changeset
    62
   * Callback the be invoked when the VirtualNetDevice is asked to queue/transmit a packet.
4540
e8a12e172432 api docs fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4537
diff changeset
    63
   * For more information, consult the documentation of NetDevice::SendFrom().
e8a12e172432 api docs fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4537
diff changeset
    64
   */
4545
8566a9f6725a VirtualNetDevice: Single Receive() (promisc. one); add trace sources to align better with CsmaNetDevice. Add SetAddress()
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4543
diff changeset
    65
  typedef Callback<bool, Ptr<Packet>, const Address&, const Address&, uint16_t> SendCallback;
4536
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    66
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    67
  static TypeId GetTypeId (void);
4541
e943b94bf523 Rename TapNetDevice to VirtualNetDevice
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4540
diff changeset
    68
  VirtualNetDevice ();
4536
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    69
4541
e943b94bf523 Rename TapNetDevice to VirtualNetDevice
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4540
diff changeset
    70
  virtual ~VirtualNetDevice ();
4536
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    71
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    72
  /**
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    73
   * \brief Set the user callback to be called when a L2 packet is to be transmitted
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    74
   * \param transmitCb the new transmit callback
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    75
   */
4545
8566a9f6725a VirtualNetDevice: Single Receive() (promisc. one); add trace sources to align better with CsmaNetDevice. Add SetAddress()
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4543
diff changeset
    76
  void SetSendCallback (SendCallback transmitCb);
4536
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    77
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    78
  /**
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    79
   * \brief Configure whether the virtual device needs ARP
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    80
   *
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    81
   * \param needsArp the the 'needs arp' value that will be returned
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    82
   * by the NeedsArp() method.  The method IsBroadcast() will also
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    83
   * return this value.
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    84
   */
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    85
  void SetNeedsArp (bool needsArp);
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    86
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    87
  /**
4543
f9509a42bc87 Make the value returned by VirtualNetDevice::IsPointToPoint configurable.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4541
diff changeset
    88
   * \brief Configure whether the virtual device is point-to-point
f9509a42bc87 Make the value returned by VirtualNetDevice::IsPointToPoint configurable.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4541
diff changeset
    89
   *
f9509a42bc87 Make the value returned by VirtualNetDevice::IsPointToPoint configurable.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4541
diff changeset
    90
   * \param isPointToPoint the value that should be returned by the
f9509a42bc87 Make the value returned by VirtualNetDevice::IsPointToPoint configurable.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4541
diff changeset
    91
   * IsPointToPoint method for this instance.
f9509a42bc87 Make the value returned by VirtualNetDevice::IsPointToPoint configurable.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4541
diff changeset
    92
   */
f9509a42bc87 Make the value returned by VirtualNetDevice::IsPointToPoint configurable.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4541
diff changeset
    93
  void SetIsPointToPoint (bool isPointToPoint);
f9509a42bc87 Make the value returned by VirtualNetDevice::IsPointToPoint configurable.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4541
diff changeset
    94
f9509a42bc87 Make the value returned by VirtualNetDevice::IsPointToPoint configurable.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4541
diff changeset
    95
  /**
4536
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    96
   * \brief Configure whether the virtual device supports SendFrom
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    97
   */
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    98
  void SetSupportsSendFrom (bool supportsSendFrom);
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    99
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   100
  /**
6183
8a5e1f9db873 [bug 822] Move Mtu attribute from NetDevice base class to subclasses
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 5227
diff changeset
   101
   * \brief Configure the reported MTU for the virtual device.
5227
ecb08c1fc273 Fix some doxygen warnings revealed by WARN_NO_PARAMDOC=YES in doc/doxygen.conf.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4764
diff changeset
   102
   * \param mtu MTU value to set
4536
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   103
   * \return whether the MTU value was within legal bounds
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   104
   */
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   105
  bool SetMtu (const uint16_t mtu);
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   106
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   107
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   108
  /**
4540
e8a12e172432 api docs fixes
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4537
diff changeset
   109
   * \param packet packet sent from below up to Network Device
4536
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   110
   * \param protocol Protocol type
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   111
   * \param source the address of the sender of this packet.
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   112
   * \param destination the address of the receiver of this packet.
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   113
   * \param packetType type of packet received (broadcast/multicast/unicast/otherhost)
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   114
   * \returns true if the packet was forwarded successfully, false otherwise.
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   115
   *
4545
8566a9f6725a VirtualNetDevice: Single Receive() (promisc. one); add trace sources to align better with CsmaNetDevice. Add SetAddress()
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4543
diff changeset
   116
   * Forward a "virtually received" packet up
4536
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   117
   * the node's protocol stack.
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   118
   */
4545
8566a9f6725a VirtualNetDevice: Single Receive() (promisc. one); add trace sources to align better with CsmaNetDevice. Add SetAddress()
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4543
diff changeset
   119
  bool Receive (Ptr<Packet> packet, uint16_t protocol,
8566a9f6725a VirtualNetDevice: Single Receive() (promisc. one); add trace sources to align better with CsmaNetDevice. Add SetAddress()
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4543
diff changeset
   120
                const Address &source, const Address &destination,
8566a9f6725a VirtualNetDevice: Single Receive() (promisc. one); add trace sources to align better with CsmaNetDevice. Add SetAddress()
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4543
diff changeset
   121
                PacketType packetType);
8566a9f6725a VirtualNetDevice: Single Receive() (promisc. one); add trace sources to align better with CsmaNetDevice. Add SetAddress()
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4543
diff changeset
   122
4536
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   123
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   124
  // inherited from NetDevice base class.
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   125
  virtual void SetIfIndex(const uint32_t index);
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   126
  virtual uint32_t GetIfIndex(void) const;
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   127
  virtual Ptr<Channel> GetChannel (void) const;
4578
88434ff8f0a5 Finally make tap bridge work with VMs (bug 569)
Craig Dowell <craigdo@ee.washington.edu>
parents: 4545
diff changeset
   128
  virtual void SetAddress (Address address);
4536
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   129
  virtual Address GetAddress (void) const;
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   130
  virtual uint16_t GetMtu (void) const;
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   131
  virtual bool IsLinkUp (void) const;
4764
e90e1ef585b0 [Bug 653] NetDevice link change callback (SetLinkChangeCallback -> AddLinkChangeCallback).
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4578
diff changeset
   132
  virtual void AddLinkChangeCallback (Callback<void> callback);
4536
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   133
  virtual bool IsBroadcast (void) const;
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   134
  virtual Address GetBroadcast (void) const;
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   135
  virtual bool IsMulticast (void) const;
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   136
  virtual Address GetMulticast (Ipv4Address multicastGroup) const;
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   137
  virtual Address GetMulticast (Ipv6Address addr) const;
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   138
  virtual bool IsPointToPoint (void) const;
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   139
  virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   140
  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   141
  virtual Ptr<Node> GetNode (void) const;
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   142
  virtual void SetNode (Ptr<Node> node);
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   143
  virtual bool NeedsArp (void) const;
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   144
  virtual void SetReceiveCallback (NetDevice::ReceiveCallback cb);
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   145
  virtual void SetPromiscReceiveCallback (NetDevice::PromiscReceiveCallback cb);
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   146
  virtual bool SupportsSendFrom () const;
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   147
  virtual bool IsBridge (void) const;
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   148
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   149
protected:
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   150
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   151
  virtual void DoDispose (void);
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   152
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   153
private:
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   154
4545
8566a9f6725a VirtualNetDevice: Single Receive() (promisc. one); add trace sources to align better with CsmaNetDevice. Add SetAddress()
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4543
diff changeset
   155
  Address m_myAddress;
8566a9f6725a VirtualNetDevice: Single Receive() (promisc. one); add trace sources to align better with CsmaNetDevice. Add SetAddress()
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4543
diff changeset
   156
  SendCallback m_sendCb;
8566a9f6725a VirtualNetDevice: Single Receive() (promisc. one); add trace sources to align better with CsmaNetDevice. Add SetAddress()
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4543
diff changeset
   157
  TracedCallback<Ptr<const Packet> > m_macRxTrace;
8566a9f6725a VirtualNetDevice: Single Receive() (promisc. one); add trace sources to align better with CsmaNetDevice. Add SetAddress()
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4543
diff changeset
   158
  TracedCallback<Ptr<const Packet> > m_macTxTrace;
8566a9f6725a VirtualNetDevice: Single Receive() (promisc. one); add trace sources to align better with CsmaNetDevice. Add SetAddress()
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4543
diff changeset
   159
  TracedCallback<Ptr<const Packet> > m_macPromiscRxTrace;
8566a9f6725a VirtualNetDevice: Single Receive() (promisc. one); add trace sources to align better with CsmaNetDevice. Add SetAddress()
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4543
diff changeset
   160
  TracedCallback<Ptr<const Packet> > m_snifferTrace;
8566a9f6725a VirtualNetDevice: Single Receive() (promisc. one); add trace sources to align better with CsmaNetDevice. Add SetAddress()
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4543
diff changeset
   161
  TracedCallback<Ptr<const Packet> > m_promiscSnifferTrace;
4536
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   162
  Ptr<Node> m_node;
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   163
  ReceiveCallback m_rxCallback;
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   164
  PromiscReceiveCallback m_promiscRxCallback;
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   165
  std::string m_name;
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   166
  uint32_t m_index;
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   167
  uint16_t m_mtu;
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   168
  bool m_needsArp;
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   169
  bool m_supportsSendFrom;
4543
f9509a42bc87 Make the value returned by VirtualNetDevice::IsPointToPoint configurable.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4541
diff changeset
   170
  bool m_isPointToPoint;
4536
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   171
};
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   172
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   173
}; // namespace ns3
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   174
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   175
#endif
dee7215f0334 Add TapNetDevice (formerly known as VirtualNetDevice)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
   176