.. _program_listing_file_liberate_net_network.h: Program Listing for File network.h ================================== |exhale_lsh| :ref:`Return to documentation for file ` (``liberate/net/network.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp /* * This file is part of liberate. * * Author(s): Jens Finkhaeuser * * Copyright (c) 2014 Unwesen Ltd. * Copyright (c) 2015-2021 Jens Finkhaeuser. * Copyright (c) 2022 Interpeer gUG (haftungsbeschränkt) * * SPDX-License-Identifier: GPL-3.0-only * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef LIBERATE_NET_NETWORK_H #define LIBERATE_NET_NETWORK_H // *** Config #include // *** C++ includes #include #include #include // *** Own includes #include #include #include namespace liberate::net { /***************************************************************************** * Forward declarations **/ class socket_address; /***************************************************************************** * Network **/ class LIBERATE_API network : public ::liberate::cpp::comparison_operators { public: explicit network(std::string const & netspec); virtual ~network(); network(network const & other); network & operator=(network const & other); void reset(std::string const & netspec); static bool verify_netspec(std::string const & netspec); size_t mask_size() const; uint64_t max_size() const; address_type family() const; bool in_network(socket_address const & address) const; socket_address local_address() const; socket_address network_address() const; socket_address gateway_address() const; socket_address broadcast_address() const; std::string netspec() const; socket_address reserve_address(); socket_address mapped_address(std::string const & identifier) const; socket_address mapped_address(void const * identifier, size_t const & length); socket_address reserve_address(std::string const & identifier); socket_address reserve_address(void const * identifier, size_t const & length); bool reserve_address(socket_address const & addr); bool release_address(socket_address const & addr); bool is_reserved(std::string const & identifier) const; bool is_reserved(void const * identifier, size_t const & length) const; bool is_reserved(socket_address const & addr) const; protected: friend struct liberate::cpp::comparison_operators; virtual bool is_equal_to(network const & other) const; virtual bool is_less_than(network const & other) const; private: // Pointer to implementation struct network_impl; std::unique_ptr m_impl; // Creates a version of the given input address with the netmask applied. socket_address make_masked(socket_address const & input) const; friend LIBERATE_API_FRIEND std::ostream & operator<<(std::ostream & os, network const & net); }; LIBERATE_API std::ostream & operator<<(std::ostream & os, network const & net); } // namespace liberate::net #endif // guard