Convert ff_is_multicast_address to take a struct sockaddr parameter

Not all users of this function will have a full struct sockaddr_storage
available, and casting other sockaddrs to sockaddr_storage is wrong,
while any sockaddr can be cast to a base sockaddr.

Originally committed as revision 25388 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Martin Storsjö 2010-10-07 07:58:56 +00:00
parent 7ac57fa5eb
commit 55b6bd1c01
2 changed files with 4 additions and 4 deletions

View File

@ -162,13 +162,13 @@ 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)
static inline int ff_is_multicast_address(struct sockaddr *addr)
{
if (addr->ss_family == AF_INET) {
if (addr->sa_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) {
if (addr->sa_family == AF_INET6) {
return IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6 *)addr)->sin6_addr);
}
#endif

View File

@ -254,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 = ff_is_multicast_address(&s->dest_addr);
s->is_multicast = ff_is_multicast_address((struct sockaddr*) &s->dest_addr);
return 0;
}