Add stub implementation of DCM ext API in client library 48/254648/11
authorTomasz Swierczek <t.swierczek@samsung.com>
Fri, 5 Mar 2021 12:13:19 +0000 (13:13 +0100)
committerTomasz Swierczek <t.swierczek@samsung.com>
Thu, 1 Apr 2021 11:41:56 +0000 (13:41 +0200)
Since this commit, clients can link with new DCM ext API
library (SO file is properly provided).

Current implemenation of ext client API just returns error.

Change-Id: If07f0714a2497d84ed1673d2ce2ded05c541ea48

packaging/device-certificate-manager.spec
pkgconfig/CMakeLists.txt
pkgconfig/device-certificate-manager-ext.pc.in [new file with mode: 0644]
src/dcm-client/CMakeLists.txt
src/dcm-client/device_certificate_manager_ext.cpp [new file with mode: 0644]
src/dcm-client/version_script_ext.lds [new file with mode: 0644]

index 1bacc49fd4ff97d130cd0e3d0b732b6889cea29b..e049bfe7b2903094b9ef38c6101c536deff5dec0 100644 (file)
@@ -130,6 +130,7 @@ fi
 %license LICENSE
 %{_bindir}/device-certificate-managerd
 %{_libdir}/libdevice-certificate-manager.so.*
+%{_libdir}/libdevice-certificate-manager-ext.so.*
 %{_unitdir}/device-certificate-manager.service
 %{_unitdir}/sockets.target.wants/device-certificate-manager.socket
 %{_unitdir}/device-certificate-manager.socket
@@ -144,8 +145,10 @@ fi
 %files ext-devel
 %manifest %{name}.manifest
 %license LICENSE
+%{_libdir}/libdevice-certificate-manager-ext.so
 %{_includedir}/device-certificate-manager/device_certificate_manager_ext.h
 %{_includedir}/device-certificate-manager/device_certificate_manager_ext_types.h
+%{_libdir}/pkgconfig/device-certificate-manager-ext.pc
 
 %files backend-devel
 %manifest %{name}.manifest
index f1362bb0ae3e814f8d64282e85866503047bf81e..08b647018304c2c95cc8f370c6d769f97caa5354 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2019 - 2020 Samsung Electronics Co., Ltd All Rights Reserved
+# Copyright (c) 2019 - 2021 Samsung Electronics Co., Ltd All Rights Reserved
 #
 #    Licensed under the Apache License, Version 2.0 (the "License");
 #    you may not use this file except in compliance with the License.
 #
 
 CONFIGURE_FILE(device-certificate-manager.pc.in device-certificate-manager.pc @ONLY)
+CONFIGURE_FILE(device-certificate-manager-ext.pc.in device-certificate-manager-ext.pc @ONLY)
 CONFIGURE_FILE(device-certificate-manager-backend.pc.in device-certificate-manager-backend.pc @ONLY)
 
 INSTALL(FILES
        ${CMAKE_CURRENT_BINARY_DIR}/device-certificate-manager.pc
+       ${CMAKE_CURRENT_BINARY_DIR}/device-certificate-manager-ext.pc
        ${CMAKE_CURRENT_BINARY_DIR}/device-certificate-manager-backend.pc
        DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
diff --git a/pkgconfig/device-certificate-manager-ext.pc.in b/pkgconfig/device-certificate-manager-ext.pc.in
new file mode 100644 (file)
index 0000000..fc3ffc7
--- /dev/null
@@ -0,0 +1,10 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=${prefix}
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=${prefix}/include
+
+Name: device-certificate-manager-ext
+Description: Device Certificate Manager Extension Package
+Version: @PROJECT_VERSION@
+Libs: -L${libdir} -ldevice-certificate-manager-ext
+Cflags: -I${includedir}/device-certificate-manager
index daea88ad718a989d0d129b8f16fb22d0022b17bb..4f7f60dafb7e0557971d585dcef64fb53693c54e 100644 (file)
@@ -32,6 +32,8 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
 PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS dcm_support.proto)
 
 SET(TARGET_CLIENT "device-certificate-manager")
+SET(TARGET_CLIENT_EXT "device-certificate-manager-ext")
+
 ADD_LIBRARY(${TARGET_CLIENT}
        SHARED
        dcm_client.cpp
@@ -41,13 +43,26 @@ ADD_LIBRARY(${TARGET_CLIENT}
        ${PROTO_SRCS}
        ${PROTO_HDRS})
 
+ADD_LIBRARY(${TARGET_CLIENT_EXT}
+       SHARED
+       device_certificate_manager_ext.cpp
+       ../shared/log.cpp
+       )
+
 TARGET_LINK_LIBRARIES(${TARGET_CLIENT}
        ${Boost_SYSTEM_LIBRARY}
        ${PROTOBUF_LITE_LIBRARIES}
        ${CLIENT_DEPS_LIBRARIES}
        ${CMAKE_THREAD_LIBS_INIT})
 
+TARGET_LINK_LIBRARIES(${TARGET_CLIENT_EXT}
+       ${Boost_SYSTEM_LIBRARY}
+       ${CLIENT_DEPS_LIBRARIES}
+       ${CMAKE_THREAD_LIBS_INIT})
+
 SET_PROPERTY(TARGET ${TARGET_CLIENT} APPEND PROPERTY LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/version_script.lds")
+SET_PROPERTY(TARGET ${TARGET_CLIENT_EXT} APPEND PROPERTY LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/version_script_ext.lds")
+
 SET_TARGET_PROPERTIES(${TARGET_CLIENT}
        PROPERTIES
        VERSION ${PROJECT_VERSION}
@@ -56,7 +71,15 @@ SET_TARGET_PROPERTIES(${TARGET_CLIENT}
        C_VISIBILITY_PRESET hidden
        CXX_VISIBILITY_PRESET hidden)
 
-INSTALL(TARGETS ${TARGET_CLIENT}
+SET_TARGET_PROPERTIES(${TARGET_CLIENT_EXT}
+       PROPERTIES
+       VERSION ${PROJECT_VERSION}
+       DEFINE_SYMBOL DEVICE_CERTIFICATE_MANAGER_EXT_EXPORT
+       VISIBILITY_INLINES_HIDDEN TRUE
+       C_VISIBILITY_PRESET hidden
+       CXX_VISIBILITY_PRESET hidden)
+
+INSTALL(TARGETS ${TARGET_CLIENT} ${TARGET_CLIENT_EXT}
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
 
 INSTALL(FILES
diff --git a/src/dcm-client/device_certificate_manager_ext.cpp b/src/dcm-client/device_certificate_manager_ext.cpp
new file mode 100644 (file)
index 0000000..ce3c4f8
--- /dev/null
@@ -0,0 +1,37 @@
+/******************************************************************
+ *
+ * Copyright 2021 Samsung Electronics All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************/
+
+#include "device_certificate_manager_ext.h"
+#include "log.h"
+
+#ifndef API_DEVICE_CERTIFICATE_MANAGER_EXT_EXPORT
+#define API_DEVICE_CERTIFICATE_MANAGER_EXT_EXPORT __attribute__((visibility("default")))
+#endif
+
+API_DEVICE_CERTIFICATE_MANAGER_EXT_EXPORT
+int dcm_ext_call_api(const char* method_name, const char* input_data, size_t input_len,
+                     char** output_data, size_t* output_len)
+{
+    (void) method_name;
+    (void) input_data;
+    (void) input_len;
+    (void) output_data;
+    (void) output_len;
+    LOGE("No implementation yet - TODO");
+    return DCM_EXT_ERROR_UNKNOWN;
+}
diff --git a/src/dcm-client/version_script_ext.lds b/src/dcm-client/version_script_ext.lds
new file mode 100644 (file)
index 0000000..50acf01
--- /dev/null
@@ -0,0 +1,6 @@
+DCMEXTCLIENT_1.0 {
+       global:
+               dcm_ext_call_api;
+       local:
+               *;
+};