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