A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tap-fd-net-device-helper.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012 INRIA, 2012 University of Washington
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 */
7
8#ifndef TAP_FD_NET_DEVICE_HELPER_H
9#define TAP_FD_NET_DEVICE_HELPER_H
10
12
13#include "ns3/attribute.h"
14#include "ns3/fd-net-device.h"
15#include "ns3/mac48-address.h"
16#include "ns3/net-device-container.h"
17#include "ns3/node-container.h"
18#include "ns3/object-factory.h"
19
20#include <string>
21
22namespace ns3
23{
24
25/**
26 * \ingroup fd-net-device
27 * \brief build a set of FdNetDevice objects attached to a virtual TAP network
28 * interface
29 *
30 */
32{
33 public:
34 /**
35 * Construct a TapFdNetDeviceHelper.
36 */
38
40 {
41 }
42
43 /**
44 * Set flag IFF_NO_PI on the device.
45 *
46 * \param pi Set the IFF_NO_PI flag if pi is false.
47 */
48 void SetModePi(bool pi);
49
50 /**
51 * Set the device IPv4 address.
52 *
53 * \param address The IPv4 address for the TAP device.
54 */
55 void SetTapIpv4Address(Ipv4Address address);
56
57 /**
58 * Set the IPv4 network mask for the TAP device.
59 *
60 * \param mask The IPv4 network mask for the TAP device.
61 */
62 void SetTapIpv4Mask(Ipv4Mask mask);
63
64 /**
65 * Set the device IPv6 address.
66 *
67 * \param address The IPv6 address for the TAP device.
68 */
69 void SetTapIpv6Address(Ipv6Address address);
70
71 /**
72 * Set the IPv6 network mask for the TAP device.
73 *
74 * \param prefix The IPv6 network prefix for the TAP device.
75 */
76 void SetTapIpv6Prefix(int prefix);
77
78 /**
79 * Set the MAC address for the TAP device.
80 *
81 * \param mac The MAC address the TAP device.
82 */
84
85 protected:
86 /**
87 * This method creates an ns3::FdNetDevice attached to a virtual TAP network
88 * interface
89 *
90 * \param node The node to install the device in
91 * \returns A container holding the added net device.
92 */
93 Ptr<NetDevice> InstallPriv(Ptr<Node> node) const override;
94
95 /**
96 * Sets a file descriptor on the FileDescriptorNetDevice.
97 * \param device the device to install the file descriptor in
98 */
99 void SetFileDescriptor(Ptr<FdNetDevice> device) const override;
100
101 /**
102 * Call out to a separate process running as suid root in order to create a
103 * TAP device and obtain the file descriptor associated to it.
104 * \returns The file descriptor associated with the TAP device.
105 */
106 int CreateFileDescriptor() const override;
107
108 /**
109 * The TAP device flag IFF_NO_PI.
110 */
112
113 /**
114 * The IPv4 address for the TAP device.
115 */
117
118 /**
119 * The IPv6 address for the TAP device.
120 */
122
123 /**
124 * The network mask IPv4 for the TAP device.
125 */
127
128 /**
129 * The network prefix IPv6 for the TAP device.
130 */
132
133 /**
134 * The TAP device MAC address.
135 */
137};
138
139} // namespace ns3
140
141#endif /* TAP_FD_NET_DEVICE_HELPER_H */
build a set of FdNetDevice objects attached to a physical network interface
Ipv4 addresses are stored in host order in this class.
a class to represent an Ipv4 address mask
Describes an IPv6 address.
an EUI-48 address
Smart pointer class similar to boost::intrusive_ptr.
build a set of FdNetDevice objects attached to a virtual TAP network interface
int CreateFileDescriptor() const override
Call out to a separate process running as suid root in order to create a TAP device and obtain the fi...
void SetTapMacAddress(Mac48Address mac)
Set the MAC address for the TAP device.
bool m_modePi
The TAP device flag IFF_NO_PI.
void SetTapIpv6Prefix(int prefix)
Set the IPv6 network mask for the TAP device.
Ipv6Address m_tapIp6
The IPv6 address for the TAP device.
Ptr< NetDevice > InstallPriv(Ptr< Node > node) const override
This method creates an ns3::FdNetDevice attached to a virtual TAP network interface.
void SetTapIpv4Mask(Ipv4Mask mask)
Set the IPv4 network mask for the TAP device.
Ipv4Mask m_tapMask4
The network mask IPv4 for the TAP device.
Ipv4Address m_tapIp4
The IPv4 address for the TAP device.
TapFdNetDeviceHelper()
Construct a TapFdNetDeviceHelper.
Mac48Address m_tapMac
The TAP device MAC address.
int m_tapPrefix6
The network prefix IPv6 for the TAP device.
void SetTapIpv4Address(Ipv4Address address)
Set the device IPv4 address.
void SetModePi(bool pi)
Set flag IFF_NO_PI on the device.
void SetTapIpv6Address(Ipv6Address address)
Set the device IPv6 address.
void SetFileDescriptor(Ptr< FdNetDevice > device) const override
Sets a file descriptor on the FileDescriptorNetDevice.
Every class exported by the ns3 library is enclosed in the ns3 namespace.