A Discrete-Event Network Simulator
API
net-device.h
Go to the documentation of this file.
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  * Modified by Emmanuelle Laprise to remove dependence on LLC headers
20  */
21 #ifndef NET_DEVICE_H
22 #define NET_DEVICE_H
23 
24 #include <stdint.h>
25 #include "ns3/callback.h"
26 #include "ns3/object.h"
27 #include "ns3/ptr.h"
28 #include "packet.h"
29 #include "address.h"
30 #include "ns3/ipv4-address.h"
31 #include "ns3/ipv6-address.h"
32 
33 namespace ns3 {
34 
35 class Node;
36 class Channel;
37 
95 class NetDevice : public Object
96 {
97 public:
102  static TypeId GetTypeId (void);
103  virtual ~NetDevice();
104 
108  virtual void SetIfIndex (const uint32_t index) = 0;
112  virtual uint32_t GetIfIndex (void) const = 0;
113 
114 
122  virtual Ptr<Channel> GetChannel (void) const = 0;
123 
124  virtual void SniffPacket(Ptr<const Packet> p);
125 
126  virtual bool ShouldSniffPacketFromDevice();
127 
128  virtual void SetSniffPacketFromDevice( bool value);
129 
134  virtual void SetAddress (Address address) = 0;
135 
139  virtual Address GetAddress (void) const = 0;
140 
147  virtual bool SetMtu (const uint16_t mtu) = 0;
154  virtual uint16_t GetMtu (void) const = 0;
158  virtual bool IsLinkUp (void) const = 0;
162  typedef void (* LinkChangeTracedCallback) (void);
171  virtual void AddLinkChangeCallback (Callback<void> callback) = 0;
176  virtual bool IsBroadcast (void) const = 0;
184  virtual Address GetBroadcast (void) const = 0;
185 
189  virtual bool IsMulticast (void) const = 0;
190 
218  virtual Address GetMulticast (Ipv4Address multicastGroup) const = 0;
219 
227  virtual Address GetMulticast (Ipv6Address addr) const = 0;
228 
234  virtual bool IsBridge (void) const = 0;
235 
241  virtual bool IsPointToPoint (void) const = 0;
254  virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) = 0;
268  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber) = 0;
277  virtual Ptr<Node> GetNode (void) const = 0;
278 
284  virtual void SetNode (Ptr<Node> node) = 0;
285 
292  virtual bool NeedsArp (void) const = 0;
293 
294 
303  {
312  };
313 
325 
333  virtual void SetReceiveCallback (ReceiveCallback cb) = 0;
334 
335 
348  typedef Callback< bool, Ptr<NetDevice>, Ptr<const Packet>, uint16_t,
350 
361  virtual void SetPromiscReceiveCallback (PromiscReceiveCallback cb) = 0;
362 
366  virtual bool SupportsSendFrom (void) const = 0;
367 
368 };
369 
370 } // namespace ns3
371 
372 #endif /* NET_DEVICE_H */
virtual void SetIfIndex(const uint32_t index)=0
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
virtual Address GetBroadcast(void) const =0
Packet addressed to someone else.
Definition: net-device.h:310
virtual Address GetMulticast(Ipv4Address multicastGroup) const =0
Make and return a MAC multicast address using the provided multicast group.
Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address & > ReceiveCallback
Definition: net-device.h:324
virtual void SniffPacket(Ptr< const Packet > p)
Definition: net-device.cc:45
virtual void SetNode(Ptr< Node > node)=0
virtual Ptr< Node > GetNode(void) const =0
virtual bool IsBroadcast(void) const =0
virtual ~NetDevice()
Definition: net-device.cc:39
a polymophic address class
Definition: address.h:90
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)=0
virtual void SetReceiveCallback(ReceiveCallback cb)=0
virtual bool SupportsSendFrom(void) const =0
virtual uint16_t GetMtu(void) const =0
virtual void SetSniffPacketFromDevice(bool value)
Definition: net-device.cc:55
virtual bool IsMulticast(void) const =0
static TypeId GetTypeId(void)
Get the type ID.
Definition: net-device.cc:30
void(* LinkChangeTracedCallback)(void)
TracedCallback signature for link changed event.
Definition: net-device.h:162
virtual bool IsBridge(void) const =0
Return true if the net device is acting as a bridge.
virtual bool NeedsArp(void) const =0
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address &, const Address &, enum PacketType > PromiscReceiveCallback
Definition: net-device.h:349
address
Definition: first.py:37
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)=0
virtual Ptr< Channel > GetChannel(void) const =0
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)=0
virtual uint32_t GetIfIndex(void) const =0
virtual bool ShouldSniffPacketFromDevice()
Definition: net-device.cc:50
Describes an IPv6 address.
Definition: ipv6-address.h:49
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
Packet addressed oo us.
Definition: net-device.h:304
Network layer to device interface.
Definition: net-device.h:95
virtual bool IsPointToPoint(void) const =0
Return true if the net device is on a point-to-point link.
A base class which provides memory management and object aggregation.
Definition: object.h:87
virtual void SetAddress(Address address)=0
Set the address of this interface.
PacketType
Packet types are used as they are in Linux.
Definition: net-device.h:302
virtual void AddLinkChangeCallback(Callback< void > callback)=0
virtual bool IsLinkUp(void) const =0
virtual bool SetMtu(const uint16_t mtu)=0
Packet addressed to multicast group.
Definition: net-device.h:308
a unique identifier for an interface.
Definition: type-id.h:58
Packet addressed to all.
Definition: net-device.h:306
virtual Address GetAddress(void) const =0