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
79f332e2
Commit
79f332e2
authored
Jan 12, 2016
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tls: replace fd with get_fd callback
parent
2f5e4399
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
56 additions
and
14 deletions
+56
-14
include/vlc_tls.h
include/vlc_tls.h
+8
-3
modules/access/http/chunked_test.c
modules/access/http/chunked_test.c
+7
-0
modules/access/http/h2conn.c
modules/access/http/h2conn.c
+1
-1
modules/access/http/h2output.c
modules/access/http/h2output.c
+1
-1
modules/access/http/h2output_test.c
modules/access/http/h2output_test.c
+7
-0
modules/access/http/tunnel.c
modules/access/http/tunnel.c
+1
-1
modules/misc/gnutls.c
modules/misc/gnutls.c
+8
-0
modules/misc/securetransport.c
modules/misc/securetransport.c
+7
-0
src/network/tls.c
src/network/tls.c
+15
-7
test/modules/misc/tls.c
test/modules/misc/tls.c
+1
-1
No files found.
include/vlc_tls.h
View file @
79f332e2
...
...
@@ -40,12 +40,12 @@ struct vlc_tls
{
vlc_object_t
*
obj
;
void
*
sys
;
int
fd
;
int
(
*
get_fd
)(
struct
vlc_tls
*
);
ssize_t
(
*
readv
)(
struct
vlc_tls
*
,
struct
iovec
*
,
unsigned
);
ssize_t
(
*
writev
)(
struct
vlc_tls
*
,
const
struct
iovec
*
,
unsigned
);
int
(
*
shutdown
)(
struct
vlc_tls
*
,
bool
duplex
);
void
(
*
close
)(
vlc_tls_t
*
);
void
(
*
close
)(
struct
vlc_tls
*
);
};
/**
...
...
@@ -89,6 +89,11 @@ VLC_API vlc_tls_t *vlc_tls_SessionCreate (vlc_tls_creds_t *, int fd,
*/
VLC_API
void
vlc_tls_SessionDelete
(
vlc_tls_t
*
);
static
inline
int
vlc_tls_GetFD
(
vlc_tls_t
*
tls
)
{
return
tls
->
get_fd
(
tls
);
}
/**
* Receives data through a TLS session.
*/
...
...
@@ -129,7 +134,7 @@ static inline int vlc_tls_Shutdown(vlc_tls_t *tls, bool duplex)
*/
static
inline
void
vlc_tls_Close
(
vlc_tls_t
*
session
)
{
int
fd
=
session
->
fd
;
int
fd
=
vlc_tls_GetFD
(
session
)
;
vlc_tls_SessionDelete
(
session
);
shutdown
(
fd
,
SHUT_RDWR
);
...
...
modules/access/http/chunked_test.c
View file @
79f332e2
...
...
@@ -39,6 +39,12 @@ static const char *stream_content;
static
size_t
stream_length
;
static
bool
stream_bad
;
static
int
fd_callback
(
struct
vlc_tls
*
tls
)
{
(
void
)
tls
;
return
-
1
;
}
static
ssize_t
recv_callback
(
struct
vlc_tls
*
tls
,
struct
iovec
*
iov
,
unsigned
count
)
{
...
...
@@ -72,6 +78,7 @@ static void close_callback(struct vlc_tls *tls)
static
struct
vlc_tls
chunked_tls
=
{
.
get_fd
=
fd_callback
,
.
readv
=
recv_callback
,
.
close
=
close_callback
,
};
...
...
modules/access/http/h2conn.c
View file @
79f332e2
...
...
@@ -528,7 +528,7 @@ static ssize_t vlc_https_recv(vlc_tls_t *tls, void *buf, size_t len)
struct
iovec
iov
;
size_t
count
=
0
;
ufd
.
fd
=
tls
->
fd
;
ufd
.
fd
=
vlc_tls_GetFD
(
tls
)
;
ufd
.
events
=
POLLIN
;
iov
.
iov_base
=
buf
;
iov
.
iov_len
=
len
;
...
...
modules/access/http/h2output.c
View file @
79f332e2
...
...
@@ -193,7 +193,7 @@ static ssize_t vlc_https_send(vlc_tls_t *tls, const void *buf, size_t len)
struct
iovec
iov
;
size_t
count
=
0
;
ufd
.
fd
=
tls
->
fd
;
ufd
.
fd
=
vlc_tls_GetFD
(
tls
)
;
ufd
.
events
=
POLLOUT
;
iov
.
iov_base
=
(
void
*
)
buf
;
iov
.
iov_len
=
len
;
...
...
modules/access/http/h2output_test.c
View file @
79f332e2
...
...
@@ -40,6 +40,12 @@ static bool send_failure = false;
static
bool
expect_hello
=
true
;
static
vlc_sem_t
rx
;
static
int
fd_callback
(
vlc_tls_t
*
tls
)
{
(
void
)
tls
;
return
-
1
;
}
static
ssize_t
send_callback
(
vlc_tls_t
*
tls
,
const
struct
iovec
*
iov
,
unsigned
count
)
{
...
...
@@ -74,6 +80,7 @@ static ssize_t send_callback(vlc_tls_t *tls, const struct iovec *iov,
static
vlc_tls_t
fake_tls
=
{
.
get_fd
=
fd_callback
,
.
writev
=
send_callback
,
};
...
...
modules/access/http/tunnel.c
View file @
79f332e2
...
...
@@ -162,7 +162,7 @@ vlc_tls_t *vlc_https_connect_proxy(vlc_tls_creds_t *creds,
# error ENOSYS
/* TODO: create a vlc_tls_t * from a struct vlc_http_msg *. */
#else
int
fd
=
session
->
fd
;
int
fd
=
vlc_tls_GetFD
(
session
)
;
session
->
shutdown
=
vlc_http_tls_shutdown_ignore
;
session
->
close
=
vlc_http_tls_close_ignore
;
...
...
modules/misc/gnutls.c
View file @
79f332e2
...
...
@@ -157,6 +157,13 @@ static ssize_t vlc_gnutls_writev (gnutls_transport_ptr_t ptr,
return
sendmsg
(
fd
,
&
msg
,
MSG_NOSIGNAL
);
}
static
int
gnutls_GetFD
(
vlc_tls_t
*
tls
)
{
gnutls_session_t
session
=
tls
->
sys
;
return
gnutls_transport_get_int
(
session
);
}
static
ssize_t
gnutls_Recv
(
vlc_tls_t
*
tls
,
struct
iovec
*
iov
,
unsigned
count
)
{
gnutls_session_t
session
=
tls
->
sys
;
...
...
@@ -293,6 +300,7 @@ static int gnutls_SessionOpen(vlc_tls_creds_t *creds, vlc_tls_t *tls, int type,
gnutls_transport_set_int
(
session
,
fd
);
gnutls_transport_set_vec_push_function
(
session
,
vlc_gnutls_writev
);
tls
->
sys
=
session
;
tls
->
get_fd
=
gnutls_GetFD
;
tls
->
readv
=
gnutls_Recv
;
tls
->
writev
=
gnutls_Send
;
tls
->
shutdown
=
gnutls_Shutdown
;
...
...
modules/misc/securetransport.c
View file @
79f332e2
...
...
@@ -424,6 +424,13 @@ static int st_Handshake (vlc_tls_creds_t *crd, vlc_tls_t *session,
}
}
static
int
st_GetFD
(
vlc_tls_t
*
session
)
{
vlc_tls_sys_t
*
sys
=
session
->
sys
;
return
sys
->
i_fd
;
}
/**
* Sends data through a TLS session.
*/
...
...
src/network/tls.c
View file @
79f332e2
...
...
@@ -136,7 +136,6 @@ vlc_tls_t *vlc_tls_SessionCreate (vlc_tls_creds_t *crd, int fd,
return
NULL
;
session
->
obj
=
crd
->
p_parent
;
session
->
fd
=
fd
;
int
val
=
crd
->
open
(
crd
,
session
,
fd
,
host
,
alpn
);
if
(
val
!=
VLC_SUCCESS
)
...
...
@@ -222,7 +221,7 @@ ssize_t vlc_tls_Read(vlc_tls_t *session, void *buf, size_t len, bool waitall)
struct
pollfd
ufd
;
struct
iovec
iov
;
ufd
.
fd
=
session
->
fd
;
ufd
.
fd
=
vlc_tls_GetFD
(
session
)
;
ufd
.
events
=
POLLIN
;
iov
.
iov_base
=
buf
;
iov
.
iov_len
=
len
;
...
...
@@ -258,7 +257,7 @@ ssize_t vlc_tls_Write(vlc_tls_t *session, const void *buf, size_t len)
struct
pollfd
ufd
;
struct
iovec
iov
;
ufd
.
fd
=
session
->
fd
;
ufd
.
fd
=
vlc_tls_GetFD
(
session
)
;
ufd
.
events
=
POLLOUT
;
iov
.
iov_base
=
(
void
*
)
buf
;
iov
.
iov_len
=
len
;
...
...
@@ -318,31 +317,39 @@ error:
return
NULL
;
}
static
int
vlc_tls_DummyGetFD
(
vlc_tls_t
*
tls
)
{
return
(
intptr_t
)
tls
->
sys
;
}
static
ssize_t
vlc_tls_DummyReceive
(
vlc_tls_t
*
tls
,
struct
iovec
*
iov
,
unsigned
count
)
{
int
fd
=
(
intptr_t
)
tls
->
sys
;
struct
msghdr
msg
=
{
.
msg_iov
=
iov
,
.
msg_iovlen
=
count
,
};
return
recvmsg
(
tls
->
fd
,
&
msg
,
0
);
return
recvmsg
(
fd
,
&
msg
,
0
);
}
static
ssize_t
vlc_tls_DummySend
(
vlc_tls_t
*
tls
,
const
struct
iovec
*
iov
,
unsigned
count
)
{
int
fd
=
(
intptr_t
)
tls
->
sys
;
const
struct
msghdr
msg
=
{
.
msg_iov
=
(
struct
iovec
*
)
iov
,
.
msg_iovlen
=
count
,
};
return
sendmsg
(
tls
->
fd
,
&
msg
,
MSG_NOSIGNAL
);
return
sendmsg
(
fd
,
&
msg
,
MSG_NOSIGNAL
);
}
static
int
vlc_tls_DummyShutdown
(
vlc_tls_t
*
tls
,
bool
duplex
)
{
return
shutdown
(
tls
->
fd
,
duplex
?
SHUT_RDWR
:
SHUT_WR
);
int
fd
=
(
intptr_t
)
tls
->
sys
;
return
shutdown
(
fd
,
duplex
?
SHUT_RDWR
:
SHUT_WR
);
}
static
void
vlc_tls_DummyClose
(
vlc_tls_t
*
tls
)
...
...
@@ -357,7 +364,8 @@ vlc_tls_t *vlc_tls_DummyCreate(vlc_object_t *obj, int fd)
return
NULL
;
session
->
obj
=
obj
;
session
->
fd
=
fd
;
session
->
sys
=
(
void
*
)(
intptr_t
)
fd
;
session
->
get_fd
=
vlc_tls_DummyGetFD
;
session
->
readv
=
vlc_tls_DummyReceive
;
session
->
writev
=
vlc_tls_DummySend
;
session
->
shutdown
=
vlc_tls_DummyShutdown
;
...
...
test/modules/misc/tls.c
View file @
79f332e2
...
...
@@ -73,7 +73,7 @@ static void *tls_echo(void *data)
ssize_t
val
;
char
buf
[
256
];
ufd
.
fd
=
tls
->
fd
;
ufd
.
fd
=
vlc_tls_GetFD
(
tls
)
;
while
((
val
=
vlc_tls_SessionHandshake
(
server_creds
,
tls
))
>
0
)
{
...
...
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