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
33namespace ns3 {
34
35class Node;
36class Channel;
37
95class NetDevice : public Object
96{
97public:
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
128 virtual void SetAddress (Address address) = 0;
129
133 virtual Address GetAddress (void) const = 0;
134
141 virtual bool SetMtu (const uint16_t mtu) = 0;
148 virtual uint16_t GetMtu (void) const = 0;
152 virtual bool IsLinkUp (void) const = 0;
156 typedef void (* LinkChangeTracedCallback) (void);
165 virtual void AddLinkChangeCallback (Callback<void> callback) = 0;
170 virtual bool IsBroadcast (void) const = 0;
178 virtual Address GetBroadcast (void) const = 0;
179
183 virtual bool IsMulticast (void) const = 0;
184
212 virtual Address GetMulticast (Ipv4Address multicastGroup) const = 0;
213
221 virtual Address GetMulticast (Ipv6Address addr) const = 0;
222
228 virtual bool IsBridge (void) const = 0;
229
235 virtual bool IsPointToPoint (void) const = 0;
248 virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) = 0;
262 virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber) = 0;
271 virtual Ptr<Node> GetNode (void) const = 0;
272
278 virtual void SetNode (Ptr<Node> node) = 0;
279
286 virtual bool NeedsArp (void) const = 0;
287
288
297 {
306 };
307
319
327 virtual void SetReceiveCallback (ReceiveCallback cb) = 0;
328
329
344
356
360 virtual bool SupportsSendFrom (void) const = 0;
361
362};
363
364} // namespace ns3
365
366#endif /* NET_DEVICE_H */
a polymophic address class
Definition: address.h:91
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
Describes an IPv6 address.
Definition: ipv6-address.h:50
Network layer to device interface.
Definition: net-device.h:96
virtual bool SupportsSendFrom(void) const =0
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)=0
virtual bool IsMulticast(void) const =0
static TypeId GetTypeId(void)
Get the type ID.
Definition: net-device.cc:30
virtual bool SetMtu(const uint16_t mtu)=0
virtual void SetIfIndex(const uint32_t index)=0
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)=0
virtual void SetNode(Ptr< Node > node)=0
Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address &, const Address &, enum PacketType > PromiscReceiveCallback
Definition: net-device.h:343
virtual Address GetMulticast(Ipv6Address addr) const =0
Get the MAC multicast address corresponding to the IPv6 address provided.
virtual Address GetBroadcast(void) const =0
void(* LinkChangeTracedCallback)(void)
TracedCallback signature for link changed event.
Definition: net-device.h:156
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)=0
virtual ~NetDevice()
Definition: net-device.cc:39
virtual Address GetAddress(void) const =0
virtual bool IsBroadcast(void) const =0
virtual bool IsPointToPoint(void) const =0
Return true if the net device is on a point-to-point link.
virtual uint32_t GetIfIndex(void) const =0
virtual uint16_t GetMtu(void) const =0
virtual Address GetMulticast(Ipv4Address multicastGroup) const =0
Make and return a MAC multicast address using the provided multicast group.
virtual bool IsBridge(void) const =0
Return true if the net device is acting as a bridge.
virtual Ptr< Node > GetNode(void) const =0
virtual void AddLinkChangeCallback(Callback< void > callback)=0
virtual bool NeedsArp(void) const =0
virtual void SetAddress(Address address)=0
Set the address of this interface.
virtual void SetReceiveCallback(ReceiveCallback cb)=0
virtual Ptr< Channel > GetChannel(void) const =0
PacketType
Packet types are used as they are in Linux.
Definition: net-device.h:297
@ PACKET_HOST
Packet addressed oo us.
Definition: net-device.h:298
@ PACKET_OTHERHOST
Packet addressed to someone else.
Definition: net-device.h:304
@ PACKET_BROADCAST
Packet addressed to all.
Definition: net-device.h:300
@ PACKET_MULTICAST
Packet addressed to multicast group.
Definition: net-device.h:302
Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address & > ReceiveCallback
Definition: net-device.h:318
virtual bool IsLinkUp(void) const =0
A base class which provides memory management and object aggregation.
Definition: object.h:88
a unique identifier for an interface.
Definition: type-id.h:59
address
Definition: first.py:44
Every class exported by the ns3 library is enclosed in the ns3 namespace.