Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
b0b8f4c4
Commit
b0b8f4c4
authored
Aug 19, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vlc_getaddrinfo: pass AI_NUMERICSERV explicitly where applicable
parent
16d8d7b7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
41 deletions
+39
-41
src/network/getaddrinfo.c
src/network/getaddrinfo.c
+0
-3
src/network/io.c
src/network/io.c
+5
-6
src/network/tcp.c
src/network/tcp.c
+15
-13
src/network/udp.c
src/network/udp.c
+19
-19
No files found.
src/network/getaddrinfo.c
View file @
b0b8f4c4
...
@@ -130,9 +130,6 @@ int vlc_getaddrinfo (const char *node, unsigned port,
...
@@ -130,9 +130,6 @@ int vlc_getaddrinfo (const char *node, unsigned port,
hints
.
ai_flags
=
p_hints
->
ai_flags
&
safe_flags
;
hints
.
ai_flags
=
p_hints
->
ai_flags
&
safe_flags
;
}
}
/* We only ever use port *numbers* */
hints
.
ai_flags
|=
AI_NUMERICSERV
;
/*
/*
* VLC extensions :
* VLC extensions :
* - accept "" as NULL
* - accept "" as NULL
...
...
src/network/io.c
View file @
b0b8f4c4
...
@@ -127,12 +127,11 @@ int net_Socket (vlc_object_t *p_this, int family, int socktype,
...
@@ -127,12 +127,11 @@ int net_Socket (vlc_object_t *p_this, int family, int socktype,
int
*
net_Listen
(
vlc_object_t
*
p_this
,
const
char
*
psz_host
,
int
*
net_Listen
(
vlc_object_t
*
p_this
,
const
char
*
psz_host
,
int
i_port
,
int
type
,
int
protocol
)
int
i_port
,
int
type
,
int
protocol
)
{
{
struct
addrinfo
hints
,
*
res
;
struct
addrinfo
hints
=
{
.
ai_socktype
=
type
,
memset
(
&
hints
,
0
,
sizeof
(
hints
));
.
ai_protocol
=
protocol
,
hints
.
ai_socktype
=
type
;
.
ai_flags
=
AI_PASSIVE
|
AI_NUMERICSERV
,
hints
.
ai_protocol
=
protocol
;
},
*
res
;
hints
.
ai_flags
=
AI_PASSIVE
;
msg_Dbg
(
p_this
,
"net: listening to %s port %d"
,
msg_Dbg
(
p_this
,
"net: listening to %s port %d"
,
(
psz_host
!=
NULL
)
?
psz_host
:
"*"
,
i_port
);
(
psz_host
!=
NULL
)
?
psz_host
:
"*"
,
i_port
);
...
...
src/network/tcp.c
View file @
b0b8f4c4
...
@@ -75,7 +75,6 @@ extern int net_Socket( vlc_object_t *p_this, int i_family, int i_socktype,
...
@@ -75,7 +75,6 @@ extern int net_Socket( vlc_object_t *p_this, int i_family, int i_socktype,
int
net_Connect
(
vlc_object_t
*
p_this
,
const
char
*
psz_host
,
int
i_port
,
int
net_Connect
(
vlc_object_t
*
p_this
,
const
char
*
psz_host
,
int
i_port
,
int
type
,
int
proto
)
int
type
,
int
proto
)
{
{
struct
addrinfo
hints
,
*
res
,
*
ptr
;
const
char
*
psz_realhost
;
const
char
*
psz_realhost
;
char
*
psz_socks
;
char
*
psz_socks
;
int
i_realport
,
i_handle
=
-
1
;
int
i_realport
,
i_handle
=
-
1
;
...
@@ -84,10 +83,6 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
...
@@ -84,10 +83,6 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
if
(
evfd
==
-
1
)
if
(
evfd
==
-
1
)
return
-
1
;
return
-
1
;
memset
(
&
hints
,
0
,
sizeof
(
hints
)
);
hints
.
ai_socktype
=
type
;
hints
.
ai_protocol
=
proto
;
psz_socks
=
var_InheritString
(
p_this
,
"socks"
);
psz_socks
=
var_InheritString
(
p_this
,
"socks"
);
if
(
psz_socks
!=
NULL
)
if
(
psz_socks
!=
NULL
)
{
{
...
@@ -98,7 +93,6 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
...
@@ -98,7 +93,6 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
psz_realhost
=
psz_socks
;
psz_realhost
=
psz_socks
;
i_realport
=
(
psz
!=
NULL
)
?
atoi
(
psz
)
:
1080
;
i_realport
=
(
psz
!=
NULL
)
?
atoi
(
psz
)
:
1080
;
hints
.
ai_flags
&=
~
AI_NUMERICHOST
;
msg_Dbg
(
p_this
,
"net: connecting to %s port %d (SOCKS) "
msg_Dbg
(
p_this
,
"net: connecting to %s port %d (SOCKS) "
"for %s port %d"
,
psz_realhost
,
i_realport
,
"for %s port %d"
,
psz_realhost
,
i_realport
,
...
@@ -137,6 +131,12 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
...
@@ -137,6 +131,12 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
i_realport
);
i_realport
);
}
}
struct
addrinfo
hints
=
{
.
ai_socktype
=
type
,
.
ai_protocol
=
proto
,
.
ai_flags
=
AI_NUMERICSERV
,
},
*
res
;
int
val
=
vlc_getaddrinfo
(
psz_realhost
,
i_realport
,
&
hints
,
&
res
);
int
val
=
vlc_getaddrinfo
(
psz_realhost
,
i_realport
,
&
hints
,
&
res
);
free
(
psz_socks
);
free
(
psz_socks
);
...
@@ -151,7 +151,7 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
...
@@ -151,7 +151,7 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
if
(
timeout
<
0
)
if
(
timeout
<
0
)
timeout
=
-
1
;
timeout
=
-
1
;
for
(
ptr
=
res
;
ptr
!=
NULL
;
ptr
=
ptr
->
ai_next
)
for
(
struct
addrinfo
*
ptr
=
res
;
ptr
!=
NULL
;
ptr
=
ptr
->
ai_next
)
{
{
int
fd
=
net_Socket
(
p_this
,
ptr
->
ai_family
,
int
fd
=
net_Socket
(
p_this
,
ptr
->
ai_family
,
ptr
->
ai_socktype
,
ptr
->
ai_protocol
);
ptr
->
ai_socktype
,
ptr
->
ai_protocol
);
...
@@ -445,13 +445,15 @@ static int SocksHandshakeTCP( vlc_object_t *p_obj,
...
@@ -445,13 +445,15 @@ static int SocksHandshakeTCP( vlc_object_t *p_obj,
if
(
i_socks_version
==
4
)
if
(
i_socks_version
==
4
)
{
{
struct
addrinfo
hints
,
*
res
;
/* v4 only support ipv4 */
/* v4 only support ipv4 */
memset
(
&
hints
,
0
,
sizeof
(
hints
));
static
const
struct
addrinfo
hints
=
{
hints
.
ai_family
=
AF_INET
;
.
ai_family
=
AF_INET
,
hints
.
ai_socktype
=
SOCK_STREAM
;
.
ai_socktype
=
SOCK_STREAM
,
hints
.
ai_protocol
=
IPPROTO_TCP
;
.
ai_protocol
=
IPPROTO_TCP
,
.
ai_flags
=
0
,
};
struct
addrinfo
*
res
;
if
(
vlc_getaddrinfo
(
psz_host
,
0
,
&
hints
,
&
res
))
if
(
vlc_getaddrinfo
(
psz_host
,
0
,
&
hints
,
&
res
))
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
...
...
src/network/udp.c
View file @
b0b8f4c4
...
@@ -94,7 +94,8 @@ extern int net_Socket( vlc_object_t *p_this, int i_family, int i_socktype,
...
@@ -94,7 +94,8 @@ extern int net_Socket( vlc_object_t *p_this, int i_family, int i_socktype,
int
i_protocol
);
int
i_protocol
);
/* */
/* */
static
int
net_SetupDgramSocket
(
vlc_object_t
*
p_obj
,
int
fd
,
const
struct
addrinfo
*
ptr
)
static
int
net_SetupDgramSocket
(
vlc_object_t
*
p_obj
,
int
fd
,
const
struct
addrinfo
*
ptr
)
{
{
#ifdef SO_REUSEPORT
#ifdef SO_REUSEPORT
setsockopt
(
fd
,
SOL_SOCKET
,
SO_REUSEPORT
,
&
(
int
){
1
},
sizeof
(
int
));
setsockopt
(
fd
,
SOL_SOCKET
,
SO_REUSEPORT
,
&
(
int
){
1
},
sizeof
(
int
));
...
@@ -137,12 +138,11 @@ static int net_SetupDgramSocket( vlc_object_t *p_obj, int fd, const struct addri
...
@@ -137,12 +138,11 @@ static int net_SetupDgramSocket( vlc_object_t *p_obj, int fd, const struct addri
static
int
net_ListenSingle
(
vlc_object_t
*
obj
,
const
char
*
host
,
int
port
,
static
int
net_ListenSingle
(
vlc_object_t
*
obj
,
const
char
*
host
,
int
port
,
int
protocol
)
int
protocol
)
{
{
struct
addrinfo
hints
,
*
res
;
struct
addrinfo
hints
=
{
.
ai_socktype
=
SOCK_DGRAM
,
memset
(
&
hints
,
0
,
sizeof
(
hints
));
.
ai_protocol
=
protocol
,
hints
.
ai_socktype
=
SOCK_DGRAM
;
.
ai_flags
=
AI_PASSIVE
|
AI_NUMERICSERV
,
hints
.
ai_protocol
=
protocol
;
},
*
res
;
hints
.
ai_flags
=
AI_PASSIVE
;
if
(
host
&&
!*
host
)
if
(
host
&&
!*
host
)
host
=
NULL
;
host
=
NULL
;
...
@@ -503,17 +503,17 @@ static int net_SetDSCP( int fd, uint8_t dscp )
...
@@ -503,17 +503,17 @@ static int net_SetDSCP( int fd, uint8_t dscp )
int
net_ConnectDgram
(
vlc_object_t
*
p_this
,
const
char
*
psz_host
,
int
i_port
,
int
net_ConnectDgram
(
vlc_object_t
*
p_this
,
const
char
*
psz_host
,
int
i_port
,
int
i_hlim
,
int
proto
)
int
i_hlim
,
int
proto
)
{
{
struct
addrinfo
hints
,
*
res
,
*
ptr
;
struct
addrinfo
hints
=
{
.
ai_socktype
=
SOCK_DGRAM
,
.
ai_protocol
=
proto
,
.
ai_flags
=
AI_NUMERICSERV
,
},
*
res
;
int
i_handle
=
-
1
;
int
i_handle
=
-
1
;
bool
b_unreach
=
false
;
bool
b_unreach
=
false
;
if
(
i_hlim
<
0
)
if
(
i_hlim
<
0
)
i_hlim
=
var_InheritInteger
(
p_this
,
"ttl"
);
i_hlim
=
var_InheritInteger
(
p_this
,
"ttl"
);
memset
(
&
hints
,
0
,
sizeof
(
hints
)
);
hints
.
ai_socktype
=
SOCK_DGRAM
;
hints
.
ai_protocol
=
proto
;
msg_Dbg
(
p_this
,
"net: connecting to [%s]:%d"
,
psz_host
,
i_port
);
msg_Dbg
(
p_this
,
"net: connecting to [%s]:%d"
,
psz_host
,
i_port
);
int
val
=
vlc_getaddrinfo
(
psz_host
,
i_port
,
&
hints
,
&
res
);
int
val
=
vlc_getaddrinfo
(
psz_host
,
i_port
,
&
hints
,
&
res
);
...
@@ -524,7 +524,7 @@ int net_ConnectDgram( vlc_object_t *p_this, const char *psz_host, int i_port,
...
@@ -524,7 +524,7 @@ int net_ConnectDgram( vlc_object_t *p_this, const char *psz_host, int i_port,
return
-
1
;
return
-
1
;
}
}
for
(
ptr
=
res
;
ptr
!=
NULL
;
ptr
=
ptr
->
ai_next
)
for
(
struct
addrinfo
*
ptr
=
res
;
ptr
!=
NULL
;
ptr
=
ptr
->
ai_next
)
{
{
char
*
str
;
char
*
str
;
int
fd
=
net_Socket
(
p_this
,
ptr
->
ai_family
,
ptr
->
ai_socktype
,
int
fd
=
net_Socket
(
p_this
,
ptr
->
ai_family
,
ptr
->
ai_socktype
,
...
@@ -601,11 +601,11 @@ int net_OpenDgram( vlc_object_t *obj, const char *psz_bind, int i_bind,
...
@@ -601,11 +601,11 @@ int net_OpenDgram( vlc_object_t *obj, const char *psz_bind, int i_bind,
msg_Dbg
(
obj
,
"net: connecting to [%s]:%d from [%s]:%d"
,
msg_Dbg
(
obj
,
"net: connecting to [%s]:%d from [%s]:%d"
,
psz_server
,
i_server
,
psz_bind
,
i_bind
);
psz_server
,
i_server
,
psz_bind
,
i_bind
);
struct
addrinfo
hints
,
*
loc
,
*
rem
;
struct
addrinfo
hints
=
{
.
ai_socktype
=
SOCK_DGRAM
,
memset
(
&
hints
,
0
,
sizeof
(
hints
));
.
ai_protocol
=
protocol
,
hints
.
ai_socktype
=
SOCK_DGRAM
;
.
ai_flags
=
AI_NUMERICSERV
,
hints
.
ai_protocol
=
protocol
;
},
*
loc
,
*
rem
;
int
val
=
vlc_getaddrinfo
(
psz_server
,
i_server
,
&
hints
,
&
rem
);
int
val
=
vlc_getaddrinfo
(
psz_server
,
i_server
,
&
hints
,
&
rem
);
if
(
val
)
if
(
val
)
...
@@ -615,7 +615,7 @@ int net_OpenDgram( vlc_object_t *obj, const char *psz_bind, int i_bind,
...
@@ -615,7 +615,7 @@ int net_OpenDgram( vlc_object_t *obj, const char *psz_bind, int i_bind,
return
-
1
;
return
-
1
;
}
}
hints
.
ai_flags
=
AI_PASSIVE
;
hints
.
ai_flags
|
=
AI_PASSIVE
;
val
=
vlc_getaddrinfo
(
psz_bind
,
i_bind
,
&
hints
,
&
loc
);
val
=
vlc_getaddrinfo
(
psz_bind
,
i_bind
,
&
hints
,
&
loc
);
if
(
val
)
if
(
val
)
{
{
...
...
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