A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
net-device.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005,2006 INRIA
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 * Modified by Emmanuelle Laprise to remove dependence on LLC headers
19 */
20#ifndef NET_DEVICE_H
21#define NET_DEVICE_H
22
23#include "address.h"
24#include "packet.h"
25
26#include "ns3/callback.h"
27#include "ns3/ipv4-address.h"
28#include "ns3/ipv6-address.h"
29#include "ns3/object.h"
30#include "ns3/ptr.h"
31
32#include <stdint.h>
33
34namespace ns3
35{
36
37class Node;
38class Channel;
39
97class NetDevice : public Object
98{
99 public:
104 static TypeId GetTypeId();
105 ~NetDevice() override;
106
110 virtual void SetIfIndex(const uint32_t index) = 0;
114 virtual uint32_t GetIfIndex() const = 0;
115
123 virtual Ptr<Channel> GetChannel() const = 0;
124
129 virtual void SetAddress(Address address) = 0;
130
134 virtual Address GetAddress() const = 0;
135
142 virtual bool SetMtu(const uint16_t mtu) = 0;
149 virtual uint16_t GetMtu() const = 0;
153 virtual bool IsLinkUp() const = 0;
157 typedef void (*LinkChangeTracedCallback)();
166 virtual void AddLinkChangeCallback(Callback<void> callback) = 0;
171 virtual bool IsBroadcast() const = 0;
179 virtual Address GetBroadcast() const = 0;
180
184 virtual bool IsMulticast() const = 0;
185
213 virtual Address GetMulticast(Ipv4Address multicastGroup) const = 0;
214
222 virtual Address GetMulticast(Ipv6Address addr) const = 0;
223
229 virtual bool IsBridge() const = 0;
230
236 virtual bool IsPointToPoint() const = 0;
249 virtual bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) = 0;
263 virtual bool SendFrom(Ptr<Packet> packet,
264 const Address& source,
265 const Address& dest,
266 uint16_t protocolNumber) = 0;
275 virtual Ptr<Node> GetNode() const = 0;
276
282 virtual void SetNode(Ptr<Node> node) = 0;
283
290 virtual bool NeedsArp() const = 0;
291
300 {
309 };
310
323
332
345 typedef Callback<bool,
348 uint16_t,
349 const Address&,
350 const Address&,
353
365
369 virtual bool SupportsSendFrom() const = 0;
370};
371
372} // namespace ns3
373
374#endif /* NET_DEVICE_H */
a polymophic address class
Definition: address.h:100
Callback template class.
Definition: callback.h:438
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
Describes an IPv6 address.
Definition: ipv6-address.h:49
Network layer to device interface.
Definition: net-device.h:98
virtual bool SupportsSendFrom() const =0
Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address &, const Address &, PacketType > PromiscReceiveCallback
Definition: net-device.h:352
virtual uint32_t GetIfIndex() const =0
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)=0
static TypeId GetTypeId()
Get the type ID.
Definition: net-device.cc:32
virtual bool SetMtu(const uint16_t mtu)=0
virtual void SetIfIndex(const uint32_t index)=0
virtual uint16_t GetMtu() const =0
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)=0
virtual void SetNode(Ptr< Node > node)=0
virtual Address GetMulticast(Ipv6Address addr) const =0
Get the MAC multicast address corresponding to the IPv6 address provided.
void(* LinkChangeTracedCallback)()
TracedCallback signature for link changed event.
Definition: net-device.h:157
virtual bool IsMulticast() const =0
virtual Address GetBroadcast() const =0
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)=0
virtual bool NeedsArp() const =0
virtual Address GetAddress() const =0
virtual bool IsLinkUp() const =0
~NetDevice() override
Definition: net-device.cc:38
virtual bool IsBridge() const =0
Return true if the net device is acting as a bridge.
virtual Address GetMulticast(Ipv4Address multicastGroup) const =0
Make and return a MAC multicast address using the provided multicast group.
virtual bool IsBroadcast() const =0
virtual void AddLinkChangeCallback(Callback< void > callback)=0
virtual void SetAddress(Address address)=0
Set the address of this interface.
virtual Ptr< Channel > GetChannel() const =0
virtual void SetReceiveCallback(ReceiveCallback cb)=0
PacketType
Packet types are used as they are in Linux.
Definition: net-device.h:300
@ PACKET_HOST
Packet addressed to us.
Definition: net-device.h:301
@ PACKET_OTHERHOST
Packet addressed to someone else.
Definition: net-device.h:307
@ PACKET_BROADCAST
Packet addressed to all.
Definition: net-device.h:303
@ PACKET_MULTICAST
Packet addressed to multicast group.
Definition: net-device.h:305
Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address & > ReceiveCallback
Definition: net-device.h:322
virtual Ptr< Node > GetNode() const =0
virtual bool IsPointToPoint() 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:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.