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 * 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 */
19#ifndef PACKET_SOCKET_ADDRESS_H
20#define PACKET_SOCKET_ADDRESS_H
21
22#include "mac48-address.h"
23#include "mac64-address.h"
24
25#include "ns3/address.h"
26#include "ns3/net-device.h"
27#include "ns3/ptr.h"
28
29namespace ns3
30{
31
32class NetDevice;
33
34/**
35 * \ingroup address
36 *
37 * \brief an address for a packet socket
38 */
40{
41 public:
43
44 /**
45 * \brief Set the protocol
46 * \param protocol the protocol
47 */
48 void SetProtocol(uint16_t protocol);
49
50 /**
51 * \brief Set the address to match all the outgoing NetDevice
52 */
53 void SetAllDevices();
54
55 /**
56 * \brief Set the address to match only a specified NetDevice
57 * \param device the NetDevice index
58 */
59 void SetSingleDevice(uint32_t device);
60
61 /**
62 * \brief Set the destination address
63 * \param address the destination address
64 */
65 void SetPhysicalAddress(const Address address);
66
67 /**
68 * \brief Get the protocol
69 * \return the protocol
70 */
71 uint16_t GetProtocol() const;
72
73 /**
74 * \brief Get the device this address is bound to
75 * \return the device index
76 */
78
79 /**
80 * \brief Checks if the address is bound to a specified NetDevice
81 * \return true if the address is bound to a NetDevice
82 */
83 bool IsSingleDevice() const;
84
85 /**
86 * \brief Get the destination address
87 * \returns The destination address
88 */
90
91 /**
92 * \returns a new Address instance
93 *
94 * Convert an instance of this class to a polymorphic Address instance.
95 */
96 operator Address() const;
97
98 /**
99 * \param address a polymorphic address
100 * \returns an Address
101 * Convert a polymorphic address to an Mac48Address instance.
102 * The conversion performs a type check.
103 */
104 static PacketSocketAddress ConvertFrom(const Address& address);
105
106 /**
107 * \brief Convert an instance of this class to a polymorphic Address instance.
108 * \returns a new Address instance
109 */
110 Address ConvertTo() const;
111
112 /**
113 * \param address address to test
114 * \returns true if the address matches, false otherwise.
115 */
116 static bool IsMatchingType(const Address& address);
117
118 private:
119 /**
120 * \brief Return the Type of address.
121 * \return type of address
122 */
123 static uint8_t GetType();
124
125 uint16_t m_protocol; //!< Protocol
126 bool m_isSingleDevice; //!< True if directed to a specific outgoing NetDevice
127 uint32_t m_device; //!< Outgoing NetDevice index
128 Address m_address; //!< Destination address
129};
130
131} // namespace ns3
132
133#endif /* PACKET_SOCKET_ADDRESS_H */
a polymophic address class
Definition: address.h:101
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.