Sese Framework
x.y.z
A cross-platform framework
载入中...
搜索中...
未找到
IPv6Address.h
浏览该文件的文档.
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
21
#pragma once
22
23
#include "
sese/net/IPv4Address.h
"
24
25
namespace
sese::net
{
26
30
class
IPv6Address
final :
public
IPAddress
{
31
public
:
32
using
Ptr
= std::shared_ptr<IPv6Address>;
33
static
IPv6Address::Ptr
create
(
const
char
*
address
, uint16_t port);
34
static
IPv6Address::Ptr
localhost
(uint16_t port = 0);
35
static
IPv6Address::Ptr
any
(uint16_t port = 0);
36
37
public
:
38
explicit
IPv6Address
() noexcept;
39
explicit
IPv6Address
(const sockaddr_in6 &
address
) noexcept;
40
explicit
IPv6Address
(const uint8_t *
address
, uint16_t port = 0);
41
42
[[nodiscard]] sockaddr *
getRawAddress
() const noexcept override;
43
[[nodiscard]] socklen_t
getRawAddressLength
() const noexcept override;
44
[[nodiscard]] std::
string
getAddress
() const noexcept override;
45
46
[[nodiscard]]
IPAddress
::
Ptr
getBroadcastAddress
(uint32_t prefix_len) const noexcept override;
47
[[nodiscard]]
IPAddress
::
Ptr
getNetworkAddress
(uint32_t prefix_len) const noexcept override;
48
[[nodiscard]]
IPAddress
::
Ptr
getSubnetMask
(uint32_t prefix_len) const noexcept override;
49
50
void
setPort
(uint16_t port) noexcept
override
{ this->address.sin6_port =
ToBigEndian16
(port); }
51
[[nodiscard]] uint16_t
getPort
() const noexcept
override
{
return
FromBigEndian16
(
address
.sin6_port); }
52
53
void
setFamily
(uint16_t family)
noexcept
override
{
54
address
.sin6_family = family;
55
}
56
uint16_t
getFamily
() noexcept
override
{
57
return
address
.sin6_family;
58
}
59
60
private
:
61
sockaddr_in6
address
{0};
62
};
63
}
// namespace sese::net
sese
net
IPv6Address.h
生成于 2024年 十一月 4日 星期一 09:58:01 , 为 Sese Framework使用
1.11.0