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
58686f3c
Commit
58686f3c
authored
May 07, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tls: add dedicated helpers for I/O
parent
04d62b00
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
134 additions
and
4 deletions
+134
-4
include/vlc_tls.h
include/vlc_tls.h
+5
-4
src/libvlccore.sym
src/libvlccore.sym
+3
-0
src/network/tls.c
src/network/tls.c
+126
-0
No files found.
include/vlc_tls.h
View file @
58686f3c
...
@@ -52,11 +52,12 @@ int vlc_tls_SessionHandshake (vlc_tls_t *, const char *host, const char *serv,
...
@@ -52,11 +52,12 @@ int vlc_tls_SessionHandshake (vlc_tls_t *, const char *host, const char *serv,
char
**
/*restrict*/
alp
);
char
**
/*restrict*/
alp
);
VLC_API
void
vlc_tls_SessionDelete
(
vlc_tls_t
*
);
VLC_API
void
vlc_tls_SessionDelete
(
vlc_tls_t
*
);
/* NOTE: It is assumed that a->sock.p_sys = a */
VLC_API
int
vlc_tls_Read
(
vlc_tls_t
*
,
void
*
buf
,
size_t
len
,
bool
waitall
);
# define tls_Send( a, b, c ) (((vlc_tls_t *)a)->sock.pf_send (a, b, c))
VLC_API
char
*
vlc_tls_GetLine
(
vlc_tls_t
*
);
VLC_API
int
vlc_tls_Write
(
vlc_tls_t
*
,
const
void
*
buf
,
size_t
len
);
# define tls_Recv( a, b, c ) (((vlc_tls_t *)a)->sock.pf_recv (a, b, c))
# 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)
/** TLS credentials (certificate, private and trust settings) */
/** TLS credentials (certificate, private and trust settings) */
struct
vlc_tls_creds
struct
vlc_tls_creds
...
...
src/libvlccore.sym
View file @
58686f3c
...
@@ -421,6 +421,9 @@ vlc_tls_ClientCreate
...
@@ -421,6 +421,9 @@ vlc_tls_ClientCreate
vlc_tls_Delete
vlc_tls_Delete
vlc_tls_ClientSessionCreate
vlc_tls_ClientSessionCreate
vlc_tls_SessionDelete
vlc_tls_SessionDelete
vlc_tls_Read
vlc_tls_Write
vlc_tls_GetLine
ToCharset
ToCharset
update_Check
update_Check
update_Delete
update_Delete
...
...
src/network/tls.c
View file @
58686f3c
...
@@ -34,6 +34,9 @@
...
@@ -34,6 +34,9 @@
# include <poll.h>
# include <poll.h>
#endif
#endif
#include <assert.h>
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <vlc_common.h>
#include <vlc_common.h>
#include "libvlc.h"
#include "libvlc.h"
...
@@ -233,3 +236,126 @@ error:
...
@@ -233,3 +236,126 @@ error:
vlc_tls_SessionDelete
(
session
);
vlc_tls_SessionDelete
(
session
);
return
NULL
;
return
NULL
;
}
}
int
vlc_tls_Read
(
vlc_tls_t
*
session
,
void
*
buf
,
size_t
len
,
bool
waitall
)
{
struct
pollfd
ufd
[
2
];
ufd
[
0
].
fd
=
session
->
fd
;
ufd
[
0
].
events
=
POLLIN
;
ufd
[
1
].
fd
=
vlc_object_waitpipe
(
session
->
p_parent
);
ufd
[
1
].
events
=
POLLIN
;
if
(
unlikely
(
ufd
[
1
].
fd
==
-
1
))
{
vlc_testcancel
();
return
-
1
;
}
for
(
size_t
rcvd
=
0
;;)
{
ssize_t
val
=
session
->
sock
.
pf_recv
(
session
,
buf
,
len
);
if
(
val
>
0
)
{
if
(
!
waitall
)
return
val
;
buf
=
((
char
*
)
buf
)
+
val
;
len
-=
val
;
rcvd
+=
val
;
}
if
(
len
==
0
||
val
==
0
)
return
rcvd
;
if
(
val
==
-
1
&&
errno
!=
EINTR
&&
errno
!=
EAGAIN
)
return
rcvd
?
(
ssize_t
)
rcvd
:
-
1
;
val
=
poll
(
ufd
,
2
,
-
1
);
if
(
val
==
-
1
)
continue
;
if
(
ufd
[
1
].
revents
)
{
if
(
rcvd
>
0
)
return
rcvd
;
msg_Dbg
(
session
,
"socket %d polling interrupted"
,
session
->
fd
);
errno
=
EINTR
;
return
-
1
;
}
}
}
int
vlc_tls_Write
(
vlc_tls_t
*
session
,
const
void
*
buf
,
size_t
len
)
{
struct
pollfd
ufd
[
2
];
ufd
[
0
].
fd
=
session
->
fd
;
ufd
[
0
].
events
=
POLLOUT
;
ufd
[
1
].
fd
=
vlc_object_waitpipe
(
session
->
p_parent
);
ufd
[
1
].
events
=
POLLIN
;
if
(
unlikely
(
ufd
[
1
].
fd
==
-
1
))
{
vlc_testcancel
();
return
-
1
;
}
for
(
size_t
sent
=
0
;;)
{
ssize_t
val
=
session
->
sock
.
pf_send
(
session
,
buf
,
len
);
if
(
val
>
0
)
{
buf
=
((
const
char
*
)
buf
)
+
val
;
len
-=
val
;
sent
+=
val
;
}
if
(
len
==
0
||
val
==
0
)
return
sent
;
if
(
val
==
-
1
&&
errno
!=
EINTR
&&
errno
!=
EAGAIN
)
return
sent
?
(
ssize_t
)
sent
:
-
1
;
val
=
poll
(
ufd
,
2
,
-
1
);
if
(
val
==
-
1
)
continue
;
if
(
ufd
[
1
].
revents
)
{
if
(
sent
>
0
)
return
sent
;
msg_Dbg
(
session
,
"socket %d polling interrupted"
,
session
->
fd
);
errno
=
EINTR
;
return
-
1
;
}
}
}
char
*
vlc_tls_GetLine
(
vlc_tls_t
*
session
)
{
char
*
line
=
NULL
;
size_t
linelen
=
0
,
linesize
=
0
;
do
{
if
(
linelen
==
linesize
)
{
linesize
+=
1024
;
char
*
newline
=
realloc
(
line
,
linesize
);
if
(
unlikely
(
newline
==
NULL
))
goto
error
;
line
=
newline
;
}
if
(
vlc_tls_Read
(
session
,
line
+
linelen
,
1
,
false
)
<=
0
)
goto
error
;
}
while
(
line
[
linelen
++
]
!=
'\n'
);
if
(
linelen
>=
2
&&
line
[
linelen
-
2
]
==
'\r'
)
line
[
linelen
-
2
]
=
'\0'
;
return
line
;
error:
free
(
line
);
return
NULL
;
}
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