A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
packet-socket-address.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8#ifndef PACKET_SOCKET_ADDRESS_H
9#define PACKET_SOCKET_ADDRESS_H
10
11#include "mac48-address.h"
12#include "mac64-address.h"
13
14#include "ns3/address.h"
15#include "ns3/net-device.h"
16#include "ns3/ptr.h"
17
18namespace ns3
19{
20
21class NetDevice;
22
23/**
24 * \ingroup address
25 *
26 * \brief an address for a packet socket
27 */
29{
30 public:
32
33 /**
34 * \brief Set the protocol
35 * \param protocol the protocol
36 */
37 void SetProtocol(uint16_t protocol);
38
39 /**
40 * \brief Set the address to match all the outgoing NetDevice
41 */
42 void SetAllDevices();
43
44 /**
45 * \brief Set the address to match only a specified NetDevice
46 * \param device the NetDevice index
47 */
48 void SetSingleDevice(uint32_t device);
49
50 /**
51 * \brief Set the destination address
52 * \param address the destination address
53 */
54 void SetPhysicalAddress(const Address address);
55
56 /**
57 * \brief Get the protocol
58 * \return the protocol
59 */
60 uint16_t GetProtocol() const;
61
62 /**
63 * \brief Get the device this address is bound to
64 * \return the device index
65 */
67
68 /**
69 * \brief Checks if the address is bound to a specified NetDevice
70 * \return true if the address is bound to a NetDevice
71 */
72 bool IsSingleDevice() const;
73
74 /**
75 * \brief Get the destination address
76 * \returns The destination address
77 */
79
80 /**
81 * \returns a new Address instance
82 *
83 * Convert an instance of this class to a polymorphic Address instance.
84 */
85 operator Address() const;
86
87 /**
88 * \param address a polymorphic address
89 * \returns an Address
90 * Convert a polymorphic address to an Mac48Address instance.
91 * The conversion performs a type check.
92 */
93 static PacketSocketAddress ConvertFrom(const Address& address);
94
95 /**
96 * \brief Convert an instance of this class to a polymorphic Address instance.
97 * \returns a new Address instance
98 */
99 Address ConvertTo() const;
100
101 /**
102 * \param address address to test
103 * \returns true if the address matches, false otherwise.
104 */
105 static bool IsMatchingType(const Address& address);
106
107 private:
108 /**
109 * \brief Return the Type of address.
110 * \return type of address
111 */
112 static uint8_t GetType();
113
114 uint16_t m_protocol; //!< Protocol
115 bool m_isSingleDevice; //!< True if directed to a specific outgoing NetDevice
116 uint32_t m_device; //!< Outgoing NetDevice index
117 Address m_address; //!< Destination address
118};
119
120} // namespace ns3
121
122#endif /* PACKET_SOCKET_ADDRESS_H */
a polymophic address class
Definition address.h:90
an address for a packet socket
Address ConvertTo() const
Convert an instance of this class to a polymorphic Address instance.
uint32_t GetSingleDevice() const
Get the device this address is bound to.
bool IsSingleDevice() const
Checks if the address is bound to a specified NetDevice.
Address GetPhysicalAddress() const
Get the destination address.
Address m_address
Destination address.
uint32_t m_device
Outgoing NetDevice index.
void SetProtocol(uint16_t protocol)
Set the protocol.
static bool IsMatchingType(const Address &address)
void SetPhysicalAddress(const Address address)
Set the destination address.
bool m_isSingleDevice
True if directed to a specific outgoing NetDevice.
static PacketSocketAddress ConvertFrom(const Address &address)
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
static uint8_t GetType()
Return the Type of address.
void SetAllDevices()
Set the address to match all the outgoing NetDevice.
uint16_t GetProtocol() const
Get the protocol.
Every class exported by the ns3 library is enclosed in the ns3 namespace.