summaryrefslogtreecommitdiff
path: root/libavformat/network.h
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2010-10-07 07:54:52 +0000
committerMartin Storsjö <martin@martin.st>2010-10-07 07:54:52 +0000
commit7ac57fa5eb117d43f95be80acd9df310eecc6d07 (patch)
tree7aa04f1da6551fcef4b851ffbad0845d01535170 /libavformat/network.h
parentf63630cdf3f79805c67e98c70177c10f9822b561 (diff)
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/network.h')
-rw-r--r--libavformat/network.h14
1 files changed, 14 insertions, 0 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 */