bneradt commented on code in PR #12790:
URL: https://github.com/apache/trafficserver/pull/12790#discussion_r2738473869
##########
include/ts/apidefs.h.in:
##########
@@ -1044,6 +1044,86 @@ struct TSHttp2Priority {
* or -1 if the stream has no dependency. */
int32_t stream_dependency;
};
+/**
+ * A structure for SSL Client Hello data
+ */
+struct tsapi_ssl_client_hello {
+ uint16_t version{0};
+ const uint8_t *cipher_suites{nullptr};
+ size_t cipher_suites_len{0};
+ const uint8_t *extensions{nullptr};
+ size_t extensions_len{0};
+ int *extension_ids{nullptr};
+ size_t extension_ids_len{0};
+ void *ssl_ptr{nullptr};
+};
+
+// Wrapper class that provides controlled access to client hello data
+class TSClientHelloImpl
+{
+public:
+ TSClientHelloImpl(tsapi_ssl_client_hello *ch) : _ssl_client_hello(ch) {}
+
+ ~TSClientHelloImpl() { delete _ssl_client_hello; }
+
+ uint16_t
+ get_version() const
+ {
+ return _ssl_client_hello->version;
+ }
+
+ const uint8_t *
+ get_cipher_suites() const
+ {
+ return _ssl_client_hello->cipher_suites;
+ }
+
+ size_t
+ get_cipher_suites_len() const
+ {
+ return _ssl_client_hello->cipher_suites_len;
+ }
+
+ const uint8_t *
+ get_extensions() const
+ {
+ return _ssl_client_hello->extensions;
+ }
+
+ size_t
+ get_extensions_len() const
+ {
+ return _ssl_client_hello->extensions_len;
+ }
+
+ const int *
+ get_extension_ids() const
+ {
+ return _ssl_client_hello->extension_ids;
+ }
+
+ size_t
+ get_extension_ids_len() const
+ {
+ return _ssl_client_hello->extension_ids_len;
+ }
+
+ void *
+ get_ssl_ptr() const
+ {
+ return _ssl_client_hello->ssl_ptr;
+ }
+
+ // Internal accessor for API implementation
+ tsapi_ssl_client_hello *
+ _get_internal() const
+ {
+ return _ssl_client_hello;
+ }
+
+private:
+ tsapi_ssl_client_hello *_ssl_client_hello;
Review Comment:
Since the TSClientHelloImpl takes ownership of the tsapi_ssl_client_hello,
lets manage this as a std::unique_ptr:
```cpp
TSClientHelloImpl(std::unique_ptr<tsapi_ssl_client_hello> ch) :
_ssl_client_hello(std::move(ch)) {}
~TSClientHelloImpl() = default;
...
std::unique_ptr<tsapi_ssl_client_hello> _ssl_client_hello;
```
With a call interface like:
```cpp
auto ch = std::make_unique<tsapi_ssl_client_hello>();
...
return new TSClientHelloImpl(std::move(ch));
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]