MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / ip_parse_addr_list

Function ip_parse_addr_list

libavformat/ip.c:96–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94
95
96static int ip_parse_addr_list(void *log_ctx, const char *buf,
97 struct sockaddr_storage **address_list_ptr,
98 int *address_list_size_ptr)
99{
100 struct addrinfo *ai = NULL;
101
102 /* Resolve all of the IPs */
103
104 while (buf && buf[0]) {
105 char* host = av_get_token(&buf, ",");
106 if (!host)
107 return AVERROR(ENOMEM);
108
109 ai = ff_ip_resolve_host(log_ctx, host, 0, SOCK_DGRAM, AF_UNSPEC, 0);
110 av_freep(&host);
111
112 if (ai) {
113 struct sockaddr_storage source_addr = {0};
114 memcpy(&source_addr, ai->ai_addr, ai->ai_addrlen);
115 freeaddrinfo(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)
118 return AVERROR(ENOMEM);
119 } else {
120 return AVERROR(EINVAL);
121 }
122
123 if (*buf)
124 buf++;
125 }
126
127 return 0;
128}
129
130static int ip_parse_sources_and_blocks(void *log_ctx, const char *buf, IPSourceFilters *filters, int parse_include_list)
131{

Callers 1

Calls 4

av_get_tokenFunction · 0.85
ff_ip_resolve_hostFunction · 0.85
av_freepFunction · 0.85
av_dynarray2_addFunction · 0.85

Tested by

no test coverage detected