TrinityCore
IpNetwork.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef IpNetwork_h__
19#define IpNetwork_h__
20
21#include "AsioHacksFwd.h"
22#include "Define.h"
23#include "Optional.h"
24#include <span>
25
26namespace Trinity::Net
27{
28TC_COMMON_API bool IsInLocalNetwork(boost::asio::ip::address const& clientAddress);
29
30TC_COMMON_API bool IsInNetwork(boost::asio::ip::network_v4 const& network, boost::asio::ip::address_v4 const& clientAddress);
31
32TC_COMMON_API bool IsInNetwork(boost::asio::ip::network_v6 const& network, boost::asio::ip::address_v6 const& clientAddress);
33
34TC_COMMON_API Optional<std::size_t> SelectAddressForClient(boost::asio::ip::address const& clientAddress, std::span<boost::asio::ip::address const> const& addresses);
35
37}
38
39#endif // IpNetwork_h__
#define TC_COMMON_API
Definition: Define.h:99
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:25
bool IsInNetwork(boost::asio::ip::network_v4 const &network, boost::asio::ip::address_v4 const &clientAddress)
Definition: IpNetwork.cpp:53
bool IsInLocalNetwork(boost::asio::ip::address const &clientAddress)
Definition: IpNetwork.cpp:32
Optional< std::size_t > SelectAddressForClient(boost::asio::ip::address const &clientAddress, std::span< boost::asio::ip::address const > const &addresses)
Definition: IpNetwork.cpp:71
TC_COMMON_API void ScanLocalNetworks()
Definition: IpNetwork.cpp:149