Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-1.1
Commits
2b9c222b
Commit
2b9c222b
authored
Nov 05, 2006
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add net_SockAddrIsMulticast
parent
790ca220
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
30 deletions
+46
-30
include/network.h
include/network.h
+46
-30
No files found.
include/network.h
View file @
2b9c222b
...
@@ -237,47 +237,63 @@ VLC_EXPORT( int, vlc_getnameinfo, ( const struct sockaddr *, int, char *, int, i
...
@@ -237,47 +237,63 @@ VLC_EXPORT( int, vlc_getnameinfo, ( const struct sockaddr *, int, char *, int, i
VLC_EXPORT
(
int
,
vlc_getaddrinfo
,
(
vlc_object_t
*
,
const
char
*
,
int
,
const
struct
addrinfo
*
,
struct
addrinfo
**
)
);
VLC_EXPORT
(
int
,
vlc_getaddrinfo
,
(
vlc_object_t
*
,
const
char
*
,
int
,
const
struct
addrinfo
*
,
struct
addrinfo
**
)
);
VLC_EXPORT
(
void
,
vlc_freeaddrinfo
,
(
struct
addrinfo
*
)
);
VLC_EXPORT
(
void
,
vlc_freeaddrinfo
,
(
struct
addrinfo
*
)
);
/*****************************************************************************
* net_AddressIsMulticast: This function returns VLC_FALSE if the psz_addr does
* not specify a multicast address or if the address is not a valid address.
*****************************************************************************/
static
inline
vlc_bool_t
net_AddressIsMulticast
(
vlc_object_t
*
p_object
,
const
char
*
psz_addr
)
{
struct
addrinfo
hints
,
*
res
;
vlc_bool_t
b_multicast
=
VLC_FALSE
;
int
i
;
memset
(
&
hints
,
0
,
sizeof
(
hints
)
);
hints
.
ai_socktype
=
SOCK_DGRAM
;
/* UDP */
hints
.
ai_flags
=
AI_NUMERICHOST
;
i
=
vlc_getaddrinfo
(
p_object
,
psz_addr
,
0
,
static
inline
vlc_bool_t
&
hints
,
&
res
);
net_SockAddrIsMulticast
(
const
struct
sockaddr
*
addr
,
socklen_t
len
)
if
(
i
)
{
switch
(
addr
->
sa_family
)
{
{
msg_Err
(
p_object
,
"invalid address for net_AddressIsMulticast: %s : %s"
,
#ifdef IN_MULTICAST
psz_addr
,
vlc_gai_strerror
(
i
)
);
case
AF_INET
:
{
struct
sockaddr_in
*
v4
=
(
struct
sockaddr_in
*
)
addr
;
if
(
len
<
sizeof
(
*
v4
))
return
VLC_FALSE
;
return
VLC_FALSE
;
return
IN_MULTICAST
(
v4
->
sin_addr
.
s_addr
)
!=
0
;
}
}
#endif
if
(
res
->
ai_family
==
AF_INET
)
#ifdef IN6_IS_ADDR_MULTICAST
case
AF_INET6
:
{
{
#if !defined( SYS_BEOS )
struct
sockaddr_in6
*
v6
=
(
struct
sockaddr_in6
*
)
addr
;
struct
sockaddr_in
*
v4
=
(
struct
sockaddr_in
*
)
res
->
ai_addr
;
if
(
len
<
sizeof
(
*
v6
))
b_multicast
=
(
ntohl
(
v4
->
sin_addr
.
s_addr
)
>=
0xe0000000
)
return
VLC_FALSE
;
&&
(
ntohl
(
v4
->
sin_addr
.
s_addr
)
<=
0xefffffff
);
return
IN6_IS_ADDR_MULTICAST
(
&
v6
->
sin6_addr
)
!=
0
;
}
#endif
#endif
}
}
#if defined( WIN32 ) || defined( HAVE_GETADDRINFO )
else
if
(
res
->
ai_family
==
AF_INET6
)
return
VLC_FALSE
;
}
/**
* net_AddressIsMulticast
* @return VLC_FALSE iff the psz_addr does not specify a multicast address,
* or the address is not a valid address.
*/
static
inline
vlc_bool_t
net_AddressIsMulticast
(
vlc_object_t
*
p_object
,
const
char
*
psz_addr
)
{
struct
addrinfo
hints
,
*
res
;
memset
(
&
hints
,
0
,
sizeof
(
hints
));
hints
.
ai_socktype
=
SOCK_DGRAM
;
/* UDP */
hints
.
ai_flags
=
AI_NUMERICHOST
;
int
i
=
vlc_getaddrinfo
(
p_object
,
psz_addr
,
0
,
&
hints
,
&
res
);
if
(
i
)
{
{
struct
sockaddr_in6
*
v6
=
(
struct
sockaddr_in6
*
)
res
->
ai_addr
;
msg_Err
(
p_object
,
"invalid address
\"
%s
\"
for net_AddressIsMulticast (%s)"
,
b_multicast
=
IN6_IS_ADDR_MULTICAST
(
&
v6
->
sin6_addr
);
psz_addr
,
vlc_gai_strerror
(
i
));
return
VLC_FALSE
;
}
}
#endif
vlc_freeaddrinfo
(
res
);
vlc_bool_t
b
=
net_SockAddrIsMulticast
(
res
->
ai_addr
,
res
->
ai_addrlen
);
return
b_multicast
;
vlc_freeaddrinfo
(
res
);
return
b
;
}
}
static
inline
int
net_GetSockAddress
(
int
fd
,
char
*
address
,
int
*
port
)
static
inline
int
net_GetSockAddress
(
int
fd
,
char
*
address
,
int
*
port
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment