Sese Framework
2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
IPv6Address.h
Go to the documentation of this file.
1
// Copyright 2024 libsese
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
22
#pragma once
23
24
#include "
sese/net/IPv4Address.h
"
25
26
namespace
sese::net
{
27
31
class
IPv6Address
final :
public
IPAddress
{
32
public
:
33
using
Ptr
= std::shared_ptr<IPv6Address>;
34
static
IPv6Address::Ptr
create
(
const
char
*
address
, uint16_t port);
35
static
IPv6Address::Ptr
localhost
(uint16_t port = 0);
36
static
IPv6Address::Ptr
any
(uint16_t port = 0);
37
38
public
:
39
explicit
IPv6Address
() noexcept;
40
explicit
IPv6Address
(const sockaddr_in6 &
address
) noexcept;
41
explicit
IPv6Address
(const uint8_t *
address
, uint16_t port = 0);
42
43
[[nodiscard]] sockaddr *
getRawAddress
() const noexcept override;
44
[[nodiscard]] socklen_t
getRawAddressLength
() const noexcept override;
45
[[nodiscard]] std::
string
getAddress
() const noexcept override;
46
47
[[nodiscard]]
IPAddress
::
Ptr
getBroadcastAddress
(uint32_t prefix_len) const noexcept override;
48
[[nodiscard]]
IPAddress
::
Ptr
getNetworkAddress
(uint32_t prefix_len) const noexcept override;
49
[[nodiscard]]
IPAddress
::
Ptr
getSubnetMask
(uint32_t prefix_len) const noexcept override;
50
51
void
setPort
(uint16_t port) noexcept
override
{ this->address.sin6_port =
ToBigEndian16
(port); }
52
[[nodiscard]] uint16_t
getPort
() const noexcept
override
{
return
FromBigEndian16
(
address
.sin6_port); }
53
54
void
setFamily
(uint16_t family)
noexcept
override
{
55
address
.sin6_family = family;
56
}
57
uint16_t
getFamily
() noexcept
override
{
58
return
address
.sin6_family;
59
}
60
61
private
:
62
sockaddr_in6
address
{0};
63
};
64
}
// namespace sese::net
sese
net
IPv6Address.h
Generated on Tue Jan 7 2025 15:49:06 for Sese Framework by
1.11.0