net/SocketAddress: move code to IsInet()
This commit is contained in:
parent
0fd6f83766
commit
7f439b01a3
@ -1,8 +1,7 @@
|
|||||||
// SPDX-License-Identifier: BSD-2-Clause
|
// SPDX-License-Identifier: BSD-2-Clause
|
||||||
// author: Max Kellermann <max.kellermann@gmail.com>
|
// author: Max Kellermann <max.kellermann@gmail.com>
|
||||||
|
|
||||||
#ifndef ALLOCATED_SOCKET_ADDRESS_HXX
|
#pragma once
|
||||||
#define ALLOCATED_SOCKET_ADDRESS_HXX
|
|
||||||
|
|
||||||
#include "SocketAddress.hxx" // IWYU pragma: export
|
#include "SocketAddress.hxx" // IWYU pragma: export
|
||||||
#include "Features.hxx"
|
#include "Features.hxx"
|
||||||
@ -117,6 +116,10 @@ public:
|
|||||||
size = 0;
|
size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsInet() const noexcept {
|
||||||
|
return GetFamily() == AF_INET || GetFamily() == AF_INET6;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_UN
|
#ifdef HAVE_UN
|
||||||
/**
|
/**
|
||||||
* @see SocketAddress::GetLocalRaw()
|
* @see SocketAddress::GetLocalRaw()
|
||||||
@ -191,5 +194,3 @@ public:
|
|||||||
private:
|
private:
|
||||||
void SetSize(size_type new_size) noexcept;
|
void SetSize(size_type new_size) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
// SPDX-License-Identifier: BSD-2-Clause
|
// SPDX-License-Identifier: BSD-2-Clause
|
||||||
// author: Max Kellermann <max.kellermann@gmail.com>
|
// author: Max Kellermann <max.kellermann@gmail.com>
|
||||||
|
|
||||||
#ifndef SOCKET_ADDRESS_HXX
|
#pragma once
|
||||||
#define SOCKET_ADDRESS_HXX
|
|
||||||
|
|
||||||
#include "Features.hxx"
|
#include "Features.hxx"
|
||||||
|
|
||||||
@ -95,6 +94,10 @@ public:
|
|||||||
return GetFamily() != AF_UNSPEC;
|
return GetFamily() != AF_UNSPEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr bool IsInet() const noexcept {
|
||||||
|
return GetFamily() == AF_INET || GetFamily() == AF_INET6;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_UN
|
#ifdef HAVE_UN
|
||||||
/**
|
/**
|
||||||
* Extract the local socket path (which may begin with a null
|
* Extract the local socket path (which may begin with a null
|
||||||
@ -135,10 +138,8 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Does the address family support port numbers?
|
* Does the address family support port numbers?
|
||||||
*/
|
*/
|
||||||
[[gnu::pure]]
|
constexpr bool HasPort() const noexcept {
|
||||||
bool HasPort() const noexcept {
|
return !IsNull() && IsInet();
|
||||||
return !IsNull() &&
|
|
||||||
(GetFamily() == AF_INET || GetFamily() == AF_INET6);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -173,5 +174,3 @@ public:
|
|||||||
return !(*this == other);
|
return !(*this == other);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -91,6 +91,10 @@ public:
|
|||||||
address.ss_family = AF_UNSPEC;
|
address.ss_family = AF_UNSPEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr bool IsInet() const noexcept {
|
||||||
|
return GetFamily() == AF_INET || GetFamily() == AF_INET6;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_UN
|
#ifdef HAVE_UN
|
||||||
/**
|
/**
|
||||||
* @see SocketAddress::GetLocalRaw()
|
* @see SocketAddress::GetLocalRaw()
|
||||||
|
Loading…
Reference in New Issue
Block a user