00001 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 2005,2006 INRIA 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation; 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> 00019 */ 00020 00021 #ifndef WIFI_NET_DEVICE_H 00022 #define WIFI_NET_DEVICE_H 00023 00024 #include "ns3/net-device.h" 00025 #include "ns3/packet.h" 00026 #include "ns3/traced-callback.h" 00027 #include "ns3/mac48-address.h" 00028 #include "wifi-remote-station-manager.h" 00029 #include <string> 00030 00031 namespace ns3 { 00032 00033 class WifiChannel; 00034 class WifiPhy; 00035 class WifiMac; 00036 00037 /** 00038 * \brief Hold together all Wifi-related objects. 00039 * 00040 * This class holds together ns3::WifiChannel, ns3::WifiPhy, 00041 * ns3::WifiMac, and, ns3::WifiRemoteStationManager. 00042 */ 00043 class WifiNetDevice : public NetDevice 00044 { 00045 public: 00046 static TypeId GetTypeId (void); 00047 00048 WifiNetDevice (); 00049 virtual ~WifiNetDevice (); 00050 00051 /** 00052 * \param mac the mac layer to use. 00053 */ 00054 void SetMac (Ptr<WifiMac> mac); 00055 /** 00056 * \param phy the phy layer to use. 00057 */ 00058 void SetPhy (Ptr<WifiPhy> phy); 00059 /** 00060 * \param manager the manager to use. 00061 */ 00062 void SetRemoteStationManager (Ptr<WifiRemoteStationManager> manager); 00063 /** 00064 * \returns the mac we are currently using. 00065 */ 00066 Ptr<WifiMac> GetMac (void) const; 00067 /** 00068 * \returns the phy we are currently using. 00069 */ 00070 Ptr<WifiPhy> GetPhy (void) const; 00071 /** 00072 * \returns the remote station manager we are currently using. 00073 */ 00074 Ptr<WifiRemoteStationManager> GetRemoteStationManager (void) const; 00075 00076 00077 // inherited from NetDevice base class. 00078 virtual void SetName(const std::string name); 00079 virtual std::string GetName(void) const; 00080 virtual void SetIfIndex(const uint32_t index); 00081 virtual uint32_t GetIfIndex(void) const; 00082 virtual Ptr<Channel> GetChannel (void) const; 00083 virtual Address GetAddress (void) const; 00084 virtual bool SetMtu (const uint16_t mtu); 00085 virtual uint16_t GetMtu (void) const; 00086 virtual bool IsLinkUp (void) const; 00087 virtual void SetLinkChangeCallback (Callback<void> callback); 00088 virtual bool IsBroadcast (void) const; 00089 virtual Address GetBroadcast (void) const; 00090 virtual bool IsMulticast (void) const; 00091 virtual Address GetMulticast (Ipv4Address multicastGroup) const; 00092 virtual bool IsPointToPoint (void) const; 00093 virtual bool IsBridge (void) const; 00094 virtual bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber); 00095 virtual Ptr<Node> GetNode (void) const; 00096 virtual void SetNode (Ptr<Node> node); 00097 virtual bool NeedsArp (void) const; 00098 virtual void SetReceiveCallback (NetDevice::ReceiveCallback cb); 00099 00100 virtual Address GetMulticast (Ipv6Address addr) const; 00101 00102 virtual bool SendFrom(Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber); 00103 virtual void SetPromiscReceiveCallback (PromiscReceiveCallback cb); 00104 virtual bool SupportsSendFrom (void) const; 00105 00106 private: 00107 virtual void DoDispose (void); 00108 void ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to); 00109 void LinkUp (void); 00110 void LinkDown (void); 00111 void Setup (void); 00112 Ptr<WifiChannel> DoGetChannel (void) const; 00113 void CompleteConfig (void); 00114 00115 Ptr<Node> m_node; 00116 Ptr<WifiPhy> m_phy; 00117 Ptr<WifiMac> m_mac; 00118 Ptr<WifiRemoteStationManager> m_stationManager; 00119 NetDevice::ReceiveCallback m_forwardUp; 00120 NetDevice::PromiscReceiveCallback m_promiscRx; 00121 TracedCallback<Ptr<const Packet>, Mac48Address> m_rxLogger; 00122 TracedCallback<Ptr<const Packet>, Mac48Address> m_txLogger; 00123 uint32_t m_ifIndex; 00124 std::string m_name; 00125 bool m_linkUp; 00126 Callback<void> m_linkChange; 00127 mutable uint16_t m_mtu; 00128 bool m_configComplete; 00129 }; 00130 00131 } // namespace ns3 00132 00133 #endif /* WIFI_NET_DEVICE_H */