aws-crt-cpp
C++ wrapper around the aws-c-* libraries. Provides Cross-Platform Transport Protocols and SSL/TLS implementations for C++.
Api.h
Go to the documentation of this file.
1#pragma once
6#include <aws/crt/Types.h>
13
14#include <aws/common/logging.h>
15
16namespace Aws
17{
18 namespace Crt
19 {
23 enum class LogLevel
24 {
25 None = AWS_LL_NONE,
26 Fatal = AWS_LL_FATAL,
27 Error = AWS_LL_ERROR,
28 Warn = AWS_LL_WARN,
29 Info = AWS_LL_INFO,
30 Debug = AWS_LL_DEBUG,
31 Trace = AWS_LL_TRACE,
32
33 Count
34 };
35
40 {
43 };
44
50 {
51 public:
52 ApiHandle(Allocator *allocator) noexcept;
53 ApiHandle() noexcept;
54 ~ApiHandle();
55 ApiHandle(const ApiHandle &) = delete;
56 ApiHandle(ApiHandle &&) = delete;
57 ApiHandle &operator=(const ApiHandle &) = delete;
59
66 void InitializeLogging(LogLevel level, const char *filename);
67
74 void InitializeLogging(LogLevel level, FILE *fp);
75
80 void SetShutdownBehavior(ApiHandleShutdownBehavior behavior);
81
86 void SetBYOCryptoNewMD5Callback(Crypto::CreateHashCallback &&callback);
87
92 void SetBYOCryptoNewSHA256Callback(Crypto::CreateHashCallback &&callback);
93
98 void SetBYOCryptoNewSHA256HMACCallback(Crypto::CreateHMACCallback &&callback);
99
105 void SetBYOCryptoClientTlsCallback(Io::NewClientTlsHandlerCallback &&callback);
106
116 void SetBYOCryptoTlsContextCallbacks(
117 Io::NewTlsContextImplCallback &&newCallback,
118 Io::DeleteTlsContextImplCallback &&deleteCallback,
119 Io::IsTlsAlpnSupportedCallback &&alpnCallback);
120
122 static const Io::NewTlsContextImplCallback &GetBYOCryptoNewTlsContextImplCallback();
124 static const Io::DeleteTlsContextImplCallback &GetBYOCryptoDeleteTlsContextImplCallback();
126 static const Io::IsTlsAlpnSupportedCallback &GetBYOCryptoIsTlsAlpnSupportedCallback();
127
128 private:
129 void InitializeLoggingCommon(struct aws_logger_standard_options &options);
130
131 aws_logger m_logger;
132
133 ApiHandleShutdownBehavior m_shutdownBehavior;
134 };
135
141 AWS_CRT_CPP_API const char *ErrorDebugString(int error) noexcept;
142
146 AWS_CRT_CPP_API int LastError() noexcept;
147
152 AWS_CRT_CPP_API int LastErrorOrUnknown() noexcept;
153 } // namespace Crt
154} // namespace Aws
#define AWS_CRT_CPP_API
Definition: Exports.h:37
Definition: Api.h:50
ApiHandle(ApiHandle &&)=delete
ApiHandle & operator=(ApiHandle &&)=delete
ApiHandle & operator=(const ApiHandle &)=delete
ApiHandle(const ApiHandle &)=delete
std::function< std::shared_ptr< ByoHMAC >(size_t digestSize, const ByteCursor &secret, Allocator *)> CreateHMACCallback
Definition: HMAC.h:146
std::function< std::shared_ptr< ByoHash >(size_t digestSize, Allocator *)> CreateHashCallback
Definition: Hash.h:164
std::function< void *(TlsContextOptions &, TlsMode, Allocator *)> NewTlsContextImplCallback
Definition: TlsOptions.h:367
std::function< bool()> IsTlsAlpnSupportedCallback
Definition: TlsOptions.h:369
std::function< std::shared_ptr< ClientTlsChannelHandler >(struct aws_channel_slot *slot, const struct aws_tls_connection_options &options, Allocator *allocator)> NewClientTlsHandlerCallback
Definition: TlsOptions.h:430
std::function< void(void *)> DeleteTlsContextImplCallback
Definition: TlsOptions.h:368
AWS_CRT_CPP_API int LastErrorOrUnknown() noexcept
Definition: Api.cpp:317
ApiHandleShutdownBehavior
Definition: Api.h:40
AWS_CRT_CPP_API const char * ErrorDebugString(int error) noexcept
Definition: Api.cpp:313
LogLevel
Definition: Api.h:24
aws_allocator Allocator
Definition: StlAllocator.h:17
AWS_CRT_CPP_API int LastError() noexcept
Definition: Api.cpp:315
Definition: Api.h:17
Definition: cJSON.cpp:105