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:
78  static TypeId GetTypeId (void);
79  virtual ~NetDevice();
80 
84  virtual void SetIfIndex (const uint32_t index) = 0;
88  virtual uint32_t GetIfIndex (void) const = 0;
89 
90 
98  virtual Ptr<Channel> GetChannel (void) const = 0;
99 
104  virtual void SetAddress (Address address) = 0;
105 
109  virtual Address GetAddress (void) const = 0;
110 
117  virtual bool SetMtu (const uint16_t mtu) = 0;
124  virtual uint16_t GetMtu (void) const = 0;
128  virtual bool IsLinkUp (void) const = 0;
137  virtual void AddLinkChangeCallback (Callback<void> callback) = 0;
142  virtual bool IsBroadcast (void) const = 0;
150  virtual Address GetBroadcast (void) const = 0;
151 
155  virtual bool IsMulticast (void) const = 0;
156 
186  virtual Address GetMulticast (Ipv4Address multicastGroup) const = 0;
187 
195  virtual Address GetMulticast (Ipv6Address addr) const = 0;
196 
202  virtual bool IsBridge (void) const = 0;
203 
209  virtual bool IsPointToPoint (void) const = 0;
222  virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) = 0;
236  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber) = 0;
245  virtual Ptr<Node> GetNode (void) const = 0;
246 
252  virtual void SetNode (Ptr<Node> node) = 0;
253 
260  virtual bool NeedsArp (void) const = 0;
261 
262 
271  {
280  };
281 
293 
299  virtual void SetReceiveCallback (ReceiveCallback cb) = 0;
300 
301 
316 
328 
332  virtual bool SupportsSendFrom (void) const = 0;
333 
334 };
335 
336 } // namespace ns3
337 
338 #endif /* NET_DEVICE_H */
virtual void SetIfIndex(const uint32_t index)=0
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
virtual Address GetBroadcast(void) const =0
Packet addressed to someone else.
Definition: net-device.h:278
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:292
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:41
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)
Definition: net-device.cc:33
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:315
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:272
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:63
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:270
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:276
a unique identifier for an interface.
Definition: type-id.h:49
Packet addressed to all.
Definition: net-device.h:274
virtual Address GetAddress(void) const =0