![]() |
UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
|
#include <arpa/inet.h>#include <ifaddrs.h>#include <netdb.h>#include <netinet/ip.h>#include <sys/socket.h>#include <sys/types.h>#include <unistd.h>#include <assert.h>#include <ctype.h>#include <errno.h>#include <limits.h>#include <stdint.h>#include <stdlib.h>#include <string.h>#include "utils/net.h"#include "utils/windows.h"#include "debug.h"
Go to the source code of this file.
Macros | |
| #define | closesocket close |
| #define | IN_LOOPBACKNET 127 |
| #define | INVALID_SOCKET (-1) |
| #define | IPV4_LL_PREFIX ((169u<<8u) | 254u) |
| #define | MOD_NAME "[utils/net] " |
Functions | |
| bool | get_local_addresses (struct sockaddr_storage *addrs, size_t *len, int ip_version) |
| unsigned | get_sockaddr_addr_port (struct sockaddr *sa) |
| void | get_sockaddr_addr_str (struct sockaddr *sa, char *buf, size_t n) |
| const char * | get_sockaddr_str (struct sockaddr *sa) |
| static bool | is_addr4 (const char *addr) |
| static bool | is_addr6 (const char *addr) |
| bool | is_addr_linklocal (struct sockaddr *sa) |
| bool | is_addr_loopback (struct sockaddr *sa) |
| bool | is_addr_multicast (const char *addr) |
| bool | is_addr_private (struct sockaddr *sa) |
| bool | is_host_loopback (const char *hostname) |
| bool | is_host_private (const char *hostname) |
| bool | is_ipv6_supported (void) |
| static struct addrinfo * | resolve_host (const char *hostname, const char *err_prefix) |
| uint16_t | socket_get_recv_port (int fd) |
| const char * | ug_gai_strerror (int errcode) |
Definition in file net.c.
| #define closesocket close |
Definition at line 52 of file net.c.
Referenced by is_ipv6_supported().
| #define IN_LOOPBACKNET 127 |
Definition at line 74 of file net.c.
Referenced by is_addr_loopback().
| #define INVALID_SOCKET (-1) |
Definition at line 53 of file net.c.
Referenced by is_ipv6_supported().
| #define IPV4_LL_PREFIX ((169u<<8u) | 254u) |
Definition at line 70 of file net.c.
Referenced by is_addr_linklocal().
| bool get_local_addresses | ( | struct sockaddr_storage * | addrs, |
| size_t * | len, | ||
| int | ip_version ) |
Returns (in output parameter) list of local public IP addresses
Code was taken perhaps from: https://social.msdn.microsoft.com/Forums/en-US/3b6a92ac-93d3-4f59-a914-340c1ba41cff/how-to-retrieve-ip-addresses-of-the-network-cards-with-getadaptersaddresses
| [out] | addrs | storage allocate to copy the addresses |
| [in] | len | length of allocated space (in bytes) |
| [out] | len | length of returned addresses (in parameter addrs, in bytes) |
| ip_version | 6 for IPv6, 4 for IPv6, 0 both |
Definition at line 229 of file net.c.
References len, LOG_LEVEL_ERROR, log_msg(), and MSG.
Referenced by new_sdp().

| unsigned get_sockaddr_addr_port | ( | struct sockaddr * | sa | ) |
Definition at line 414 of file net.c.
Referenced by get_sockaddr_str(), and Participant_manager::tick().
| void get_sockaddr_addr_str | ( | struct sockaddr * | sa, |
| char * | buf, | ||
| size_t | n ) |
Definition at line 427 of file net.c.
References IN6_MAX_ASCII_LEN.
Referenced by get_sockaddr_str(), and Participant_manager::tick().
| const char * get_sockaddr_str | ( | struct sockaddr * | sa | ) |
Definition at line 450 of file net.c.
References get_sockaddr_addr_port(), get_sockaddr_addr_str(), and IN6_MAX_ASCII_LEN.
Referenced by rtp_process_data(), and Participant_manager::tick().

|
static |
Checks if the address is a dot-separated numeric IPv4 address.
Definition at line 353 of file net.c.
Referenced by is_addr_multicast().
|
static |
Checks if the address is a colon-separated numeric IPv6 address (with optional zone index).
Definition at line 368 of file net.c.
Referenced by is_addr_multicast().
| bool is_addr_linklocal | ( | struct sockaddr * | sa | ) |
Definition at line 79 of file net.c.
References IPV4_LL_PREFIX.
Referenced by new_sdp().
| bool is_addr_loopback | ( | struct sockaddr * | sa | ) |
Definition at line 108 of file net.c.
References IN_LOOPBACKNET.
Referenced by control_thread(), is_host_loopback(), is_host_private(), and new_sdp().
| bool is_addr_multicast | ( | const char * | addr | ) |
Definition at line 382 of file net.c.
References is_addr4(), and is_addr6().
Referenced by udp_init_if().

| bool is_addr_private | ( | struct sockaddr * | sa | ) |
Definition at line 139 of file net.c.
Referenced by start_nat_traverse().
| bool is_host_loopback | ( | const char * | hostname | ) |
Definition at line 174 of file net.c.
References is_addr_loopback(), and resolve_host().
Referenced by adjust_params(), rtp_init_if(), start_nat_traverse(), and udp_init_if().

| bool is_host_private | ( | const char * | hostname | ) |
Definition at line 187 of file net.c.
References is_addr_loopback(), and resolve_host().
Referenced by start_nat_traverse().

| bool is_ipv6_supported | ( | void | ) |
Definition at line 402 of file net.c.
References closesocket, and INVALID_SOCKET.
Referenced by adjust_params().
|
static |
Definition at line 160 of file net.c.
References error_msg, and ug_gai_strerror().
Referenced by is_host_loopback(), and is_host_private().

| uint16_t socket_get_recv_port | ( | int | fd | ) |
Definition at line 200 of file net.c.
References len.
Referenced by control_start(), and process_messages().
| const char * ug_gai_strerror | ( | int | errcode | ) |
Definition at line 466 of file net.c.
References UNUSED.
Referenced by resolve_addrinfo(), resolve_host(), udp_host_addr6(), and udp_init_if().