src/node/simple-net-device.h
author vincent@clarinet.u-strasbg.fr
Fri Nov 07 11:36:15 2008 -0800 (2008-11-07)
changeset 3852 9cf7ad0cac85
parent 3841 1e7abf5fca79
child 3936 e525995ce5dc
permissions -rw-r--r--
Initial IPv6 capability
mathieu@2833
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
mathieu@2833
     2
/*
mathieu@2833
     3
 * Copyright (c) 2008 INRIA
mathieu@2833
     4
 *
mathieu@2833
     5
 * This program is free software; you can redistribute it and/or modify
mathieu@2833
     6
 * it under the terms of the GNU General Public License version 2 as
mathieu@2833
     7
 * published by the Free Software Foundation;
mathieu@2833
     8
 *
mathieu@2833
     9
 * This program is distributed in the hope that it will be useful,
mathieu@2833
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
mathieu@2833
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
mathieu@2833
    12
 * GNU General Public License for more details.
mathieu@2833
    13
 *
mathieu@2833
    14
 * You should have received a copy of the GNU General Public License
mathieu@2833
    15
 * along with this program; if not, write to the Free Software
mathieu@2833
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
mathieu@2833
    17
 *
mathieu@2833
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
mathieu@2833
    19
 */
mathieu@2832
    20
#ifndef SIMPLE_NET_DEVICE_H
mathieu@2832
    21
#define SIMPLE_NET_DEVICE_H
mathieu@2673
    22
mathieu@2673
    23
#include "net-device.h"
mathieu@2673
    24
#include "mac48-address.h"
mathieu@2673
    25
#include <stdint.h>
mathieu@2673
    26
#include <string>
mathieu@2673
    27
mathieu@2673
    28
namespace ns3 {
mathieu@2673
    29
mathieu@2673
    30
class SimpleChannel;
mathieu@2673
    31
class Node;
mathieu@2673
    32
tomh@3183
    33
/**
tomh@3183
    34
 * \ingroup netdevice
tomh@3183
    35
 * 
tomh@3183
    36
 * \brief simple net device for simple things and testing
tomh@3183
    37
 */
mathieu@2673
    38
class SimpleNetDevice : public NetDevice
mathieu@2673
    39
{
mathieu@2673
    40
public:
mathieu@2673
    41
  static TypeId GetTypeId (void);
mathieu@2673
    42
  SimpleNetDevice ();
mathieu@2673
    43
mathieu@2673
    44
  void Receive (Ptr<Packet> packet, uint16_t protocol, Mac48Address to, Mac48Address from);
mathieu@2673
    45
  void SetChannel (Ptr<SimpleChannel> channel);
mathieu@2673
    46
  void SetAddress (Mac48Address address);
mathieu@2673
    47
mathieu@2673
    48
  // inherited from NetDevice base class.
mathieu@2673
    49
  virtual void SetName(const std::string name);
mathieu@2673
    50
  virtual std::string GetName(void) const;
mathieu@2673
    51
  virtual void SetIfIndex(const uint32_t index);
mathieu@2673
    52
  virtual uint32_t GetIfIndex(void) const;
mathieu@2673
    53
  virtual Ptr<Channel> GetChannel (void) const;
mathieu@2673
    54
  virtual Address GetAddress (void) const;
mathieu@2673
    55
  virtual bool SetMtu (const uint16_t mtu);
mathieu@2673
    56
  virtual uint16_t GetMtu (void) const;
mathieu@2673
    57
  virtual bool IsLinkUp (void) const;
mathieu@2673
    58
  virtual void SetLinkChangeCallback (Callback<void> callback);
mathieu@2673
    59
  virtual bool IsBroadcast (void) const;
mathieu@2673
    60
  virtual Address GetBroadcast (void) const;
mathieu@2673
    61
  virtual bool IsMulticast (void) const;
craigdo@3841
    62
  virtual Address GetMulticast (Ipv4Address multicastGroup) const;
mathieu@2673
    63
  virtual bool IsPointToPoint (void) const;
mathieu@2673
    64
  virtual bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
gjc@3442
    65
  virtual bool SendFrom(Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
mathieu@2673
    66
  virtual Ptr<Node> GetNode (void) const;
mathieu@2673
    67
  virtual void SetNode (Ptr<Node> node);
mathieu@2673
    68
  virtual bool NeedsArp (void) const;
mathieu@2673
    69
  virtual void SetReceiveCallback (NetDevice::ReceiveCallback cb);
vincent@3852
    70
vincent@3852
    71
  virtual Address GetMulticast (Ipv6Address addr) const;
vincent@3852
    72
gjc@3480
    73
  virtual void SetPromiscReceiveCallback (PromiscReceiveCallback cb);
mathieu@3584
    74
  virtual bool SupportsSendFrom (void) const;
mathieu@2673
    75
mathieu@2831
    76
protected:
mathieu@2831
    77
  virtual void DoDispose (void);
mathieu@2673
    78
private:
mathieu@2673
    79
  Ptr<SimpleChannel> m_channel;
mathieu@2673
    80
  NetDevice::ReceiveCallback m_rxCallback;
mathieu@3584
    81
  NetDevice::PromiscReceiveCallback m_promiscCallback;
mathieu@2673
    82
  Ptr<Node> m_node;
mathieu@2673
    83
  uint16_t m_mtu;
mathieu@2673
    84
  std::string m_name;
mathieu@2673
    85
  uint32_t m_ifIndex;
mathieu@2673
    86
  Mac48Address m_address;
mathieu@2673
    87
};
mathieu@2673
    88
mathieu@2673
    89
} // namespace ns3
mathieu@2673
    90
mathieu@2832
    91
#endif /* SIMPLE_NET_DEVICE_H */