|
Hermes 0.7.0
Linux game streaming host
|
Declarations for networking related functions. More...
#include <span>#include <tuple>#include <utility>#include <vector>#include <boost/asio.hpp>#include <enet/enet.h>#include "network_link.h"#include "utility.h"Go to the source code of this file.
Typedefs | |
| using | net::host_t = util::safe_ptr<ENetHost, free_host> |
| using | net::peer_t = ENetPeer * |
| using | net::packet_t = util::safe_ptr<ENetPacket, enet_packet_destroy> |
Enumerations | |
| enum | net::net_e : int { net::PC , net::LAN , net::WAN } |
| enum | net::af_e : int { net::IPV4 , net::BOTH } |
Functions | |
| void | net::free_host (ENetHost *host) |
| std::uint16_t | net::map_port (int port) |
| Map a specified port based on the base port. | |
| net_e | net::from_enum_string (const std::string_view &view) |
| std::string_view | net::to_enum_string (net_e net) |
| net_e | net::from_address (const std::string_view &view) |
| Classify the network an address belongs to. | |
| net_e | net::from_address (const std::string_view &view, std::span< const interface_address_t > links) |
| Classify an address against the given interface subnets. | |
| net_e | net::from_address_ranges (const std::string_view &view) |
| Classify an address by the fixed ranges alone. | |
| std::vector< interface_address_t > | net::interface_addresses () |
| The addresses of every interface that is up, loopback aside, with their prefix lengths. | |
| raw_address_t | net::to_raw_address (const boost::asio::ip::address &address) |
| The raw bytes of an address, IPv4-mapped IPv6 as IPv4, the IPv6 scope kept. | |
| host_t | net::host_create (af_e af, ENetAddress &addr, std::uint16_t port, boost::system::error_code *error_out) |
| bool | net::prevent_socket_inheritance (boost::asio::ip::udp::socket::native_handle_type socket, boost::system::error_code &error) |
| bool | net::udp_port_available (af_e af, std::uint16_t port) |
| Whether a UDP port can still be bound on this host. | |
| af_e | net::af_from_enum_string (const std::string_view &view) |
| Get the address family enum value from a string. | |
| std::string_view | net::af_to_any_address_string (af_e af) |
| Get the wildcard binding address for a given address family. | |
| boost::asio::ip::address | net::normalize_address (boost::asio::ip::address address) |
| Convert an address to a normalized form. | |
| std::string | net::addr_to_normalized_string (boost::asio::ip::address address) |
| Get the given address in normalized string form. | |
| std::string | net::addr_to_url_escaped_string (boost::asio::ip::address address) |
| Get the given address in a normalized form for the host portion of a URL. | |
| int | net::encryption_mode_for_address (boost::asio::ip::address address) |
| Get the encryption mode for the given remote endpoint address. | |
| std::string | net::mdns_instance_name (const std::string_view &hostname) |
| Returns a string for use as the instance name for mDNS. | |
Declarations for networking related functions.
Definition in file network.h.
| using net::packet_t = util::safe_ptr<ENetPacket, enet_packet_destroy> |
| enum net::af_e : int |
| enum net::net_e : int |
| std::string net::addr_to_normalized_string | ( | boost::asio::ip::address | address | ) |
Get the given address in normalized string form.
Normalization converts IPv4-mapped IPv6 addresses into IPv4 addresses.
| address | The address to normalize. |
Definition at line 202 of file network.cpp.
| std::string net::addr_to_url_escaped_string | ( | boost::asio::ip::address | address | ) |
Get the given address in a normalized form for the host portion of a URL.
Normalization converts IPv4-mapped IPv6 addresses into IPv4 addresses.
| address | The address to normalize and escape. |
Definition at line 206 of file network.cpp.
| af_e net::af_from_enum_string | ( | const std::string_view & | view | ) |
Get the address family enum value from a string.
| view | The config option value. |
Definition at line 166 of file network.cpp.
| std::string_view net::af_to_any_address_string | ( | af_e | af | ) |
Get the wildcard binding address for a given address family.
| af | Address family. |
Definition at line 178 of file network.cpp.
| int net::encryption_mode_for_address | ( | boost::asio::ip::address | address | ) |
Get the encryption mode for the given remote endpoint address.
| address | The address used to look up the desired encryption mode. |
Definition at line 217 of file network.cpp.
| void net::free_host | ( | ENetHost * | host | ) |
Definition at line 338 of file network.cpp.
| net_e net::from_address | ( | const std::string_view & | view | ) |
Classify the network an address belongs to.
PC for loopback, LAN for the private, shared and link-local ranges and for any address on a subnet this host is attached to (an IPv6 global address of the home network, for one), WAN otherwise.
| view | The address. |
Definition at line 120 of file network.cpp.
| net_e net::from_address | ( | const std::string_view & | view, |
| std::span< const interface_address_t > | links ) |
Classify an address against the given interface subnets.
from_address() with the subnets passed in instead of read from the host's interfaces.
| view | The address. |
| links | The host's interface addresses and their prefixes. |
Definition at line 112 of file network.cpp.
| net_e net::from_address_ranges | ( | const std::string_view & | view | ) |
Classify an address by the fixed ranges alone.
PC or LAN only for loopback and the private, shared and link-local ranges, whatever this host is attached to. For questions about an address itself, such as whether a router's external address is private.
| view | The address. |
Definition at line 108 of file network.cpp.
| net_e net::from_enum_string | ( | const std::string_view & | view | ) |
Definition at line 46 of file network.cpp.
| host_t net::host_create | ( | af_e | af, |
| ENetAddress & | addr, | ||
| std::uint16_t | port, | ||
| boost::system::error_code * | error_out ) |
Definition at line 226 of file network.cpp.
| std::vector< interface_address_t > net::interface_addresses | ( | ) |
The addresses of every interface that is up, loopback aside, with their prefix lengths.
Definition at line 132 of file network.cpp.
| std::uint16_t net::map_port | ( | int | port | ) |
Map a specified port based on the base port.
| port | The port to map as a difference from the base port. |
Examples
Definition at line 350 of file network.cpp.
| std::string net::mdns_instance_name | ( | const std::string_view & | hostname | ) |
Returns a string for use as the instance name for mDNS.
| hostname | The hostname to use for instance name generation. |
Definition at line 367 of file network.cpp.
| boost::asio::ip::address net::normalize_address | ( | boost::asio::ip::address | address | ) |
Convert an address to a normalized form.
Normalization converts IPv4-mapped IPv6 addresses into IPv4 addresses.
| address | The address to normalize. |
Definition at line 190 of file network.cpp.
| bool net::prevent_socket_inheritance | ( | boost::asio::ip::udp::socket::native_handle_type | socket, |
| boost::system::error_code & | error ) |
Definition at line 306 of file network.cpp.
| std::string_view net::to_enum_string | ( | net_e | net | ) |
Definition at line 152 of file network.cpp.
| raw_address_t net::to_raw_address | ( | const boost::asio::ip::address & | address | ) |
The raw bytes of an address, IPv4-mapped IPv6 as IPv4, the IPv6 scope kept.
| address | The address. |
Definition at line 92 of file network.cpp.
| bool net::udp_port_available | ( | af_e | af, |
| std::uint16_t | port ) |
Whether a UDP port can still be bound on this host.
The streaming ports are only bound when a session starts, so a port another program has taken is invisible until someone tries to play - at which point the stream fails for a reason that is nowhere near where it is felt. This answers the question ahead of time, by doing exactly what the stream will do: bind the wildcard address on the same address family.
Definition at line 316 of file network.cpp.