A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 <string>
25 #include <stdint.h>
26 #include "ns3/callback.h"
27 #include "ns3/object.h"
28 #include "ns3/ptr.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 class Packet;
38 
75 class NetDevice : public Object
76 {
77 public:
82  static TypeId GetTypeId (void);
83  virtual ~NetDevice();
84 
88  virtual void SetIfIndex (const uint32_t index) = 0;
92  virtual uint32_t GetIfIndex (void) const = 0;
93 
94 
102  virtual Ptr<Channel> GetChannel (void) const = 0;
103 
108  virtual void SetAddress (Address address) = 0;
109 
113  virtual Address GetAddress (void) const = 0;
114 
121  virtual bool SetMtu (const uint16_t mtu) = 0;
128  virtual uint16_t GetMtu (void) const = 0;
132  virtual bool IsLinkUp (void) const = 0;
141  virtual void AddLinkChangeCallback (Callback<void> callback) = 0;
146  virtual bool IsBroadcast (void) const = 0;
154  virtual Address GetBroadcast (void) const = 0;
155 
159  virtual bool IsMulticast (void) const = 0;
160 
190  virtual Address GetMulticast (Ipv4Address multicastGroup) const = 0;
191 
199  virtual Address GetMulticast (Ipv6Address addr) const = 0;
200 
206  virtual bool IsBridge (void) const = 0;
207 
213  virtual bool IsPointToPoint (void) const = 0;
226  virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) = 0;
240  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber) = 0;
249  virtual Ptr<Node> GetNode (void) const = 0;
250 
256  virtual void SetNode (Ptr<Node> node) = 0;
257 
264  virtual bool NeedsArp (void) const = 0;
265 
266 
275  {
284  };
285 
297 
303  virtual void SetReceiveCallback (ReceiveCallback cb) = 0;
304 
305 
320 
332 
336  virtual bool SupportsSendFrom (void) const = 0;
337 
338 };
339 
340 } // namespace ns3
341 
342 #endif /* NET_DEVICE_H */
virtual void SetIfIndex(const uint32_t index)=0
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
virtual Address GetBroadcast(void) const =0
Packet addressed to someone else.
Definition: net-device.h:282
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:296
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:40
a polymophic address class
Definition: address.h:86
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 bool IsMulticast(void) const =0
static TypeId GetTypeId(void)
Get the type ID.
Definition: net-device.cc:32
virtual bool IsBridge(void) const =0
Return true if the net device is acting as a bridge.
virtual bool NeedsArp(void) const =0
Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address &, const Address &, enum PacketType > PromiscReceiveCallback
Definition: net-device.h:319
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
Describes an IPv6 address.
Definition: ipv6-address.h:46
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
Packet addressed oo us.
Definition: net-device.h:276
Network layer to device interface.
Definition: net-device.h:75
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:64
tuple address
Definition: first.py:37
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:274
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:280
a unique identifier for an interface.
Definition: type-id.h:49
Packet addressed to all.
Definition: net-device.h:278
virtual Address GetAddress(void) const =0