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
3b6bb8ae
Commit
3b6bb8ae
authored
Dec 20, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tls: add separate callback for shutdown
parent
8bff13ad
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
1 deletion
+35
-1
include/vlc_tls.h
include/vlc_tls.h
+20
-0
modules/misc/gnutls.c
modules/misc/gnutls.c
+9
-1
src/network/tls.c
src/network/tls.c
+6
-0
No files found.
include/vlc_tls.h
View file @
3b6bb8ae
...
...
@@ -44,6 +44,7 @@ struct vlc_tls
ssize_t
(
*
recv
)(
struct
vlc_tls
*
,
void
*
,
size_t
);
ssize_t
(
*
send
)(
struct
vlc_tls
*
,
const
void
*
,
size_t
);
int
(
*
shutdown
)(
struct
vlc_tls
*
,
bool
duplex
);
void
(
*
close
)(
vlc_tls_t
*
);
};
...
...
@@ -88,6 +89,25 @@ VLC_API int vlc_tls_Read(vlc_tls_t *, void *buf, size_t len, bool waitall);
VLC_API
char
*
vlc_tls_GetLine
(
vlc_tls_t
*
);
VLC_API
int
vlc_tls_Write
(
vlc_tls_t
*
,
const
void
*
buf
,
size_t
len
);
/**
* Terminates a TLS session.
*
* This sends the TLS session close notification to the other end, securely
* indicating that no further data will be sent. Data can still be received
* until a close notification is received from the other end.
*
* @param duplex whether to stop receiving data as well
* @retval 0 the session was terminated securely and cleanly
* (the underlying socket can be reused for other purposes)
* @return -1 the session was terminated locally, but either a notification
* could not be sent or received (the underlying socket cannot be
* reused and must be closed)
*/
static
inline
int
vlc_tls_Shutdown
(
vlc_tls_t
*
tls
,
bool
duplex
)
{
return
tls
->
shutdown
(
tls
,
duplex
);
}
# define tls_Recv(a,b,c) vlc_tls_Read(a,b,c,false)
# define tls_Send(a,b,c) vlc_tls_Write(a,b,c)
...
...
modules/misc/gnutls.c
View file @
3b6bb8ae
...
...
@@ -182,6 +182,14 @@ static ssize_t gnutls_Recv (vlc_tls_t *tls, void *buf, size_t length)
return
(
val
<
0
)
?
gnutls_Error
(
tls
,
val
)
:
val
;
}
static
int
gnutls_Shutdown
(
vlc_tls_t
*
tls
,
bool
duplex
)
{
gnutls_session_t
session
=
tls
->
sys
;
int
val
=
gnutls_bye
(
session
,
duplex
?
GNUTLS_SHUT_RDWR
:
GNUTLS_SHUT_WR
);
return
(
val
<
0
)
?
gnutls_Error
(
tls
,
val
)
:
0
;
}
/**
* Terminates a TLS session.
*
...
...
@@ -192,7 +200,6 @@ static void gnutls_Close (vlc_tls_t *tls)
{
gnutls_session_t
session
=
tls
->
sys
;
gnutls_bye
(
session
,
GNUTLS_SHUT_RDWR
);
gnutls_deinit
(
session
);
}
...
...
@@ -264,6 +271,7 @@ static int gnutls_SessionOpen(vlc_tls_creds_t *creds, vlc_tls_t *tls, int type,
tls
->
sys
=
session
;
tls
->
send
=
gnutls_Send
;
tls
->
recv
=
gnutls_Recv
;
tls
->
shutdown
=
gnutls_Shutdown
;
tls
->
close
=
gnutls_Close
;
return
VLC_SUCCESS
;
...
...
src/network/tls.c
View file @
3b6bb8ae
...
...
@@ -322,6 +322,11 @@ static ssize_t vlc_tls_DummySend(vlc_tls_t *tls, const void *buf, size_t len)
return
send
(
tls
->
fd
,
buf
,
len
,
MSG_NOSIGNAL
);
}
static
int
vlc_tls_DummyShutdown
(
vlc_tls_t
*
tls
,
bool
duplex
)
{
return
shutdown
(
tls
->
fd
,
duplex
?
SHUT_RDWR
:
SHUT_WR
);
}
static
void
vlc_tls_DummyClose
(
vlc_tls_t
*
tls
)
{
(
void
)
tls
;
...
...
@@ -337,6 +342,7 @@ vlc_tls_t *vlc_tls_DummyCreate(vlc_object_t *obj, int fd)
session
->
fd
=
fd
;
session
->
recv
=
vlc_tls_DummyReceive
;
session
->
send
=
vlc_tls_DummySend
;
session
->
shutdown
=
vlc_tls_DummyShutdown
;
session
->
close
=
vlc_tls_DummyClose
;
return
session
;
}
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