OpenShot Library | libopenshot-audio
0.2.0
juce_IPAddress.h
1
2
/** @weakgroup juce_core-network
3
* @{
4
*/
5
/*
6
==============================================================================
7
8
This file is part of the JUCE library.
9
Copyright (c) 2017 - ROLI Ltd.
10
11
JUCE is an open source library subject to commercial or open-source
12
licensing.
13
14
The code included in this file is provided under the terms of the ISC license
15
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
16
To use, copy, modify, and/or distribute this software for any purpose with or
17
without fee is hereby granted provided that the above copyright notice and
18
this permission notice appear in all copies.
19
20
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
21
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
22
DISCLAIMED.
23
24
==============================================================================
25
*/
26
27
namespace
juce
28
{
29
30
//==============================================================================
31
/**
32
Represents an IP address.
33
34
@tags{Core}
35
*/
36
class
JUCE_API
IPAddress
final
37
{
38
public
:
39
//==============================================================================
40
/** Returns an IP address meaning "any", equivalent to 0.0.0.0 (IPv4) or ::, (IPv6) */
41
static
IPAddress
any()
noexcept
;
42
43
/** Returns an IPv4 address meaning "broadcast" (255.255.255.255) */
44
static
IPAddress
broadcast()
noexcept
;
45
46
/** Returns an IPv4 or IPv6 address meaning "localhost", equivalent to 127.0.0.1 (IPv4) or ::1 (IPv6) */
47
static
IPAddress
local (
bool
IPv6
=
false
)
noexcept
;
48
49
//==============================================================================
50
/** Populates a list of all the IP addresses that this machine is using. */
51
static
void
findAllAddresses
(
Array<IPAddress>
& results,
bool
includeIPv6
=
false
);
52
53
/** Populates a list of all the IP addresses that this machine is using. */
54
static
Array<IPAddress>
getAllAddresses (
bool
includeIPv6
=
false
);
55
56
/** Returns the first 'real' address for the local machine.
57
Unlike local(), this will attempt to find the machine's actual assigned
58
address rather than "127.0.0.1". If there are multiple network cards, this
59
may return any of their addresses. If it doesn't find any, then it'll return
60
local() as a fallback.
61
*/
62
static
IPAddress
getLocalAddress (
bool
includeIPv6
=
false
);
63
64
//==============================================================================
65
/** Creates a null address - 0.0.0.0 (IPv4) or ::, (IPv6) */
66
IPAddress
()
noexcept
;
67
68
/** Creates an IPv4 or IPv6 address by reading 4 or 16 bytes from an array.
69
@param bytes The array containing the bytes to read.
70
@param IPv6 if true indicates that 16 bytes should be read instead of 4.
71
*/
72
explicit
IPAddress
(
const
uint8*
bytes
,
bool
IPv6
=
false
)
noexcept
;
73
74
/** Creates an IPv6 address from an array of 8 16-bit integers
75
@param bytes The array containing the bytes to read.
76
*/
77
explicit
IPAddress
(
const
uint16*
bytes
)
noexcept
;
78
79
/** Creates an IPv4 address from 4 bytes. */
80
IPAddress
(uint8
address1
, uint8
address2
, uint8
address3
, uint8
address4
)
noexcept
;
81
82
/** Creates an IPv6 address from 8 16-bit integers */
83
IPAddress
(uint16
address1
, uint16
address2
, uint16
address3
, uint16
address4
,
84
uint16
address5
, uint16
address6
, uint16
address7
, uint16
address8
)
noexcept
;
85
86
/** Creates an IPv4 address from a packed 32-bit integer, where the
87
MSB is the first number in the address, and the LSB is the last.
88
*/
89
explicit
IPAddress
(uint32
asNativeEndian32Bit
)
noexcept
;
90
91
/** Parses a string IP address of the form "1.2.3.4" (IPv4) or "1:2:3:4:5:6:7:8" (IPv6). */
92
explicit
IPAddress
(
const
String
& address);
93
94
/** Returns whether the address contains the null address (e.g. 0.0.0.0). */
95
bool
isNull()
const
;
96
97
//==============================================================================
98
/** Returns a dot- or colon-separated string in the form "1.2.3.4" (IPv4) or "1:2:3:4:5:6:7:8" (IPv6). */
99
String
toString()
const
;
100
101
/** Compares this IPAddress with another.
102
103
@returns 0 if the two addresses are identical, negative if this address is smaller than
104
the other one, or positive if is greater.
105
*/
106
int
compare (
const
IPAddress
&)
const
noexcept
;
107
108
bool
operator
== (
const
IPAddress
&)
const
noexcept
;
109
bool
operator
!= (
const
IPAddress
&)
const
noexcept
;
110
bool
operator
< (
const
IPAddress
&)
const
noexcept
;
111
bool
operator
> (
const
IPAddress
&)
const
noexcept
;
112
bool
operator
<= (
const
IPAddress
&)
const
noexcept
;
113
bool
operator
>= (
const
IPAddress
&)
const
noexcept
;
114
115
//==============================================================================
116
/** The elements of the IP address. */
117
uint8 address[16];
118
119
bool
isIPv6 =
false
;
120
121
//==============================================================================
122
/** Returns a formatted version of the provided IPv6 address conforming to RFC 5952 with leading zeros suppressed,
123
lower case characters, and double-colon notation used to represent contiguous 16-bit fields of zeros.
124
125
@param unformattedAddress the IPv6 address to be formatted
126
*/
127
static
String
getFormattedAddress (
const
String
&
unformattedAddress
);
128
129
/** Returns true if the given IP address is an IPv4-mapped IPv6 address. */
130
static
bool
isIPv4MappedAddress (
const
IPAddress
&
mappedAddress
);
131
132
/** Converts an IPv4-mapped IPv6 address to an IPv4 address.
133
If the address is not IPv4-mapped, this will return a null address.
134
*/
135
static
IPAddress
convertIPv4MappedAddressToIPv4 (
const
IPAddress
&
mappedAddress
);
136
137
/** Converts an IPv4 address to an IPv4-mapped IPv6 address. */
138
static
IPAddress
convertIPv4AddressToIPv4Mapped (
const
IPAddress
&
addressToMap
);
139
140
/** If the IPAdress is the address of an interface on the machine, returns the associated broadcast address.
141
If the address is not an interface, it will return a null address.
142
*/
143
static
IPAddress
getInterfaceBroadcastAddress (
const
IPAddress
&
interfaceAddress
);
144
};
145
146
}
// namespace juce
147
148
/** @}*/
juce::Array
Holds a resizable array of primitive or copy-by-value objects.
Definition
juce_Array.h:60
juce::IPAddress
Represents an IP address.
Definition
juce_IPAddress.h:37
juce::IPAddress::findAllAddresses
static void findAllAddresses(Array< IPAddress > &results, bool includeIPv6=false)
Populates a list of all the IP addresses that this machine is using.
juce::String
The JUCE String class!
Definition
juce_String.h:43
JUCE_API
#define JUCE_API
This macro is added to all JUCE public class declarations.
Definition
juce_StandardHeader.h:143
juce_core
network
juce_IPAddress.h
Generated on Fri Sep 20 2024 04:11:05 for OpenShot Library | libopenshot-audio by
1.9.8