Mercurial > libavformat.hg
changeset 5567:9934ca658946 libavformat
Remove IPv4-only codepath. Patch by Martin Storsj <$first $first st>.
author | rbultje |
---|---|
date | Thu, 21 Jan 2010 15:42:05 +0000 |
parents | 28094e9bd013 |
children | 1cdf9bbfbc7f |
files | udp.c |
diffstat | 1 files changed, 5 insertions(+), 52 deletions(-) [+] |
line wrap: on
line diff
--- a/udp.c Thu Jan 21 09:47:02 2010 +0000 +++ b/udp.c Thu Jan 21 15:42:05 2010 +0000 @@ -52,11 +52,7 @@ int is_multicast; int local_port; int reuse_socket; -#if !CONFIG_IPV6 - struct sockaddr_in dest_addr; -#else struct sockaddr_storage dest_addr; -#endif int dest_addr_len; } UDPContext; @@ -72,7 +68,7 @@ } } #endif -#if CONFIG_IPV6 +#if defined(IPPROTO_IPV6) && defined(IPV6_MULTICAST_HOPS) if (addr->sa_family == AF_INET6) { if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &mcastTTL, sizeof(mcastTTL)) < 0) { av_log(NULL, AV_LOG_ERROR, "setsockopt(IPV6_MULTICAST_HOPS): %s\n", strerror(errno)); @@ -96,7 +92,7 @@ } } #endif -#if CONFIG_IPV6 +#if HAVE_STRUCT_IPV6_MREQ if (addr->sa_family == AF_INET6) { struct ipv6_mreq mreq6; @@ -124,7 +120,7 @@ } } #endif -#if CONFIG_IPV6 +#if HAVE_STRUCT_IPV6_MREQ if (addr->sa_family == AF_INET6) { struct ipv6_mreq mreq6; @@ -139,7 +135,6 @@ return 0; } -#if CONFIG_IPV6 static struct addrinfo* udp_ipv6_resolve_host(const char *hostname, int port, int type, int family, int flags) { struct addrinfo hints, *res = 0; int error; @@ -182,9 +177,11 @@ if (addr->ss_family == AF_INET) { return IN_MULTICAST(ntohl(((struct sockaddr_in *)addr)->sin_addr.s_addr)); } +#if HAVE_STRUCT_SOCKADDR_IN6 if (addr->ss_family == AF_INET6) { return IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6 *)addr)->sin6_addr); } +#endif return 0; } @@ -236,46 +233,6 @@ return strtol(sbuf, NULL, 10); } -#else - -static int udp_set_url(struct sockaddr_in *addr, const char *hostname, int port) -{ - /* set the destination address */ - if (resolve_host(&addr->sin_addr, hostname) < 0) - return AVERROR(EIO); - addr->sin_family = AF_INET; - addr->sin_port = htons(port); - - return sizeof(struct sockaddr_in); -} - -static int is_multicast_address(struct sockaddr_in *addr) -{ - return IN_MULTICAST(ntohl(addr->sin_addr.s_addr)); -} - -static int udp_socket_create(UDPContext *s, struct sockaddr_in *addr, int *addr_len) -{ - int fd; - - fd = socket(AF_INET, SOCK_DGRAM, 0); - if (fd < 0) - return -1; - - addr->sin_family = AF_INET; - addr->sin_addr.s_addr = htonl (INADDR_ANY); - addr->sin_port = htons(s->local_port); - *addr_len = sizeof(struct sockaddr_in); - - return fd; -} - -static int udp_port(struct sockaddr_in *addr, int len) -{ - return ntohs(addr->sin_port); -} -#endif /* CONFIG_IPV6 */ - /** * If no filename is given to av_open_input_file because you want to @@ -345,11 +302,7 @@ int is_output; const char *p; char buf[256]; -#if !CONFIG_IPV6 - struct sockaddr_in my_addr; -#else struct sockaddr_storage my_addr; -#endif int len; h->is_streamed = 1;