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
aa9562a3
Commit
aa9562a3
authored
Aug 09, 2008
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Presumptively avoid using getaddrinfo for the Windows 2000
parent
c2df0b03
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
101 deletions
+82
-101
src/network/getaddrinfo.c
src/network/getaddrinfo.c
+82
-0
src/network/io.c
src/network/io.c
+0
-101
No files found.
src/network/getaddrinfo.c
View file @
aa9562a3
...
...
@@ -688,3 +688,85 @@ void vlc_freeaddrinfo( struct addrinfo *infos )
{
freeaddrinfo
(
infos
);
}
/**
* inet_pton() replacement
*/
int
vlc_inet_pton
(
int
af
,
const
char
*
src
,
void
*
dst
)
{
#ifndef HAVE_INET_PTON
/* Windows Vista has inet_pton(), but not XP. */
/* We have a pretty good example of abstraction inversion here... */
struct
addrinfo
hints
=
{
.
ai_family
=
af
,
.
ai_socktype
=
SOCK_DGRAM
,
/* make sure we have... */
.
ai_protocol
=
IPPROTO_UDP
,
/* ...only one response */
.
ai_flags
=
AI_NUMERICHOST
,
},
*
res
;
if
(
getaddrinfo
(
src
,
NULL
,
&
hints
,
&
res
))
return
-
1
;
const
void
*
data
;
size_t
len
;
switch
(
af
)
{
case
AF_INET
:
data
=
&
((
const
struct
sockaddr_in
*
)
res
->
ai_addr
)
->
sin_addr
;
len
=
sizeof
(
struct
in_addr
);
break
;
#ifdef AF_INET6
case
AF_INET6
:
data
=
&
((
const
struct
sockaddr_in6
*
)
res
->
ai_addr
)
->
sin6_addr
;
len
=
sizeof
(
struct
in6_addr
);
break
;
#endif
default:
return
-
1
;
}
memcpy
(
dst
,
data
,
len
);
return
0
;
#else
/* HAVE_INET_PTON */
return
inet_pton
(
af
,
src
,
dst
);
#endif
/* HAVE_INET_PTON */
}
/**
* inet_ntop() replacement
*/
const
char
*
vlc_inet_ntop
(
int
af
,
const
void
*
src
,
char
*
dst
,
socklen_t
cnt
)
{
#ifndef HAVE_INET_NTOP
int
ret
=
EAI_FAMILY
;
switch
(
af
)
{
#ifdef AF_INET6
case
AF_INET6
:
{
struct
sockaddr_in6
addr
;
memset
(
&
addr
,
0
,
sizeof
(
addr
));
addr
.
sin6_family
=
AF_INET6
;
addr
.
sin6_addr
=
*
(
struct
in6_addr
*
)
src
;
ret
=
getnameinfo
((
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
),
dst
,
cnt
,
NULL
,
0
,
NI_NUMERICHOST
);
}
#endif
case
AF_INET
:
{
struct
sockaddr_in
addr
;
memset
(
&
addr
,
0
,
sizeof
(
addr
));
addr
.
sin_family
=
AF_INET
;
addr
.
sin_addr
=
*
(
struct
in_addr
*
)
src
;
ret
=
getnameinfo
((
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
),
dst
,
cnt
,
NULL
,
0
,
NI_NUMERICHOST
);
}
}
return
(
ret
==
0
)
?
dst
:
NULL
;
#else
/* HAVE_INET_NTOP */
return
inet_ntop
(
af
,
src
,
dst
,
cnt
);
#endif
/* HAVE_INET_NTOP */
}
src/network/io.c
View file @
aa9562a3
...
...
@@ -32,7 +32,6 @@
# include "config.h"
#endif
#define _WIN32_WINNT 0x0501
#include <vlc_common.h>
#include <stdlib.h>
...
...
@@ -552,106 +551,6 @@ ssize_t __net_vaPrintf( vlc_object_t *p_this, int fd, const v_socket_t *p_vs,
return
i_ret
;
}
/*****************************************************************************
* inet_pton replacement for obsolete and/or crap operating systems
*****************************************************************************/
int
vlc_inet_pton
(
int
af
,
const
char
*
src
,
void
*
dst
)
{
#ifndef HAVE_INET_PTON
/* Windows Vista has inet_pton(), but not XP. */
/* We have a pretty good example of abstraction inversion here... */
struct
addrinfo
hints
=
{
.
ai_family
=
af
,
.
ai_socktype
=
SOCK_DGRAM
,
/* make sure we have... */
.
ai_protocol
=
IPPROTO_UDP
,
/* ...only one response */
.
ai_flags
=
AI_NUMERICHOST
,
},
*
res
;
if
(
getaddrinfo
(
src
,
NULL
,
&
hints
,
&
res
))
return
-
1
;
const
void
*
data
;
size_t
len
;
switch
(
af
)
{
case
AF_INET
:
data
=
&
((
const
struct
sockaddr_in
*
)
res
->
ai_addr
)
->
sin_addr
;
len
=
4
;
break
;
#ifdef AF_INET6
case
AF_INET6
:
data
=
&
((
const
struct
sockaddr_in6
*
)
res
->
ai_addr
)
->
sin6_addr
;
len
=
16
;
break
;
#endif
default:
errno
=
EAFNOSUPPORT
;
return
-
1
;
}
memcpy
(
dst
,
data
,
len
);
return
0
;
#else
/* HAVE_INET_PTON */
return
inet_pton
(
af
,
src
,
dst
);
#endif
/* HAVE_INET_PTON */
}
const
char
*
vlc_inet_ntop
(
int
af
,
const
void
*
src
,
char
*
dst
,
socklen_t
cnt
)
{
#ifndef HAVE_INET_NTOP
#ifdef WIN32
switch
(
af
)
{
#ifdef AF_INET6
case
AF_INET6
:
{
struct
sockaddr_in6
addr
;
memset
(
&
addr
,
0
,
sizeof
(
addr
));
addr
.
sin6_family
=
AF_INET6
;
addr
.
sin6_addr
=
*
((
struct
in6_addr
*
)
src
);
if
(
0
==
WSAAddressToStringA
((
LPSOCKADDR
)
&
addr
,
sizeof
(
struct
sockaddr_in6
),
NULL
,
dst
,
&
cnt
)
)
{
dst
[
cnt
]
=
'\0'
;
return
dst
;
}
errno
=
WSAGetLastError
();
return
NULL
;
}
#endif
case
AF_INET
:
{
struct
sockaddr_in
addr
;
memset
(
&
addr
,
0
,
sizeof
(
addr
));
addr
.
sin_family
=
AF_INET
;
addr
.
sin_addr
=
*
((
struct
in_addr
*
)
src
);
if
(
0
==
WSAAddressToStringA
((
LPSOCKADDR
)
&
addr
,
sizeof
(
struct
sockaddr_in
),
NULL
,
dst
,
&
cnt
)
)
{
dst
[
cnt
]
=
'\0'
;
return
dst
;
}
errno
=
WSAGetLastError
();
return
NULL
;
}
}
errno
=
EAFNOSUPPORT
;
return
NULL
;
#else
/* WIN32 */
return
NULL
;
#endif
/* WIN32 */
#else
/* HAVE_INET_NTOP */
return
inet_ntop
(
af
,
src
,
dst
,
cnt
);
#endif
/* HAVE_INET_NTOP */
}
#ifdef WIN32
/* vlc_sendmsg, vlc_recvmsg Defined in winsock.c */
#else
/* !WIN32 */
...
...
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