src/devices/wifi/wifi-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 3914 18ac5bec5c49
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) 2005,2006 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 
    21 #ifndef WIFI_NET_DEVICE_H
    22 #define WIFI_NET_DEVICE_H
    23 
    24 #include "ns3/net-device.h"
    25 #include "ns3/packet.h"
    26 #include "ns3/traced-callback.h"
    27 #include "ns3/mac48-address.h"
    28 #include "wifi-remote-station-manager.h"
    29 #include <string>
    30 
    31 namespace ns3 {
    32 
    33 class WifiChannel;
    34 class WifiPhy;
    35 class WifiMac;
    36 
    37 /**
    38  * \brief Hold together all Wifi-related objects.
    39  *
    40  * This class holds together ns3::WifiChannel, ns3::WifiPhy,
    41  * ns3::WifiMac, and, ns3::WifiRemoteStationManager.
    42  */
    43 class WifiNetDevice : public NetDevice 
    44 {
    45 public:
    46   static TypeId GetTypeId (void);
    47 
    48   WifiNetDevice ();
    49   virtual ~WifiNetDevice ();
    50 
    51   /**
    52    * \param mac the mac layer to use.
    53    */
    54   void SetMac (Ptr<WifiMac> mac);
    55   /**
    56    * \param phy the phy layer to use.
    57    */
    58   void SetPhy (Ptr<WifiPhy> phy);
    59   /**
    60    * \param manager the manager to use.
    61    */
    62   void SetRemoteStationManager (Ptr<WifiRemoteStationManager> manager);
    63   /**
    64    * \param channel the channel to connect to.
    65    */
    66   void SetChannel (Ptr<WifiChannel> channel);
    67   /**
    68    * \returns the mac we are currently using.
    69    */
    70   Ptr<WifiMac> GetMac (void) const;
    71   /**
    72    * \returns the phy we are currently using.
    73    */
    74   Ptr<WifiPhy> GetPhy (void) const;
    75   /**
    76    * \returns the remote station manager we are currently using.
    77    */
    78   Ptr<WifiRemoteStationManager> GetRemoteStationManager (void) const;
    79 
    80 
    81   // inherited from NetDevice base class.
    82   virtual void SetName(const std::string name);
    83   virtual std::string GetName(void) const;
    84   virtual void SetIfIndex(const uint32_t index);
    85   virtual uint32_t GetIfIndex(void) const;
    86   virtual Ptr<Channel> GetChannel (void) const;
    87   virtual Address GetAddress (void) const;
    88   virtual bool SetMtu (const uint16_t mtu);
    89   virtual uint16_t GetMtu (void) const;
    90   virtual bool IsLinkUp (void) const;
    91   virtual void SetLinkChangeCallback (Callback<void> callback);
    92   virtual bool IsBroadcast (void) const;
    93   virtual Address GetBroadcast (void) const;
    94   virtual bool IsMulticast (void) const;
    95   virtual Address GetMulticast (Ipv4Address multicastGroup) const;
    96   virtual bool IsPointToPoint (void) const;
    97   virtual bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
    98   virtual Ptr<Node> GetNode (void) const;
    99   virtual void SetNode (Ptr<Node> node);
   100   virtual bool NeedsArp (void) const;
   101   virtual void SetReceiveCallback (NetDevice::ReceiveCallback cb);
   102 
   103   virtual Address GetMulticast (Ipv6Address addr) const;
   104 
   105   virtual bool SendFrom(Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
   106   virtual void SetPromiscReceiveCallback (PromiscReceiveCallback cb);
   107   virtual bool SupportsSendFrom (void) const;
   108 
   109 private:
   110   virtual void DoDispose (void);
   111   void ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to);
   112   void LinkUp (void);
   113   void LinkDown (void);
   114   void Setup (void);
   115   Ptr<WifiChannel> DoGetChannel (void) const;
   116   Ptr<Node> m_node;
   117   Ptr<WifiPhy> m_phy;
   118   Ptr<WifiChannel> m_channel;
   119   Ptr<WifiMac> m_mac;
   120   Ptr<WifiRemoteStationManager> m_stationManager;
   121   NetDevice::ReceiveCallback m_forwardUp;
   122   NetDevice::PromiscReceiveCallback m_promiscRx;
   123   TracedCallback<Ptr<const Packet>, Mac48Address> m_rxLogger;
   124   TracedCallback<Ptr<const Packet>, Mac48Address> m_txLogger;
   125   uint32_t m_ifIndex;
   126   std::string m_name;
   127   bool m_linkUp;
   128   Callback<void> m_linkChange;
   129   mutable uint16_t m_mtu;
   130 };
   131 
   132 } // namespace ns3
   133 
   134 #endif /* WIFI_NET_DEVICE_H */