A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
inet-socket-address.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2005 INRIA
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7
*/
8
9
#ifndef INET_SOCKET_ADDRESS_H
10
#define INET_SOCKET_ADDRESS_H
11
12
#include "
ipv4-address.h
"
13
14
#include "ns3/address.h"
15
16
#include <stdint.h>
17
18
namespace
ns3
19
{
20
21
/**
22
* \ingroup address
23
*
24
* \brief an Inet address class
25
*
26
* This class is similar to inet_sockaddr in the BSD socket
27
* API. i.e., this class holds an Ipv4Address and a port number
28
* to form an ipv4 transport endpoint.
29
*/
30
class
InetSocketAddress
31
{
32
public
:
33
/**
34
* \param ipv4 the ipv4 address
35
* \param port the port number
36
*/
37
InetSocketAddress
(
Ipv4Address
ipv4, uint16_t
port
);
38
/**
39
* \param ipv4 the ipv4 address
40
*
41
* The port number is set to zero by default.
42
*/
43
InetSocketAddress
(
Ipv4Address
ipv4);
44
/**
45
* \param port the port number
46
*
47
* The ipv4 address is set to the "Any" address by default.
48
*/
49
InetSocketAddress
(uint16_t
port
);
50
/**
51
* \param ipv4 string which represents an ipv4 address
52
* \param port the port number
53
*/
54
InetSocketAddress
(
const
char
* ipv4, uint16_t
port
);
55
/**
56
* \param ipv4 string which represents an ipv4 address
57
*
58
* The port number is set to zero.
59
*/
60
InetSocketAddress
(
const
char
* ipv4);
61
/**
62
* \returns the port number
63
*/
64
uint16_t
GetPort
()
const
;
65
/**
66
* \returns the ipv4 address
67
*/
68
Ipv4Address
GetIpv4
()
const
;
69
70
/**
71
* \param port the new port number.
72
*/
73
void
SetPort
(uint16_t
port
);
74
/**
75
* \param address the new ipv4 address
76
*/
77
void
SetIpv4
(
Ipv4Address
address);
78
79
/**
80
* \param address address to test
81
* \returns true if the address matches, false otherwise.
82
*/
83
static
bool
IsMatchingType
(
const
Address
& address);
84
85
/**
86
* \returns an Address instance which represents this
87
* InetSocketAddress instance.
88
*/
89
operator
Address
()
const
;
90
91
/**
92
* \brief Returns an InetSocketAddress which corresponds to the input
93
* Address.
94
*
95
* \param address the Address instance to convert from.
96
* \returns an InetSocketAddress
97
*/
98
static
InetSocketAddress
ConvertFrom
(
const
Address
& address);
99
100
/**
101
* \brief Convert to an Address type
102
* \return the Address corresponding to this object.
103
*/
104
Address
ConvertTo
()
const
;
105
106
private
:
107
/**
108
* \brief Get the underlying address type (automatically assigned).
109
*
110
* \returns the address type
111
*/
112
static
uint8_t
GetType
();
113
Ipv4Address
m_ipv4
;
//!< the IPv4 address
114
uint16_t
m_port
;
//!< the port
115
};
116
117
}
// namespace ns3
118
119
#endif
/* INET_SOCKET_ADDRESS_H */
ns3::Address
a polymophic address class
Definition
address.h:90
ns3::InetSocketAddress
an Inet address class
Definition
inet-socket-address.h:31
ns3::InetSocketAddress::SetPort
void SetPort(uint16_t port)
Definition
inet-socket-address.cc:69
ns3::InetSocketAddress::GetType
static uint8_t GetType()
Get the underlying address type (automatically assigned).
Definition
inet-socket-address.cc:119
ns3::InetSocketAddress::ConvertTo
Address ConvertTo() const
Convert to an Address type.
Definition
inet-socket-address.cc:95
ns3::InetSocketAddress::GetPort
uint16_t GetPort() const
Definition
inet-socket-address.cc:55
ns3::InetSocketAddress::m_port
uint16_t m_port
the port
Definition
inet-socket-address.h:114
ns3::InetSocketAddress::SetIpv4
void SetIpv4(Ipv4Address address)
Definition
inet-socket-address.cc:76
ns3::InetSocketAddress::IsMatchingType
static bool IsMatchingType(const Address &address)
Definition
inet-socket-address.cc:83
ns3::InetSocketAddress::InetSocketAddress
InetSocketAddress(Ipv4Address ipv4, uint16_t port)
Definition
inet-socket-address.cc:19
ns3::InetSocketAddress::m_ipv4
Ipv4Address m_ipv4
the IPv4 address
Definition
inet-socket-address.h:113
ns3::InetSocketAddress::GetIpv4
Ipv4Address GetIpv4() const
Definition
inet-socket-address.cc:62
ns3::InetSocketAddress::ConvertFrom
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address.
Definition
inet-socket-address.cc:106
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition
ipv4-address.h:31
port
uint16_t port
Definition
dsdv-manet.cc:33
ipv4-address.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
network
utils
inet-socket-address.h
Generated on Fri Nov 8 2024 13:59:05 for ns-3 by
1.11.0