1 /* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
2 
3   This program is free software; you can redistribute it and/or modify
4   it under the terms of the GNU General Public License, version 2.0,
5   as published by the Free Software Foundation.
6 
7   This program is also distributed with certain software (including
8   but not limited to OpenSSL) that is licensed under separate terms,
9   as designated in a particular file or component or in included license
10   documentation.  The authors of MySQL hereby grant you an additional
11   permission to link the program and your derivative works with the
12   separately licensed software that they have included with MySQL.
13 
14   This program is distributed in the hope that it will be useful,
15   but WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   GNU General Public License, version 2.0, for more details.
18 
19   You should have received a copy of the GNU General Public License
20   along with this program; if not, write to the Free Software
21   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */
22 
23 #ifndef COMPONENT_SERVICES_PSI_TLS_CHANNEL_BITS_H
24 #define COMPONENT_SERVICES_PSI_TLS_CHANNEL_BITS_H
25 
26 /**
27   @file
28   Instrumentation helpers for TLS channels.
29   This header file provides necessary declarations to instrument
30   TLS context information.
31 */
32 
33 /**
34   @defgroup psi_abi_tls_channel TLS Channel Instrumentation (ABI)
35   @ingroup psi_abi
36   @{
37 */
38 
39 /**
40   @def PSI_TLS_CHANNEL_VERSION_1
41   Performance Schema TLS Channel Interface number for version 1.
42   This version is supported.
43 */
44 #define PSI_TLS_CHANNEL_VERSION_1 1
45 
46 /**
47   @def PSI_CURRENT_TLS_CHANNEL_VERSION
48   Performance Schema TLS Channel Interface number for the most recent version.
49   The most current version is @c PSI_TLS_CHANNEL_VERSION_1
50 */
51 #define PSI_CURRENT_TLS_CHANNEL_VERSION 1
52 
53 const size_t MAX_CHANNEL_NAME_SIZE = 64;
54 const size_t MAX_PROPERTY_NAME_SIZE = 64;
55 const size_t MAX_PROPERTY_VALUE_SIZE = 512;
56 
57 /** TLS property */
58 class TLS_channel_property {
59  public:
60   /** Channel name */
61   char channel_name[MAX_CHANNEL_NAME_SIZE + 1];
62   /** Property name */
63   char property_name[MAX_PROPERTY_NAME_SIZE + 1];
64   /** Property value */
65   char property_value[MAX_PROPERTY_VALUE_SIZE + 1];
66 };
67 
68 /** Iterator object */
69 typedef struct property_iterator_imp *property_iterator;
70 
71 /**
72   Initialize TLS property iterator
73 
74   @param [out] iterator TLS Property iterator object
75 
76   @returns Result of iterator creation
77     @retval true  Success
78     @retval false Failure
79 */
80 typedef bool (*init_tls_property_iterator_t)(property_iterator *iterator);
81 
82 /**
83   De-initialize TLS property iterator
84 
85   @param [in] iterator TLS Property iterator object
86 */
87 typedef void (*deinit_tls_property_iterator_t)(property_iterator iterator);
88 
89 /**
90   Get one TLS property information from current iterator position
91 
92   @param [in]  iterator TLS Property iterator object
93   @param [out] property Property details
94 
95   @returns status of fetch operation
96     @retval true  Success
97     @retval false Failure
98 */
99 typedef bool (*get_tls_property_t)(property_iterator iterator,
100                                    TLS_channel_property *property);
101 
102 /**
103   Move TLS Property iterator to next position
104 
105   @param [in] iterator TLS Property iterator object
106 
107   @returns Status of operation
108     @retval true  Success
109     @retval false Iterator reached at the end
110 */
111 typedef bool (*next_tls_property_t)(property_iterator iterator);
112 
113 /** Property iterator callbacks */
114 struct TLS_channel_property_iterator {
115   init_tls_property_iterator_t init_tls_property_iterator;
116   deinit_tls_property_iterator_t deinit_tls_property_iterator;
117   get_tls_property_t get_tls_property;
118   next_tls_property_t next_tls_property;
119 };
120 
121 typedef struct TLS_channel_property_iterator TLS_channel_property_iterator;
122 
123 /**
124   TLS channel information registration API
125 */
126 typedef void (*register_tls_channel_v1_t)(
127     TLS_channel_property_iterator *provider);
128 
129 /**
130   TLS channel information un registration API
131 */
132 typedef void (*unregister_tls_channel_v1_t)(
133     TLS_channel_property_iterator *provider);
134 
135 /** @} (end of group psi_abi_tls_channel) */
136 #endif  // !COMPONENT_SERVICES_PSI_TLS_CHANNEL_BITS_H
137