maskit commented on code in PR #12790:
URL: https://github.com/apache/trafficserver/pull/12790#discussion_r2742848310


##########
include/ts/apidefs.h.in:
##########
@@ -1044,6 +1046,122 @@ 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(std::unique_ptr<tsapi_ssl_client_hello> ch) : 
_ssl_client_hello(std::move(ch)) {}
+
+  ~TSClientHelloImpl() = default;
+
+  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;
+  }
+
+  // Returns a vector of extension type IDs
+  // This abstracts the difference between BoringSSL (extensions buffer) and 
OpenSSL (extension_ids array)
+  std::vector<uint16_t>

Review Comment:
   Hmm, I was expecting a custom iterable object. This implementation copies 
each item (extension type) into a vector. A custom iterator that internally 
manages an index/offset would avoid the copy.
   
   Maybe we can hide the actual type, which is currently std:vector, by 
typedef/using for now, and tell that this function returns an iterable object. 
Then we can replace/optimize the implementation later. It would be nice if we 
could declare it like Iterable interface in Java, but I'm not sure how to do it 
in C++.



-- 
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]

Reply via email to