diff options
author | Martin Storsjö <martin@martin.st> | 2010-10-07 07:54:52 +0000 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2010-10-07 07:54:52 +0000 |
commit | 7ac57fa5eb117d43f95be80acd9df310eecc6d07 (patch) | |
tree | 7aa04f1da6551fcef4b851ffbad0845d01535170 /libavformat | |
parent | f63630cdf3f79805c67e98c70177c10f9822b561 (diff) | |
download | ffmpeg-7ac57fa5eb117d43f95be80acd9df310eecc6d07.tar.gz |
Share the is_multicast_address function
The header probably isn't the right permanent place for this function, but
it is quite small, and consensus seems to be that it can stay in the
header for now, instead of creating a new file network.c just for this one.
Originally committed as revision 25387 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/network.h | 14 | ||||
-rw-r--r-- | libavformat/udp.c | 16 |
2 files changed, 15 insertions, 15 deletions
diff --git a/libavformat/network.h b/libavformat/network.h index 07112ef7ef..1ad7319649 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -162,4 +162,18 @@ const char *ff_gai_strerror(int ecode); #define IN6_IS_ADDR_MULTICAST(a) (((uint8_t *) (a))[0] == 0xff) #endif +static inline int ff_is_multicast_address(struct sockaddr_storage *addr) +{ + 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; +} + #endif /* AVFORMAT_NETWORK_H */ diff --git a/libavformat/udp.c b/libavformat/udp.c index c1160cf98c..bfb9b77495 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -177,20 +177,6 @@ static int udp_set_url(struct sockaddr_storage *addr, return addr_len; } -static int is_multicast_address(struct sockaddr_storage *addr) -{ - 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; -} - static int udp_socket_create(UDPContext *s, struct sockaddr_storage *addr, int *addr_len) { @@ -268,7 +254,7 @@ int udp_set_remote_url(URLContext *h, const char *uri) if (s->dest_addr_len < 0) { return AVERROR(EIO); } - s->is_multicast = is_multicast_address(&s->dest_addr); + s->is_multicast = ff_is_multicast_address(&s->dest_addr); return 0; } |