1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
3 * Copyright (c) 2005,2006 INRIA
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;
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.
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
18 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
21 #ifndef WIFI_NET_DEVICE_H
22 #define WIFI_NET_DEVICE_H
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"
38 * \brief Hold together all Wifi-related objects.
40 * This class holds together ns3::WifiChannel, ns3::WifiPhy,
41 * ns3::WifiMac, and, ns3::WifiRemoteStationManager.
43 class WifiNetDevice : public NetDevice
46 static TypeId GetTypeId (void);
49 virtual ~WifiNetDevice ();
52 * \param mac the mac layer to use.
54 void SetMac (Ptr<WifiMac> mac);
56 * \param phy the phy layer to use.
58 void SetPhy (Ptr<WifiPhy> phy);
60 * \param manager the manager to use.
62 void SetRemoteStationManager (Ptr<WifiRemoteStationManager> manager);
64 * \param channel the channel to connect to.
66 void SetChannel (Ptr<WifiChannel> channel);
68 * \returns the mac we are currently using.
70 Ptr<WifiMac> GetMac (void) const;
72 * \returns the phy we are currently using.
74 Ptr<WifiPhy> GetPhy (void) const;
76 * \returns the remote station manager we are currently using.
78 Ptr<WifiRemoteStationManager> GetRemoteStationManager (void) const;
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);
103 virtual Address GetMulticast (Ipv6Address addr) const;
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;
110 virtual void DoDispose (void);
111 void ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to);
113 void LinkDown (void);
115 Ptr<WifiChannel> DoGetChannel (void) const;
118 Ptr<WifiChannel> m_channel;
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;
128 Callback<void> m_linkChange;
129 mutable uint16_t m_mtu;
134 #endif /* WIFI_NET_DEVICE_H */