27 if (
a->ss_family !=
b->ss_family)
29 if (
a->ss_family == AF_INET) {
30 return (((
const struct sockaddr_in *)
a)->sin_addr.s_addr !=
31 ((
const struct sockaddr_in *)
b)->sin_addr.s_addr);
34 #if HAVE_STRUCT_SOCKADDR_IN6
35 if (
a->ss_family == AF_INET6) {
36 const uint8_t *s6_addr_a = ((
const struct sockaddr_in6 *)
a)->sin6_addr.s6_addr;
37 const uint8_t *s6_addr_b = ((
const struct sockaddr_in6 *)
b)->sin6_addr.s6_addr;
38 return memcmp(s6_addr_a, s6_addr_b, 16);
47 if (
s->nb_exclude_addrs) {
48 for (
i = 0;
i <
s->nb_exclude_addrs;
i++) {
53 if (
s->nb_include_addrs) {
54 for (
i = 0;
i <
s->nb_include_addrs;
i++) {
64 const char *hostname,
int port,
67 struct addrinfo hints = { 0 }, *res = 0;
70 const char *node = 0, *service =
"0";
73 snprintf(sport,
sizeof(sport),
"%d", port);
76 if ((hostname) && (hostname[0] !=
'\0') && (hostname[0] !=
'?')) {
85 node ? node :
"unknown",
96 int *address_list_size_ptr)
102 while (buf && buf[0]) {
114 av_dynarray2_add((
void **)address_list_ptr, address_list_size_ptr,
sizeof(source_addr), (
uint8_t *)&source_addr);
115 if (!*address_list_ptr)
131 if (parse_include_list)
136 if (ret >= 0 &&
filters->nb_include_addrs &&
filters->nb_exclude_addrs) {
137 av_log(log_ctx,
AV_LOG_ERROR,
"Simultaneously including and excluding sources is not supported.\n");
#define flags(name, subs,...)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * av_dynarray2_add(void **tab_ptr, int *nb_ptr, size_t elem_size, const uint8_t *elem_data)
Add an element of size elem_size to a dynamic array.
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
int ff_ip_check_source_lists(struct sockaddr_storage *source_addr_ptr, IPSourceFilters *s)
Checks the source address against a given IP source filter.
void ff_ip_reset_filters(IPSourceFilters *filters)
Resets the IP filter list and frees the internal fields of an IPSourceFilters structure.
static int ip_parse_addr_list(void *log_ctx, const char *buf, struct sockaddr_storage **address_list_ptr, int *address_list_size_ptr)
int ff_ip_parse_blocks(void *log_ctx, const char *buf, IPSourceFilters *filters)
Parses the address[,address] source block list in buf and adds it to the filters in the IPSourceFilte...
static int ip_parse_sources_and_blocks(void *log_ctx, const char *buf, IPSourceFilters *filters, int parse_include_list)
struct addrinfo * ff_ip_resolve_host(void *log_ctx, const char *hostname, int port, int type, int family, int flags)
Resolves hostname into an addrinfo structure.
int ff_ip_parse_sources(void *log_ctx, const char *buf, IPSourceFilters *filters)
Parses the address[,address] source list in buf and adds it to the filters in the IPSourceFilters str...
static int compare_addr(const struct sockaddr_storage *a, const struct sockaddr_storage *b)
static const struct PPFilter filters[]
Structure for storing IP (UDP) source filters or block lists.
struct sockaddr * ai_addr
static void error(const char *err)