A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
uan-net-device.h
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 University of Washington
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: Leonard Tracy <lentracy@gmail.com>
19  */
20 
21 #ifndef UAN_NET_DEVICE_H
22 #define UAN_NET_DEVICE_H
23 
24 #include "ns3/net-device.h"
25 #include "ns3/pointer.h"
26 #include "ns3/traced-callback.h"
27 #include "uan-address.h"
28 #include <list>
29 
30 namespace ns3 {
31 
32 class UanChannel;
33 class UanPhy;
34 class UanMac;
35 class UanTransducer;
36 
48 class UanNetDevice : public NetDevice
49 {
50 public:
54  typedef std::list<Ptr<UanPhy> > UanPhyList;
58  typedef std::list<Ptr<UanTransducer> > UanTransducerList;
59 
60  static TypeId GetTypeId (void);
61 
62  UanNetDevice ();
63  virtual ~UanNetDevice ();
64 
68  void SetMac (Ptr<UanMac> mac);
69 
73  void SetPhy (Ptr<UanPhy> phy);
74 
78  void SetChannel (Ptr<UanChannel> channel);
79 
83  Ptr<UanMac> GetMac (void) const;
84 
88  Ptr<UanPhy> GetPhy (void) const;
89 
93  Ptr<UanTransducer> GetTransducer (void) const;
97  void SetTransducer (Ptr<UanTransducer> trans);
98 
102  void Clear (void);
103 
104  void SetSleepMode (bool sleep);
105 
106  // Purely virtual functions from base class
107  virtual void SetIfIndex (const uint32_t index);
108  virtual uint32_t GetIfIndex (void) const;
109  virtual Ptr<Channel> GetChannel (void) const;
110  virtual Address GetAddress (void) const;
111  virtual bool SetMtu (const uint16_t mtu);
112  virtual uint16_t GetMtu (void) const;
113  virtual bool IsLinkUp (void) const;
114  virtual bool IsBroadcast (void) const;
115  virtual Address GetBroadcast (void) const;
116  virtual bool IsMulticast (void) const;
117  virtual Address GetMulticast (Ipv4Address multicastGroup) const;
118  virtual Address GetMulticast (Ipv6Address addr) const;
119  virtual bool IsBridge (void) const;
120  virtual bool IsPointToPoint (void) const;
121  virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
122  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
123  virtual Ptr<Node> GetNode (void) const;
124  virtual void SetNode (Ptr<Node> node);
125  virtual bool NeedsArp (void) const;
128  virtual bool SupportsSendFrom (void) const;
129  virtual void AddLinkChangeCallback (Callback<void> callback);
130  virtual void SetAddress (Address address);
131 private:
132  virtual void ForwardUp (Ptr<Packet> pkt, const UanAddress &src);
133  Ptr<UanChannel> DoGetChannel (void) const;
134 
135  Ptr<UanTransducer> m_trans;
136  Ptr<Node> m_node;
137  Ptr<UanChannel> m_channel;
138  Ptr<UanMac> m_mac;
139  Ptr<UanPhy> m_phy;
140 
141  std::string m_name;
142  uint32_t m_ifIndex;
143  uint16_t m_mtu;
144  bool m_linkup;
145  TracedCallback<> m_linkChanges;
146  ReceiveCallback m_forwardUp;
147 
150 
151  bool m_cleared;
152 
153 protected:
154  virtual void DoDispose ();
155 };
156 
157 } // namespace ns3
158 
159 #endif /* UAN_NET_DEVICE_H */
virtual bool SetMtu(const uint16_t mtu)
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Ptr< UanMac > GetMac(void) const
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
void SetMac(Ptr< UanMac > mac)
virtual void SetAddress(Address address)
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
virtual void DoDispose()
void SetChannel(Ptr< UanChannel > channel)
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
std::list< Ptr< UanPhy > > UanPhyList
UanPhyList is defined as a standard template lib list of UanPhy objects.
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
virtual bool IsMulticast(void) const
virtual bool IsLinkUp(void) const
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
virtual uint16_t GetMtu(void) const
virtual Ptr< Channel > GetChannel(void) const
virtual Address GetBroadcast(void) const
a polymophic address class
Definition: address.h:86
Ptr< UanTransducer > GetTransducer(void) const
virtual void AddLinkChangeCallback(Callback< void > callback)
virtual uint32_t GetIfIndex(void) const
virtual Ptr< Node > GetNode(void) const
virtual bool IsBroadcast(void) const
std::list< Ptr< UanTransducer > > UanTransducerList
UanTransducerList is a standard template lib list of UanTransducer objects.
virtual bool SupportsSendFrom(void) const
Net device for UAN models.
Ptr< UanPhy > GetPhy(void) const
virtual Address GetAddress(void) const
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
void SetPhy(Ptr< UanPhy > phy)
Describes an IPv6 address.
Definition: ipv6-address.h:44
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
Network layer to device interface.
Definition: net-device.h:75
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
virtual void SetNode(Ptr< Node > node)
void SetTransducer(Ptr< UanTransducer > trans)
virtual bool NeedsArp(void) const
a unique identifier for an interface.
Definition: type-id.h:44
virtual void SetIfIndex(const uint32_t index)