UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
net.h
Go to the documentation of this file.
1
5/*
6 * Copyright (c) 2016-2024 CESNET
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, is permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * 3. Neither the name of CESNET nor the names of its contributors may be
21 * used to endorse or promote products derived from this software without
22 * specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
26 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
27 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
28 * EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
29 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
35 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#ifndef UTILS_NET_H_
39#define UTILS_NET_H_
40
41#ifdef __cplusplus
42#include <cstddef>
43#include <cstdint>
44#else
45#include <stdbool.h>
46#include <stddef.h>
47#include <stdint.h>
48#endif // __cplusplus
49
50#define IN6_MAX_ASCII_LEN 39 // 32 nibbles + 7 colons
51// RFC 6666 prefix 100::/64, suffix 'UltrGrS'
52#define IN6_BLACKHOLE_SERVER_MODE_STR "100::556C:7472:4772:6453"
53
54#ifdef __cplusplus
55extern "C" {
56#endif
57
58struct sockaddr;
59struct sockaddr_storage;
60bool is_addr_linklocal(struct sockaddr *sa);
61bool is_addr_loopback(struct sockaddr *sa);
62bool is_addr_private(struct sockaddr *sa);
63bool is_addr_multicast(const char *addr);
64bool is_host_loopback(const char *hostname);
65bool is_host_private(const char *hostname);
66uint16_t socket_get_recv_port(int fd);
67bool get_local_addresses(struct sockaddr_storage *addrs, size_t *len, int ip_version);
68bool is_ipv6_supported(void);
69void get_sockaddr_addr_str(struct sockaddr *sa, char *buf, size_t n);
70unsigned get_sockaddr_addr_port(struct sockaddr *sa);
71const char *get_sockaddr_str(struct sockaddr *sa);
72const char *ug_gai_strerror(int errcode);
73
74#ifdef _WIN32
75#define CLOSESOCKET closesocket
76#else
77#define CLOSESOCKET close
78#endif
79
80#ifdef __cplusplus
81}
82#endif
83
84#endif// UTILS_NET_H_
85
int void size_t * len
unsigned get_sockaddr_addr_port(struct sockaddr *sa)
Definition net.c:414
void get_sockaddr_addr_str(struct sockaddr *sa, char *buf, size_t n)
Definition net.c:427
bool is_addr_multicast(const char *addr)
Definition net.c:382
const char * get_sockaddr_str(struct sockaddr *sa)
Definition net.c:450
bool is_addr_private(struct sockaddr *sa)
Definition net.c:139
bool is_addr_linklocal(struct sockaddr *sa)
Definition net.c:79
bool is_host_private(const char *hostname)
Definition net.c:187
bool get_local_addresses(struct sockaddr_storage *addrs, size_t *len, int ip_version)
Definition net.c:229
bool is_addr_loopback(struct sockaddr *sa)
Definition net.c:108
uint16_t socket_get_recv_port(int fd)
Definition net.c:200
bool is_host_loopback(const char *hostname)
Definition net.c:174
const char * ug_gai_strerror(int errcode)
Definition net.c:466
bool is_ipv6_supported(void)
Definition net.c:402