xine-lib  1.2.10
xine_tls_plugin.h
Go to the documentation of this file.
1  /*
2  * Copyright (C) 2019 the xine project
3  * Copyright (C) 2018 Petri Hintukainen <phintuka@users.sourceforge.net>
4  *
5  * This file is part of xine, a free video player.
6  *
7  * xine is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * xine is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
20  *
21  * xine TLS provider plugin interface
22  */
23 
24 #ifndef _XINE_TLS_PLUGIN_H_
25 #define _XINE_TLS_PLUGIN_H_
26 
27 #include <sys/types.h>
28 
29 #include <xine/xine_module.h>
30 
31 #define TLS_PLUGIN_TYPE "tls_v1"
32 
33 typedef struct {
36  int fd;
38 
39 typedef struct tls_plugin_s tls_plugin_t;
40 
41 struct tls_plugin_s {
43 
44  int (*handshake)(tls_plugin_t *, const char *host, int verify);
45  void (*shutdown)(tls_plugin_t *);
46 
47  ssize_t (*read)(tls_plugin_t *, void *buf, size_t len);
48  ssize_t (*write)(tls_plugin_t *, const void *buf, size_t len);
49  ssize_t (*part_read)(tls_plugin_t *, void *buf, size_t min, size_t max);
50 };
51 
52 /*
53  * config helpers
54  */
55 
56 #include <xine/configfile.h>
57 
58 #define TLS_VERIFY_CERT_KEY "media.network.verify_tls_certificate"
59 
60 static inline void tls_register_config_keys(config_values_t *config)
61 {
62  config->register_bool(config,
64  1, _("Verify server TLS certificate"),
65  _("If enabled, server TLS certificate is always checked. "
66  "If check fails, connections to server are not allowed."),
67  10, NULL, NULL);
68 }
69 
70 static inline int tls_get_verify_tls_cert(config_values_t *config)
71 {
72  cfg_entry_t *entry;
73 
74  entry = config->lookup_entry(config, TLS_VERIFY_CERT_KEY);
75  if (entry) {
76  return entry->num_value;
77  }
78  return 1;
79 }
80 
81 #endif /* _XINE_TLS_PLUGIN_H_ */
xine_s
Definition: xine_internal.h:80
tls_register_config_keys
static void tls_register_config_keys(config_values_t *config)
Definition: xine_tls_plugin.h:60
xine_stream_s
Definition: xine_internal.h:123
config_values_s::lookup_entry
cfg_entry_t *(* lookup_entry)(config_values_t *self, const char *key)
lookup config entries
Definition: configfile.h:182
tls_plugin_params_t::stream
xine_stream_t * stream
Definition: xine_tls_plugin.h:35
xine_module_s
Definition: xine_module.h:62
tls_plugin_s
Definition: xine_tls_plugin.h:41
tls_plugin_params_t::fd
int fd
Definition: xine_tls_plugin.h:36
NULL
NULL
Definition: xine_plugin.c:78
TLS_VERIFY_CERT_KEY
#define TLS_VERIFY_CERT_KEY
Definition: xine_tls_plugin.h:58
cfg_entry_s::num_value
int num_value
Definition: configfile.h:64
_
#define _(String)
Definition: vcdplayer.h:39
config_values_s
Definition: configfile.h:83
tls_plugin_s::write
ssize_t(* write)(tls_plugin_t *, const void *buf, size_t len)
Definition: xine_tls_plugin.h:48
tls_get_verify_tls_cert
static int tls_get_verify_tls_cert(config_values_t *config)
Definition: xine_tls_plugin.h:70
tls_plugin_params_t
Definition: xine_tls_plugin.h:33
xine_module.h
tls_plugin_s::module
xine_module_t module
Definition: xine_tls_plugin.h:42
tls_plugin_s::read
ssize_t(* read)(tls_plugin_t *, void *buf, size_t len)
Definition: xine_tls_plugin.h:47
tls_plugin_params_t::xine
xine_t * xine
Definition: xine_tls_plugin.h:34
tls_plugin_s::shutdown
void(* shutdown)(tls_plugin_t *)
Definition: xine_tls_plugin.h:45
cfg_entry_s
Definition: configfile.h:46
configfile.h
tls_plugin_s::handshake
int(* handshake)(tls_plugin_t *, const char *host, int verify)
Definition: xine_tls_plugin.h:44
tls_plugin_s::part_read
ssize_t(* part_read)(tls_plugin_t *, void *buf, size_t min, size_t max)
Definition: xine_tls_plugin.h:49
config_values_s::register_bool
int(* register_bool)(config_values_t *self, const char *key, int def_value, const char *description, const char *help, int exp_level, xine_config_cb_t changed_cb, void *cb_data)
Definition: configfile.h:154