1 /*
2 * IP common code
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with FFmpeg; if not, write to the Free Software * Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include <string.h>
25
28 {
29 if (
a->ss_family !=
b->ss_family)
30 return 1;
31 if (
a->ss_family == AF_INET) {
32 return (((
const struct sockaddr_in *)
a)->sin_addr.s_addr !=
33 ((
const struct sockaddr_in *)
b)->sin_addr.s_addr);
34 }
35
36 #if HAVE_STRUCT_SOCKADDR_IN6
37 if (
a->ss_family == AF_INET6) {
38 const uint8_t *s6_addr_a = ((
const struct sockaddr_in6 *)
a)->sin6_addr.s6_addr;
39 const uint8_t *s6_addr_b = ((
const struct sockaddr_in6 *)
b)->sin6_addr.s6_addr;
40 return memcmp(s6_addr_a, s6_addr_b, 16);
41 }
42 #endif
43 return 1;
44 }
45
47 {
49 if (
s->nb_exclude_addrs) {
50 for (
i = 0;
i <
s->nb_exclude_addrs;
i++) {
52 return 1;
53 }
54 }
55 if (
s->nb_include_addrs) {
56 for (
i = 0;
i <
s->nb_include_addrs;
i++) {
58 return 0;
59 }
60 return 1;
61 }
62 return 0;
63 }
64
66 const char *hostname, int port,
68 {
69 struct addrinfo hints = { 0 }, *res = 0;
71 char sport[16];
72 const char *node = 0, *service = "0";
73
74 if (port > 0) {
75 snprintf(sport,
sizeof(sport),
"%d", port);
76 service = sport;
77 }
78 if ((hostname) && (hostname[0] != '0円') && (hostname[0] != '?')) {
79 node = hostname;
80 }
87 node ? node : "unknown",
88 service,
90 }
91
92 return res;
93 }
94
95
98 int *address_list_size_ptr)
99 {
101
102 /* Resolve all of the IPs */
103
104 while (buf && buf[0]) {
106 if (!host)
108
111
112 if (ai) {
116 av_dynarray2_add((
void **)address_list_ptr, address_list_size_ptr,
sizeof(source_addr), (uint8_t *)&source_addr);
117 if (!*address_list_ptr)
119 } else {
121 }
122
123 if (*buf)
124 buf++;
125 }
126
127 return 0;
128 }
129
131 {
133 if (parse_include_list)
135 else
137
139 av_log(log_ctx,
AV_LOG_ERROR,
"Simultaneously including and excluding sources is not supported.\n");
141 }
143 }
144
146 {
148 }
149
151 {
153 }
154
156 {
161 }