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
2c91228b
Commit
2c91228b
authored
Jul 28, 2005
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inet_pton() replacement
parent
5cd565b2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
22 deletions
+66
-22
include/network.h
include/network.h
+6
-0
src/misc/net.c
src/misc/net.c
+59
-0
src/stream_output/sap.c
src/stream_output/sap.c
+1
-22
No files found.
include/network.h
View file @
2c91228b
...
...
@@ -360,6 +360,12 @@ VLC_EXPORT( int, __net_vaPrintf, ( vlc_object_t *p_this, int fd, v_socket_t *, c
#define net_GetPeerAddress(a,b,c,d) __net_GetAddress(VLC_OBJECT(a),VLC_TRUE,b,c,d)
VLC_EXPORT
(
int
,
__net_GetAddress
,
(
vlc_object_t
*
p_this
,
vlc_bool_t
peer
,
int
fd
,
char
*
address
,
int
*
port
)
);
#if !HAVE_INET_PTON
/* only in core, so no need for C++ extern "C" */
int
inet_pton
(
int
af
,
const
char
*
src
,
void
*
dst
);
#endif
/*****************************************************************************
* net_StopRecv/Send
*****************************************************************************
...
...
src/misc/net.c
View file @
2c91228b
...
...
@@ -1185,3 +1185,62 @@ int __net_GetAddress( vlc_object_t *p_this, vlc_bool_t peer, int fd,
}
return
0
;
}
/*****************************************************************************
* inet_pton replacement for obsolete and/or crap operating systems
*****************************************************************************/
#ifndef HAVE_INET_PTON
int
inet_pton
(
int
af
,
const
char
*
src
,
void
*
dst
)
{
# ifdef WIN32
/* As we already know, Microsoft always go its own way, so even if they do
* provide IPv6, they don't provide the API. */
struct
sockaddr_storage
addr
;
int
len
=
sizeof
(
addr
);
/* Damn it, they didn't even put LPCSTR for the firs parameter!!! */
char
*
workaround_for_ill_designed_api
=
strdup
(
src
);
if
(
!
WSAStringToAddress
(
workaround_for_ill_designed_api
,
af
,
NULL
,
(
LPSOCKADDR
)
&
addr
,
&
len
)
)
{
free
(
workaround_for_ill_designed_api
);
return
-
1
;
}
free
(
workaround_for_ill_designed_api
);
switch
(
af
)
{
case
AF_INET6
:
memcpy
(
dst
,
&
((
struct
sockaddr_in6
*
)
&
addr
)
->
sin6_addr
,
16
);
break
;
case
AF_INET
:
memcpy
(
dst
,
&
((
struct
sockaddr_in
*
)
&
addr
)
->
sin_addr
,
4
);
break
;
default:
WSASetLastError
(
WSAEAFNOSUPPORT
);
return
-
1
;
}
# else
/* Assume IPv6 is not supported. */
/* Would be safer and more simpler to use inet_aton() but it is most
* likely not provided either. */
uint32_t
ipv4
;
if
(
af
!=
AF_INET
)
{
errno
=
EAFNOSUPPORT
;
return
-
1
;
}
ipv4
=
inet_addr
(
src
);
if
(
ipv4
==
INADDR_NONE
)
return
-
1
;
memcpy
(
dst
;
&
ipv4
,
4
);
# endif
/* WIN32 */
return
0
;
}
#endif
/* HAVE_INET_PTON */
src/stream_output/sap.c
View file @
2c91228b
...
...
@@ -300,7 +300,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
switch
(
addr
.
ss_family
)
{
#if defined (
HAVE_GETADDRINFO
) || defined (WIN32)
#if defined (
INET_PTON
) || defined (WIN32)
case
AF_INET6
:
{
/* See RFC3513 for list of valid IPv6 scopes */
...
...
@@ -457,29 +457,8 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
psz_head
[
2
]
=
(
i_hash
&
0xFF00
)
>>
8
;
/* Msg id hash */
psz_head
[
3
]
=
(
i_hash
&
0xFF
);
/* Msg id hash 2 */
#if defined(WIN32)
if
(
b_ipv6
)
{
struct
sockaddr_in6
saddr
;
int
len
=
sizeof
(
saddr
);
if
(
!
WSAStringToAddress
(
p_sap_session
->
p_address
->
psz_machine
,
AF_INET6
,
NULL
,
(
LPSOCKADDR
)
&
saddr
,
&
len
)
)
return
VLC_ENOMEM
;
memcpy
(
psz_head
+
4
,
&
saddr
.
sin6_addr
,
sizeof
(
struct
in6_addr
));
}
else
{
struct
sockaddr_in
saddr
;
int
len
=
sizeof
(
saddr
);
if
(
!
WSAStringToAddress
(
p_sap_session
->
p_address
->
psz_machine
,
AF_INET
,
NULL
,
(
LPSOCKADDR
)
&
saddr
,
&
len
)
)
return
VLC_ENOMEM
;
memcpy
(
psz_head
+
4
,
&
saddr
.
sin_addr
,
sizeof
(
struct
in_addr
));
}
#else
inet_pton
(
b_ipv6
?
AF_INET6
:
AF_INET
,
/* can't fail */
p_sap_session
->
p_address
->
psz_machine
,
psz_head
+
4
);
#endif
memcpy
(
psz_head
+
(
b_ipv6
?
20
:
8
),
"application/sdp"
,
15
);
...
...
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