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
9c8d0bf2
Commit
9c8d0bf2
authored
Jul 23, 2011
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge tls_ServerSessionPrepare() and tls_SessionHandshake()
parent
e424248a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
36 deletions
+23
-36
include/vlc_tls.h
include/vlc_tls.h
+3
-4
src/network/httpd.c
src/network/httpd.c
+12
-20
src/network/tls.c
src/network/tls.c
+8
-12
No files found.
include/vlc_tls.h
View file @
9c8d0bf2
...
...
@@ -67,10 +67,9 @@ void tls_ServerDelete (tls_server_t *);
int
tls_ServerAddCA
(
tls_server_t
*
srv
,
const
char
*
path
);
int
tls_ServerAddCRL
(
tls_server_t
*
srv
,
const
char
*
path
);
tls_session_t
*
tls_ServerSessionPrepare
(
tls_server_t
*
);
int
tls_ServerSessionHandshake
(
tls_session_t
*
,
int
fd
);
int
tls_SessionContinueHandshake
(
tls_session_t
*
);
void
tls_ServerSessionClose
(
tls_session_t
*
);
tls_session_t
*
tls_ServerSessionCreate
(
tls_server_t
*
,
int
fd
);
int
tls_ServerSessionHandshake
(
tls_session_t
*
);
void
tls_ServerSessionDelete
(
tls_session_t
*
);
VLC_API
tls_session_t
*
tls_ClientCreate
(
vlc_object_t
*
,
int
,
const
char
*
);
VLC_API
void
tls_ClientDelete
(
tls_session_t
*
);
...
...
src/network/httpd.c
View file @
9c8d0bf2
...
...
@@ -1429,7 +1429,7 @@ static void httpd_ClientClean( httpd_client_t *cl )
if
(
cl
->
fd
>=
0
)
{
if
(
cl
->
p_tls
!=
NULL
)
tls_ServerSession
Clos
e
(
cl
->
p_tls
);
tls_ServerSession
Delet
e
(
cl
->
p_tls
);
net_Close
(
cl
->
fd
);
cl
->
fd
=
-
1
;
}
...
...
@@ -2015,7 +2015,7 @@ static void httpd_ClientSend( httpd_client_t *cl )
static
void
httpd_ClientTlsHsIn
(
httpd_client_t
*
cl
)
{
switch
(
tls_Se
ssionContinue
Handshake
(
cl
->
p_tls
)
)
switch
(
tls_Se
rverSession
Handshake
(
cl
->
p_tls
)
)
{
case
0
:
cl
->
i_state
=
HTTPD_CLIENT_RECEIVING
;
...
...
@@ -2033,7 +2033,7 @@ static void httpd_ClientTlsHsIn( httpd_client_t *cl )
static
void
httpd_ClientTlsHsOut
(
httpd_client_t
*
cl
)
{
switch
(
tls_Se
ssionContinue
Handshake
(
cl
->
p_tls
)
)
switch
(
tls_Se
rverSession
Handshake
(
cl
->
p_tls
)
)
{
case
0
:
cl
->
i_state
=
HTTPD_CLIENT_RECEIVING
;
...
...
@@ -2053,17 +2053,12 @@ static void httpd_ClientTlsHsOut( httpd_client_t *cl )
static
void
*
httpd_HostThread
(
void
*
data
)
{
httpd_host_t
*
host
=
data
;
tls_session_t
*
p_tls
=
NULL
;
counter_t
*
p_total_counter
=
stats_CounterCreate
(
host
,
VLC_VAR_INTEGER
,
STATS_COUNTER
);
counter_t
*
p_active_counter
=
stats_CounterCreate
(
host
,
VLC_VAR_INTEGER
,
STATS_COUNTER
);
int
evfd
=
vlc_object_waitpipe
(
VLC_OBJECT
(
host
)
);
for
(
;;
)
{
/* prepare a new TLS session */
if
(
(
p_tls
==
NULL
)
&&
(
host
->
p_tls
!=
NULL
)
)
p_tls
=
tls_ServerSessionPrepare
(
host
->
p_tls
);
struct
pollfd
ufd
[
host
->
nfd
+
host
->
i_client
+
1
];
unsigned
nfd
;
for
(
nfd
=
0
;
nfd
<
host
->
nfd
;
nfd
++
)
...
...
@@ -2538,16 +2533,20 @@ static void* httpd_HostThread( void *data )
setsockopt
(
fd
,
SOL_SOCKET
,
SO_REUSEADDR
,
&
(
int
){
1
},
sizeof
(
int
));
if
(
p_tls
!=
NULL
)
tls_session_t
*
p_tls
;
if
(
host
->
p_tls
!=
NULL
)
{
switch
(
tls_ServerSessionHandshake
(
p_tls
,
fd
)
)
p_tls
=
tls_ServerSessionCreate
(
host
->
p_tls
,
fd
);
switch
(
tls_ServerSessionHandshake
(
p_tls
)
)
{
case
-
1
:
msg_Err
(
host
,
"Rejecting TLS connection"
);
/* p_tls is destroyed implicitly */
net_Close
(
fd
);
fd
=
-
1
;
p_tls
=
NULL
;
break
;
continue
;
case
1
:
/* missing input - most likely */
i_state
=
HTTPD_CLIENT_TLS_HS_IN
;
...
...
@@ -2557,29 +2556,22 @@ static void* httpd_HostThread( void *data )
i_state
=
HTTPD_CLIENT_TLS_HS_OUT
;
break
;
}
if
(
(
p_tls
==
NULL
)
!=
(
host
->
p_tls
==
NULL
)
)
break
;
// wasted TLS session, cannot accept() anymore
}
else
p_tls
=
NULL
;
stats_UpdateInteger
(
host
,
p_total_counter
,
1
,
NULL
);
stats_UpdateInteger
(
host
,
p_active_counter
,
1
,
NULL
);
cl
=
httpd_ClientNew
(
fd
,
p_tls
,
now
);
p_tls
=
NULL
;
vlc_mutex_lock
(
&
host
->
lock
);
TAB_APPEND
(
host
->
i_client
,
host
->
client
,
cl
);
vlc_mutex_unlock
(
&
host
->
lock
);
if
(
i_state
!=
-
1
)
cl
->
i_state
=
i_state
;
// override state for TLS
if
(
host
->
p_tls
!=
NULL
)
break
;
// cannot accept further without new TLS session
}
}
if
(
p_tls
!=
NULL
)
tls_ServerSessionClose
(
p_tls
);
if
(
p_total_counter
)
stats_CounterClean
(
p_total_counter
);
if
(
p_active_counter
)
...
...
src/network/tls.c
View file @
9c8d0bf2
...
...
@@ -115,31 +115,27 @@ int tls_ServerAddCRL (tls_server_t *srv, const char *path)
}
tls_session_t
*
tls_ServerSession
Prepare
(
tls_server_t
*
srv
)
tls_session_t
*
tls_ServerSession
Create
(
tls_server_t
*
srv
,
int
fd
)
{
return
srv
->
pf_open
(
srv
);
tls_session_t
*
ses
=
srv
->
pf_open
(
srv
);
if
(
ses
!=
NULL
)
ses
->
pf_set_fd
(
ses
,
fd
);
return
ses
;
}
void
tls_ServerSession
Clos
e
(
tls_session_t
*
ses
)
void
tls_ServerSession
Delet
e
(
tls_session_t
*
ses
)
{
tls_server_t
*
srv
=
(
tls_server_t
*
)(
ses
->
p_parent
);
srv
->
pf_close
(
srv
,
ses
);
}
int
tls_ServerSessionHandshake
(
tls_session_t
*
ses
,
int
fd
)
{
ses
->
pf_set_fd
(
ses
,
fd
);
return
2
;
}
int
tls_SessionContinueHandshake
(
tls_session_t
*
ses
)
int
tls_ServerSessionHandshake
(
tls_session_t
*
ses
)
{
int
val
=
ses
->
pf_handshake
(
ses
);
if
(
val
<
0
)
tls_ServerSession
Clos
e
(
ses
);
tls_ServerSession
Delet
e
(
ses
);
return
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