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
6f987b51
Commit
6f987b51
authored
Jun 26, 2005
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes httpd_ClientIP on Win32 & the likes
parent
22571f1a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
55 deletions
+35
-55
include/network.h
include/network.h
+1
-1
include/vlc_symbols.h
include/vlc_symbols.h
+1
-1
modules/access/ftp.c
modules/access/ftp.c
+2
-3
src/misc/getaddrinfo.c
src/misc/getaddrinfo.c
+9
-6
src/misc/httpd.c
src/misc/httpd.c
+20
-41
src/stream_output/sap.c
src/stream_output/sap.c
+2
-3
No files found.
include/network.h
View file @
6f987b51
...
...
@@ -422,7 +422,7 @@ struct addrinfo
# endif
VLC_EXPORT
(
const
char
*
,
vlc_gai_strerror
,
(
int
)
);
VLC_EXPORT
(
int
,
vlc_getnameinfo
,
(
vlc_object_t
*
,
const
struct
sockaddr
*
,
int
,
char
*
,
int
,
int
*
,
int
)
);
VLC_EXPORT
(
int
,
vlc_getnameinfo
,
(
const
struct
sockaddr
*
,
int
,
char
*
,
int
,
int
*
,
int
)
);
VLC_EXPORT
(
int
,
vlc_getaddrinfo
,
(
vlc_object_t
*
,
const
char
*
,
int
,
const
struct
addrinfo
*
,
struct
addrinfo
**
)
);
VLC_EXPORT
(
void
,
vlc_freeaddrinfo
,
(
struct
addrinfo
*
)
);
...
...
include/vlc_symbols.h
View file @
6f987b51
...
...
@@ -367,7 +367,7 @@ struct module_symbols_t
mtime_t
(
*
vout_SynchroDate_inner
)
(
vout_synchro_t
*
);
void
(
*
vout_SynchroNewPicture_inner
)
(
vout_synchro_t
*
,
int
,
int
,
mtime_t
,
mtime_t
,
int
,
vlc_bool_t
);
int
(
*
vlc_getaddrinfo_inner
)
(
vlc_object_t
*
,
const
char
*
,
int
,
const
struct
addrinfo
*
,
struct
addrinfo
**
);
int
(
*
vlc_getnameinfo_inner
)
(
vlc_object_t
*
,
const
struct
sockaddr
*
,
int
,
char
*
,
int
,
int
*
,
int
);
int
(
*
vlc_getnameinfo_inner
)
(
const
struct
sockaddr
*
,
int
,
char
*
,
int
,
int
*
,
int
);
void
(
*
InitMD5_inner
)
(
struct
md5_s
*
);
void
(
*
EndMD5_inner
)
(
struct
md5_s
*
);
void
(
*
vlc_freeaddrinfo_inner
)
(
struct
addrinfo
*
);
...
...
modules/access/ftp.c
View file @
6f987b51
...
...
@@ -250,9 +250,8 @@ static int Open( vlc_object_t *p_this )
goto
exit_error
;
}
i_answer
=
vlc_getnameinfo
(
p_this
,
(
struct
sockaddr
*
)
&
addr
,
len
,
hostaddr
,
sizeof
(
hostaddr
),
NULL
,
NI_NUMERICHOST
);
i_answer
=
vlc_getnameinfo
(
(
struct
sockaddr
*
)
&
addr
,
len
,
hostaddr
,
sizeof
(
hostaddr
),
NULL
,
NI_NUMERICHOST
);
if
(
i_answer
)
{
msg_Err
(
p_access
,
"getnameinfo failed: %s"
,
...
...
src/misc/getaddrinfo.c
View file @
6f987b51
...
...
@@ -493,7 +493,7 @@ __getaddrinfo (const char *node, const char *service,
#endif
/* if !HAVE_GETADDRINFO */
int
vlc_getnameinfo
(
vlc_object_t
*
p_this
,
const
struct
sockaddr
*
sa
,
int
salen
,
int
vlc_getnameinfo
(
const
struct
sockaddr
*
sa
,
int
salen
,
char
*
host
,
int
hostlen
,
int
*
portnum
,
int
flags
)
{
char
psz_servbuf
[
6
],
*
psz_serv
;
...
...
@@ -545,17 +545,20 @@ int vlc_getnameinfo( vlc_object_t *p_this, const struct sockaddr *sa, int salen,
flags
);
#else
{
vlc_value_t
lock
;
# ifdef HAVE_USABLE_MUTEX_THAT_DONT_NEED_LIBVLC_POINTER
static
vlc_value_t
lock
;
/* my getnameinfo implementation is not thread-safe as it uses
* gethostbyaddr and the likes */
var_Create
(
p_this
->
p_libvlc
,
"getnameinfo_mutex"
,
VLC_VAR_MUTEX
);
var_Get
(
p_this
->
p_libvlc
,
"getnameinfo_mutex"
,
&
lock
);
* gethostbyaddr and the likes */
vlc_mutex_lock
(
lock
.
p_address
);
#else
# warning FIXME : This is not thread-safe! Your platform is outdated.
#endif
i_val
=
__getnameinfo
(
sa
,
salen
,
host
,
hostlen
,
psz_serv
,
i_servlen
,
flags
);
# ifdef HAVE_USABLE_MUTEX_THAT_DONT_NEED_LIBVLC_POINTER
vlc_mutex_unlock
(
lock
.
p_address
);
# endif
}
#endif
...
...
src/misc/httpd.c
View file @
6f987b51
...
...
@@ -1331,15 +1331,13 @@ void httpd_ClientModeBidir( httpd_client_t *cl )
cl
->
i_mode
=
HTTPD_CLIENT_BIDIR
;
}
/*
* FIXME: use vlc_getnameinfo
*/
char
*
httpd_ClientIP
(
httpd_client_t
*
cl
)
{
#ifdef HAVE_GETNAMEINFO
char
sz_ip
[
INET6_ADDRSTRLEN
+
2
];
int
i
;
char
*
psz_ip
;
psz_ip
=
(
char
*
)
malloc
(
NI_MAXNUMERICHOST
+
2
);
#ifdef HAVE_GETNAMEINFO
/* FIXME not very good check */
if
(
(
cl
->
sock
.
ss_family
==
AF_INET6
)
&&
IN6_IS_ADDR_V4MAPPED
(
&
((
const
struct
sockaddr_in6
*
)
&
cl
->
sock
)
->
sin6_addr
)
)
...
...
@@ -1352,34 +1350,31 @@ char* httpd_ClientIP( httpd_client_t *cl )
a
.
sin_port
=
((
const
struct
sockaddr_in6
*
)
&
cl
->
sock
)
->
sin6_port
;
a
.
sin_addr
.
s_addr
=
((
const
uint32_t
*
)
&
((
const
struct
sockaddr_in6
*
)
&
cl
->
sock
)
->
sin6_addr
)[
3
];
i
=
getnameinfo
(
(
const
struct
sockaddr
*
)
&
a
,
sizeof
(
a
),
&
sz_ip
[
1
],
INET6_ADDRSTRLEN
,
NULL
,
0
,
NI_NUMERICHOST
);
i
=
vlc_getnameinfo
(
(
const
struct
sockaddr
*
)
&
a
,
sizeof
(
a
),
psz_ip
+
1
,
NI_MAXNUMERICHOST
,
NULL
,
NI_NUMERICHOST
);
}
else
i
=
getnameinfo
(
(
const
struct
sockaddr
*
)
&
cl
->
sock
,
cl
->
i_sock_size
,
&
sz_ip
[
1
],
INET6_ADDRSTRLEN
,
NULL
,
0
,
NI_NUMERICHOST
);
#endif
i
=
vlc_getnameinfo
(
(
const
struct
sockaddr
*
)
&
cl
->
sock
,
cl
->
i_sock_size
,
psz_ip
+
1
,
NI_MAXNUMERICHOST
,
NULL
,
NI_NUMERICHOST
);
if
(
i
!=
0
)
/* FIXME: msg_Err */
return
NULL
;
if
(
strchr
(
&
sz_ip
[
1
],
':'
)
!=
NULL
)
/* semi-colon in address => must add bracket for HTTP */
if
(
strchr
(
psz_ip
+
1
,
':'
)
!=
NULL
)
{
*
sz_ip
=
'['
;
i
=
strlen
(
sz_ip
);
sz_ip
[
i
++
]
=
']'
;
sz_ip
[
i
]
=
'\0'
;
return
strdup
(
sz_ip
)
;
psz_ip
[
0
]
=
'['
;
i
=
strlen
(
p
sz_ip
);
p
sz_ip
[
i
++
]
=
']'
;
p
sz_ip
[
i
]
=
'\0'
;
return
psz_ip
;
}
return
strdup
(
&
sz_ip
[
1
]
);
#else
/* FIXME not thread safe */
return
strdup
(
inet_ntoa
(
((
const
struct
sockaddr_in
*
)
&
cl
->
sock
)
->
sin_addr
)
);
#endif
return
psz_ip
+
1
;
}
static
void
httpd_ClientClean
(
httpd_client_t
*
cl
)
...
...
@@ -1961,14 +1956,6 @@ static void httpd_HostThread( httpd_host_t *host )
(
cl
->
i_activity_timeout
>
0
&&
cl
->
i_activity_date
+
cl
->
i_activity_timeout
<
mdate
())
)
)
)
{
char
*
ip
;
// FIXME: it sucks to allocate memory on the stack for debug
ip
=
httpd_ClientIP
(
cl
);
msg_Dbg
(
host
,
"connection closed(%s)"
,
(
ip
!=
NULL
)
?
ip
:
"unknown"
);
free
(
ip
);
httpd_ClientClean
(
cl
);
TAB_REMOVE
(
host
->
i_client
,
host
->
client
,
cl
);
free
(
cl
);
...
...
@@ -2392,7 +2379,6 @@ static void httpd_HostThread( httpd_host_t *host )
if
(
fd
>=
0
)
{
char
*
ip
;
httpd_client_t
*
cl
;
cl
=
httpd_ClientNew
(
fd
,
&
sock
,
i_sock_size
,
p_tls
);
...
...
@@ -2403,13 +2389,6 @@ static void httpd_HostThread( httpd_host_t *host )
if
(
i_state
!=
0
)
cl
->
i_state
=
i_state
;
// override state for TLS
// FIXME: it sucks to allocate memory for debug
ip
=
httpd_ClientIP
(
cl
);
msg_Dbg
(
host
,
"new connection (%s)"
,
ip
!=
NULL
?
ip
:
"unknown"
);
if
(
ip
!=
NULL
)
free
(
ip
);
}
}
}
...
...
src/stream_output/sap.c
View file @
6f987b51
...
...
@@ -298,9 +298,8 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
i
=
vlc_getaddrinfo
(
(
vlc_object_t
*
)
p_sap
,
p_session
->
psz_uri
,
0
,
&
hints
,
&
res
);
if
(
i
==
0
)
i
=
vlc_getnameinfo
(
(
vlc_object_t
*
)
p_sap
,
res
->
ai_addr
,
res
->
ai_addrlen
,
psz_buf
,
sizeof
(
psz_buf
),
NULL
,
NI_NUMERICHOST
);
i
=
vlc_getnameinfo
(
res
->
ai_addr
,
res
->
ai_addrlen
,
psz_buf
,
sizeof
(
psz_buf
),
NULL
,
NI_NUMERICHOST
);
if
(
i
)
{
msg_Err
(
p_sap
,
"Invalid URI for SAP announce : %s : %s"
,
...
...
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