Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
VideoLAN
multicat
Commits
d29953f1
Commit
d29953f1
authored
Jan 19, 2012
by
Christophe Massiot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* util.c: Fix getaddrinfo() failures.
parent
552ac59b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
util.c
util.c
+35
-0
No files found.
util.c
View file @
d29953f1
...
@@ -45,6 +45,8 @@
...
@@ -45,6 +45,8 @@
#include "util.h"
#include "util.h"
#undef DEBUG_SOCKET
/*****************************************************************************
/*****************************************************************************
* Local declarations
* Local declarations
*****************************************************************************/
*****************************************************************************/
...
@@ -339,6 +341,35 @@ static struct addrinfo *ParseNodeService( char *_psz_string, char **ppsz_end,
...
@@ -339,6 +341,35 @@ static struct addrinfo *ParseNodeService( char *_psz_string, char **ppsz_end,
if
(
psz_node
[
0
]
==
'\0'
)
if
(
psz_node
[
0
]
==
'\0'
)
psz_node
=
"0.0.0.0"
;
psz_node
=
"0.0.0.0"
;
if
(
i_family
!=
AF_INET6
)
{
/* Give a try to inet_aton because experience shows that getaddrinfo()
* fails in certain cases, like when network is down. */
struct
in_addr
addr
;
if
(
inet_aton
(
psz_node
,
&
addr
)
!=
0
)
{
struct
sockaddr_in
*
p_sin
=
malloc
(
sizeof
(
struct
sockaddr_in
)
);
p_sin
->
sin_family
=
AF_INET
;
if
(
psz_port
!=
NULL
)
p_sin
->
sin_port
=
ntohs
(
atoi
(
psz_port
)
);
else
p_sin
->
sin_port
=
0
;
p_sin
->
sin_addr
=
addr
;
p_res
=
malloc
(
sizeof
(
struct
addrinfo
)
);
p_res
->
ai_family
=
AF_INET
;
p_res
->
ai_socktype
=
SOCK_DGRAM
;
p_res
->
ai_protocol
=
0
;
p_res
->
ai_addrlen
=
sizeof
(
struct
sockaddr_in
);
p_res
->
ai_addr
=
(
struct
sockaddr
*
)
p_sin
;
p_res
->
ai_canonname
=
NULL
;
p_res
->
ai_next
=
NULL
;
free
(
psz_string
);
return
p_res
;
}
}
memset
(
&
hint
,
0
,
sizeof
(
hint
)
);
memset
(
&
hint
,
0
,
sizeof
(
hint
)
);
hint
.
ai_family
=
i_family
;
hint
.
ai_family
=
i_family
;
hint
.
ai_socktype
=
SOCK_DGRAM
;
hint
.
ai_socktype
=
SOCK_DGRAM
;
...
@@ -424,6 +455,10 @@ int OpenSocket( const char *_psz_arg, int i_ttl, uint16_t i_bind_port,
...
@@ -424,6 +455,10 @@ int OpenSocket( const char *_psz_arg, int i_ttl, uint16_t i_bind_port,
connect_addr
.
ss
.
ss_family
==
AF_UNSPEC
)
connect_addr
.
ss
.
ss_family
==
AF_UNSPEC
)
return
-
1
;
return
-
1
;
#ifdef DEBUG_SOCKET
PrintSocket
(
"socket definition:"
,
&
bind_addr
,
&
connect_addr
);
#endif
/* Weights and options */
/* Weights and options */
if
(
psz_token2
)
if
(
psz_token2
)
{
{
...
...
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