-
Notifications
You must be signed in to change notification settings - Fork 6
PS-10068 Production code for new KMIP C++ library #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
PS-10068 Production code for new KMIP C++ library #23
Conversation
The "kmipclient" C++ library implementation is added, that wraps low-level "kmip.h" calls and bypasses mid-level "kmip_bio" level.
https://perconadev.atlassian.net/browse/PS-10068 Addressing PR comments and other fixes, finallizing the interface of the library, adding test suite
f5f8fbc to
6da142e
Compare
kmipclient/CMakeLists.txt
Outdated
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -g") | ||
| set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address -g") | ||
|
|
||
| include_directories(${PROJECT_SOURCE_DIR}/include) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to target_include_directories
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
kmipclient/CMakeLists.txt
Outdated
| set(CMAKE_CXX_STANDARD 23) | ||
| set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
| set(CMAKE_CXX_EXTENSIONS OFF) # Optional, but recommended for standard compliance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use target-specific options
target_compile_features(target INTERFACE cxx_std_20)
set_target_properties(my_target PROPERTIES
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Kid of. I still need 2 statements at the top of CMakeLists.txt to compile
kmipclient/CMakeLists.txt
Outdated
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -g") | ||
| set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address -g") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unconditionaly always enabled Address Sanitazer looks weird to me. I would declare an option
option(WITH_ASAN "Enable Address Sanitizer" OFF)
if(WITH_ASAN)
target_compile_options(mytarget INTERFACE "-fsanitize=address")
target_link_options(mytarget INTERFACE "-fsanitize=address")
endif()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
| ) | ||
|
|
||
| target_link_libraries(kmipclient kmip) | ||
| set_property(TARGET kmipclient PROPERTY POSITION_INDEPENDENT_CODE ON) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set_target_property()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not fixed, there's no such funtion
kmipclient/CMakeLists.txt
Outdated
|
|
||
| macro(add_example name) | ||
| add_executable(example_${name} examples/example_${name}.cpp) | ||
| target_link_libraries(example_${name} kmipclient) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| target_link_libraries(example_${name} kmipclient) | |
| target_link_libraries(example_${name} PRIVATE kmipclient) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
kmipclient/src/KmipClient.cpp
Outdated
| KmipClient::KmipClient (NetClient &net_client, const std::shared_ptr<Logger> &log) : net_client (net_client) | ||
| { | ||
| io = std::make_unique<IOUtils> (net_client); | ||
| logger = log; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| KmipClient::KmipClient (NetClient &net_client, const std::shared_ptr<Logger> &log) : net_client (net_client) | |
| { | |
| io = std::make_unique<IOUtils> (net_client); | |
| logger = log; | |
| } | |
| KmipClient::KmipClient (NetClient &net_client, const std::shared_ptr<Logger> &log) : net_client (net_client), | |
| io(std::make_unique<IOUtils> (net_client)), | |
| logger(log) | |
| {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in all constructors
| int buffer_blocks = 1; | ||
| const int buffer_block_size = 1024; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, signed types for sizes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the reason is signed types in the lower level functions (kmip.h).
| inline void | ||
| KmipRequest::add_batch_item (RequestBatchItem *rbi) | ||
| { | ||
| // Sorry, C++ guys, we have to use address arithmetic here because of the lower level |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I know, I know... The goal of the next development iteration is to replace kmip.c with KmipSerializer and KmipDeserializer classes and get rid of all malloc's and address arithmetic. So, ... let's keep it for a while this way. You can't imageine what a mess we have in a "heritage" code.
kmipclient/src/NetClientOpenSSL.cpp
Outdated
| return BIO_read (bio_, data, dlen); | ||
| } | ||
|
|
||
| } // namespace No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No EOL at the end of file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
| static void create_get_rq (KmipCtx &ctx, const id_t &id); | ||
| static void create_activate_rq (KmipCtx &ctx, const id_t &id); | ||
| static void create_create_aes_rq (KmipCtx &ctx, const name_t &name, const name_t &group); | ||
| static void create_register_key_rq (KmipCtx &ctx, const name_t &name, const name_t &group, const Key &k); | ||
| static void create_register_secret_rq (KmipCtx &ctx, const name_t &name, const name_t &group, std::string &secret, | ||
| int secret_data_type); | ||
| static void create_revoke_rq (KmipCtx &ctx, const id_t &id, int reason, const name_t &message, | ||
| time_t occurrence_time); | ||
| static void create_destroy_rq (KmipCtx &ctx, const id_t &id); | ||
| static void create_get_attributes_rq (KmipCtx &ctx, const id_t &id, const std::vector<std::string> &attr_names); | ||
| static void create_get_attribute_list_rq (KmipCtx &ctx, const id_t &id); | ||
| static void create_locate_by_name_rq (KmipCtx &ctx, const name_t &name, enum object_type o_type, int max_items, | ||
| int offset); | ||
| static void create_locate_by_group_rq (KmipCtx &ctx, const name_t &group_name, enum object_type o_type, int max_items, | ||
| size_t offset); | ||
| static void create_locate_all_rq (KmipCtx &ctxm, enum object_type o_type, int max_items, int offset); | ||
|
|
||
| private: | ||
| static void create_locate_rq (KmipCtx &ctx, bool is_group, const name_t &name, enum object_type o_type, int max_items, | ||
| size_t offset); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove enum for types, use std::size_t for sizes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
c407d1d to
95a4c5f
Compare
95a4c5f to
8e534f5
Compare
The "kmipclient" C++ library implementation is added, that wraps low-level "kmip.h" calls and bypasses mid-level "kmip_bio" level. The kmip.h file was splitted in 3 to export enums, structures and functions separately.
Comparing to the 1st version (POC), The interface was simplified and uses exceptions now.
There are plans to replace C implementation of the protocol serialization/deserialization (kmip.c and others) with C++ code, so the current version of "kmipclient" library contains a lot of TODO and skeletons for future work. Ath this stage of development, the middle-level C implementation (kmip_bio.c) is removed and the library works directly with kmip.c.
Previous PR of POC is closed.