UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
net_udp.h
Go to the documentation of this file.
1/*
2 * FILE: rtp/net_udp.h
3 * AUTHORS: Colin Perkins
4 *
5 * Copyright (c) 1998-2000 University College London
6 * Copyright (c) 2005-2021 CESNET, z. s. p. o.
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 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the Computer Science
20 * Department at University College London
21 * 4. Neither the name of the University nor of the Department may be used
22 * to endorse or promote products derived from this software without
23 * specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * $Revision: 1.1 $
37 * $Date: 2007/11/08 09:48:59 $
38 */
39
40#ifndef _NET_UDP
41#define _NET_UDP
42
43#ifdef HAVE_CONFIG_H
44#include "config.h"
45#include "config_unix.h"
46#include "config_win32.h"
47#endif // HAVE_CONFIG_H
48
49#ifndef __cplusplus
50#include <stdbool.h>
51#endif
52
53typedef struct _socket_udp socket_udp;
54struct socket_udp_local;
55
56#if defined(__cplusplus)
57extern "C" {
58#endif
59
60int resolve_addrinfo(const char *addr, uint16_t tx_port,
61 struct sockaddr_storage *dst, socklen_t *len, int *mode);
62
63bool udp_addr_valid(const char *addr);
64socket_udp *udp_init(const char *addr, uint16_t rx_port, uint16_t tx_port, int ttl, int force_ip_version, bool multithreaded);
65socket_udp *udp_init_if(const char *addr, const char *iface, uint16_t rx_port, uint16_t tx_port, int ttl, int force_ip_version, bool multithreaded);
66void udp_exit(socket_udp *s);
67
68int udp_peek(socket_udp *s, char *buffer, int buflen);
69int udp_recv(socket_udp *s, char *buffer, int buflen);
70int udp_recv_timeout(socket_udp *s, char *buffer, int buflen, struct timeval *timeout);
71int udp_recvfrom_timeout(socket_udp *s, char *buffer, int buflen,
72 struct timeval *timeout,
73 struct sockaddr *src_addr, socklen_t *addrlen);
74int udp_recvfrom(socket_udp *s, char *buffer, int buflen, struct sockaddr *src_addr, socklen_t *addrlen);
75int udp_send(socket_udp *s, char *buffer, int buflen);
76int udp_sendto(socket_udp *s, char *buffer, int buflen, struct sockaddr *dst_addr, socklen_t addrlen);
77
78int udp_recvv(socket_udp *s, struct msghdr *m);
79void udp_async_start(socket_udp *s, int nr_packets);
81#ifdef _WIN32
82int udp_sendv(socket_udp *s, LPWSABUF vector, int count, void *d);
83#else
84int udp_sendv(socket_udp *s, struct iovec *vector, int count, void *d);
85#endif
86
88int udp_fd(socket_udp *s);
89
90int udp_select(struct timeval *timeout);
91void udp_fd_zero(void);
92void udp_fd_set(socket_udp *s);
94
96bool udp_set_recv_buf(socket_udp *s, int size);
97bool udp_set_send_buf(socket_udp *s, int size);
99
100struct udp_fd_r {
101 fd_set rfd;
103};
104
105int udp_select_r(struct timeval *timeout, struct udp_fd_r *);
106void udp_fd_zero_r(struct udp_fd_r *);
107void udp_fd_set_r(socket_udp *s, struct udp_fd_r *);
108int udp_fd_isset_r(socket_udp *s, struct udp_fd_r *);
109
110int udp_recv_data(socket_udp * s, char **buffer);
111int udp_recvfrom_data(socket_udp * s, char **buffer,
112 struct sockaddr *src_addr, socklen_t *addrlen);
113bool udp_not_empty(socket_udp *s, struct timeval *timeout);
114int udp_port_pair_is_free(int force_ip_version, int even_port);
115bool udp_is_ipv6(socket_udp *s);
116
117void socket_error(const char *msg, ...);
118
119#ifdef _WIN32
120int udp_send_wsa_async(socket_udp *s, char *buffer, int buflen, LPWSAOVERLAPPED_COMPLETION_ROUTINE, LPWSAOVERLAPPED);
121int udp_sendto_wsa_async(socket_udp *s, char *buffer, int buflen, LPWSAOVERLAPPED_COMPLETION_ROUTINE l, LPWSAOVERLAPPED o, struct sockaddr *addr, socklen_t addrlen);
122#endif
123
126socket_udp *udp_init_with_local(struct socket_udp_local *l, struct sockaddr *sa, socklen_t len);
127void udp_set_receiver(socket_udp *s, struct sockaddr *sa, socklen_t len);
129
130/*************************************************************************************************/
131#if defined(__cplusplus)
132}
133#endif
134
135#endif
136
int void size_t * len
int fd_t
int count
Definition hd-rum.c:44
bool udp_addr_valid(const char *addr)
Definition net_udp.c:664
void udp_set_receiver(socket_udp *s, struct sockaddr *sa, socklen_t len)
Definition net_udp.c:922
void udp_exit(socket_udp *s)
Definition net_udp.c:974
int udp_recvfrom(socket_udp *s, char *buffer, int buflen, struct sockaddr *src_addr, socklen_t *addrlen)
Definition net_udp.c:1245
int udp_recv(socket_udp *s, char *buffer, int buflen)
Definition net_udp.c:1236
int udp_get_udp_rx_port(socket_udp *s)
Definition net_udp.c:1756
int udp_fd_isset_r(socket_udp *s, struct udp_fd_r *)
Definition net_udp.c:1336
struct socket_udp_local * udp_get_local(socket_udp *s)
Definition net_udp.c:1751
int udp_recv_data(socket_udp *s, char **buffer)
Definition net_udp.c:1281
int udp_recvfrom_timeout(socket_udp *s, char *buffer, int buflen, struct timeval *timeout, struct sockaddr *src_addr, socklen_t *addrlen)
Definition net_udp.c:1715
void udp_async_start(socket_udp *s, int nr_packets)
Definition net_udp.c:1530
void udp_async_wait(socket_udp *s)
Definition net_udp.c:1557
int udp_recvfrom_data(socket_udp *s, char **buffer, struct sockaddr *src_addr, socklen_t *addrlen)
Definition net_udp.c:1257
socket_udp * udp_init(const char *addr, uint16_t rx_port, uint16_t tx_port, int ttl, int force_ip_version, bool multithreaded)
Definition net_udp.c:681
char * udp_host_addr(socket_udp *s)
Definition net_udp.c:1367
int udp_peek(socket_udp *s, char *buffer, int buflen)
Definition net_udp.c:1185
int udp_sendto(socket_udp *s, char *buffer, int buflen, struct sockaddr *dst_addr, socklen_t addrlen)
Definition net_udp.c:1038
int udp_sendv(socket_udp *s, struct iovec *vector, int count, void *d)
Definition net_udp.c:1067
socket_udp * udp_init_with_local(struct socket_udp_local *l, struct sockaddr *sa, socklen_t len)
Definition net_udp.c:927
int udp_select_r(struct timeval *timeout, struct udp_fd_r *)
Definition net_udp.c:1355
bool udp_set_recv_buf(socket_udp *s, int size)
Definition net_udp.c:1486
bool udp_not_empty(socket_udp *s, struct timeval *timeout)
Checks whether there are data ready to read in socket.
Definition net_udp.c:1197
int udp_send(socket_udp *s, char *buffer, int buflen)
Definition net_udp.c:1028
int udp_recvv(socket_udp *s, struct msghdr *m)
Definition net_udp.c:1286
void udp_fd_set(socket_udp *s)
Definition net_udp.c:1304
int udp_fd_isset(socket_udp *s)
Definition net_udp.c:1331
bool udp_set_send_buf(socket_udp *s, int size)
Definition net_udp.c:1492
void udp_fd_zero_r(struct udp_fd_r *)
Definition net_udp.c:961
int udp_port_pair_is_free(int force_ip_version, int even_port)
Definition net_udp.c:1608
int udp_get_recv_buf(socket_udp *s)
Definition net_udp.c:1445
bool udp_is_ipv6(socket_udp *s)
Definition net_udp.c:1598
void udp_flush_recv_buf(socket_udp *s)
Definition net_udp.c:1500
void udp_fd_set_r(socket_udp *s, struct udp_fd_r *)
Definition net_udp.c:1312
socket_udp * udp_init_if(const char *addr, const char *iface, uint16_t rx_port, uint16_t tx_port, int ttl, int force_ip_version, bool multithreaded)
Definition net_udp.c:789
int resolve_addrinfo(const char *addr, uint16_t tx_port, struct sockaddr_storage *dst, socklen_t *len, int *mode)
Definition net_udp.c:1397
int udp_fd(socket_udp *s)
Definition net_udp.c:1389
bool udp_is_server_mode_blackhole(socket_udp *s)
Definition net_udp.c:911
int udp_recv_timeout(socket_udp *s, char *buffer, int buflen, struct timeval *timeout)
Definition net_udp.c:1746
void udp_fd_zero(void)
Definition net_udp.c:955
int udp_select(struct timeval *timeout)
Definition net_udp.c:1350
enum openssl_mode mode
#define socket_error(...)
fd_t max_fd
Definition net_udp.h:102
fd_set rfd
Definition net_udp.h:101