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
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);
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] !=
'?')) {
82 if ((error =
getaddrinfo(node, service, &hints, &res))) {
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)
137 av_log(log_ctx,
AV_LOG_ERROR,
"Simultaneously including and excluding sources is not supported.\n");
static int compare_addr(const struct sockaddr_storage *a, const struct sockaddr_storage *b)
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...
struct sockaddr_storage * exclude_addrs
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...
struct sockaddr_storage * include_addrs
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void ff_ip_reset_filters(IPSourceFilters *filters)
Resets the IP filter list and frees the internal fields of an IPSourceFilters structure.
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...
static int ip_parse_addr_list(void *log_ctx, const char *buf, struct sockaddr_storage **address_list_ptr, int *address_list_size_ptr)
static void error(const char *err)
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.
int ff_ip_check_source_lists(struct sockaddr_storage *source_addr_ptr, IPSourceFilters *s)
Checks the source address against a given IP source filter.
#define flags(name, subs,...)
static int ip_parse_sources_and_blocks(void *log_ctx, const char *buf, IPSourceFilters *filters, int parse_include_list)
static const struct PPFilter filters[]
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.
struct sockaddr * ai_addr
Structure for storing IP (UDP) source filters or block lists.