Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
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-gpu
Commits
10493879
Commit
10493879
authored
Dec 05, 2005
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement multicast hop limit
parent
8acc19a5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
9 deletions
+75
-9
src/network/udp.c
src/network/udp.c
+75
-9
No files found.
src/network/udp.c
View file @
10493879
...
@@ -42,16 +42,66 @@
...
@@ -42,16 +42,66 @@
#include "network.h"
#include "network.h"
#ifndef INADDR_ANY
#ifdef WIN32
# define INADDR_ANY 0x00000000
# if defined(UNDER_CE)
# undef IP_MULTICAST_TTL
# define IP_MULTICAST_TTL 3
# undef IP_ADD_MEMBERSHIP
# define IP_ADD_MEMBERSHIP 5
# endif
#endif
#endif
#ifndef INADDR_NONE
# define INADDR_NONE 0xFFFFFFFF
#ifndef SOL_IP
# define SOL_IP IPPROTO_IP
#endif
#ifndef SOL_IPV6
# define SOL_IPV6 IPPROTO_IPV6
#endif
#ifndef IPPROTO_IPV6
# define IPPROTO_IPV6 41
#endif
#endif
extern
int
net_Socket
(
vlc_object_t
*
p_this
,
int
i_family
,
int
i_socktype
,
extern
int
net_Socket
(
vlc_object_t
*
p_this
,
int
i_family
,
int
i_socktype
,
int
i_protocol
);
int
i_protocol
);
static
void
net_SetMcastHopLimit
(
int
fd
,
int
family
,
int
hlim
)
{
int
proto
,
cmd
;
/* There is some confusion in the world whether IP_MULTICAST_TTL
* takes a byte or an int as an argument.
* BSD seems to indicate byte so we are going with that and use
* int as a fallback to be safe */
switch
(
family
)
{
case
AF_INET
:
proto
=
SOL_IP
;
cmd
=
IP_MULTICAST_TTL
;
break
;
#ifdef IPV6_MULTICAST_HOPS
case
AF_INET6
:
proto
=
SOL_IPV6
;
cmd
=
IPV6_MULTICAST_HOPS
;
break
;
#endif
default:
return
;
}
if
(
setsockopt
(
fd
,
proto
,
cmd
,
&
hlim
,
sizeof
(
hlim
)
)
<
0
)
{
/* BSD compatibility */
unsigned
char
buf
;
buf
=
(
unsigned
char
)((
hlim
>
255
)
?
255
:
hlim
);
setsockopt
(
fd
,
proto
,
cmd
,
&
buf
,
sizeof
(
buf
)
);
}
}
/*****************************************************************************
/*****************************************************************************
* __net_ConnectUDP:
* __net_ConnectUDP:
*****************************************************************************
*****************************************************************************
...
@@ -59,7 +109,7 @@ extern int net_Socket( vlc_object_t *p_this, int i_family, int i_socktype,
...
@@ -59,7 +109,7 @@ extern int net_Socket( vlc_object_t *p_this, int i_family, int i_socktype,
* hop limit.
* hop limit.
*****************************************************************************/
*****************************************************************************/
int
__net_ConnectUDP
(
vlc_object_t
*
p_this
,
const
char
*
psz_host
,
int
i_port
,
int
__net_ConnectUDP
(
vlc_object_t
*
p_this
,
const
char
*
psz_host
,
int
i_port
,
int
hlim
)
int
i_
hlim
)
{
{
struct
addrinfo
hints
,
*
res
,
*
ptr
;
struct
addrinfo
hints
,
*
res
,
*
ptr
;
int
i_val
,
i_handle
=
-
1
;
int
i_val
,
i_handle
=
-
1
;
...
@@ -68,6 +118,20 @@ int __net_ConnectUDP( vlc_object_t *p_this, const char *psz_host, int i_port,
...
@@ -68,6 +118,20 @@ int __net_ConnectUDP( vlc_object_t *p_this, const char *psz_host, int i_port,
if
(
i_port
==
0
)
if
(
i_port
==
0
)
i_port
=
1234
;
/* historical VLC thing */
i_port
=
1234
;
/* historical VLC thing */
if
(
i_hlim
<
1
)
{
vlc_value_t
val
;
if
(
var_Get
(
p_this
,
"ttl"
,
&
val
)
!=
VLC_SUCCESS
)
{
var_Create
(
p_this
,
"ttl"
,
VLC_VAR_INTEGER
|
VLC_VAR_DOINHERIT
);
var_Get
(
p_this
,
"ttl"
,
&
val
);
}
i_hlim
=
val
.
i_int
;
if
(
i_hlim
<
1
)
i_hlim
=
1
;
}
memset
(
&
hints
,
0
,
sizeof
(
hints
)
);
memset
(
&
hints
,
0
,
sizeof
(
hints
)
);
hints
.
ai_socktype
=
SOCK_DGRAM
;
hints
.
ai_socktype
=
SOCK_DGRAM
;
...
@@ -94,17 +158,19 @@ int __net_ConnectUDP( vlc_object_t *p_this, const char *psz_host, int i_port,
...
@@ -94,17 +158,19 @@ int __net_ConnectUDP( vlc_object_t *p_this, const char *psz_host, int i_port,
{
{
int
i_val
;
int
i_val
;
/* Increase the receive buffer size to 1/2MB (8Mb/s during 1/2s)
to avoid
/* Increase the receive buffer size to 1/2MB (8Mb/s during 1/2s)
*
packet loss caused by scheduling problems */
* to avoid
packet loss caused by scheduling problems */
i_val
=
0x80000
;
i_val
=
0x80000
;
setsockopt
(
i_handle
,
SOL_SOCKET
,
SO_RCVBUF
,
(
void
*
)
&
i_val
,
setsockopt
(
fd
,
SOL_SOCKET
,
SO_RCVBUF
,
(
void
*
)
&
i_val
,
sizeof
(
i_val
)
);
sizeof
(
i_val
)
);
i_val
=
0x80000
;
i_val
=
0x80000
;
setsockopt
(
i_handle
,
SOL_SOCKET
,
SO_SNDBUF
,
(
void
*
)
&
i_val
,
setsockopt
(
fd
,
SOL_SOCKET
,
SO_SNDBUF
,
(
void
*
)
&
i_val
,
sizeof
(
i_val
)
);
sizeof
(
i_val
)
);
}
}
#endif
#endif
net_SetMcastHopLimit
(
i_handle
,
ptr
->
ai_family
,
i_hlim
);
if
(
connect
(
fd
,
ptr
->
ai_addr
,
ptr
->
ai_addrlen
)
==
0
)
if
(
connect
(
fd
,
ptr
->
ai_addr
,
ptr
->
ai_addrlen
)
==
0
)
{
{
/* success */
/* success */
...
...
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