From 5a421a8c91d2a597b5809fb1b1a75f9eacc4ff43 Mon Sep 17 00:00:00 2001 From: "saerome.kim" Date: Fri, 8 Dec 2017 19:22:30 +0900 Subject: [PATCH] Clean up base codes Signed-off-by: saerome.kim --- CMakeLists.txt | 42 +- packaging/d2d-manager.service | 8 +- packaging/d2d-manager.spec | 37 +- packaging/d2d-subowner.service | 12 + packaging/fn-manager.service | 14 + packaging/net.d2d.manager.service | 2 +- packaging/net.d2d.subowner.service | 7 + packaging/net.fn.manager.service | 10 + src/d2d-manager/.d2d-manager.c.swp | Bin 0 -> 12288 bytes src/d2d-manager/.d2d-manager.h.swp | Bin 0 -> 12288 bytes src/d2d-manager/CMakeLists.txt | 11 + src/d2d-manager/d2d-manager-log.h | 62 ++ src/d2d-manager/d2d-manager.c | 79 ++ src/d2d-manager/d2d-manager.h | 50 + src/fn-manager/CMakeLists.txt | 11 + src/fn-manager/fn-manager.c | 529 ++++++++++ src/include/.d2d-common.h.swp | Bin 0 -> 12288 bytes {test => src}/include/cjson/cJSON.h | 0 {test => src}/include/coap/address.h | 0 {test => src}/include/coap/async.h | 0 {test => src}/include/coap/bits.h | 0 {test => src}/include/coap/block.h | 0 {test => src}/include/coap/coap.h | 0 {test => src}/include/coap/coap_list.h | 0 {test => src}/include/coap/coap_time.h | 0 {test => src}/include/coap/config.h | 0 {test => src}/include/coap/debug.h | 0 {test => src}/include/coap/encode.h | 0 {test => src}/include/coap/hashkey.h | 0 {test => src}/include/coap/mem.h | 0 {test => src}/include/coap/net.h | 0 {test => src}/include/coap/option.h | 0 {test => src}/include/coap/pdu.h | 0 {test => src}/include/coap/prng.h | 0 {test => src}/include/coap/resource.h | 0 {test => src}/include/coap/str.h | 0 {test => src}/include/coap/subscribe.h | 0 {test => src}/include/coap/t_list.h | 0 {test => src}/include/coap/uri.h | 0 {test => src}/include/coap/uthash.h | 0 {test => src}/include/coap/utlist.h | 0 include/d2dd-util.h => src/include/d2d-common.h | 8 +- src/include/d2d-log.h | 62 ++ {test => src}/include/hw_emul/hw_interface.h | 0 {test => src}/include/hw_emul/ss_emul.h | 0 {test => src}/include/security/base64.h | 0 {test => src}/include/security/iotvticalendar.h | 0 {test => src}/include/security/oxmverifycommon.h | 0 {test => src}/include/security/pbkdf2.h | 0 {test => src}/include/security/pinoxmcommon.h | 0 {test => src}/include/security/pkix_interface.h | 0 .../include/security/securevirtualresourcetypes.h | 0 {test => src}/include/security/srmutility.h | 0 src/subowner/CMakeLists.txt | 11 + src/subowner/d2d-subowner-log.h | 62 ++ src/subowner/d2d-subowner.c | 1046 ++++++++++++++++++++ test/CMakeLists.txt | 94 +- test/hw_interface.c | 105 +- test/ocamsservice.cpp | 12 +- test/ocserverbasicops.cpp | 42 +- test/provisioningclient.c | 308 +++--- test/sampleserver_justworks.cpp | 41 +- test/sampleserver_justworks_protectedDB.cpp | 46 +- test/sampleserver_mfg.cpp | 40 +- test/sampleserver_mvjustworks.cpp | 53 +- test/sampleserver_preconfpin.cpp | 40 +- test/sampleserver_randompin.cpp | 58 +- test/ss_emul.c | 72 +- test/subownerclient.c | 95 +- test/test.c | 6 - 70 files changed, 2523 insertions(+), 552 deletions(-) mode change 100644 => 100755 packaging/d2d-manager.spec create mode 100755 packaging/d2d-subowner.service create mode 100755 packaging/fn-manager.service create mode 100755 packaging/net.d2d.subowner.service create mode 100755 packaging/net.fn.manager.service create mode 100755 src/d2d-manager/.d2d-manager.c.swp create mode 100755 src/d2d-manager/.d2d-manager.h.swp create mode 100644 src/d2d-manager/CMakeLists.txt create mode 100644 src/d2d-manager/d2d-manager-log.h create mode 100644 src/d2d-manager/d2d-manager.c create mode 100644 src/d2d-manager/d2d-manager.h create mode 100644 src/fn-manager/CMakeLists.txt create mode 100644 src/fn-manager/fn-manager.c create mode 100755 src/include/.d2d-common.h.swp rename {test => src}/include/cjson/cJSON.h (100%) rename {test => src}/include/coap/address.h (100%) rename {test => src}/include/coap/async.h (100%) rename {test => src}/include/coap/bits.h (100%) rename {test => src}/include/coap/block.h (100%) rename {test => src}/include/coap/coap.h (100%) rename {test => src}/include/coap/coap_list.h (100%) rename {test => src}/include/coap/coap_time.h (100%) rename {test => src}/include/coap/config.h (100%) rename {test => src}/include/coap/debug.h (100%) rename {test => src}/include/coap/encode.h (100%) rename {test => src}/include/coap/hashkey.h (100%) rename {test => src}/include/coap/mem.h (100%) rename {test => src}/include/coap/net.h (100%) rename {test => src}/include/coap/option.h (100%) rename {test => src}/include/coap/pdu.h (100%) rename {test => src}/include/coap/prng.h (100%) rename {test => src}/include/coap/resource.h (100%) rename {test => src}/include/coap/str.h (100%) rename {test => src}/include/coap/subscribe.h (100%) rename {test => src}/include/coap/t_list.h (100%) rename {test => src}/include/coap/uri.h (100%) rename {test => src}/include/coap/uthash.h (100%) rename {test => src}/include/coap/utlist.h (100%) rename include/d2dd-util.h => src/include/d2d-common.h (89%) create mode 100644 src/include/d2d-log.h rename {test => src}/include/hw_emul/hw_interface.h (100%) rename {test => src}/include/hw_emul/ss_emul.h (100%) rename {test => src}/include/security/base64.h (100%) rename {test => src}/include/security/iotvticalendar.h (100%) rename {test => src}/include/security/oxmverifycommon.h (100%) rename {test => src}/include/security/pbkdf2.h (100%) rename {test => src}/include/security/pinoxmcommon.h (100%) rename {test => src}/include/security/pkix_interface.h (100%) rename {test => src}/include/security/securevirtualresourcetypes.h (100%) rename {test => src}/include/security/srmutility.h (100%) create mode 100644 src/subowner/CMakeLists.txt create mode 100644 src/subowner/d2d-subowner-log.h create mode 100644 src/subowner/d2d-subowner.c delete mode 100644 test/test.c diff --git a/CMakeLists.txt b/CMakeLists.txt index a287a52..1468b10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,45 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(d2d-manager-daemon C CXX) MESSAGE("===================================================================") -MESSAGE("Building...d2d-manager") +MESSAGE("Making...common configuration") MESSAGE("===================================================================") -SET(PREFIX ${CMAKE_INSTALL_PREFIX}) -SET(LIBDIR "${PREFIX}/lib") +MESSAGE(" - Set include folder") +INCLUDE(FindPkgConfig) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/include) -ADD_SUBDIRECTORY(src/subownerclient) +MESSAGE(" - Checking...packages dependency") +SET(COMMON_DEPS glib-2.0 gio-2.0 gio-unix-2.0 dlog dbus-1 iotivity uuid) +IF (LINUX) + PKG_CHECK_MODULES(daemon_pkgs REQUIRED ${COMMON_DEPS}) + ADD_DEFINITIONS("-DLINUX") +ELSE () + SET(TIZEN_DEPS dlog libtzplatform-config) + PKG_CHECK_MODULES(daemon_pkgs REQUIRED ${COMMON_DEPS} ${TIZEN_DEPS}) + ADD_DEFINITIONS("-DUSE_DLOG") +ENDIF() + +MESSAGE(" - Adding external C flags") +FOREACH(flag ${daemon_pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") + SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fpic") +SET(CMAKE_CXX_FLAGS "${EXTRA_CXXFLAGS} -std=gnu++11 -fPIC -fvisibility=hidden") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") + +MESSAGE(" - Define...iotivity macro") +ADD_DEFINITIONS("-D__TIZEN__") +ADD_DEFINITIONS("-DMULTIPLE_OWNER=1") +ADD_DEFINITIONS("-D__WITH_TLS__") +ADD_DEFINITIONS("-DWITH_TCP") +ADD_DEFINITIONS("-D__WITH_DTLS__") +ADD_DEFINITIONS("-DTCP_ADAPTER") + +MESSAGE(" - Start building src directories") +ADD_SUBDIRECTORY(src/d2d-manager) +ADD_SUBDIRECTORY(src/subowner) +ADD_SUBDIRECTORY(src/fn-manager) ADD_SUBDIRECTORY(test) diff --git a/packaging/d2d-manager.service b/packaging/d2d-manager.service index 099aa6a..5f4f684 100644 --- a/packaging/d2d-manager.service +++ b/packaging/d2d-manager.service @@ -1,6 +1,7 @@ [Unit] Description=OCF D2D Manager -After=feedbackd.service +Requires=dbus.socket +After=dbus.socket [Service] Type=dbus @@ -8,7 +9,4 @@ User=network_fw Group=network_fw BusName=net.d2d.manager SmackProcessLabel=System -ExecStart=/usr/bin/d2d-manager-daemon - -[Install] -WantedBy=multi-user.target \ No newline at end of file +ExecStart=/usr/bin/d2d-manager diff --git a/packaging/d2d-manager.spec b/packaging/d2d-manager.spec old mode 100644 new mode 100755 index 999afd9..7f64aa1 --- a/packaging/d2d-manager.spec +++ b/packaging/d2d-manager.spec @@ -9,7 +9,10 @@ Source2: %{name}.service Source3: %{name}.manifest Source4: %{name}-devel.manifest Source5: net.d2d.manager.service -#Source5: d2dpt.manifest +Source6: fn-manager.service +Source7: net.fn.manager.service +Source8: d2d-subowner.service +Source9: net.d2d.subowner.service BuildRequires: cmake BuildRequires: pkgconfig(iotivity) @@ -42,12 +45,20 @@ chmod 644 %{SOURCE0} chmod 644 %{SOURCE2} chmod 644 %{SOURCE3} chmod 644 %{SOURCE4} -#chmod 644 %{SOURCE5} +chmod 644 %{SOURCE5} +chmod 644 %{SOURCE6} +chmod 644 %{SOURCE7} +chmod 644 %{SOURCE8} +chmod 644 %{SOURCE9} cp %{SOURCE2} . cp %{SOURCE3} . cp %{SOURCE4} . -#cp %{SOURCE5} . +cp %{SOURCE5} . +cp %{SOURCE6} . +cp %{SOURCE7} . +cp %{SOURCE8} . +cp %{SOURCE9} . %build CFLAGS=$(echo $CFLAGS | sed 's/-O2/-O0/' | sed 's/-O1/-O0/' | sed 's/-Wp,-D_FORTIFY_SOURCE=2//') @@ -70,12 +81,17 @@ rm -rf %{buildroot}/BUILD/%{name}* %make_install mkdir -p %{buildroot}%{_datadir}/dbus-1/system-services/ -cp %{SOURCE4} %{buildroot}%{_datadir}/dbus-1/system-services/net.d2d.manager.service +cp %{SOURCE5} %{buildroot}%{_datadir}/dbus-1/system-services/net.d2d.manager.service +mkdir -p %{buildroot}%{_unitdir} +cp %{SOURCE2} %{buildroot}%{_unitdir}/%{name}.service -mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants +cp %{SOURCE7} %{buildroot}%{_datadir}/dbus-1/system-services/net.fn.manager.service +mkdir -p %{buildroot}%{_unitdir} +cp %{SOURCE6} %{buildroot}%{_unitdir}/fn-manager.service -cp %{SOURCE2} %{buildroot}%{_unitdir}/%{name}.service -ln -s %{SOURCE2} %{buildroot}%{_unitdir}/multi-user.target.wants/%{name}.service +cp %{SOURCE9} %{buildroot}%{_datadir}/dbus-1/system-services/net.d2d.subowner.service +mkdir -p %{buildroot}%{_unitdir} +cp %{SOURCE8} %{buildroot}%{_unitdir}/d2d-subowner.service cp test/oic_svr_db_client.dat oic_svr_db_subowner_client.dat @@ -83,10 +99,13 @@ cp test/oic_svr_db_client.dat oic_svr_db_subowner_client.dat %manifest %{name}.manifest %license LICENSE %defattr(-,root,root,-) -%{_bindir}/%{name}-daemon +%{_bindir}/%{name} +%{_bindir}/subowner +%{_bindir}/fn-manager %attr(644,root,root) %{_datadir}/dbus-1/system-services/* %attr(644,root,root) %{_unitdir}/%{name}.service -%attr(644,root,root) %{_unitdir}/multi-user.target.wants/%{name}.service +%attr(644,root,root) %{_unitdir}/fn-manager.service +%attr(644,root,root) %{_unitdir}/d2d-subowner.service %files devel %manifest %{name}-devel.manifest diff --git a/packaging/d2d-subowner.service b/packaging/d2d-subowner.service new file mode 100755 index 0000000..ca0fc1d --- /dev/null +++ b/packaging/d2d-subowner.service @@ -0,0 +1,12 @@ +[Unit] +Description=OCF D2D Sub-Owner Client +Requires=dbus.socket +After=dbus.socket + +[Service] +Type=dbus +User=network_fw +Group=network_fw +BusName=net.d2d.subowner +SmackProcessLabel=System +ExecStart=/usr/bin/d2d-subowner diff --git a/packaging/fn-manager.service b/packaging/fn-manager.service new file mode 100755 index 0000000..fdba735 --- /dev/null +++ b/packaging/fn-manager.service @@ -0,0 +1,14 @@ +[Unit] +Description=OCF Familynet Manager +After=feedbckd.service + +[Service] +Type=dbus +User=network_fw +Group=network_fw +BusName=net.fn.manager +SmackProcessLabel=System +ExecStart=/usr/bin/fn-manager + +[Install] +WantedBy=multi-user.target diff --git a/packaging/net.d2d.manager.service b/packaging/net.d2d.manager.service index 35576e8..187065c 100644 --- a/packaging/net.d2d.manager.service +++ b/packaging/net.d2d.manager.service @@ -4,4 +4,4 @@ Name=net.d2d.manager Exec=/bin/false User=network_fw Group=network_fw -SystemdService=d2dd.service +SystemdService=d2d-manager.service diff --git a/packaging/net.d2d.subowner.service b/packaging/net.d2d.subowner.service new file mode 100755 index 0000000..17bed18 --- /dev/null +++ b/packaging/net.d2d.subowner.service @@ -0,0 +1,7 @@ +[D-BUS Service] +Name=net.d2d.subowner + +Exec=/bin/false +User=network_fw +Group=network_fw +SystemdService=d2d-subowner.service diff --git a/packaging/net.fn.manager.service b/packaging/net.fn.manager.service new file mode 100755 index 0000000..0bbecfc --- /dev/null +++ b/packaging/net.fn.manager.service @@ -0,0 +1,10 @@ +[D-BUS Service] +Name=net.fn.manager + +Exec=/bin/false +User=network_fw +Group=network_fw +SystemdService=fn-manager.service + +[Install] +WantedBy=multi-user.target diff --git a/src/d2d-manager/.d2d-manager.c.swp b/src/d2d-manager/.d2d-manager.c.swp new file mode 100755 index 0000000000000000000000000000000000000000..7dbefb320abb95a5b29e784b936c5c38baa17a9f GIT binary patch literal 12288 zcmeI2&2Jk;7>B1^ilHsEoIoJGaY3?!znWGQ+N6@}Y}!>ETk=Ogg_ia1cs=TRciEkd zNvlc~H!g@G4*UfO32}oPC-?`7$^}Fb65Kf=4t)H^v0W!^P{n~mHC7(Qvpe(7JI}nc zhh%$|3+4u$ES+HZJjgn zOQ*`7kb|^mCEO{yOKx#!2e!xKauV-s&)q9Id&bi@v;l445e=lWUwr)_JHB+Rax}X@ z&mHML;y~R^8_)){0c}7V&<3;tZ9p5)1|Am!GTO)f#$uiTO|WkQe(8@kpbcmP+JH8o z4QK<}fHt5FXam}SHlPhWCI)Pmv0M8YyYnO#g#Z7mzXAOD3}g4e58yU^|84ud}qF!nR}27C=Z0k^>iAOu6u1k0cZ z3g8Gh41Rl>vAf_a@Fn;Hd*G2Rpo zxB4;Xxk)3x`=$sakNY;dxm*N7&UY*?(i+Cn+-r<9i9?HJW;9k$F_uB5Dpkt~U5*UK zsjXGbdbed@vdlDbBbRNZ!EAir7Cv_uvMM3br`$QK+o+rCM*VVbty*szw6a2on$OdX zu?a*T4S6zfXUmGyU{|s#zUniZ1W9h^=Y=vPzVv(s%Gt2sONHdXk!wuAPx20cq|Mcf(}k-CgI7S7epvsUfAQCqhz z7_GM1Y~+>-bo{jfRq|{$GJ~N5B;-40!> zwp!Ij$28j1Y*DS*ST#E+B(&D3+PF;XW@EKL9B*VJ7yeEZ^CTfmDTa|RxI0eC6>7!3 z6y@_^(j*d^?+^xr(#TfZWVW+(w%Rt^1(i@Y@KxxTznzL0fqGkHN0`I0dp^gaMru~u z!xPgbJZ?llqZo%g@CuZKeL1pYjxZ|HK+5P;xjY(;N_J#B16~SauZ&2_VN$M}HKWls zic6)+WWePxMZIlN*psL_vdIY}wE8+Oq$LQ+%-XZwp<{QS=v(M(=oa)G^!r)HeuaL3 zzK1yU7Ign*#=e4LD1ttQwxBiWZRkztS?J%F82bnM4*CX~Kn`>c`twD`eu8GuCFsEm zjQtJ$1^oj32z>#41f7Qnx{tWOgtj0TdJnn;nf;uD>}3g90+xU!U$3Wt3mV z^u{&Xod`#CRteW7v|XG*4p&=jgP#T=>9BYzJEXu{J7YaMe}D5@M$rd25N zDmbHy(?_Ohf`83ta+7u#g4%oK?K1BA-y5ncA+@z*=R^Jd6UNwbB9dwq$ba`u@NV zyne9b54L@GIGpEAWkOf`C7F{<4U<^cP!{GnUEg&&`+@Ind&6DVcROqI`M&tH6i7Qy zwBXSpX%V9eghuYo&KFm{?R33Pu;chn&xMQHftMce1Y9$&`Ba#UK0a@-`{gRP+F_6Giby^<=c>YSpM^x?5p`h%e3>^ik&hZmeuRgk!c z&CIKJVJCw*%%cso2UMXx;j-`2`?Ox04a?9J+qg`O-BE@`T27Br>X~}RX{o)1DiSoq zi^NprI;ze6`~q47Zey+wf!<=IySx>Gp?ibECChPuN!_YT=O7 zs6Zbfj;@&DZu}T$UKrnpwW%rZGB=sP_Qp6uU=xb0FmZ*-urb|wURlR8SZ8yQl~cue zl;<_NEwsrNAx2s?^Ox&M%NMTJL2n{PE#pZ+tKkLOSig9ghJ2crNVl7yrE8VSFsDt` sTBB|ewaCHGf@*?+Y + +#undef D2D_MAN_LOG_TAG +#define D2D_MAN_LOG_TAG "D2D_MANAGER" + +#define D2DM_LOGV(format, args...) LOGV(format, ##args) +#define D2DM_LOGD(format, args...) LOGD(format, ##args) +#define D2DM_LOGI(format, args...) LOGI(format, ##args) +#define D2DM_LOGW(format, args...) LOGW(format, ##args) +#define D2DM_LOGE(format, args...) LOGE(format, ##args) +#define D2DM_LOGF(format, args...) LOGF(format, ##args) + +#define __D2DM_LOG_FUNC_ENTER__ LOGD("Enter") +#define __D2DM_LOG_FUNC_EXIT__ LOGD("Quit") + +#define D2DM_SECLOGI(format, args...) SECURE_LOG(LOG_INFO, D2D_MAN_LOG_TAG, format, ##args) +#define D2DM_SECLOGD(format, args...) SECURE_LOG(LOG_DEBUG, D2D_MAN_LOG_TAG, format, ##args) + +#else /* USE_DLOG */ + +#define D2DM_LOGV(format, args...) +#define D2DM_LOGD(format, args...) +#define D2DM_LOGI(format, args...) +#define D2DM_LOGW(format, args...) +#define D2DM_LOGE(format, args...) +#define D2DM_LOGF(format, args...) + +#define __D2DM_LOG_FUNC_ENTER__ +#define __D2DM_LOG_FUNC_EXIT__ + +#define D2DM_SECLOGI(format, args...) +#define D2DM_SECLOGD(format, args...) + +#endif /* USE_DLOG */ + +#endif /* __D2D_MANAGER_LOG_H__ */ diff --git a/src/d2d-manager/d2d-manager.c b/src/d2d-manager/d2d-manager.c new file mode 100644 index 0000000..2edd988 --- /dev/null +++ b/src/d2d-manager/d2d-manager.c @@ -0,0 +1,79 @@ +/* + * Network Configuration Module + * + * Copyright (c) 2017 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. + * 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 +#include +#include + +#include + +#include "d2d-common.h" +#include "d2d-manager.h" +#include "d2d-manager-log.h" + +/**< d2d-manager service */ +d2d_service *d2dsvc; + +int main(int argc, char *argv[]) +{ + d2d_service *service = NULL; + int ret_code = 0; + gboolean ret; + + __D2DM_LOG_FUNC_ENTER__; + +#if !GLIB_CHECK_VERSION(2, 32, 0) + if (!g_thread_supported()) + g_thread_init(NULL); +#endif + +#if !GLIB_CHECK_VERSION(2, 36, 0) + g_type_init(); +#endif + NOTUSED(argc); + NOTUSED(argv); + + D2DM_LOGI("service mainloop start"); +#if 0 + /* Create d2d-manager service */ + d2dsvc = service = d2dm_service_new(); + + /* Initialize d2d-manager service interface layer */ + ret = d2dm_service_interface_init(service); + if (G_UNLIKELY(FALSE == ret)) { + D2DM_LOGE("wmeshd_service_interface_init failed!"); + goto END; + } + + /* Run mesh service */ + ret = wmeshd_service_run(service); + if (G_UNLIKELY(FALSE == ret)) { + D2DM_LOGE("Run service failed!"); + ret_code = EXIT_FAILURE; + } + +END: + /* Free d2d-manager service */ + d2dm_service_interface_deinit(service); + d2dm_service_free(service); + d2dsvc = NULL; +#endif + __D2DM_LOG_FUNC_EXIT__; + return 0; +} + diff --git a/src/d2d-manager/d2d-manager.h b/src/d2d-manager/d2d-manager.h new file mode 100644 index 0000000..9f907be --- /dev/null +++ b/src/d2d-manager/d2d-manager.h @@ -0,0 +1,50 @@ +/* + * Network Configuration Module + * + * Copyright (c) 2017 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. + * 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. + * + */ +#ifndef __D2D_MANAGER_H__ +#define __D2D_MANAGER_H__ + +#include +#include +#include + +/**< Internal error code with mesh daemon. It should be matched with API side */ +typedef enum { + D2D_ERROR_NONE = 0, /**< Successful */ + D2D_ERROR_IO_ERROR, /**< I/O error */ + D2D_ERROR_NO_DATA, /**< Data not exists */ + D2D_ERROR_OUT_OF_MEMORY, /**< out of memory */ + D2D_ERROR_OPERATION_FAILED, /**< operation failed */ + D2D_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + D2D_ERROR_ALREADY_REGISTERED, /**< Request already registered */ + D2D_ERROR_IN_PROGRESS /**< operation is in progress */ +} meshd_error_e; + +/**< mesh service structure */ +typedef struct _d2d_service { + GMainLoop *main_loop; /**< Service main-loop */ + guint dbus_id; /**< D-Bus id */ + guint activation_dbus_id; /**< D-Bus id for activation */ + + gpointer connection; /**< Connection handle for D-Bus call to other process */ + GCancellable *ca; /**< Cancellable object for D-Bus call (Daemon->other) */ + GList *dbus_sub_ids; /**< The list of subscribed signals */ + +} d2d_service; + +#endif /* __D2D_MANAGER_H__ */ diff --git a/src/fn-manager/CMakeLists.txt b/src/fn-manager/CMakeLists.txt new file mode 100644 index 0000000..1376c11 --- /dev/null +++ b/src/fn-manager/CMakeLists.txt @@ -0,0 +1,11 @@ +MESSAGE("===================================================================") +MESSAGE("Building...fn-manager") +MESSAGE("===================================================================") + +MESSAGE(" - Set source folder") +FILE(GLOB FN_MANAGER_SRCS *.c) + +SET(FN_MANAGER "fn-manager") +ADD_EXECUTABLE(${FN_MANAGER} ${FN_MANAGER_SRCS}) +TARGET_LINK_LIBRARIES(${FN_MANAGER} ${daemon_pkgs_LIBRARIES} pthread) +INSTALL(TARGETS ${FN_MANAGER} DESTINATION bin) diff --git a/src/fn-manager/fn-manager.c b/src/fn-manager/fn-manager.c new file mode 100644 index 0000000..f2559f0 --- /dev/null +++ b/src/fn-manager/fn-manager.c @@ -0,0 +1,529 @@ +/****************************************************************** +* +* Copyright 2015 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. +* +******************************************************************/ +/////////////////////////////////////////////////////////////////////// +//NOTE : This sample server is generated based on ocserverbasicops.cpp +/////////////////////////////////////////////////////////////////////// +#include "iotivity_config.h" +#include +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_PTHREAD_H +#include +#endif +#include +#include "ocstack.h" +#include "ocpayload.h" +#include "pinoxmcommon.h" +#include "srmutility.h" + +#include + +#define MAX_FILE_PATH_LEN 1024 + +#ifdef HAVE_WINDOWS_H +#include +/** @todo stop-gap for naming issue. Windows.h does not like us to use ERROR */ +#ifdef ERROR +#undef ERROR +#endif //ERROR +#endif //HAVE_WINDOWS_H +#include "platform_features.h" +#include "logger.h" + + +#define TAG "SAMPLE_JUSTWORKS" + +int gQuitFlag = 0; + +/* Structure to represent a LED resource */ +typedef struct LEDRESOURCE{ + OCResourceHandle handle; + bool state; + int power; +} LEDResource; + +static LEDResource LED; +// This variable determines instance number of the LED resource. +// Used by POST method to create a new instance of LED resource. +static int gCurrLedInstance = 0; +#define SAMPLE_MAX_NUM_POST_INSTANCE 2 +static LEDResource gLedInstance[SAMPLE_MAX_NUM_POST_INSTANCE]; + +char *gResourceUri= (char *)"/a/led"; + +//Secure Virtual Resource database for Iotivity Server +//It contains Server's Identity and the PSK credentials +//of other devices which the server trusts +static char CRED_FILE[] = "oic_svr_db_server_justworks.dat"; + +/* Function that creates a new LED resource by calling the + * OCCreateResource() method. + */ +int createLEDResource (char *uri, LEDResource *ledResource, bool resourceState, int resourcePower); + +/* This method converts the payload to JSON format */ +OCRepPayload* constructResponse (OCEntityHandlerRequest *ehRequest); + +/* Following methods process the PUT, GET, POST + * requests + */ +OCEntityHandlerResult ProcessGetRequest (OCEntityHandlerRequest *ehRequest, + OCRepPayload **payload); +OCEntityHandlerResult ProcessPutRequest (OCEntityHandlerRequest *ehRequest, + OCRepPayload **payload); +OCEntityHandlerResult ProcessPostRequest (OCEntityHandlerRequest *ehRequest, + OCEntityHandlerResponse *response, + OCRepPayload **payload); + +/* Entity Handler callback functions */ +OCEntityHandlerResult +OCEntityHandlerCb (OCEntityHandlerFlag flag, + OCEntityHandlerRequest *entityHandlerRequest, + void* callbackParam); + +const char *getResult(OCStackResult result) { + switch (result) { + case OC_STACK_OK: + return "OC_STACK_OK"; + case OC_STACK_RESOURCE_CREATED: + return "OC_STACK_RESOURCE_CREATED"; + case OC_STACK_RESOURCE_DELETED: + return "OC_STACK_RESOURCE_DELETED"; + case OC_STACK_INVALID_URI: + return "OC_STACK_INVALID_URI"; + case OC_STACK_INVALID_QUERY: + return "OC_STACK_INVALID_QUERY"; + case OC_STACK_INVALID_IP: + return "OC_STACK_INVALID_IP"; + case OC_STACK_INVALID_PORT: + return "OC_STACK_INVALID_PORT"; + case OC_STACK_INVALID_CALLBACK: + return "OC_STACK_INVALID_CALLBACK"; + case OC_STACK_INVALID_METHOD: + return "OC_STACK_INVALID_METHOD"; + case OC_STACK_NO_MEMORY: + return "OC_STACK_NO_MEMORY"; + case OC_STACK_COMM_ERROR: + return "OC_STACK_COMM_ERROR"; + case OC_STACK_INVALID_PARAM: + return "OC_STACK_INVALID_PARAM"; + case OC_STACK_NOTIMPL: + return "OC_STACK_NOTIMPL"; + case OC_STACK_NO_RESOURCE: + return "OC_STACK_NO_RESOURCE"; + case OC_STACK_RESOURCE_ERROR: + return "OC_STACK_RESOURCE_ERROR"; + case OC_STACK_SLOW_RESOURCE: + return "OC_STACK_SLOW_RESOURCE"; + case OC_STACK_NO_OBSERVERS: + return "OC_STACK_NO_OBSERVERS"; + #ifdef WITH_PRESENCE + case OC_STACK_PRESENCE_STOPPED: + return "OC_STACK_PRESENCE_STOPPED"; + #endif + case OC_STACK_ERROR: + return "OC_STACK_ERROR"; + default: + return "UNKNOWN"; + } +} + +OCRepPayload* getPayload(const char* uri, int64_t power, bool state) +{ + OCRepPayload* payload = OCRepPayloadCreate(); + if(!payload) + { + OIC_LOG(ERROR, TAG, "Failed to allocate Payload"); + return NULL; + } + + OCRepPayloadSetUri(payload, uri); + OCRepPayloadSetPropBool(payload, "state", state); + OCRepPayloadSetPropInt(payload, "power", power); + + return payload; +} + +//This function takes the request as an input and returns the response +OCRepPayload* constructResponse (OCEntityHandlerRequest *ehRequest) +{ + if(ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION) + { + OIC_LOG(ERROR, TAG, "Incoming payload not a representation"); + return NULL; + } + + OCRepPayload* input = (OCRepPayload*)(ehRequest->payload); + + LEDResource *currLEDResource = &LED; + + if (ehRequest->resource == gLedInstance[0].handle) + { + currLEDResource = &gLedInstance[0]; + gResourceUri = (char *) "/a/led/0"; + } + else if (ehRequest->resource == gLedInstance[1].handle) + { + currLEDResource = &gLedInstance[1]; + gResourceUri = (char *) "/a/led/1"; + } + + if(OC_REST_PUT == ehRequest->method) + { + // Get pointer to query + int64_t pow; + if(OCRepPayloadGetPropInt(input, "power", &pow)) + { + currLEDResource->power =pow; + } + + bool state; + if(OCRepPayloadGetPropBool(input, "state", &state)) + { + currLEDResource->state = state; + } + } + + return getPayload(gResourceUri, currLEDResource->power, currLEDResource->state); +} + +OCEntityHandlerResult ProcessGetRequest (OCEntityHandlerRequest *ehRequest, + OCRepPayload **payload) +{ + OCEntityHandlerResult ehResult; + + OCRepPayload *getResp = constructResponse(ehRequest); + + if(getResp) + { + *payload = getResp; + ehResult = OC_EH_OK; + } + else + { + ehResult = OC_EH_ERROR; + } + + return ehResult; +} + +OCEntityHandlerResult ProcessPutRequest (OCEntityHandlerRequest *ehRequest, + OCRepPayload **payload) +{ + OCEntityHandlerResult ehResult; + + OCRepPayload *putResp = constructResponse(ehRequest); + + if(putResp) + { + *payload = putResp; + ehResult = OC_EH_OK; + } + else + { + ehResult = OC_EH_ERROR; + } + + return ehResult; +} + +OCEntityHandlerResult ProcessPostRequest (OCEntityHandlerRequest *ehRequest, + OCEntityHandlerResponse *response, OCRepPayload **payload) +{ + OCRepPayload *respPLPost_led = NULL; + OCEntityHandlerResult ehResult = OC_EH_OK; + + /* + * The entity handler determines how to process a POST request. + * Per the REST paradigm, POST can also be used to update representation of existing + * resource or create a new resource. + * In the sample below, if the POST is for /a/led then a new instance of the LED + * resource is created with default representation (if representation is included in + * POST payload it can be used as initial values) as long as the instance is + * lesser than max new instance count. Once max instance count is reached, POST on + * /a/led updated the representation of /a/led (just like PUT) + */ + + if (ehRequest->resource == LED.handle) + { + if (gCurrLedInstance < SAMPLE_MAX_NUM_POST_INSTANCE) + { + // Create new LED instance + char newLedUri[15] = "/a/led/"; + int newLedUriLength = strlen(newLedUri); + snprintf (newLedUri + newLedUriLength, sizeof(newLedUri)-newLedUriLength, "%d", gCurrLedInstance); + + respPLPost_led = OCRepPayloadCreate(); + OCRepPayloadSetUri(respPLPost_led, gResourceUri); + OCRepPayloadSetPropString(respPLPost_led, "createduri", newLedUri); + + if (0 == createLEDResource (newLedUri, &gLedInstance[gCurrLedInstance], false, 0)) + { + OIC_LOG (INFO, TAG, "Created new LED instance"); + gLedInstance[gCurrLedInstance].state = 0; + gLedInstance[gCurrLedInstance].power = 0; + gCurrLedInstance++; + strncpy ((char *)response->resourceUri, newLedUri, sizeof(response->resourceUri)); + ehResult = OC_EH_RESOURCE_CREATED; + } + } + else + { + respPLPost_led = constructResponse(ehRequest); + } + } + else + { + for (int i = 0; i < SAMPLE_MAX_NUM_POST_INSTANCE; i++) + { + if (ehRequest->resource == gLedInstance[i].handle) + { + if (i == 0) + { + respPLPost_led = constructResponse(ehRequest); + break; + } + else if (i == 1) + { + respPLPost_led = constructResponse(ehRequest); + } + } + } + } + + if (respPLPost_led != NULL) + { + *payload = respPLPost_led; + ehResult = OC_EH_OK; + } + else + { + OIC_LOG_V (INFO, TAG, "Payload was NULL"); + ehResult = OC_EH_ERROR; + } + + return ehResult; +} + +OCEntityHandlerResult +OCEntityHandlerCb (OCEntityHandlerFlag flag, + OCEntityHandlerRequest *entityHandlerRequest, + void* callbackParam) +{ + OIC_LOG_V (INFO, TAG, "Inside entity handler - flags: 0x%x", flag); + (void)callbackParam; + OCEntityHandlerResult ehResult = OC_EH_ERROR; + + OCEntityHandlerResponse response; + memset(&response, 0, sizeof(response)); + + // Validate pointer + if (!entityHandlerRequest) + { + OIC_LOG (ERROR, TAG, "Invalid request pointer"); + return OC_EH_ERROR; + } + + OCRepPayload* payload = NULL; + + if (flag & OC_REQUEST_FLAG) + { + OIC_LOG (INFO, TAG, "Flag includes OC_REQUEST_FLAG"); + if (entityHandlerRequest) + { + if (OC_REST_GET == entityHandlerRequest->method) + { + OIC_LOG (INFO, TAG, "Received OC_REST_GET from client"); + ehResult = ProcessGetRequest (entityHandlerRequest, &payload); + } + else if (OC_REST_PUT == entityHandlerRequest->method) + { + OIC_LOG (INFO, TAG, "Received OC_REST_PUT from client"); + ehResult = ProcessPutRequest (entityHandlerRequest, &payload); + } + else if (OC_REST_POST == entityHandlerRequest->method) + { + OIC_LOG (INFO, TAG, "Received OC_REST_POST from client"); + ehResult = ProcessPostRequest (entityHandlerRequest, &response, &payload); + } + else + { + OIC_LOG_V (INFO, TAG, "Received unsupported method %d from client", + entityHandlerRequest->method); + ehResult = OC_EH_ERROR; + } + + if (ehResult == OC_EH_OK && ehResult != OC_EH_FORBIDDEN) + { + // Format the response. Note this requires some info about the request + response.requestHandle = entityHandlerRequest->requestHandle; + response.resourceHandle = entityHandlerRequest->resource; + response.ehResult = ehResult; + response.payload = (OCPayload*)(payload); + response.numSendVendorSpecificHeaderOptions = 0; + memset(response.sendVendorSpecificHeaderOptions, 0, + sizeof(response.sendVendorSpecificHeaderOptions)); + memset(response.resourceUri, 0, sizeof(response.resourceUri)); + // Indicate that response is NOT in a persistent buffer + response.persistentBufferFlag = 0; + + // Send the response + if (OCDoResponse(&response) != OC_STACK_OK) + { + OIC_LOG(ERROR, TAG, "Error sending response"); + ehResult = OC_EH_ERROR; + } + } + } + } + + OCPayloadDestroy(response.payload); + return ehResult; +} + +/* SIGINT handler: set gQuitFlag to 1 for graceful termination */ +void handleSigInt(int signum) +{ + if (signum == SIGINT) + { + gQuitFlag = 1; + } +} + +FILE* server_fopen(const char *path, const char *mode) +{ + char data_dir[MAX_FILE_PATH_LEN] = {0,}; + + snprintf(data_dir, MAX_FILE_PATH_LEN, "%s/network/%s", + tzplatform_getenv(TZ_SYS_GLOBALUSER_DATA), CRED_FILE); + + (void)path; + + return fopen(data_dir, mode); +} + +static void OtmEventHandler(void *ctx, const char *addr, uint16_t port, + const char* ownerId, OCOtmEvent_t event) +{ + (void)ctx; + printf("--------------------------------------\n"); + printf("Get OTM event.\n"); + printf("Address : %s\n", addr); + printf("Port : %d\n", port); + printf("Owner ID : %s\n", ownerId); + + switch (event) + { + case OIC_OTM_READY: + printf("State : OIC_OTM_READY\n"); + break; + case OIC_OTM_STARTED: + printf("State : OIC_OTM_STARTED\n"); + break; + case OIC_OTM_DONE: + printf("State : OIC_OTM_DONE\n"); + break; + case OIC_OTM_ERROR: + printf("State : OIC_OTM_ERROR\n"); + break; + default: + printf("State : Unknown state.\n"); + break; + } + printf("--------------------------------------\n"); +} + +int main() +{ + struct timespec timeout; + + OIC_LOG(DEBUG, TAG, "OCServer is starting..."); + + //This function should be invoked before invoke OCInit + OCSetOtmEventHandler(NULL, OtmEventHandler); + + // Initialize Persistent Storage for SVR database + OCPersistentStorage ps = {server_fopen, fread, fwrite, fclose, unlink, NULL, NULL}; + + OCRegisterPersistentStorageHandler(&ps); + + if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK) + { + OIC_LOG(ERROR, TAG, "OCStack init error"); + return 0; + } + + /* + * Declare and create the example resource: LED + */ + createLEDResource(gResourceUri, &LED, false, 0); + + timeout.tv_sec = 0; + timeout.tv_nsec = 100000000L; + + // Break from loop with Ctrl-C + OIC_LOG(INFO, TAG, "Entering ocserver main loop..."); + signal(SIGINT, handleSigInt); + while (!gQuitFlag) + { + if (OCProcess() != OC_STACK_OK) + { + OIC_LOG(ERROR, TAG, "OCStack process error"); + return 0; + } + nanosleep(&timeout, NULL); + } + + OIC_LOG(INFO, TAG, "Exiting ocserver main loop..."); + + if (OCStop() != OC_STACK_OK) + { + OIC_LOG(ERROR, TAG, "OCStack process error"); + } + + return 0; +} + +int createLEDResource (char *uri, LEDResource *ledResource, bool resourceState, int resourcePower) +{ + if (!uri) + { + OIC_LOG(ERROR, TAG, "Resource URI cannot be NULL"); + return -1; + } + + ledResource->state = resourceState; + ledResource->power= resourcePower; + OCStackResult res = OCCreateResource(&(ledResource->handle), + "core.led", + OC_RSRVD_INTERFACE_DEFAULT, + uri, + OCEntityHandlerCb, + NULL, + OC_DISCOVERABLE|OC_OBSERVABLE | OC_SECURE); + OIC_LOG_V(INFO, TAG, "Created LED resource with result: %s", getResult(res)); + + return 0; +} + + diff --git a/src/include/.d2d-common.h.swp b/src/include/.d2d-common.h.swp new file mode 100755 index 0000000000000000000000000000000000000000..4373074e50fa9b2382ae8695406081317898ff2f GIT binary patch literal 12288 zcmeI1Pe>F|9LJwsYAP$rphDp_1FI@lrT6i6aO-NWb*6_kBv-KAx8b{gG7#qYs~x4z%+{odQpFz>-S z9vx03c}KXNp&elCdslGG{pP0FGEL~GPFZ?rQq znJr{y$MqR=B4V@|AuE+jO`6k@Y;Iy|)-a1>6M4(Z=fWA+G87;KWWcY1*+M#Wx_;VM$#2k;&&gIC}gcna==YhVm?f+OJTUdEQd z6L1&IgFD~`m;*Tw2ONCb!`Lc#2bRDKa1Rtf2RH=|g9fkzeB900TksMrg2!MU+y=LR z1x|ov0c!#U^n)gF46N>A>=DQS6EuRO;M-2dz5r@ufDDiUGC&6YG6Rw+nK>hy=8+)R z^;lahruV7Iq^juWbe#tyj3MroBFynCne3Fw1JPzC2m@+77U)w4R88+47?MRukuadK(mP2wV=$UHk$Qj6A=J zUNX#dHfM5NB06G$W;<5xC6dKnIi67X8MNXVrP=dbYZjATs>-EXOOsH2Vw-lN3_b=|eTtZ4yEY~kT>*kkXSI-+cOorH2$bzf-mqPTwl{_z^W06} +#include +#include #define NOTUSED(var) (var = var) @@ -37,4 +39,4 @@ } \ } while (FALSE) -#endif /* __D2DD_UTIL_H__ */ +#endif /* __D2D_COMMON_H__ */ diff --git a/src/include/d2d-log.h b/src/include/d2d-log.h new file mode 100644 index 0000000..549c7b9 --- /dev/null +++ b/src/include/d2d-log.h @@ -0,0 +1,62 @@ +/* + * Network Configuration Module + * + * Copyright (c) 2017 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. + * 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. + * + */ +#ifndef __D2D_LOG_H__ +#define __D2D_LOG_H__ + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#ifdef USE_DLOG +#include + +#undef LOG_TAG +#define LOG_TAG "D2D_COMMON" + +#define D2D_LOGV(format, args...) LOGV(format, ##args) +#define D2D_LOGD(format, args...) LOGD(format, ##args) +#define D2D_LOGI(format, args...) LOGI(format, ##args) +#define D2D_LOGW(format, args...) LOGW(format, ##args) +#define D2D_LOGE(format, args...) LOGE(format, ##args) +#define D2D_LOGF(format, args...) LOGF(format, ##args) + +#define __D2D_LOG_FUNC_ENTER__ LOGD("Enter") +#define __D2D_LOG_FUNC_EXIT__ LOGD("Quit") + +#define D2D_SECLOGI(format, args...) SECURE_LOG(LOG_INFO, LOG_TAG, format, ##args) +#define D2D_SECLOGD(format, args...) SECURE_LOG(LOG_DEBUG, LOG_TAG, format, ##args) + +#else /* USE_DLOG */ + +#define D2D_LOGV(format, args...) +#define D2D_LOGD(format, args...) +#define D2D_LOGI(format, args...) +#define D2D_LOGW(format, args...) +#define D2D_LOGE(format, args...) +#define D2D_LOGF(format, args...) + +#define __D2D_LOG_FUNC_ENTER__ +#define __D2D_LOG_FUNC_EXIT__ + +#define D2D_SECLOGI(format, args...) +#define D2D_SECLOGD(format, args...) + +#endif /* USE_DLOG */ + +#endif /* __D2D_LOG_H__ */ diff --git a/test/include/hw_emul/hw_interface.h b/src/include/hw_emul/hw_interface.h similarity index 100% rename from test/include/hw_emul/hw_interface.h rename to src/include/hw_emul/hw_interface.h diff --git a/test/include/hw_emul/ss_emul.h b/src/include/hw_emul/ss_emul.h similarity index 100% rename from test/include/hw_emul/ss_emul.h rename to src/include/hw_emul/ss_emul.h diff --git a/test/include/security/base64.h b/src/include/security/base64.h similarity index 100% rename from test/include/security/base64.h rename to src/include/security/base64.h diff --git a/test/include/security/iotvticalendar.h b/src/include/security/iotvticalendar.h similarity index 100% rename from test/include/security/iotvticalendar.h rename to src/include/security/iotvticalendar.h diff --git a/test/include/security/oxmverifycommon.h b/src/include/security/oxmverifycommon.h similarity index 100% rename from test/include/security/oxmverifycommon.h rename to src/include/security/oxmverifycommon.h diff --git a/test/include/security/pbkdf2.h b/src/include/security/pbkdf2.h similarity index 100% rename from test/include/security/pbkdf2.h rename to src/include/security/pbkdf2.h diff --git a/test/include/security/pinoxmcommon.h b/src/include/security/pinoxmcommon.h similarity index 100% rename from test/include/security/pinoxmcommon.h rename to src/include/security/pinoxmcommon.h diff --git a/test/include/security/pkix_interface.h b/src/include/security/pkix_interface.h similarity index 100% rename from test/include/security/pkix_interface.h rename to src/include/security/pkix_interface.h diff --git a/test/include/security/securevirtualresourcetypes.h b/src/include/security/securevirtualresourcetypes.h similarity index 100% rename from test/include/security/securevirtualresourcetypes.h rename to src/include/security/securevirtualresourcetypes.h diff --git a/test/include/security/srmutility.h b/src/include/security/srmutility.h similarity index 100% rename from test/include/security/srmutility.h rename to src/include/security/srmutility.h diff --git a/src/subowner/CMakeLists.txt b/src/subowner/CMakeLists.txt new file mode 100644 index 0000000..dc27532 --- /dev/null +++ b/src/subowner/CMakeLists.txt @@ -0,0 +1,11 @@ +MESSAGE("===================================================================") +MESSAGE("Building...subowner client") +MESSAGE("===================================================================") + +MESSAGE(" - Set source folder") +FILE(GLOB SUBOWNER_SRCS *.c) + +SET(SUBOWNER "subowner") +ADD_EXECUTABLE(${SUBOWNER} ${SUBOWNER_SRCS}) +TARGET_LINK_LIBRARIES(${SUBOWNER} ${daemon_pkgs_LIBRARIES} pthread) +INSTALL(TARGETS ${SUBOWNER} DESTINATION bin) diff --git a/src/subowner/d2d-subowner-log.h b/src/subowner/d2d-subowner-log.h new file mode 100644 index 0000000..236ebac --- /dev/null +++ b/src/subowner/d2d-subowner-log.h @@ -0,0 +1,62 @@ +/* + * Network Configuration Module + * + * Copyright (c) 2017 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. + * 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. + * + */ +#ifndef __D2D_SUBOWNER_LOG_H__ +#define __D2D_SUBOWNER_LOG_H__ + +#ifdef D2DS_LOG_TAG +#undef D2DS_LOG_TAG +#endif + +#ifdef USE_DLOG +#include + +#undef D2DS_LOG_TAG +#define D2DS_LOG_TAG "D2D_SUBOWNER" + +#define D2DS_LOGV(format, args...) LOGV(format, ##args) +#define D2DS_LOGD(format, args...) LOGD(format, ##args) +#define D2DS_LOGI(format, args...) LOGI(format, ##args) +#define D2DS_LOGW(format, args...) LOGW(format, ##args) +#define D2DS_LOGE(format, args...) LOGE(format, ##args) +#define D2DS_LOGF(format, args...) LOGF(format, ##args) + +#define __D2DS_LOG_FUNC_ENTER__ LOGD("Enter") +#define __D2DS_LOG_FUNC_EXIT__ LOGD("Quit") + +#define D2DS_SECLOGI(format, args...) SECURE_LOG(LOG_INFO, D2DS_LOG_TAG, format, ##args) +#define D2DS_SECLOGD(format, args...) SECURE_LOG(LOG_DEBUG, D2DS_LOG_TAG, format, ##args) + +#else /* USE_DLOG */ + +#define D2DS_LOGV(format, args...) +#define D2DS_LOGD(format, args...) +#define D2DS_LOGI(format, args...) +#define D2DS_LOGW(format, args...) +#define D2DS_LOGE(format, args...) +#define D2DS_LOGF(format, args...) + +#define __D2DS_LOG_FUNC_ENTER__ +#define __D2DS_LOG_FUNC_EXIT__ + +#define D2DS_SECLOGI(format, args...) +#define D2DS_SECLOGD(format, args...) + +#endif /* USE_DLOG */ + +#endif /* __D2D_SUBOWNER_LOG_H__ */ diff --git a/src/subowner/d2d-subowner.c b/src/subowner/d2d-subowner.c new file mode 100644 index 0000000..8b29d25 --- /dev/null +++ b/src/subowner/d2d-subowner.c @@ -0,0 +1,1046 @@ +/****************************************************************** + * + * Copyright 2016 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 "iotivity_config.h" + +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif + +#include "platform_features.h" +#include "utlist.h" +#include "logger.h" +#include "oic_malloc.h" +#include "oic_string.h" +#include "ocprovisioningmanager.h" +#include "oxmjustworks.h" +#include "oxmrandompin.h" +#include "securevirtualresourcetypes.h" +#include "security/srmutility.h" +//#include "srmutility.h" +#include "pmtypes.h" +#include "pmutility.h" + +#include + +#define MAX_FILE_PATH_LEN 1024 + +#include "d2d-subowner-log.h" + +#ifdef __cplusplus +extern "C" +{ +#endif //__cplusplus + +// declaration(s) for provisioning client using C-level provisioning API +// user input definition for main loop on provisioning client +#define _10_DISCOV_MOT_ENABLED_DEV_ 10 +#define _11_DISCOV_MULTIPLE_OWNED_DEV_ 11 +#define _20_PERFORM_MOT_ 20 +#define _30_GET_LED_RESOURCE_ 30 +#define _31_PUT_LED_RESOURCE_ 31 +#define _40_PROVISION_ACL_ 40 +#define _41_PROVISION_CRED_ 41 +#define _99_EXIT_PRVN_CLT_ 99 + +#define ACL_RESRC_MAX_NUM 16 +#define ACL_RESRC_ARRAY_SIZE 3 //This value is used only for sample (not OCF spec) +#define ACL_RESRC_MAX_LEN 128 +#define ACL_PEMISN_CNT 5 +#define DISCOVERY_TIMEOUT 5 // 5 sec +#define CALLBACK_TIMEOUT 60 // 1 min +#define TAG "subownerclient" + +static const char* SVR_DB_FILE_NAME = "oic_svr_db_subowner_client.dat"; + // '_' for separaing from the same constant variable in |srmresourcestrings.c| +static const char* PRVN_DB_FILE_NAME = "oic_pdm_subowner.db"; +static const OicSecPrm_t SUPPORTED_PRMS[1] = +{ + PRM_PRE_CONFIGURED, +}; + +// |g_ctx| means provision manager application context and +// the following, includes |un/own_list|, could be variables, which |g_ctx| has, +// for accessing all function(s) for these, they are declared on global domain +static const char* g_ctx = "SubOwner Client Application Context"; +static char* g_svr_fname; +static char* g_prvn_fname; +static OCProvisionDev_t* g_own_list; +static OCProvisionDev_t* g_unown_list; +static OCProvisionDev_t* g_motdev_list; +static OCProvisionDev_t* g_mowned_list; +static int g_own_cnt; +static int g_unown_cnt; +static int g_motdev_cnt; +static int g_mowned_cnt; +static bool g_doneCB; + +// function declaration(s) for calling them before implementing +static OCProvisionDev_t* getDevInst(const OCProvisionDev_t*, const int); +static int printDevList(const OCProvisionDev_t*); +static size_t printUuidList(const OCUuidList_t*); +static int printResultList(const OCProvisionResult_t*, const int); +static void printUuid(const OicUuid_t*); +static FILE* fopen_prvnMng(const char*, const char*); +static int waitCallbackRet(void); +static int selectTwoDiffNum(int*, int*, const int, const char*); + +// callback function(s) for provisioning client using C-level provisioning API +static void multipleOwnershipTransferCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, bool hasError) +{ + if(!hasError) + { + D2DS_LOGD("Multiple Ownership Transfer SUCCEEDED - ctx: %s", (char*) ctx); + } + else + { + D2DS_LOGD( "Multiple Ownership Transfer FAILED - ctx: %s", (char*) ctx); + printResultList((const OCProvisionResult_t*) arr, nOfRes); + } + g_doneCB = true; +} + +// callback function(s) for provisioning client using C-level provisioning API +static void ownershipTransferCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, bool hasError) +{ + if(!hasError) + { + D2DS_LOGD( "Ownership Transfer SUCCEEDED - ctx: %s", (char*) ctx); + } + else + { + D2DS_LOGD( "Ownership Transfer FAILED - ctx: %s", (char*) ctx); + printResultList((const OCProvisionResult_t*) arr, nOfRes); + } + g_doneCB = true; +} + +static void updateDoxmForMOTCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, bool hasError) +{ + if(!hasError) + { + D2DS_LOGD( "POST 'doxm' SUCCEEDED - ctx: %s", (char*) ctx); + } + else + { + D2DS_LOGD( "POST 'doxm' FAILED - ctx: %s", (char*) ctx); + printResultList((const OCProvisionResult_t*) arr, nOfRes); + } + g_doneCB = true; +} + +static void provisionCredCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, bool hasError) +{ + if(!hasError) + { + D2DS_LOGD( "Provision Credential SUCCEEDED - ctx: %s", (char*) ctx); + } + else + { + D2DS_LOGD( "Provision Credential FAILED - ctx: %s", (char*) ctx); + printResultList((const OCProvisionResult_t*) arr, nOfRes); + } + g_doneCB = true; +} + +static void provisionAclCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, bool hasError) +{ + if(!hasError) + { + D2DS_LOGD( "Provision ACL SUCCEEDED - ctx: %s", (char*) ctx); + } + else + { + D2DS_LOGD( "Provision ACL FAILED - ctx: %s", (char*) ctx); + printResultList((const OCProvisionResult_t*) arr, nOfRes); + } + g_doneCB = true; +} + +// response handler for LED requests. +static void LedCB(void *ctx, OCDoHandle UNUSED, + OCClientResponse *clientResponse) +{ + if(clientResponse) + { + if(OC_STACK_OK == clientResponse->result) + { + printf("Received OC_STACK_OK from server\n"); + if(clientResponse->payload) + { + printf("Response ===================> %s\n", clientResponse->payload); + } + } + else if(OC_STACK_RESOURCE_CHANGED == clientResponse->result) + { + printf("Received OC_STACK_RESOURCE_CHANGED from server\n"); + } + else + { + printf("Error in response : %d\n", clientResponse->result); + } + } + else + { + printf("Hit the response callback but can not find response data\n"); + } + + g_doneCB = true; +} + +static void inputPinCB(char* pin, size_t len) +{ + if(!pin || OXM_RANDOM_PIN_MAX_SIZE>=len) + { + D2DS_LOGE( "inputPinCB invalid parameters"); + return; + } + + printf(" > INPUT PIN: "); + for(int ret=0; 1!=ret; ) + { + ret = scanf("%32s", pin); + for( ; 0x20<=getchar(); ); // for removing overflow garbages + // '0x20<=code' is character region + } +} + +// function(s) for provisioning client using C-level provisioning API +static int initProvisionClient(void) +{ + // initialize persistent storage for SVR DB + static OCPersistentStorage ps = {fopen_prvnMng, fread, fwrite, fclose, unlink}; + if(OC_STACK_OK != OCRegisterPersistentStorageHandler(&ps)) + { + D2DS_LOGE( "OCRegisterPersistentStorageHandler error"); + return -1; + } + + // initialize OC stack and provisioning manager + if(OC_STACK_OK != OCInit(NULL, 0, OC_CLIENT_SERVER)) + { + D2DS_LOGE( "OCStack init error"); + return -1; + } + + if (access(PRVN_DB_FILE_NAME, F_OK) != -1) + { + printf("************************************************************\n"); + printf("************Provisioning DB file already exists.************\n"); + printf("************************************************************\n"); + } + else + { + printf("*************************************************************\n"); + printf("************No provisioning DB file, creating new************\n"); + printf("*************************************************************\n"); + } + + if(OC_STACK_OK != OCInitPM(PRVN_DB_FILE_NAME)) + { + D2DS_LOGE( "OC_PM init error"); + return -1; + } + + SetInputPinCB(inputPinCB); + + return 0; +} + +static int discoverMotSupportedDevices(void) +{ + // delete un/owned device lists before updating them + if(g_motdev_list) + { + OCDeleteDiscoveredDevices(g_motdev_list); + g_motdev_list = NULL; + } + + // call |OCDiscoverMultipleOwnerEnabledDevices| API actually + printf(" Discovering Multiple Ownership Transfer enabled Devices on Network..\n"); + if(OC_STACK_OK != OCDiscoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT, &g_motdev_list)) + { + D2DS_LOGE( "OCDiscoverMultipleOwnerEnalbedDevices API error"); + return -1; + } + + // display the discovered device lists + printf(" > Discovered Multiple Ownership Transfer Enabled Devices\n"); + g_motdev_cnt = printDevList(g_motdev_list); + + return 0; +} + +static int discoverSubOwnerDevices() +{ + // delete un/owned device lists before updating them + if(g_mowned_list) + { + OCDeleteDiscoveredDevices(g_mowned_list); + g_mowned_list = NULL; + } + + // call |OCDiscoverMultipleOwnedDevices| API actually + printf(" Discovering Multiple Owned Devices on Network..\n"); + if(OC_STACK_OK != OCDiscoverMultipleOwnedDevices(DISCOVERY_TIMEOUT, &g_mowned_list)) + { + D2DS_LOGE( "OCDiscoverMultipleOwnerEnabledDevices API error"); + return -1; + } + + // display the discovered device lists + printf(" > Discovered Multiple Owned Devices\n"); + g_mowned_cnt = printDevList(g_mowned_list); + + return 0; +} + +static int multipleOwnershipTransfer(void) +{ + // check |unown_list| for registering devices + if(!g_motdev_list || 0 >=g_motdev_cnt) + { + printf(" > MultipleOwnershipTransfer Enabled Device List is Empty\n"); + printf(" > Please Discover Devices first, with [10] Menu\n"); + return 0; // normal case + } + + // call |getDevInst| API actually + // calling this API with callback actually acts like blocking + // for error checking, the return value saved and printed + g_doneCB = false; + +#ifdef MULTIPLE_OWNER + OCProvisionDev_t* dev = NULL; + LL_FOREACH(g_motdev_list, dev) + { + if(OIC_PRECONFIG_PIN == dev->doxm->oxmSel) + { + //Pre-Configured PIN initialization + const char* testPreconfigPin = "12341234"; + if(OC_STACK_OK != OCAddPreconfigPin(dev, testPreconfigPin, strlen(testPreconfigPin))) + { + printf("\n\n\n*** %60s ***\n", "WARNNING : Failed to save the pre-configured PIN"); + printf("*** %60s ***\n\n\n", "WARNNING : You can't use the pre-configured PIN OxM for MOT"); + return -1; + } + } + } +#endif //MULTIPLE_OWNER + + if(OC_STACK_OK != OCDoMultipleOwnershipTransfer(g_ctx, g_motdev_list, multipleOwnershipTransferCB)) + { + D2DS_LOGE( "_20_PERFORM_MOT_: error"); + return -1; + } + + if(waitCallbackRet()) // input |g_doneCB| flag implicitly + { + D2DS_LOGE( "OCProvisionCredentials callback error"); + return -1; + } + + // display the registered result + printf(" > Registered Discovered Devices\n"); + + return 0; +} + +static int sendGetLed() +{ + int selDevNum; + char query[256] = {0}; + OCCallbackData cbData; + cbData.cb = &LedCB; + cbData.context = NULL; + cbData.cd = NULL; + + printDevList(g_mowned_list); + + // select device for provisioning access control list + for( ; ; ) + { + printf(" > Enter Device Number, for sending GET LED request: "); + for(int ret=0; 1!=ret; ) + { + ret = scanf("%d", &selDevNum); + for( ; 0x20<=getchar(); ); // for removing overflow garbages + // '0x20<=code' is character region + } + if(0=selDevNum) + { + break; + } + printf(" Entered Wrong Number. Please Enter Again\n"); + } + + OCProvisionDev_t* selDev = getDevInst(g_mowned_list, selDevNum); + if(NULL == selDev) + { + printf("Failed to getDevInst()\n"); + return -1; + } + + if(PMGenerateQuery(true, selDev->endpoint.addr, selDev->securePort, selDev->connType, + query, sizeof(query), "/a/led")) + { + g_doneCB = false; + printf("query=%s\n", query); + if(OC_STACK_OK != OCDoResource(NULL, OC_REST_GET, query, NULL, NULL, selDev->connType, + OC_HIGH_QOS, &cbData, NULL, 0)) + { + printf("********************************\n"); + printf("Failed to send GET request to %s\n", query); + printf("********************************\n"); + g_doneCB = true; + return -1; + } + + waitCallbackRet(); + } + else + { + printf("Failed to generate GET request for /a/led\n"); + return -1; + } + + return 0; +} + +static int sendPutLed() +{ + int selDevNum; + char query[256] = {0}; + OCCallbackData cbData; + cbData.cb = &LedCB; + cbData.context = NULL; + cbData.cd = NULL; + + printDevList(g_mowned_list); + // select device for provisioning access control list + for( ; ; ) + { + printf(" > Enter Device Number, for sending PUT LED request: "); + for(int ret=0; 1!=ret; ) + { + ret = scanf("%d", &selDevNum); + for( ; 0x20<=getchar(); ); // for removing overflow garbages + // '0x20<=code' is character region + } + if(0=selDevNum) + { + break; + } + printf(" Entered Wrong Number. Please Enter Again\n"); + } + + OCProvisionDev_t* selDev = getDevInst(g_mowned_list, selDevNum); + if(NULL == selDev) + { + printf("Failed to getDevInst()\n"); + return -1; + } + + if(PMGenerateQuery(true, selDev->endpoint.addr, selDev->securePort, selDev->connType, + query, sizeof(query), "/a/led")) + { + g_doneCB = false; + printf("query=%s\n", query); + if(OC_STACK_OK != OCDoResource(NULL, OC_REST_PUT, query, NULL, NULL, selDev->connType, + OC_LOW_QOS, &cbData, NULL, 0)) + { + printf("********************************\n"); + printf("Failed to send PUT request to %s\n", query); + printf("********************************\n"); + g_doneCB = true; + return -1; + } + + waitCallbackRet(); + } + else + { + printf("Failed to generate PUT request for /a/led\n"); + return -1; + } + + return 0; +} + + +static OicSecAcl_t* createAclForLEDAccess(const OicUuid_t* subject) +{ + if(NULL == subject) + { + D2DS_LOGE( "createAcl: Invalid paramters"); + return NULL; + } + // allocate memory for |acl| struct + OicSecAcl_t* acl = (OicSecAcl_t*) OICCalloc(1, sizeof(OicSecAcl_t)); + if(!acl) + { + D2DS_LOGE( "createAcl: OICCalloc error return"); + return NULL; // not need to 'goto' |ERROR| before allocating |acl| + } + OicSecAce_t* ace = (OicSecAce_t*) OICCalloc(1, sizeof(OicSecAce_t)); + if(!ace) + { + D2DS_LOGE( "createAcl: OICCalloc error return"); + return NULL; // not need to 'goto' |ERROR| before allocating |acl| + } + LL_APPEND(acl->aces, ace); + memcpy(ace->subjectuuid.id, subject->id, sizeof(subject->id)); + + // fill the href + char* rsrc_in = "/a/led"; // '1' for null termination + OicSecRsrc_t* rsrc = (OicSecRsrc_t*)OICCalloc(1, sizeof(OicSecRsrc_t)); + if(!rsrc) + { + D2DS_LOGE( "createAcl: OICCalloc error return"); + goto CRACL_ERROR; + } + + size_t len = strlen(rsrc_in)+1; // '1' for null termination + rsrc->href = (char*) OICCalloc(len, sizeof(char)); + if(!rsrc->href) + { + D2DS_LOGE( "createAcl: OICCalloc error return"); + goto CRACL_ERROR; + } + OICStrcpy(rsrc->href, len, rsrc_in); + + //fill the resource type (rt) + rsrc->typeLen = 1; + rsrc->types = (char**)OICCalloc(1, sizeof(char*)); + if(!rsrc->types) + { + D2DS_LOGE( "createAcl: OICCalloc error return"); + goto CRACL_ERROR; + } + rsrc->types[0] = OICStrdup("oic.r.core"); + if(!rsrc->types[0]) + { + D2DS_LOGE( "createAcl: OICStrdup error return"); + goto CRACL_ERROR; + } + + //fill the interface (if) + rsrc->interfaceLen = 1; + rsrc->interfaces = (char**)OICCalloc(1, sizeof(char*)); + if(!rsrc->interfaces) + { + D2DS_LOGE( "createAcl: OICCalloc error return"); + goto CRACL_ERROR; + } + rsrc->interfaces[0] = OICStrdup("oic.if.baseline"); + if(!rsrc->interfaces[0]) + { + D2DS_LOGE( "createAcl: OICStrdup error return"); + goto CRACL_ERROR; + } + + LL_APPEND(ace->resources, rsrc); + + // full permission for /a/led + ace->permission = PERMISSION_FULL_CONTROL; + + ace->eownerID = (OicUuid_t*)OICCalloc(1, sizeof(OicUuid_t)); + if(NULL == ace->eownerID) + { + D2DS_LOGE( "createAcl: OICCalloc error return"); + goto CRACL_ERROR; + } + + memcpy(ace->eownerID->id, subject->id, sizeof(subject->id)); + + return acl; + +CRACL_ERROR: + OCDeleteACLList(acl); // after here |acl| points nothing + return NULL; +} + +static int provisionAclForLed() +{ + OicSecAcl_t* acl = NULL; + + // check |own_list| for provisioning access control list + if(!g_mowned_list || 1> g_mowned_cnt) + { + printf(" > MOT Device List is Empty\n"); + printf(" > Please Perform MOT first, with [12|21] Menu\n"); + return 0; // normal case + } + + // display the MOT dev list + printf(" > MOT Devices\n"); + g_mowned_cnt = printDevList(g_mowned_list); + + // select device for provisioning access control list + int dev_num = 0; + for( ; ; ) + { + printf(" > Enter Device Number, for Provisioning LED's ACL: "); + for(int ret=0; 1!=ret; ) + { + ret = scanf("%d", &dev_num); + for( ; 0x20<=getchar(); ); // for removing overflow garbages + // '0x20<=code' is character region + } + if(0=dev_num) + { + break; + } + printf(" Entered Wrong Number. Please Enter Again\n"); + } + + g_doneCB = false; + printf(" Provisioning Selected ACL..\n"); + OCProvisionDev_t* dev = getDevInst((const OCProvisionDev_t*) g_mowned_list, dev_num); + if(!dev) + { + D2DS_LOGE( "provisionAcl: device instance empty"); + goto PVACL_ERROR; + } + + acl = createAclForLEDAccess(&dev->doxm->subOwners->uuid); + if(NULL == acl) + { + D2DS_LOGE( "provisionAcl: Failed to create ACL for LED"); + return -1; + } + + OCStackResult rst = OCProvisionACL((void*) g_ctx, dev, acl, provisionAclCB); + if(OC_STACK_OK != rst) + { + D2DS_LOGD( "OCProvisionACL API error: %d", rst); + goto PVACL_ERROR; + } + if(waitCallbackRet()) // input |g_doneCB| flag implicitly + { + D2DS_LOGE( "OCProvisionCredentials callback error"); + goto PVACL_ERROR; + } + // display the ACL-provisioned result + printf(" > Provisioned Selected ACL\n"); + + OCDeleteACLList(acl); // after here |acl| points nothing + return 0; + +PVACL_ERROR: + OCDeleteACLList(acl); + return -1; +} + +static int provisionCred() +{ + // check |unown_list| for registering devices + if(!g_mowned_list|| 0 >=g_mowned_cnt) + { + printf(" > Multiple Owned Device List is Empty\n"); + printf(" > Please Discover Devices first, with [13] Menu\n"); + return 0; // normal case + } + + // display the MOT dev list + printf(" > Multiple Owned Devices\n"); + g_mowned_cnt = printDevList(g_mowned_list); + + int dev_num = 0; + for( ; ; ) + { + printf(" > Enter Multiple Owned Device Number to link : "); + for(int ret=0; 1!=ret; ) + { + ret = scanf("%d", &dev_num); + for( ; 0x20<=getchar(); ); // for removing overflow garbages + // '0x20<=code' is character region + } + if(0=dev_num) + { + break; + } + printf(" Entered Wrong Number. Please Enter Again\n"); + } + + OCProvisionDev_t* motDev = getDevInst(g_mowned_list, dev_num); + if(NULL == motDev) + { + D2DS_LOGE( "Failed to getDevInst()"); + return -1; + } + + // display the MOT dev list + printf(" > Owned Devices\n"); + g_own_cnt = printDevList(g_own_list); + + for( ; ; ) + { + printf(" > Enter Owned Device Number to link : "); + for(int ret=0; 1!=ret; ) + { + ret = scanf("%d", &dev_num); + for( ; 0x20<=getchar(); ); // for removing overflow garbages + // '0x20<=code' is character region + } + if(0=dev_num) + { + break; + } + printf(" Entered Wrong Number. Please Enter Again\n"); + } + + OCProvisionDev_t* ownDev = getDevInst(g_own_list, dev_num); + if(NULL == ownDev) + { + D2DS_LOGE( "Failed to getDevInst()"); + return -1; + } + + // call |OCProvisionCredentials| API actually + // calling this API with callback actually acts like blocking + // for error checking, the return value saved and printed + g_doneCB = false; + printf(" Provisioning Selected Pairwise Devices..\n"); + OCStackResult rst = OCProvisionCredentials((void*) g_ctx, + SYMMETRIC_PAIR_WISE_KEY, OWNER_PSK_LENGTH_128, + ownDev, motDev, provisionCredCB); + if(OC_STACK_OK != rst) + { + D2DS_LOGD( "OCProvisionPairwiseDevices API error: %d", rst); + goto PVPWS_ERROR; + } + if(waitCallbackRet()) // input |g_doneCB| flag implicitly + { + D2DS_LOGE( "OCProvisionCredentials callback error"); + goto PVPWS_ERROR; + } + + // display the pairwise-provisioned result + printf(" > Provisioned Selected Pairwise Devices\n"); + + return 0; + +PVPWS_ERROR: + return -1; +} + +static OCProvisionDev_t* getDevInst(const OCProvisionDev_t* dev_lst, const int dev_num) +{ + if(!dev_lst || 0>=dev_num) + { + printf(" Device List is Empty..\n"); + return NULL; + } + + OCProvisionDev_t* lst = (OCProvisionDev_t*) dev_lst; + for(int i=0; lst; ) + { + if(dev_num == ++i) + { + return lst; + } + lst = lst->next; + } + + return NULL; // in here |lst| is always |NULL| +} + +static int printDevList(const OCProvisionDev_t* dev_lst) +{ + if(!dev_lst) + { + printf(" Device List is Empty..\n\n"); + return 0; + } + + OCProvisionDev_t* lst = (OCProvisionDev_t*) dev_lst; + int lst_cnt = 0; + for( ; lst; ) + { + printf(" [%d] ", ++lst_cnt); + printUuid((const OicUuid_t*) &lst->doxm->deviceID); + printf("\n"); + lst = lst->next; + } + printf("\n"); + + return lst_cnt; +} + +static size_t printUuidList(const OCUuidList_t* uid_lst) +{ + if(!uid_lst) + { + printf(" Device List is Empty..\n\n"); + return 0; + } + + OCUuidList_t* lst = (OCUuidList_t*) uid_lst; + size_t lst_cnt = 0; + for( ; lst; ) + { + printf(" [%zu] ", ++lst_cnt); + printUuid((const OicUuid_t*) &lst->dev); + printf("\n"); + lst = lst->next; + } + printf("\n"); + + return lst_cnt; +} + +static int printResultList(const OCProvisionResult_t* rslt_lst, const int rslt_cnt) +{ + if(!rslt_lst || 0>=rslt_cnt) + { + printf(" Device List is Empty..\n\n"); + return 0; + } + + int lst_cnt = 0; + for( ; rslt_cnt>lst_cnt; ++lst_cnt) + { + printf(" [%d] ", lst_cnt+1); + printUuid((const OicUuid_t*) &rslt_lst[lst_cnt].deviceId); + printf(" - result: %d\n", rslt_lst[lst_cnt].res); + } + printf("\n"); + + return lst_cnt; +} + +static void printUuid(const OicUuid_t* uid) +{ + for(int i=0; ii; ++i) + { + sleep(1); + if(OC_STACK_OK != OCProcess()) + { + D2DS_LOGE( "OCStack process error"); + return -1; + } + } + + if(!g_doneCB) + { + OCPDMCleanupForTimeout(); + } + + return 0; +} + +static int selectTwoDiffNum(int* a, int* b, const int max, const char* str) +{ + if(!a || !b || 2>max || !str) + { + return -1; + } + + for( ; ; ) + { + for(int i=0; 2>i; ++i) + { + int* num = 0==i?a:b; + for( ; ; ) + { + printf(" > Enter Device[%d] Number, %s: ", i+1, str); + for(int ret=0; 1!=ret; ) + { + ret = scanf("%d", num); + for( ; 0x20<=getchar(); ); // for removing overflow garbages + // '0x20<=code' is character region + } + if(0<*num && max>=*num) + { + break; + } + printf(" Entered Wrong Number. Please Enter Again\n"); + } + } + if(*a != *b) + { + printf("\n"); + return 0; + } + } + + return -1; +} + +static void printMenu(void) +{ + printf("************************************************************\n"); + printf("****** OIC Provisioning Client with using C-level API ******\n"); + printf("************************************************************\n\n"); + + printf("** [A] DISCOVER DEVICES ON NETWORK\n"); + printf("** 10. Discover Multiple Ownership Transfer Enabled Devices on Network\n"); + printf("** 11. Discover Multiple Owned Devices on Network\n\n"); + + printf("** [B] PERFORM MULTIPLE OWNERSHIP TRANSFER\n"); + printf("** 20. Perform the Multiple Ownership Transfer for ALL discovered dievices\n\n"); + + printf("** [C] Get/Put Request for APPLICATION RESOURCE\n"); + printf("** 30. Get LED resource\n"); + printf("** 31. Put LED resource\n\n"); + + printf("** [D] LINK DEVICES\n"); + printf("** 40. Provision ACL for LED Resource\n"); + printf("** 41. Provison Credential\n\n"); + + printf("** [F] EXIT PROVISIONING CLIENT\n"); + printf("** 99. Exit Provisionong Client\n\n"); + + printf("************************************************************\n\n"); +} + +// main function for provisioning client using C-level provisioning API +int main() +{ + // initialize provisioning client + if(initProvisionClient()) + { + D2DS_LOGE( "ProvisionClient init error"); + goto PMCLT_ERROR; + } + + // main loop for provisioning manager + int mnNum = 0; + int selDevNum = 0; + for( ; ; ) + { + printf("\n"); + printMenu(); + printf(">> Enter Menu Number: "); + for(int ret=0; 1!=ret; ) + { + ret = scanf("%d", &mnNum); + for( ; 0x20<=getchar(); ); // for removing overflow garbages + // '0x20<=code' is character region + } + printf("\n"); + switch(mnNum) + { + case _10_DISCOV_MOT_ENABLED_DEV_: + if(discoverMotSupportedDevices()) + { + D2DS_LOGE( "_12_MOT_DISCOV_DEV_: error"); + } + break; + case _11_DISCOV_MULTIPLE_OWNED_DEV_: + if(discoverSubOwnerDevices()) + { + D2DS_LOGE( "_13_DISCOV_MULTIPLE_OWNED_DEV_: error"); + } + break; + case _20_PERFORM_MOT_: + if(multipleOwnershipTransfer()) + { + D2DS_LOGE( "_21_PERFORM_MOT_: error"); + } + break; + case _30_GET_LED_RESOURCE_: + if(sendGetLed()) + { + D2DS_LOGE( "_30_GET_LED_RESOURCE_: error"); + } + break; + case _31_PUT_LED_RESOURCE_: + if(sendPutLed()) + { + D2DS_LOGE( "_31_PUT_LED_RESOURCE_: error"); + } + break; + case _40_PROVISION_ACL_: + if(provisionAclForLed()) + { + D2DS_LOGE( "_40_PROVISION_ACL_: error"); + } + break; + case _41_PROVISION_CRED_: + D2DS_LOGE( "NOT SUPPORTED YET."); + break; + /* + if(provisionCred()) + { + D2D_LOGE( "_41_PROVISION_CRED_: error"); + } + break; + */ + case _99_EXIT_PRVN_CLT_: + goto PMCLT_ERROR; + default: + printf(">> Entered Wrong Number. Please Enter Again\n\n"); + break; + } + } + +PMCLT_ERROR: + if(OC_STACK_OK != OCStop()) + { + //D2D_LOGE( "OCStack stop error"); + } + OCDeleteDiscoveredDevices(g_own_list); // after here |g_own_list| points nothing + OCDeleteDiscoveredDevices(g_unown_list); // after here |g_unown_list| points nothing + OCDeleteDiscoveredDevices(g_motdev_list); // after here |g_motdev_list| points nothing + + if(g_svr_fname) + { + OICFree(g_svr_fname); // after here |g_svr_fname| points nothing + } + if(g_prvn_fname) + { + OICFree(g_prvn_fname); // after here |g_prvn_fname| points nothing + } + return 0; // always return normal case +} + +#ifdef __cplusplus +} +#endif //__cplusplus + diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 029f783..6b03a9b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,60 +1,39 @@ -MESSAGE(" - Check minimum CMake version") - -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(d2d-manager-test) - -MESSAGE(" - Check cmake packagesion") -INCLUDE(FindPkgConfig) - -MESSAGE(" - Search for packages") -SET(COMMON_DEPS glib-2.0 gio-2.0 iotivity) - -IF (LINUX) - PKG_CHECK_MODULES(test_pkgs REQUIRED ${COMMON_DEPS}) - ADD_DEFINITIONS("-DLINUX") -ELSE () - SET(TIZEN_DEPS dlog libtzplatform-config) - PKG_CHECK_MODULES(test_pkgs REQUIRED ${COMMON_DEPS} ${TIZEN_DEPS}) - ADD_DEFINITIONS("-DUSE_DLOG") -ENDIF() - -MESSAGE(" - Check complier flag") -FOREACH(flag ${mesh_pkgs_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") - SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} ${flag}") -ENDFOREACH(flag) - -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fpic -Wall -Werror-implicit-function-declaration -fvisibility=hidden") -SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} -std=gnu++11 -fpic -Wall -Werror-implicit-function-declaration -fvisibility=hidden") - -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS}") - -SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") +#MESSAGE(" - Include header files") +#INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) +#INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/test) +#INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/test/include) MESSAGE(" - Build executable") -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/test) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/test/include) - SET(SERVER_BASIC_OPS "ocserverbasicops") SET(SERVER_BASIC_OPS_SRCS ocserverbasicops.cpp common.cpp) -ADD_EXECUTABLE(${SERVER_BASIC_OPS} ${SERVER_BASIC_OPS_SRCS}) -TARGET_LINK_LIBRARIES(${SERVER_BASIC_OPS} ${test_pkgs_LDFLAGS} -ldl) -INSTALL(TARGETS ${SERVER_BASIC_OPS} DESTINATION ${SBIN_DIR}) -INSTALL(FILES oic_svr_db_server.dat DESTINATION ${NETWORK_FW_DATADIR}) - - SET(SAMPLESERVER_JUSTWORKS "sampleserver_justworks") SET(SAMPLESERVER_JUSTWORKS_SRCS sampleserver_justworks.cpp) +SET(PROVISIONING_CLIENT "provisioningclient") +SET(PROVISIONING_CLIENT_SRCS + provisioningclient.c + hw_interface.c + ss_emul.c) + +SET(SUBOWNER_CLIENT "subownerclient") +SET(SUBOWNER_CLIENT_SRCS + subownerclient.c) + +#MESSAGE(" - Check cmake packagesion") +#pkg_check_modules(test_pkgs REQUIRED iotivity uuid libtzplatform-config) + +ADD_EXECUTABLE(${SERVER_BASIC_OPS} ${SERVER_BASIC_OPS_SRCS}) +TARGET_LINK_LIBRARIES(${SERVER_BASIC_OPS} ${daemon_pkgs_LIBRARIES} -ldl) +INSTALL(TARGETS ${SERVER_BASIC_OPS} DESTINATION ${SBIN_DIR}) +INSTALL(FILES oic_svr_db_server.dat DESTINATION ${NETWORK_FW_DATADIR}) + ADD_EXECUTABLE(${SAMPLESERVER_JUSTWORKS} ${SAMPLESERVER_JUSTWORKS_SRCS}) -TARGET_LINK_LIBRARIES(${SAMPLESERVER_JUSTWORKS} ${test_pkgs_LDFLAGS} -ldl) +TARGET_LINK_LIBRARIES(${SAMPLESERVER_JUSTWORKS} ${daemon_pkgs_LIBRARIES} ) INSTALL(TARGETS ${SAMPLESERVER_JUSTWORKS} DESTINATION ${SBIN_DIR}) INSTALL(FILES oic_svr_db_server_justworks.dat DESTINATION ${NETWORK_FW_DATADIR}) @@ -70,36 +49,13 @@ INSTALL(FILES oic_svr_db_server_mvjustworks.dat DESTINATION ${NETWORK_FW_DATADIR INSTALL(FILES oic_svr_db_server_preconfpin.dat DESTINATION ${NETWORK_FW_DATADIR}) -SET(PROVISIONING_CLIENT "provisioningclient") -SET(PROVISIONING_CLIENT_SRCS - provisioningclient.c - hw_interface.c - ss_emul.c - ) - -# For test -#INSTALL(FILES lib/libmbedtls.so DESTINATION ${LIB_DIR}) - ADD_EXECUTABLE(${PROVISIONING_CLIENT} ${PROVISIONING_CLIENT_SRCS}) -TARGET_LINK_LIBRARIES(${PROVISIONING_CLIENT} ${test_pkgs_LDFLAGS} -lmbedtls) +TARGET_LINK_LIBRARIES(${PROVISIONING_CLIENT} ${daemon_pkgs_LIBRARIES} -lmbedtls) INSTALL(TARGETS ${PROVISIONING_CLIENT} DESTINATION ${SBIN_DIR}) INSTALL(FILES oic_svr_db_client.dat DESTINATION ${NETWORK_FW_DATADIR}) -# Current IoTivity regards multiple-owener feature as optional -ADD_DEFINITIONS("-DMULTIPLE_OWNER=1") -# With reliable TCP file transfer -ADD_DEFINITIONS("-D__WITH_TLS__") -ADD_DEFINITIONS("-DWITH_TCP") -# Default message comm. with DTLS -ADD_DEFINITIONS("-D__WITH_DTLS__") -# Default network type : IP -ADD_DEFINITIONS("-DTCP_ADAPTER") - -SET(SUBOWNER_CLIENT "subownerclient") -SET(SUBOWNER_CLIENT_SRCS - subownerclient.c) ADD_EXECUTABLE(${SUBOWNER_CLIENT} ${SUBOWNER_CLIENT_SRCS}) -TARGET_LINK_LIBRARIES(${SUBOWNER_CLIENT} ${test_pkgs_LDFLAGS}) +TARGET_LINK_LIBRARIES(${SUBOWNER_CLIENT} ${daemon_pkgs_LIBRARIES}) INSTALL(TARGETS ${SUBOWNER_CLIENT} DESTINATION ${SBIN_DIR}) INSTALL(FILES oic_svr_db_subowner_client.dat DESTINATION ${NETWORK_FW_DATADIR}) diff --git a/test/hw_interface.c b/test/hw_interface.c index 52821c7..9da5886 100644 --- a/test/hw_interface.c +++ b/test/hw_interface.c @@ -27,8 +27,7 @@ #include "mbedtls/pk_internal.h" #include "hw_emul/hw_interface.h" - -#define TAG "OIC_HWIF" +#include #define HWIF_KEY_DEFAULT_ALIAS "HW_KEY_DEFAULT" #define HWIF_KEY_CONTEXT HWIF_KEY_DEFAULT_ALIAS @@ -53,8 +52,8 @@ static int RsaDecryptAlt(void *ctx, int mode, size_t *olen, (void)output; (void)output_max_len; - OIC_LOG_V(INFO, TAG, "In %s", __func__); - OIC_LOG_V(INFO, TAG, "Out %s", __func__); + D2D_LOGI( "In %s", __func__); + D2D_LOGI( "Out %s", __func__); return 0; } @@ -63,19 +62,19 @@ static int RsaSignAlt(void *ctx, int mode, mbedtls_md_type_t md_alg, unsigned int hashlen, const unsigned char *hash, unsigned char *sig ) { - OIC_LOG_V(INFO, TAG, "In %s", __func__); + D2D_LOGD("In %s", __func__); if(!ctx || 0 != strncmp((const char*)(ctx), HWIF_RSA_ALIAS, strlen(HWIF_RSA_ALIAS))) { - OIC_LOG(ERROR, TAG, "Invalid paramters, ctx must has same key id"); - OIC_LOG_V(INFO, TAG, "Out %s", __func__); + D2D_LOGE("Invalid paramters, ctx must has same key id"); + D2D_LOGD("Out %s", __func__); return MBEDTLS_ERR_RSA_BAD_INPUT_DATA; } if(mode != MBEDTLS_RSA_PRIVATE) { - OIC_LOG(ERROR, TAG, "Invalid mode requested"); - OIC_LOG_V(INFO, TAG, "Out %s", __func__); + D2D_LOGE("Invalid mode requested"); + D2D_LOGD("Out %s", __func__); return MBEDTLS_ERR_PK_BAD_INPUT_DATA; } @@ -83,24 +82,24 @@ static int RsaSignAlt(void *ctx, int ret = SSemulRsaSign(ctx, f_rng, p_rng, mode, md_alg, hashlen, hash, sig); if(0 != ret ) { - OIC_LOG_V(ERROR, TAG, "Fail to RSA sign [0x%x]", ret); + D2D_LOGD("Fail to RSA sign [0x%x]", ret); goto exit; } - OIC_LOG_V(INFO, TAG, "Success to RSA sign"); + D2D_LOGD("Success to RSA sign"); exit: - OIC_LOG_V(INFO, TAG, "Out %s", __func__); + D2D_LOGD("Out %s", __func__); return ret; } static size_t RsaKeyLen( void *ctx ) { - OIC_LOG_V(INFO, TAG, "In %s", __func__); + D2D_LOGD( "In %s", __func__); if(!ctx || 0 != strncmp((const char*)(ctx), HWIF_RSA_ALIAS, strlen(HWIF_RSA_ALIAS))) { - OIC_LOG(ERROR, TAG, "Invalid paramters, ctx must has same key id"); - OIC_LOG_V(INFO, TAG, "Out %s", __func__); + D2D_LOGE("Invalid paramters, ctx must has same key id"); + D2D_LOGD("Out %s", __func__); return 0; } @@ -108,14 +107,14 @@ static size_t RsaKeyLen( void *ctx ) int ret = SSemulGetKeylen(ctx); if (0 >= ret) { - OIC_LOG_V(ERROR, TAG, "Fail to load key length [0x%x]", ret); + D2D_LOGD("Fail to load key length [0x%x]", ret); goto exit; } - OIC_LOG_V(INFO, TAG, "key length : %d", ret); + D2D_LOGD("key length : %d", ret); exit: - OIC_LOG_V(INFO, TAG, "Out %s", __func__); + D2D_LOGD("Out %s", __func__); return (size_t)ret; } @@ -130,26 +129,26 @@ static int EcdsaSignAlt( void *ctx, mbedtls_md_type_t md_alg, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) { (void)ctx; - OIC_LOG_V(INFO, TAG, "In %s", __func__); + D2D_LOGD("In %s", __func__); - OIC_LOG_V(ERROR, TAG, "hash_len : %zu md_alg : %d", hash_len, md_alg); + D2D_LOGD("hash_len : %zu md_alg : %d", hash_len, md_alg); // ECDSA signing with hw stored private key int ret = SSemulEcdsaSign(ctx, md_alg, hash, hash_len, sig, sig_len, f_rng, p_rng); if(0 != ret ) { - OIC_LOG_V(ERROR, TAG, "Fail to ECDSA sign [0x%x]", ret); + D2D_LOGD("Fail to ECDSA sign [0x%x]", ret); goto exit; } - OIC_LOG_V(INFO, TAG, "Success to ECDSA sign"); + D2D_LOGD("Success to ECDSA sign"); - OIC_LOG_V(DEBUG, TAG, "# [hash - %zu bytes] #", hash_len); - OIC_LOG_BUFFER(DEBUG, TAG, hash, hash_len); - OIC_LOG_V(DEBUG, TAG, "# [signature - %zu bytes] #", *sig_len); - OIC_LOG_BUFFER(DEBUG, TAG, sig, *sig_len); + D2D_LOGD("# [hash - %zu bytes] #", hash_len); + D2D_LOGD("%s %s", hash, hash_len); + D2D_LOGD("# [signature - %zu bytes] #", *sig_len); + D2D_LOGD("%s %s", sig, *sig_len); exit: - OIC_LOG_V(INFO, TAG, "Out %s", __func__); + D2D_LOGD( "Out %s", __func__); return ret; } @@ -160,12 +159,12 @@ exit: int SetupRSAContext(mbedtls_pk_context* ctx, void* key_context) { - OIC_LOG_V(INFO, TAG, "In %s", __func__); + D2D_LOGD("In %s", __func__); int ret = HWIF_SUCCESS; if(NULL == ctx || NULL == key_context) { - OIC_LOG(ERROR, TAG, "Invalid input parameters."); + D2D_LOGE("Invalid input parameters."); ret = HWIF_ERR_INVALID_PARAM; goto exit; } @@ -174,26 +173,26 @@ int SetupRSAContext(mbedtls_pk_context* ctx, void* key_context) RsaDecryptAlt, RsaSignAlt, RsaKeyLen); if(0 != ret) { - OIC_LOG_V(ERROR, TAG, "Failed to setup rsa alt [%d]", ret); + D2D_LOGD("Failed to setup rsa alt [%d]", ret); ret = HWIF_ERROR; goto exit; } - OIC_LOG(INFO, TAG, "Success to setup RSA alt"); + D2D_LOGE("Success to setup RSA alt"); exit: - OIC_LOG_V(INFO, TAG, "Out %s", __func__); + D2D_LOGD("Out %s", __func__); return ret; } int SetupECDSAContext(mbedtls_pk_context* ctx, void* key_context) { - OIC_LOG_V(INFO, TAG, "In %s", __func__); + D2D_LOGD("In %s", __func__); int ret = HWIF_SUCCESS; if(NULL == ctx || NULL == key_context) { - OIC_LOG(ERROR, TAG, "Invalid input parameters."); + D2D_LOGE("Invalid input parameters."); ret = HWIF_ERR_INVALID_PARAM; goto exit; } @@ -205,7 +204,7 @@ int SetupECDSAContext(mbedtls_pk_context* ctx, void* key_context) mbedtls_ec_info = mbedtls_pk_info_from_type(MBEDTLS_PK_ECKEY); if (NULL == mbedtls_ec_info) { - OIC_LOG(ERROR, TAG, "mbedtls_pk_info_from_type error"); + D2D_LOGE("mbedtls_pk_info_from_type error"); ret = HWIF_ERROR; goto exit; } @@ -215,15 +214,15 @@ int SetupECDSAContext(mbedtls_pk_context* ctx, void* key_context) ec_info.sign_func = EcdsaSignAlt; if (0 != mbedtls_pk_setup(ctx, &ec_info)) { - OIC_LOG(ERROR, TAG, "mbedtls_pk_setup error"); + D2D_LOGE("mbedtls_pk_setup error"); ret = HWIF_ERROR; goto exit; } - OIC_LOG(INFO, TAG, "Success to setup ECDSA alt"); + D2D_LOGE("Success to setup ECDSA alt"); exit: - OIC_LOG_V(INFO, TAG, "Out %s", __func__); + D2D_LOGD("Out %s", __func__); return ret; } @@ -235,10 +234,10 @@ void* HWGetKeyContext(const char* service, const char* usage, const char* keytyp { (void)keytype; - OIC_LOG_V(INFO, TAG, "In %s", __func__); + D2D_LOGD("In %s", __func__); if(NULL == service || NULL == usage) { - OIC_LOG(ERROR, TAG, "Invalid input parameters. service and usage should be not NULL."); + D2D_LOGE("Invalid input parameters. service and usage should be not NULL."); return NULL; } @@ -249,16 +248,16 @@ void* HWGetKeyContext(const char* service, const char* usage, const char* keytyp // #define HWKEY_SVC_IOTIVITY "iotivity" // #define HWKEY_USAGE_PRIMARY "primary" - OIC_LOG_V(INFO, TAG, "Out %s", __func__); + D2D_LOGD("Out %s", __func__); return (void*)HWIF_KEY_CONTEXT; } int HWFreeKeyContext(void* keyContext) { - OIC_LOG_V(INFO, TAG, "In %s", __func__); + D2D_LOGD("In %s", __func__); if(NULL == keyContext) { - OIC_LOG(ERROR, TAG, "key context value is NULL."); + D2D_LOGE("key context value is NULL."); return HWIF_ERR_INVALID_PARAM; } @@ -270,19 +269,19 @@ int HWFreeKeyContext(void* keyContext) } g_ownCertLen = 0; - OIC_LOG_V(INFO, TAG, "Out %s", __func__); + D2D_LOGD("Out %s", __func__); return HWIF_SUCCESS; } int HWGetOwnCertificateChain(const void* keyContext, uint8_t** cert_chain, size_t* cert_chain_len) { - OIC_LOG_V(INFO, TAG, "In %s", __func__); + D2D_LOGD("In %s", __func__); int ret = HWIF_SUCCESS; if(NULL == keyContext || NULL == cert_chain || NULL == cert_chain_len) { - OIC_LOG(ERROR, TAG, "Invalid input parameters."); + D2D_LOGE( "Invalid input parameters."); ret = HWIF_ERR_INVALID_PARAM; goto exit; } @@ -292,7 +291,7 @@ int HWGetOwnCertificateChain(const void* keyContext, // Load own certificate from cache *cert_chain = g_ownCert; *cert_chain_len = g_ownCertLen; - OIC_LOG(DEBUG, TAG, "Load from the cache"); + D2D_LOGE("Load from the cache"); } else { @@ -300,7 +299,7 @@ int HWGetOwnCertificateChain(const void* keyContext, ret = SSemulLoadOwncert(keyContext, cert_chain, cert_chain_len); if (0 != ret) { - OIC_LOG(ERROR, TAG, "Failed to load the own certificate from Secure Storage"); + D2D_LOGE("Failed to load the own certificate from Secure Storage"); ret = HWIF_ERROR; goto exit; } @@ -310,21 +309,21 @@ int HWGetOwnCertificateChain(const void* keyContext, g_ownCertLen = *cert_chain_len; } - OIC_LOG_V(DEBUG, TAG, "cert chain size : %zu", *cert_chain_len); + D2D_LOGD("cert chain size : %zu", *cert_chain_len); exit: - OIC_LOG_V(INFO, TAG, "Out %s", __func__); + D2D_LOGD("Out %s", __func__); return ret; } int HWSetupPkContext(mbedtls_pk_context* ctx, void* key_context) { - OIC_LOG_V(INFO, TAG, "In %s", __func__); + D2D_LOGD("In %s", __func__); int ret = HWIF_SUCCESS; if(NULL == ctx || NULL == key_context) { - OIC_LOG(ERROR, TAG, "Invalid input parameters."); + D2D_LOGE( "Invalid input parameters."); ret = HWIF_ERR_INVALID_PARAM; goto exit; } @@ -340,7 +339,7 @@ int HWSetupPkContext(mbedtls_pk_context* ctx, void* key_context) } exit: - OIC_LOG_V(INFO, TAG, "Out %s", __func__); + D2D_LOGD("Out %s", __func__); return ret; } diff --git a/test/ocamsservice.cpp b/test/ocamsservice.cpp index 2f6d6ca..270f1da 100644 --- a/test/ocamsservice.cpp +++ b/test/ocamsservice.cpp @@ -50,7 +50,7 @@ int main(int /*argc*/, char* /*argv*/[]) { struct timespec timeout; - OIC_LOG(DEBUG, TAG, "OCAMS service is starting..."); + D2D_LOGE( "OCAMS service is starting..."); // Initialize Persistent Storage for SVR database OCPersistentStorage ps = { service_fopen, fread, fwrite, fclose, unlink }; @@ -58,7 +58,7 @@ int main(int /*argc*/, char* /*argv*/[]) if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCStack init error"); + D2D_LOGE( "OCStack init error"); return 0; } @@ -66,23 +66,23 @@ int main(int /*argc*/, char* /*argv*/[]) timeout.tv_nsec = 100000000L; // Break from loop with Ctrl-C - OIC_LOG(INFO, TAG, "Entering ocamsservice main loop..."); + D2D_LOGE( "Entering ocamsservice main loop..."); signal(SIGINT, handleSigInt); while (!gQuitFlag) { if (OCProcess() != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCStack process error"); + D2D_LOGE( "OCStack process error"); return 0; } nanosleep(&timeout, NULL); } - OIC_LOG(INFO, TAG, "Exiting ocamsservice main loop..."); + D2D_LOGE( "Exiting ocamsservice main loop..."); if (OCStop() != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCStack process error"); + D2D_LOGE( "OCStack process error"); } return 0; diff --git a/test/ocserverbasicops.cpp b/test/ocserverbasicops.cpp index f3475a4..445de1f 100644 --- a/test/ocserverbasicops.cpp +++ b/test/ocserverbasicops.cpp @@ -38,6 +38,8 @@ #include "ocserverbasicops.h" #include "common.h" +#include + //<-- For Tizen #include @@ -64,7 +66,7 @@ OCRepPayload* getPayload(const char* uri, int64_t power, bool state) OCRepPayload* payload = OCRepPayloadCreate(); if(!payload) { - OIC_LOG(ERROR, TAG, PCF("Failed to allocate Payload")); + D2D_LOGE( PCF("Failed to allocate Payload")); return nullptr; } @@ -80,7 +82,7 @@ OCRepPayload* constructResponse (OCEntityHandlerRequest *ehRequest) { if(ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION) { - OIC_LOG(ERROR, TAG, PCF("Incoming payload not a representation")); + D2D_LOGE( PCF("Incoming payload not a representation")); return nullptr; } @@ -191,7 +193,7 @@ OCEntityHandlerResult ProcessPostRequest (OCEntityHandlerRequest *ehRequest, if (0 == createLEDResource (newLedUri, &gLedInstance[gCurrLedInstance], false, 0)) { - OIC_LOG (INFO, TAG, "Created new LED instance"); + D2D_LOGE ( "Created new LED instance"); gLedInstance[gCurrLedInstance].state = 0; gLedInstance[gCurrLedInstance].power = 0; gCurrLedInstance++; @@ -230,7 +232,7 @@ OCEntityHandlerResult ProcessPostRequest (OCEntityHandlerRequest *ehRequest, } else { - OIC_LOG_V (INFO, TAG, "Payload was NULL"); + D2D_LOGD ( "Payload was NULL"); ehResult = OC_EH_ERROR; } @@ -242,14 +244,14 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, OCEntityHandlerRequest *entityHandlerRequest, void* /*callbackParam*/) { - OIC_LOG_V (INFO, TAG, "Inside entity handler - flags: 0x%x", flag); + D2D_LOGD ( "Inside entity handler - flags: 0x%x", flag); OCEntityHandlerResult ehResult = OC_EH_ERROR; OCEntityHandlerResponse response = { 0, 0, OC_EH_ERROR, 0, 0, { },{ 0 }, false }; // Validate pointer if (!entityHandlerRequest) { - OIC_LOG (ERROR, TAG, "Invalid request pointer"); + D2D_LOGE ( "Invalid request pointer"); return OC_EH_ERROR; } @@ -257,27 +259,27 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, if (flag & OC_REQUEST_FLAG) { - OIC_LOG (INFO, TAG, "Flag includes OC_REQUEST_FLAG"); + D2D_LOGE ( "Flag includes OC_REQUEST_FLAG"); if (entityHandlerRequest) { if (OC_REST_GET == entityHandlerRequest->method) { - OIC_LOG (INFO, TAG, "Received OC_REST_GET from client"); + D2D_LOGE ( "Received OC_REST_GET from client"); ehResult = ProcessGetRequest (entityHandlerRequest, &payload); } else if (OC_REST_PUT == entityHandlerRequest->method) { - OIC_LOG (INFO, TAG, "Received OC_REST_PUT from client"); + D2D_LOGE ( "Received OC_REST_PUT from client"); ehResult = ProcessPutRequest (entityHandlerRequest, &payload); } else if (OC_REST_POST == entityHandlerRequest->method) { - OIC_LOG (INFO, TAG, "Received OC_REST_POST from client"); + D2D_LOGE ( "Received OC_REST_POST from client"); ehResult = ProcessPostRequest (entityHandlerRequest, &response, &payload); } else { - OIC_LOG_V (INFO, TAG, "Received unsupported method %d from client", + D2D_LOGD ( "Received unsupported method %d from client", entityHandlerRequest->method); ehResult = OC_EH_ERROR; } @@ -297,7 +299,7 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, // Send the response if (OCDoResponse(&response) != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "Error sending response"); + D2D_LOGE( "Error sending response"); ehResult = OC_EH_ERROR; } } @@ -339,7 +341,7 @@ int main(int /*argc*/, char* /*argv*/[]) { struct timespec timeout; - OIC_LOG(DEBUG, TAG, "OCServer is starting..."); + D2D_LOGE( "OCServer is starting..."); // Initialize Persistent Storage for SVR database OCPersistentStorage ps = { server_fopen, fread, fwrite, fclose, unlink }; @@ -347,7 +349,7 @@ int main(int /*argc*/, char* /*argv*/[]) if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCStack init error"); + D2D_LOGE( "OCStack init error"); return 0; } @@ -360,23 +362,23 @@ int main(int /*argc*/, char* /*argv*/[]) timeout.tv_nsec = 100000000L; // Break from loop with Ctrl-C - OIC_LOG(INFO, TAG, "Entering ocserver main loop..."); + D2D_LOGE( "Entering ocserver main loop..."); signal(SIGINT, handleSigInt); while (!gQuitFlag) { if (OCProcess() != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCStack process error"); + D2D_LOGE( "OCStack process error"); return 0; } nanosleep(&timeout, NULL); } - OIC_LOG(INFO, TAG, "Exiting ocserver main loop..."); + D2D_LOGE( "Exiting ocserver main loop..."); if (OCStop() != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCStack process error"); + D2D_LOGE( "OCStack process error"); } return 0; @@ -386,7 +388,7 @@ int createLEDResource (char *uri, LEDResource *ledResource, bool resourceState, { if (!uri) { - OIC_LOG(ERROR, TAG, "Resource URI cannot be NULL"); + D2D_LOGE( "Resource URI cannot be NULL"); return -1; } @@ -399,7 +401,7 @@ int createLEDResource (char *uri, LEDResource *ledResource, bool resourceState, OCEntityHandlerCb, NULL, OC_DISCOVERABLE|OC_OBSERVABLE | OC_SECURE); - OIC_LOG_V(INFO, TAG, "Created LED resource with result: %s", getResult(res)); + D2D_LOGD( "Created LED resource with result: %s", getResult(res)); return 0; } diff --git a/test/provisioningclient.c b/test/provisioningclient.c index 1ce4aff..f6def4c 100644 --- a/test/provisioningclient.c +++ b/test/provisioningclient.c @@ -42,6 +42,8 @@ #include "mbedtls/x509_crt.h" #include "casecurityinterface.h" +#include + //<-- For Tizen #include #define MAX_FILE_PATH_LEN 1024 @@ -140,11 +142,11 @@ static void ownershipTransferCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, { if(!hasError) { - OIC_LOG_V(INFO, TAG, "Ownership Transfer SUCCEEDED - ctx: %s", (char*) ctx); + D2D_LOGD( "Ownership Transfer SUCCEEDED - ctx: %s", (char*) ctx); } else { - OIC_LOG_V(ERROR, TAG, "Ownership Transfer FAILED - ctx: %s", (char*) ctx); + D2D_LOGD( "Ownership Transfer FAILED - ctx: %s", (char*) ctx); printResultList((const OCProvisionResult_t*) arr, nOfRes); } g_doneCB = true; @@ -154,11 +156,11 @@ static void provisionPairwiseCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, { if(!hasError) { - OIC_LOG_V(INFO, TAG, "Provision Pairwise SUCCEEDED - ctx: %s", (char*) ctx); + D2D_LOGD( "Provision Pairwise SUCCEEDED - ctx: %s", (char*) ctx); } else { - OIC_LOG_V(ERROR, TAG, "Provision Pairwise FAILED - ctx: %s", (char*) ctx); + D2D_LOGD( "Provision Pairwise FAILED - ctx: %s", (char*) ctx); printResultList((const OCProvisionResult_t*) arr, nOfRes); } g_doneCB = true; @@ -168,11 +170,11 @@ static void provisionCredCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, boo { if(!hasError) { - OIC_LOG_V(INFO, TAG, "Provision Credential SUCCEEDED - ctx: %s", (char*) ctx); + D2D_LOGD( "Provision Credential SUCCEEDED - ctx: %s", (char*) ctx); } else { - OIC_LOG_V(ERROR, TAG, "Provision Credential FAILED - ctx: %s", (char*) ctx); + D2D_LOGD( "Provision Credential FAILED - ctx: %s", (char*) ctx); printResultList((const OCProvisionResult_t*) arr, nOfRes); } g_doneCB = true; @@ -182,11 +184,11 @@ static void provisionAclCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, bool { if(!hasError) { - OIC_LOG_V(INFO, TAG, "Provision ACL SUCCEEDED - ctx: %s", (char*) ctx); + D2D_LOGD( "Provision ACL SUCCEEDED - ctx: %s", (char*) ctx); } else { - OIC_LOG_V(ERROR, TAG, "Provision ACL FAILED - ctx: %s", (char*) ctx); + D2D_LOGD( "Provision ACL FAILED - ctx: %s", (char*) ctx); printResultList((const OCProvisionResult_t*) arr, nOfRes); } g_doneCB = true; @@ -196,11 +198,11 @@ static void getCredCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, bool hasE { if(!hasError) { - OIC_LOG_V(INFO, TAG, "getCredCB SUCCEEDED - ctx: %s", (char*) ctx); + D2D_LOGD( "getCredCB SUCCEEDED - ctx: %s", (char*) ctx); } else { - OIC_LOG_V(ERROR, TAG, "getCredCB FAILED - ctx: %s", (char*) ctx); + D2D_LOGD( "getCredCB FAILED - ctx: %s", (char*) ctx); printResultList((const OCProvisionResult_t*) arr, nOfRes); } g_doneCB = true; @@ -210,11 +212,11 @@ static void getAclCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, bool hasEr { if(!hasError) { - OIC_LOG_V(INFO, TAG, "getAclCB SUCCEEDED - ctx: %s", (char*) ctx); + D2D_LOGD( "getAclCB SUCCEEDED - ctx: %s", (char*) ctx); } else { - OIC_LOG_V(ERROR, TAG, "getAclCB FAILED - ctx: %s", (char*) ctx); + D2D_LOGD( "getAclCB FAILED - ctx: %s", (char*) ctx); printResultList((const OCProvisionResult_t*) arr, nOfRes); } g_doneCB = true; @@ -224,11 +226,11 @@ static void provisionDPCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, bool { if(!hasError) { - OIC_LOG_V(INFO, TAG, "Provision Direct-Pairing SUCCEEDED - ctx: %s", (char*) ctx); + D2D_LOGD( "Provision Direct-Pairing SUCCEEDED - ctx: %s", (char*) ctx); } else { - OIC_LOG_V(ERROR, TAG, "Provision Direct-Pairing FAILED - ctx: %s", (char*) ctx); + D2D_LOGD( "Provision Direct-Pairing FAILED - ctx: %s", (char*) ctx); printResultList((const OCProvisionResult_t*) arr, nOfRes); } g_doneCB = true; @@ -238,11 +240,11 @@ static void unlinkDevicesCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, boo { if(!hasError) { - OIC_LOG_V(INFO, TAG, "Unlink Devices SUCCEEDED - ctx: %s", (char*) ctx); + D2D_LOGD( "Unlink Devices SUCCEEDED - ctx: %s", (char*) ctx); } else { - OIC_LOG_V(ERROR, TAG, "Unlink Devices FAILED - ctx: %s", (char*) ctx); + D2D_LOGD( "Unlink Devices FAILED - ctx: %s", (char*) ctx); printResultList((const OCProvisionResult_t*) arr, nOfRes); } g_doneCB = true; @@ -252,11 +254,11 @@ static void removeDeviceCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, bool { if(!hasError) { - OIC_LOG_V(INFO, TAG, "Remove Device SUCCEEDED - ctx: %s", (char*) ctx); + D2D_LOGD( "Remove Device SUCCEEDED - ctx: %s", (char*) ctx); } else { - OIC_LOG_V(ERROR, TAG, "Remove Device FAILED - ctx: %s", (char*) ctx); + D2D_LOGD( "Remove Device FAILED - ctx: %s", (char*) ctx); printResultList((const OCProvisionResult_t*) arr, nOfRes); } g_doneCB = true; @@ -266,11 +268,11 @@ static void syncDeviceCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, bool h { if(!hasError) { - OIC_LOG_V(INFO, TAG, "Sync Device SUCCEEDED - ctx: %s", (char*) ctx); + D2D_LOGD( "Sync Device SUCCEEDED - ctx: %s", (char*) ctx); } else { - OIC_LOG_V(ERROR, TAG, "Sync Device FAILED - ctx: %s", (char*) ctx); + D2D_LOGD( "Sync Device FAILED - ctx: %s", (char*) ctx); printResultList((const OCProvisionResult_t*) arr, nOfRes); } g_doneCB = true; @@ -281,11 +283,11 @@ static void updateDoxmForMOTCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, { if(!hasError) { - OIC_LOG_V(INFO, TAG, "POST 'doxm' SUCCEEDED - ctx: %s", (char*) ctx); + D2D_LOGD( "POST 'doxm' SUCCEEDED - ctx: %s", (char*) ctx); } else { - OIC_LOG_V(ERROR, TAG, "POST 'doxm' FAILED - ctx: %s", (char*) ctx); + D2D_LOGD( "POST 'doxm' FAILED - ctx: %s", (char*) ctx); printResultList((const OCProvisionResult_t*) arr, nOfRes); } g_doneCB = true; @@ -295,11 +297,11 @@ static void deleteDoxmForMOTCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, { if(!hasError) { - OIC_LOG_V(INFO, TAG, "DELETE 'doxm' SUCCEEDED - ctx: %s", (char*) ctx); + D2D_LOGD( "DELETE 'doxm' SUCCEEDED - ctx: %s", (char*) ctx); } else { - OIC_LOG_V(ERROR, TAG, "DELETE 'doxm' FAILED - ctx: %s", (char*) ctx); + D2D_LOGD( "DELETE 'doxm' FAILED - ctx: %s", (char*) ctx); printResultList((const OCProvisionResult_t*) arr, nOfRes); } g_doneCB = true; @@ -311,7 +313,7 @@ static void inputPinCB(char* pin, size_t len) { if(!pin || OXM_RANDOM_PIN_MIN_SIZE > len) { - OIC_LOG(ERROR, TAG, "inputPinCB invalid parameters"); + D2D_LOGE( "inputPinCB invalid parameters"); return; } @@ -338,14 +340,14 @@ static int initProvisionClient(void) }; if(OC_STACK_OK != OCRegisterPersistentStorageHandler(&pstStr)) { - OIC_LOG(ERROR, TAG, "OCRegisterPersistentStorageHandler error"); + D2D_LOGE( "OCRegisterPersistentStorageHandler error"); return -1; } // initialize OC stack and provisioning manager if(OC_STACK_OK != OCInit(NULL, 0, OC_CLIENT_SERVER)) { - OIC_LOG(ERROR, TAG, "OCStack init error"); + D2D_LOGE( "OCStack init error"); return -1; } @@ -364,7 +366,7 @@ static int initProvisionClient(void) if(OC_STACK_OK != OCInitPM(PRVN_DB_FILE_NAME)) { - OIC_LOG(ERROR, TAG, "OC_PM init error"); + D2D_LOGE( "OC_PM init error"); return -1; } @@ -391,7 +393,7 @@ static int discoverAllDevices(void) printf(" Discovering All Un/Owned Devices on Network..\n"); if(OC_STACK_OK != OCGetDevInfoFromNetwork(DISCOVERY_TIMEOUT, &g_own_list, &g_unown_list)) { - OIC_LOG(ERROR, TAG, "OCGetDevInfoFromNetwork API error"); + D2D_LOGE( "OCGetDevInfoFromNetwork API error"); return -1; } @@ -421,7 +423,7 @@ static int discoverUnownedDevices(void) printf(" Discovering Only Unowned Devices on Network..\n"); if(OC_STACK_OK != OCDiscoverUnownedDevices(DISCOVERY_TIMEOUT, &g_unown_list)) { - OIC_LOG(ERROR, TAG, "OCDiscoverUnownedDevices API error"); + D2D_LOGE( "OCDiscoverUnownedDevices API error"); return -1; } @@ -447,7 +449,7 @@ static int discoverOwnedDevices(void) printf(" Discovering Only Owned Devices on Network..\n"); if(OC_STACK_OK != OCDiscoverOwnedDevices(DISCOVERY_TIMEOUT, &g_own_list)) { - OIC_LOG(ERROR, TAG, "OCDiscoverOwnedDevices API error"); + D2D_LOGE( "OCDiscoverOwnedDevices API error"); return -1; } @@ -474,7 +476,7 @@ static int discoverMOTEnabledDevices(void) printf(" Discovering Multiple Ownership Transfer Enabled Devices on Network..\n"); if(OC_STACK_OK != OCDiscoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT, &g_mot_enable_list)) { - OIC_LOG(ERROR, TAG, "OCDiscoverMultipleOwnerEnalbedDevices API error"); + D2D_LOGE( "OCDiscoverMultipleOwnerEnalbedDevices API error"); return -1; } @@ -504,12 +506,12 @@ static int registerDevices(void) OCStackResult rst = OCDoOwnershipTransfer((void*) g_ctx, g_unown_list, ownershipTransferCB); if(OC_STACK_OK != rst) { - OIC_LOG_V(ERROR, TAG, "OCDoOwnershipTransfer API error: %d", rst); + D2D_LOGD( "OCDoOwnershipTransfer API error: %d", rst); return -1; } if(waitCallbackRet()) // input |g_doneCB| flag implicitly { - OIC_LOG(ERROR, TAG, "OCProvisionCredentials callback error"); + D2D_LOGE( "OCProvisionCredentials callback error"); return -1; } @@ -534,7 +536,7 @@ static int provisionPairwise(void) int dev_num[2] = {0}; if(selectTwoDiffNum(&(dev_num[0]), &(dev_num[1]), g_own_cnt, "for Linking Devices")) { - OIC_LOG(ERROR, TAG, "selectTwoDiffNum error return"); + D2D_LOGE( "selectTwoDiffNum error return"); return -1; // not need to 'goto' |ERROR| before allocating |acl| } @@ -545,7 +547,7 @@ static int provisionPairwise(void) acl[i] = createAcl(dev_num[i]); if(!acl[i]) { - OIC_LOG(ERROR, TAG, "createAcl error return"); + D2D_LOGE( "createAcl error return"); goto PVPWS_ERROR; } } @@ -563,12 +565,12 @@ static int provisionPairwise(void) provisionPairwiseCB); if(OC_STACK_OK != rst) { - OIC_LOG_V(ERROR, TAG, "OCProvisionPairwiseDevices API error: %d", rst); + D2D_LOGD( "OCProvisionPairwiseDevices API error: %d", rst); goto PVPWS_ERROR; } if(waitCallbackRet()) // input |g_doneCB| flag implicitly { - OIC_LOG(ERROR, TAG, "OCProvisionCredentials callback error"); + D2D_LOGE( "OCProvisionCredentials callback error"); goto PVPWS_ERROR; } OCDeleteACLList(acl[0]); @@ -600,7 +602,7 @@ static int provisionCred(void) int dev_num[2] = {0}; if(selectTwoDiffNum(&(dev_num[0]), &(dev_num[1]), g_own_cnt, "for Linking CRED(s)")) { - OIC_LOG(ERROR, TAG, "selectTwoDiffNum error return"); + D2D_LOGE( "selectTwoDiffNum error return"); return -1; } @@ -650,12 +652,12 @@ static int provisionCred(void) provisionCredCB); if(OC_STACK_OK != rst) { - OIC_LOG_V(ERROR, TAG, "OCProvisionCredentials API error: %d", rst); + D2D_LOGD( "OCProvisionCredentials API error: %d", rst); return -1; } if(waitCallbackRet()) // input |g_doneCB| flag implicitly { - OIC_LOG(ERROR, TAG, "OCProvisionCredentials callback error"); + D2D_LOGE( "OCProvisionCredentials callback error"); return -1; } @@ -699,7 +701,7 @@ static int provisionAcl(void) acl = createAcl(dev_num); if(!acl) { - OIC_LOG(ERROR, TAG, "createAcl error return"); + D2D_LOGE( "createAcl error return"); goto PVACL_ERROR; } @@ -711,18 +713,18 @@ static int provisionAcl(void) OCProvisionDev_t* dev = getDevInst((const OCProvisionDev_t*) g_own_list, dev_num); if(!dev) { - OIC_LOG(ERROR, TAG, "provisionAcl: device instance empty"); + D2D_LOGE( "provisionAcl: device instance empty"); goto PVACL_ERROR; } OCStackResult rst = OCProvisionACL((void*) g_ctx, dev, acl, provisionAclCB); if(OC_STACK_OK != rst) { - OIC_LOG_V(ERROR, TAG, "OCProvisionACL API error: %d", rst); + D2D_LOGD( "OCProvisionACL API error: %d", rst); goto PVACL_ERROR; } if(waitCallbackRet()) // input |g_doneCB| flag implicitly { - OIC_LOG(ERROR, TAG, "OCProvisionCredentials callback error"); + D2D_LOGE( "OCProvisionCredentials callback error"); goto PVACL_ERROR; } OCDeleteACLList(acl); // after here |acl| points nothing @@ -785,7 +787,7 @@ static int provisionDirectPairing(void) } else { - OIC_LOG(ERROR, TAG, "create prm error return"); + D2D_LOGE( "create prm error return"); goto PVDP_ERROR; } @@ -797,7 +799,7 @@ static int provisionDirectPairing(void) pconf.pdacls = createPdAcl(dev_num); if(!pconf.pdacls) { - OIC_LOG(ERROR, TAG, "createPdAcl error return"); + D2D_LOGE( "createPdAcl error return"); goto PVDP_ERROR; } @@ -811,16 +813,16 @@ static int provisionDirectPairing(void) &pconf, provisionDPCB); if(OC_STACK_OK != rst) { - OIC_LOG_V(ERROR, TAG, "OCProvisionDirectPairing API error: %d", rst); + D2D_LOGD( "OCProvisionDirectPairing API error: %d", rst); if (OC_STACK_UNAUTHORIZED_REQ == rst) { - OIC_LOG(ERROR, TAG, "Target Server NOT Support Direct-Pairing !!! (DPC == false)"); + D2D_LOGE( "Target Server NOT Support Direct-Pairing !!! (DPC == false)"); } goto PVDP_ERROR; } if(waitCallbackRet()) // input |g_doneCB| flag implicitly { - OIC_LOG(ERROR, TAG, "OCProvisionCredentials callback error"); + D2D_LOGE( "OCProvisionCredentials callback error"); goto PVDP_ERROR; } OCDeletePdAclList(pconf.pdacls); @@ -870,7 +872,7 @@ static int checkLinkedStatus(void) OCProvisionDev_t* dev = getDevInst((const OCProvisionDev_t*)g_own_list, dev_num); if(!dev || !dev->doxm) { - OIC_LOG(ERROR, TAG, "checkLinkedStatus: device instance empty"); + D2D_LOGE( "checkLinkedStatus: device instance empty"); goto CKLST_ERROR; } @@ -879,7 +881,7 @@ static int checkLinkedStatus(void) &dev->doxm->deviceID, &dvid_lst, &dvid_cnt)) // allow empty list { - OIC_LOG(ERROR, TAG, "OCGetLinkedStatus API error"); + D2D_LOGE( "OCGetLinkedStatus API error"); goto CKLST_ERROR; } @@ -892,7 +894,7 @@ static int checkLinkedStatus(void) } if(dvid_cnt != printUuidList((const OCUuidList_t*) dvid_lst)) { - OIC_LOG(ERROR, TAG, "printUuidList error return"); + D2D_LOGE( "printUuidList error return"); goto CKLST_ERROR; } OCDeleteUuidList(dvid_lst); @@ -947,14 +949,14 @@ static int saveAcl(void) OCStackResult rst = ConvertStrToUuid(strUuid, &uuid); if(OC_STACK_OK != rst) { - OIC_LOG_V(ERROR, TAG, "ConvertStrToUuid API error: %d", rst); + D2D_LOGD( "ConvertStrToUuid API error: %d", rst); goto SVACL_ERROR; } acl = createSimpleAcl(uuid); if(!acl) { - OIC_LOG(ERROR, TAG, "createAcl error return"); + D2D_LOGE( "createAcl error return"); goto SVACL_ERROR; } @@ -962,7 +964,7 @@ static int saveAcl(void) rst = OCSaveACL(acl); if(OC_STACK_OK != rst) { - OIC_LOG_V(ERROR, TAG, "OCSaveACL API error: %d", rst); + D2D_LOGD( "OCSaveACL API error: %d", rst); goto SVACL_ERROR; } OCDeleteACLList(acl); // after here |acl| points nothing @@ -1012,18 +1014,18 @@ static int getCred(void) OCProvisionDev_t* dev = getDevInst((const OCProvisionDev_t*) g_own_list, dev_num); if(!dev) { - OIC_LOG(ERROR, TAG, "getDevInst: device instance empty"); + D2D_LOGE( "getDevInst: device instance empty"); goto PVACL_ERROR; } OCStackResult rst = OCGetCredResource((void*) g_ctx, dev, getCredCB); if(OC_STACK_OK != rst) { - OIC_LOG_V(ERROR, TAG, "OCGetCred API error: %d", rst); + D2D_LOGD( "OCGetCred API error: %d", rst); goto PVACL_ERROR; } if(waitCallbackRet()) // input |g_doneCB| flag implicitly { - OIC_LOG(ERROR, TAG, "OCGetCredResource callback error"); + D2D_LOGE( "OCGetCredResource callback error"); goto PVACL_ERROR; } @@ -1071,19 +1073,19 @@ static int getAcl(void) OCProvisionDev_t* dev = getDevInst((const OCProvisionDev_t*) g_own_list, dev_num); if(!dev) { - OIC_LOG(ERROR, TAG, "getDevInst: device instance empty"); + D2D_LOGE( "getDevInst: device instance empty"); goto PVACL_ERROR; } OCStackResult rst = OCGetACLResource((void*) g_ctx, dev, getAclCB); if(OC_STACK_OK != rst) { - OIC_LOG_V(ERROR, TAG, "OCGetACLResource API error: %d", rst); + D2D_LOGD( "OCGetACLResource API error: %d", rst); goto PVACL_ERROR; } if(waitCallbackRet()) // input |g_doneCB| flag implicitly { - OIC_LOG(ERROR, TAG, "OCGetACLResource callback error"); + D2D_LOGE( "OCGetACLResource callback error"); goto PVACL_ERROR; } @@ -1110,7 +1112,7 @@ static int unlinkPairwise(void) int dev_num[2] = {0}; if(selectTwoDiffNum(&(dev_num[0]), &(dev_num[1]), g_own_cnt, "for Unlinking Devices")) { - OIC_LOG(ERROR, TAG, "selectTwoDiffNum error return"); + D2D_LOGE( "selectTwoDiffNum error return"); return -1; } @@ -1126,12 +1128,12 @@ static int unlinkPairwise(void) unlinkDevicesCB); if(OC_STACK_OK != rst) { - OIC_LOG_V(ERROR, TAG, "OCUnlinkDevices API error: %d", rst); + D2D_LOGD( "OCUnlinkDevices API error: %d", rst); return -1; } if(waitCallbackRet()) // input |g_doneCB| flag implicitly { - OIC_LOG(ERROR, TAG, "OCProvisionCredentials callback error"); + D2D_LOGE( "OCProvisionCredentials callback error"); return -1; } @@ -1180,12 +1182,12 @@ static int removeDevice(void) getDevInst((const OCProvisionDev_t*) g_own_list, dev_num), removeDeviceCB); if(OC_STACK_OK != rst) { - OIC_LOG_V(ERROR, TAG, "OCRemoveDevice API error: %d", rst); + D2D_LOGD( "OCRemoveDevice API error: %d", rst); return -1; } if(waitCallbackRet()) // input |g_doneCB| flag implicitly { - OIC_LOG(ERROR, TAG, "OCProvisionCredentials callback error"); + D2D_LOGE( "OCProvisionCredentials callback error"); return -1; } @@ -1210,7 +1212,7 @@ static int removeDeviceWithUuid(void) OCStackResult rst = ConvertStrToUuid(strUuid, &revUuid); if(OC_STACK_OK != rst) { - OIC_LOG_V(ERROR, TAG, "ConvertStrToUuid API error: %d", rst); + D2D_LOGD( "ConvertStrToUuid API error: %d", rst); return -1; } @@ -1218,13 +1220,13 @@ static int removeDeviceWithUuid(void) rst = OCRemoveDeviceWithUuid("RemoveDeviceWithUUID", DISCOVERY_TIMEOUT, &revUuid, removeDeviceCB); if(OC_STACK_OK != rst) { - OIC_LOG_V(ERROR, TAG, "OCRemoveDeviceWithUuid API error: %d", rst); + D2D_LOGD( "OCRemoveDeviceWithUuid API error: %d", rst); return -1; } if(waitCallbackRet()) // input |g_doneCB| flag implicitly { - OIC_LOG(ERROR, TAG, "OCRemoveDeviceWithUuid callback error"); + D2D_LOGE( "OCRemoveDeviceWithUuid callback error"); return -1; } @@ -1237,18 +1239,18 @@ static int removeDeviceWithUuid(void) OCStackResult displayNumCB(void * ctx, uint8_t mutualVerifNum[MUTUAL_VERIF_NUM_LEN]) { - OIC_LOG(INFO, TAG, "IN displayMutualVerifNumCB"); + D2D_LOGE( "IN displayMutualVerifNumCB"); OC_UNUSED(ctx); if (NULL != mutualVerifNum) { - OIC_LOG(INFO, TAG, "############ mutualVerifNum ############"); - OIC_LOG_BUFFER(INFO, TAG, mutualVerifNum, MUTUAL_VERIF_NUM_LEN); - OIC_LOG(INFO, TAG, "############ mutualVerifNum ############"); - OIC_LOG(INFO, TAG, "OUT displayMutualVerifNumCB"); + D2D_LOGE( "############ mutualVerifNum ############"); + //D2D_LOGD( mutualVerifNum, MUTUAL_VERIF_NUM_LEN); + D2D_LOGE( "############ mutualVerifNum ############"); + D2D_LOGE( "OUT displayMutualVerifNumCB"); } else { - OIC_LOG(INFO, TAG, "############ Confirm on the Server side ############"); + D2D_LOGE( "############ Confirm on the Server side ############"); } return OC_STACK_OK; } @@ -1286,9 +1288,9 @@ OCStackResult notifyInputStateCB(void * ctx) { OC_UNUSED(ctx); - OIC_LOG(DEBUG, TAG, "IN notifyInputStateCB"); - OIC_LOG(DEBUG, TAG, "User input Callback in progress"); - OIC_LOG(DEBUG, TAG, "OUT notifyInputStateCB"); + D2D_LOGE( "IN notifyInputStateCB"); + D2D_LOGE( "User input Callback in progress"); + D2D_LOGE( "OUT notifyInputStateCB"); return OC_STACK_OK; } @@ -1349,13 +1351,13 @@ static int changeMultipleOwnershipTrnasferMode(void) } else { - OIC_LOG(ERROR, TAG, "OCChangeMOTMode API error"); + D2D_LOGE( "OCChangeMOTMode API error"); return -1; } if(waitCallbackRet()) // input |g_doneCB| flag implicitly { - OIC_LOG(ERROR, TAG, "waitCallbackRet callback error"); + D2D_LOGE( "waitCallbackRet callback error"); return -1; } @@ -1420,13 +1422,13 @@ static int selectMultipleOwnershipTrnasferMethod(void) } else { - OIC_LOG(ERROR, TAG, "OCSelectMOTMethod API error"); + D2D_LOGE( "OCSelectMOTMethod API error"); return -1; } if(waitCallbackRet()) // input |g_doneCB| flag implicitly { - OIC_LOG(ERROR, TAG, "waitCallbackRet callback error"); + D2D_LOGE( "waitCallbackRet callback error"); return -1; } @@ -1477,13 +1479,13 @@ static int provisionPreconfigPIN() } else { - OIC_LOG(ERROR, TAG, "OCProvisionPreconfigPin API error"); + D2D_LOGE( "OCProvisionPreconfigPin API error"); return -1; } if(waitCallbackRet()) // input |g_doneCB| flag implicitly { - OIC_LOG(ERROR, TAG, "waitCallbackRet callback error"); + D2D_LOGE( "waitCallbackRet callback error"); return -1; } @@ -1558,7 +1560,7 @@ static int removeSubOwner(void) if(waitCallbackRet()) // input |g_doneCB| flag implicitly { - OIC_LOG(ERROR, TAG, "waitCallbackRet callback error"); + D2D_LOGE( "waitCallbackRet callback error"); return -1; } return 0; @@ -1618,7 +1620,7 @@ static int removeAllSubOwner(void) if(waitCallbackRet()) // input |g_doneCB| flag implicitly { - OIC_LOG(ERROR, TAG, "waitCallbackRet callback error"); + D2D_LOGE( "waitCallbackRet callback error"); return -1; } return 0; @@ -1668,13 +1670,13 @@ static int resetDevice(void) getDevInst((const OCProvisionDev_t *) g_own_list, dev_num), syncDeviceCB); if (OC_STACK_OK != rst) { - OIC_LOG_V(ERROR, TAG, "OCResetDevice API error: %d", rst); + D2D_LOGD( "OCResetDevice API error: %d", rst); return -1; } if (waitCallbackRet()) // input |g_doneCB| flag implicitly { - OIC_LOG(ERROR, TAG, "OCProvisionCredentials callback error"); + D2D_LOGE( "OCProvisionCredentials callback error"); return -1; } @@ -1691,7 +1693,7 @@ static int resetSVRDB(void) OCStackResult rst = OCResetSVRDB(); if (OC_STACK_OK != rst) { - OIC_LOG_V(ERROR, TAG, "OCResetSVRDB API error: %d", rst); + D2D_LOGD( "OCResetSVRDB API error: %d", rst); return -1; } return 0; @@ -1701,7 +1703,7 @@ static OicSecAcl_t* createAcl(const int dev_num) { if(0>=dev_num || g_own_cntaces, ace); @@ -1742,7 +1744,7 @@ static OicSecAcl_t* createAcl(const int dev_num) OCProvisionDev_t* dev = getDevInst((const OCProvisionDev_t*)g_own_list, num); if(!dev || !dev->doxm) { - OIC_LOG(ERROR, TAG, "createAcl: device instance empty"); + D2D_LOGE( "createAcl: device instance empty"); goto CRACL_ERROR; } memcpy(&ace->subjectuuid, &dev->doxm->deviceID, UUID_LENGTH); @@ -1776,7 +1778,7 @@ static OicSecAcl_t* createAcl(const int dev_num) OicSecRsrc_t* rsrc = (OicSecRsrc_t*)OICCalloc(1, sizeof(OicSecRsrc_t)); if(!rsrc) { - OIC_LOG(ERROR, TAG, "createAcl: OICCalloc error return"); + D2D_LOGE( "createAcl: OICCalloc error return"); goto CRACL_ERROR; } @@ -1791,7 +1793,7 @@ static OicSecAcl_t* createAcl(const int dev_num) rsrc->href = (char*) OICCalloc(len, sizeof(char)); if(!rsrc->href) { - OIC_LOG(ERROR, TAG, "createAcl: OICCalloc error return"); + D2D_LOGE( "createAcl: OICCalloc error return"); goto CRACL_ERROR; } OICStrcpy(rsrc->href, len, rsrc_in); @@ -1817,7 +1819,7 @@ static OicSecAcl_t* createAcl(const int dev_num) rsrc->types = (char**)OICCalloc(arrLen, sizeof(char*)); if(!rsrc->types) { - OIC_LOG(ERROR, TAG, "createAcl: OICCalloc error return"); + D2D_LOGE( "createAcl: OICCalloc error return"); goto CRACL_ERROR; } @@ -1833,7 +1835,7 @@ static OicSecAcl_t* createAcl(const int dev_num) rsrc->types[i] = OICStrdup(rsrc_in); if(!rsrc->types[i]) { - OIC_LOG(ERROR, TAG, "createAcl: OICStrdup error return"); + D2D_LOGE( "createAcl: OICStrdup error return"); goto CRACL_ERROR; } } @@ -1858,7 +1860,7 @@ static OicSecAcl_t* createAcl(const int dev_num) rsrc->interfaces = (char**)OICCalloc(arrLen, sizeof(char*)); if(!rsrc->interfaces) { - OIC_LOG(ERROR, TAG, "createAcl: OICCalloc error return"); + D2D_LOGE( "createAcl: OICCalloc error return"); goto CRACL_ERROR; } @@ -1874,7 +1876,7 @@ static OicSecAcl_t* createAcl(const int dev_num) rsrc->interfaces[i] = OICStrdup(rsrc_in); if(!rsrc->interfaces[i]) { - OIC_LOG(ERROR, TAG, "createAcl: OICStrdup error return"); + D2D_LOGE( "createAcl: OICStrdup error return"); goto CRACL_ERROR; } } @@ -1922,19 +1924,19 @@ CRACL_ERROR: static OicSecAcl_t* createSimpleAcl(const OicUuid_t uuid) { - OIC_LOG(DEBUG, TAG, "createSimpleAcl IN"); + D2D_LOGE( "createSimpleAcl IN"); // allocate memory for |acl| struct OicSecAcl_t* acl = (OicSecAcl_t*) OICCalloc(1, sizeof(OicSecAcl_t)); if(!acl) { - OIC_LOG(DEBUG, TAG, "OICCalloc error return"); + D2D_LOGE( "OICCalloc error return"); return NULL; // not need to 'goto' |ERROR| before allocating |acl| } OicSecAce_t* ace = (OicSecAce_t*) OICCalloc(1, sizeof(OicSecAce_t)); if(!ace) { - OIC_LOG(DEBUG, TAG, "OICCalloc error return"); + D2D_LOGE( "OICCalloc error return"); return NULL; // not need to 'goto' |ERROR| before allocating |acl| } LL_APPEND(acl->aces, ace); @@ -1944,7 +1946,7 @@ static OicSecAcl_t* createSimpleAcl(const OicUuid_t uuid) OicSecRsrc_t* rsrc = (OicSecRsrc_t*)OICCalloc(1, sizeof(OicSecRsrc_t)); if(!rsrc) { - OIC_LOG(DEBUG, TAG, "OICCalloc error return"); + D2D_LOGE( "OICCalloc error return"); OCDeleteACLList(acl); return NULL; } @@ -1954,7 +1956,7 @@ static OicSecAcl_t* createSimpleAcl(const OicUuid_t uuid) rsrc->href = (char*) OICCalloc(len, sizeof(char)); if(!rsrc->href) { - OIC_LOG(DEBUG, TAG, "OICCalloc error return"); + D2D_LOGE( "OICCalloc error return"); OCDeleteACLList(acl); return NULL; } @@ -1965,7 +1967,7 @@ static OicSecAcl_t* createSimpleAcl(const OicUuid_t uuid) rsrc->types = (char**)OICCalloc(arrLen, sizeof(char*)); if(!rsrc->types) { - OIC_LOG(DEBUG, TAG, "OICCalloc error return"); + D2D_LOGE( "OICCalloc error return"); OCDeleteACLList(acl); return NULL; } @@ -1975,7 +1977,7 @@ static OicSecAcl_t* createSimpleAcl(const OicUuid_t uuid) rsrc->interfaces = (char**)OICCalloc(arrLen, sizeof(char*)); if(!rsrc->interfaces) { - OIC_LOG(DEBUG, TAG, "OICCalloc error return"); + D2D_LOGE( "OICCalloc error return"); OCDeleteACLList(acl); return NULL; } @@ -1985,7 +1987,7 @@ static OicSecAcl_t* createSimpleAcl(const OicUuid_t uuid) ace->permission = 31; // R/W/U/D - OIC_LOG(DEBUG, TAG, "createSimpleAcl OUT"); + D2D_LOGE( "createSimpleAcl OUT"); return acl; } @@ -1994,7 +1996,7 @@ static OicSecPdAcl_t* createPdAcl(const int dev_num) { if(0>=dev_num || g_own_cntresources = (char**) OICCalloc(num, sizeof(char*)); if(!pdAcl->resources) { - OIC_LOG(ERROR, TAG, "createPdAcl: OICCalloc error return"); + D2D_LOGE( "createPdAcl: OICCalloc error return"); goto CRPDACL_ERROR; } for(int i=0; num>i; ++i) @@ -2026,7 +2028,7 @@ static OicSecPdAcl_t* createPdAcl(const int dev_num) char* rsrc = (char*) OICCalloc(len, sizeof(char)); if(!rsrc) { - OIC_LOG(ERROR, TAG, "createPdAcl: OICCalloc error return"); + D2D_LOGE( "createPdAcl: OICCalloc error return"); goto CRPDACL_ERROR; } OICStrcpy(rsrc, len, rsrc_in[i]); @@ -2159,12 +2161,12 @@ static int peerCertCallback(void *ctx, const mbedtls_x509_crt *cert, int depth) { (void)ctx; - OIC_LOG_V(DEBUG, TAG, "Depth : %d", depth); - OIC_LOG_V(DEBUG, TAG, "IN %s", __func__); - OIC_LOG(DEBUG, TAG, "***** Serial number of certificate is below *****"); - OIC_LOG_BUFFER(DEBUG, TAG, cert->serial.p, cert->serial.len); - OIC_LOG(DEBUG, TAG, "***** Serial number of certificate is above *****"); - OIC_LOG_V(DEBUG, TAG, "OUT%s", __func__); + D2D_LOGD( "Depth : %d", depth); + D2D_LOGD( "IN %s", __func__); + D2D_LOGE( "***** Serial number of certificate is below *****"); + //D2D_LOGD( cert->serial.p, cert->serial.len); + D2D_LOGE( "***** Serial number of certificate is above *****"); + D2D_LOGD( "OUT%s", __func__); return 0; } @@ -2176,7 +2178,7 @@ static int waitCallbackRet(void) sleep(1); if(OC_STACK_OK != OCProcess()) { - OIC_LOG(ERROR, TAG, "OCStack process error"); + D2D_LOGE( "OCStack process error"); return -1; } } @@ -2454,18 +2456,18 @@ static void SslExportKeysCallback(const unsigned char* masterSecret, const unsigned char* keyBlock, size_t macLen, size_t keyLen, size_t ivLen) { - OIC_LOG_V(INFO, TAG, "In %s ", __func__); + D2D_LOGD("In %s ", __func__); - OIC_LOG(INFO, TAG, "[MASTER SECRET] : "); - OIC_LOG_BUFFER(INFO, TAG, masterSecret, 48); + D2D_LOGE("[MASTER SECRET] : "); + //D2D_LOGD("%s %d", masterSecret, 48); - OIC_LOG(INFO, TAG, "[KEY BLOCK] : "); - OIC_LOG_BUFFER(INFO, TAG, keyBlock, (2 * macLen) + (2 * keyLen) + (2 * ivLen)); + D2D_LOGE("[KEY BLOCK] : "); + //D2D_LOGD("%s %d", keyBlock, (2 * macLen) + (2 * keyLen) + (2 * ivLen)); - OIC_LOG_V(INFO, TAG, "Mac Length = %zu, Key Length = %zu, IV Length = %zu", + D2D_LOGD("Mac Length = %zu, Key Length = %zu, IV Length = %zu", macLen, keyLen, ivLen); - OIC_LOG_V(INFO, TAG, "Out %s ", __func__); + D2D_LOGD("Out %s ", __func__); } // main function for provisioning client using C-level provisioning API @@ -2474,21 +2476,21 @@ int main() // initialize provisioning client if(initProvisionClient()) { - OIC_LOG(ERROR, TAG, "ProvisionClient init error"); + D2D_LOGE( "ProvisionClient init error"); goto PMCLT_ERROR; } if (CA_STATUS_OK != CASetSslExportKeysCallback(SslExportKeysCallback, CA_SSL_EKCB_DTLS, CA_SSL_EKCB_CLIENT)) { - OIC_LOG(ERROR, TAG, "Failed to register the (D)TLS export Key Callback!"); + D2D_LOGE( "Failed to register the (D)TLS export Key Callback!"); goto PMCLT_ERROR; } // Client can choose a allowed/not-allowed OxM method. if(OC_STACK_OK != OCSetOxmAllowStatus(OIC_DECENTRALIZED_PUBLIC_KEY, false)) { - OIC_LOG(WARNING, TAG, "Failed to disable OIC_DECENTRALIZED_PUBLIC_KEY OxM"); + D2D_LOGE( "Failed to disable OIC_DECENTRALIZED_PUBLIC_KEY OxM"); } // set callbacks for verification options @@ -2522,142 +2524,142 @@ int main() case _10_DISCOV_ALL_DEVS_: if(discoverAllDevices()) { - OIC_LOG(ERROR, TAG, "_10_DISCOV_ALL_DEVS_: error"); + D2D_LOGE( "_10_DISCOV_ALL_DEVS_: error"); } break; case _11_DISCOV_UNOWN_DEVS_: if(discoverUnownedDevices()) { - OIC_LOG(ERROR, TAG, "_11_DISCOV_UNOWN_DEVS_: error"); + D2D_LOGE( "_11_DISCOV_UNOWN_DEVS_: error"); } break; case _12_DISCOV_OWN_DEVS_: if(discoverOwnedDevices()) { - OIC_LOG(ERROR, TAG, "_12_DISCOV_OWN_DEVS_: error"); + D2D_LOGE( "_12_DISCOV_OWN_DEVS_: error"); } break; #ifdef MULTIPLE_OWNER case _13_MOT_DISCOV_DEV_: if(discoverMOTEnabledDevices()) { - OIC_LOG(ERROR, TAG, "_13_MOT_DISCOV_DEV_: error"); + D2D_LOGE( "_13_MOT_DISCOV_DEV_: error"); } break; #endif //MULTIPLE_OWNER case _20_REGIST_DEVS_: if(registerDevices()) { - OIC_LOG(ERROR, TAG, "_20_REGIST_DEVS_: error"); + D2D_LOGE( "_20_REGIST_DEVS_: error"); } break; case _30_PROVIS_PAIR_DEVS_: if(provisionPairwise()) { - OIC_LOG(ERROR, TAG, "_30_PROVIS_PAIR_DEVS_: error"); + D2D_LOGE( "_30_PROVIS_PAIR_DEVS_: error"); } break; case _31_PROVIS_CRED_: if(provisionCred()) { - OIC_LOG(ERROR, TAG, "_31_PROVIS_CRED_: error"); + D2D_LOGE( "_31_PROVIS_CRED_: error"); } break; case _32_PROVIS_ACL_: if(provisionAcl()) { - OIC_LOG(ERROR, TAG, "_32_PROVIS_ACL_: error"); + D2D_LOGE( "_32_PROVIS_ACL_: error"); } break; case _33_PROVIS_DP_: if(provisionDirectPairing()) { - OIC_LOG(ERROR, TAG, "_33_PROVIS_DP_: error"); + D2D_LOGE( "_33_PROVIS_DP_: error"); } break; case _34_CHECK_LINK_STATUS_: if(checkLinkedStatus()) { - OIC_LOG(ERROR, TAG, "_34_CHECK_LINK_STATUS_: error"); + D2D_LOGE( "_34_CHECK_LINK_STATUS_: error"); } break; case _35_SAVE_ACL_: if(saveAcl()) { - OIC_LOG(ERROR, TAG, "_35_SAVE_ACL_: error"); + D2D_LOGE( "_35_SAVE_ACL_: error"); } break; case _40_UNLINK_PAIR_DEVS_: if(unlinkPairwise()) { - OIC_LOG(ERROR, TAG, "_40_UNLINK_PAIR_DEVS_: error"); + D2D_LOGE( "_40_UNLINK_PAIR_DEVS_: error"); } break; case _50_REMOVE_SELEC_DEV_: if(removeDevice()) { - OIC_LOG(ERROR, TAG, "_50_REMOVE_SELEC_DEV_: error"); + D2D_LOGE( "_50_REMOVE_SELEC_DEV_: error"); } break; case _51_REMOVE_DEV_WITH_UUID_: if(removeDeviceWithUuid()) { - OIC_LOG(ERROR, TAG, "_51_REMOVE_DEV_WITH_UUID_: error"); + D2D_LOGE( "_51_REMOVE_DEV_WITH_UUID_: error"); } break; case _52_RESET_SELEC_DEV_: if(resetDevice()) { - OIC_LOG(ERROR, TAG, "_52_RESET_SELEC_DEV_: error"); + D2D_LOGE( "_52_RESET_SELEC_DEV_: error"); } break; case _53_RESET_SVR_DB_: if(resetSVRDB()) { - OIC_LOG(ERROR, TAG, "_53_RESET_SVR_DB_: error"); + D2D_LOGE( "_53_RESET_SVR_DB_: error"); } break; case _60_GET_CRED_: if(getCred()) { - OIC_LOG(ERROR, TAG, "_60_GET_CRED_: error"); + D2D_LOGE( "_60_GET_CRED_: error"); } break; case _61_GET_ACL_: if(getAcl()) { - OIC_LOG(ERROR, TAG, "_61_GET_ACL_: error"); + D2D_LOGE( "_61_GET_ACL_: error"); } break; #ifdef MULTIPLE_OWNER case _70_MOT_CHANGE_MOM_: if(changeMultipleOwnershipTrnasferMode()) { - OIC_LOG(ERROR, TAG, "_70_MOT_CHANGE_MOM_: error"); + D2D_LOGE( "_70_MOT_CHANGE_MOM_: error"); } break; case _71_MOT_PROV_PRECONF_PIN_: if(provisionPreconfigPIN()) { - OIC_LOG(ERROR, TAG, "_71_MOT_PROV_PRECONF_PIN_: error"); + D2D_LOGE( "_71_MOT_PROV_PRECONF_PIN_: error"); } break; case _72_MOT_OXM_SEL_: if(selectMultipleOwnershipTrnasferMethod()) { - OIC_LOG(ERROR, TAG, "_72_MOT_OXM_SEL_: error"); + D2D_LOGE( "_72_MOT_OXM_SEL_: error"); } break; case _73_MOT_REMOVE_SUBOWNER_: if(removeSubOwner()) { - OIC_LOG(ERROR, TAG, "_73_MOT_REMOVE_SUBOWNER_ : error"); + D2D_LOGE( "_73_MOT_REMOVE_SUBOWNER_ : error"); } break; case _74_MOT_REMOVE_ALL_SUBOWNER_: if(removeAllSubOwner()) { - OIC_LOG(ERROR, TAG, "_74_MOT_REMOVE_ALL_SUBOWNER_ : error"); + D2D_LOGE( "_74_MOT_REMOVE_ALL_SUBOWNER_ : error"); } break; #endif //MULTIPLE_OWNER @@ -2683,7 +2685,7 @@ int main() PMCLT_ERROR: if(OC_STACK_OK != OCStop()) { - OIC_LOG(ERROR, TAG, "OCStack stop error"); + D2D_LOGE( "OCStack stop error"); } OCDeleteDiscoveredDevices(g_own_list); // after here |g_own_list| points nothing OCDeleteDiscoveredDevices(g_unown_list); // after here |g_unown_list| points nothing diff --git a/test/sampleserver_justworks.cpp b/test/sampleserver_justworks.cpp index 4df1b94..f242ee4 100644 --- a/test/sampleserver_justworks.cpp +++ b/test/sampleserver_justworks.cpp @@ -37,6 +37,7 @@ #include "srmutility.h" #include +#include #define MAX_FILE_PATH_LEN 1024 @@ -153,7 +154,7 @@ OCRepPayload* getPayload(const char* uri, int64_t power, bool state) OCRepPayload* payload = OCRepPayloadCreate(); if(!payload) { - OIC_LOG(ERROR, TAG, "Failed to allocate Payload"); + D2D_LOGE( "Failed to allocate Payload"); return NULL; } @@ -169,7 +170,7 @@ OCRepPayload* constructResponse (OCEntityHandlerRequest *ehRequest) { if(ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION) { - OIC_LOG(ERROR, TAG, "Incoming payload not a representation"); + D2D_LOGE( "Incoming payload not a representation"); return NULL; } @@ -279,7 +280,7 @@ OCEntityHandlerResult ProcessPostRequest (OCEntityHandlerRequest *ehRequest, if (0 == createLEDResource (newLedUri, &gLedInstance[gCurrLedInstance], false, 0)) { - OIC_LOG (INFO, TAG, "Created new LED instance"); + D2D_LOGE ( "Created new LED instance"); gLedInstance[gCurrLedInstance].state = 0; gLedInstance[gCurrLedInstance].power = 0; gCurrLedInstance++; @@ -318,7 +319,7 @@ OCEntityHandlerResult ProcessPostRequest (OCEntityHandlerRequest *ehRequest, } else { - OIC_LOG_V (INFO, TAG, "Payload was NULL"); + D2D_LOGD ( "Payload was NULL"); ehResult = OC_EH_ERROR; } @@ -330,7 +331,7 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, OCEntityHandlerRequest *entityHandlerRequest, void* callbackParam) { - OIC_LOG_V (INFO, TAG, "Inside entity handler - flags: 0x%x", flag); + D2D_LOGD ( "Inside entity handler - flags: 0x%x", flag); (void)callbackParam; OCEntityHandlerResult ehResult = OC_EH_ERROR; @@ -340,7 +341,7 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, // Validate pointer if (!entityHandlerRequest) { - OIC_LOG (ERROR, TAG, "Invalid request pointer"); + D2D_LOGE ( "Invalid request pointer"); return OC_EH_ERROR; } @@ -348,27 +349,27 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, if (flag & OC_REQUEST_FLAG) { - OIC_LOG (INFO, TAG, "Flag includes OC_REQUEST_FLAG"); + D2D_LOGE ( "Flag includes OC_REQUEST_FLAG"); if (entityHandlerRequest) { if (OC_REST_GET == entityHandlerRequest->method) { - OIC_LOG (INFO, TAG, "Received OC_REST_GET from client"); + D2D_LOGE ( "Received OC_REST_GET from client"); ehResult = ProcessGetRequest (entityHandlerRequest, &payload); } else if (OC_REST_PUT == entityHandlerRequest->method) { - OIC_LOG (INFO, TAG, "Received OC_REST_PUT from client"); + D2D_LOGE ( "Received OC_REST_PUT from client"); ehResult = ProcessPutRequest (entityHandlerRequest, &payload); } else if (OC_REST_POST == entityHandlerRequest->method) { - OIC_LOG (INFO, TAG, "Received OC_REST_POST from client"); + D2D_LOGE ( "Received OC_REST_POST from client"); ehResult = ProcessPostRequest (entityHandlerRequest, &response, &payload); } else { - OIC_LOG_V (INFO, TAG, "Received unsupported method %d from client", + D2D_LOGD ( "Received unsupported method %d from client", entityHandlerRequest->method); ehResult = OC_EH_ERROR; } @@ -390,7 +391,7 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, // Send the response if (OCDoResponse(&response) != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "Error sending response"); + D2D_LOGE( "Error sending response"); ehResult = OC_EH_ERROR; } } @@ -457,7 +458,7 @@ int main() { struct timespec timeout; - OIC_LOG(DEBUG, TAG, "OCServer is starting..."); + D2D_LOGE( "OCServer is starting..."); //This function should be invoked before invoke OCInit OCSetOtmEventHandler(NULL, OtmEventHandler); @@ -469,7 +470,7 @@ int main() if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCStack init error"); + D2D_LOGE( "OCStack init error"); return 0; } @@ -482,23 +483,23 @@ int main() timeout.tv_nsec = 100000000L; // Break from loop with Ctrl-C - OIC_LOG(INFO, TAG, "Entering ocserver main loop..."); + D2D_LOGE( "Entering ocserver main loop..."); signal(SIGINT, handleSigInt); while (!gQuitFlag) { if (OCProcess() != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCStack process error"); + D2D_LOGE( "OCStack process error"); return 0; } nanosleep(&timeout, NULL); } - OIC_LOG(INFO, TAG, "Exiting ocserver main loop..."); + D2D_LOGE( "Exiting ocserver main loop..."); if (OCStop() != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCStack process error"); + D2D_LOGE( "OCStack process error"); } return 0; @@ -508,7 +509,7 @@ int createLEDResource (char *uri, LEDResource *ledResource, bool resourceState, { if (!uri) { - OIC_LOG(ERROR, TAG, "Resource URI cannot be NULL"); + D2D_LOGE( "Resource URI cannot be NULL"); return -1; } @@ -521,7 +522,7 @@ int createLEDResource (char *uri, LEDResource *ledResource, bool resourceState, OCEntityHandlerCb, NULL, OC_DISCOVERABLE|OC_OBSERVABLE | OC_SECURE); - OIC_LOG_V(INFO, TAG, "Created LED resource with result: %s", getResult(res)); + D2D_LOGD( "Created LED resource with result: %s", getResult(res)); return 0; } diff --git a/test/sampleserver_justworks_protectedDB.cpp b/test/sampleserver_justworks_protectedDB.cpp index c4fbc0d..4f8cd25 100644 --- a/test/sampleserver_justworks_protectedDB.cpp +++ b/test/sampleserver_justworks_protectedDB.cpp @@ -160,7 +160,7 @@ OCRepPayload* getPayload(const char* uri, int64_t power, bool state) OCRepPayload* payload = OCRepPayloadCreate(); if(!payload) { - OIC_LOG(ERROR, TAG, "Failed to allocate Payload"); + D2D_LOGE( "Failed to allocate Payload"); return NULL; } @@ -176,7 +176,7 @@ OCRepPayload* constructResponse (OCEntityHandlerRequest *ehRequest) { if(ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION) { - OIC_LOG(ERROR, TAG, "Incoming payload not a representation"); + D2D_LOGE( "Incoming payload not a representation"); return NULL; } @@ -286,7 +286,7 @@ OCEntityHandlerResult ProcessPostRequest (OCEntityHandlerRequest *ehRequest, if (0 == createLEDResource (newLedUri, &gLedInstance[gCurrLedInstance], false, 0)) { - OIC_LOG (INFO, TAG, "Created new LED instance"); + D2D_LOGE ( "Created new LED instance"); gLedInstance[gCurrLedInstance].state = 0; gLedInstance[gCurrLedInstance].power = 0; gCurrLedInstance++; @@ -325,7 +325,7 @@ OCEntityHandlerResult ProcessPostRequest (OCEntityHandlerRequest *ehRequest, } else { - OIC_LOG_V (INFO, TAG, "Payload was NULL"); + D2D_LOGD ( "Payload was NULL"); ehResult = OC_EH_ERROR; } @@ -337,7 +337,7 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, OCEntityHandlerRequest *entityHandlerRequest, void* callbackParam) { - OIC_LOG_V (INFO, TAG, "Inside entity handler - flags: 0x%x", flag); + D2D_LOGD ( "Inside entity handler - flags: 0x%x", flag); (void)callbackParam; OCEntityHandlerResult ehResult = OC_EH_ERROR; @@ -347,7 +347,7 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, // Validate pointer if (!entityHandlerRequest) { - OIC_LOG (ERROR, TAG, "Invalid request pointer"); + D2D_LOGE ( "Invalid request pointer"); return OC_EH_ERROR; } @@ -355,27 +355,27 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, if (flag & OC_REQUEST_FLAG) { - OIC_LOG (INFO, TAG, "Flag includes OC_REQUEST_FLAG"); + D2D_LOGE ( "Flag includes OC_REQUEST_FLAG"); if (entityHandlerRequest) { if (OC_REST_GET == entityHandlerRequest->method) { - OIC_LOG (INFO, TAG, "Received OC_REST_GET from client"); + D2D_LOGE ( "Received OC_REST_GET from client"); ehResult = ProcessGetRequest (entityHandlerRequest, &payload); } else if (OC_REST_PUT == entityHandlerRequest->method) { - OIC_LOG (INFO, TAG, "Received OC_REST_PUT from client"); + D2D_LOGE ( "Received OC_REST_PUT from client"); ehResult = ProcessPutRequest (entityHandlerRequest, &payload); } else if (OC_REST_POST == entityHandlerRequest->method) { - OIC_LOG (INFO, TAG, "Received OC_REST_POST from client"); + D2D_LOGE ( "Received OC_REST_POST from client"); ehResult = ProcessPostRequest (entityHandlerRequest, &response, &payload); } else { - OIC_LOG_V (INFO, TAG, "Received unsupported method %d from client", + D2D_LOGD ( "Received unsupported method %d from client", entityHandlerRequest->method); ehResult = OC_EH_ERROR; } @@ -397,7 +397,7 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, // Send the response if (OCDoResponse(&response) != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "Error sending response"); + D2D_LOGE( "Error sending response"); ehResult = OC_EH_ERROR; } } @@ -431,7 +431,7 @@ FILE* plain_fopen(const char *path, const char *mode) int plain_unlink(const char *path) { - OIC_LOG(INFO, TAG, "plain DB is removed"); + D2D_LOGE( "plain DB is removed"); (void)path; return unlink(SVR_DB_PLAIN_FILE); } @@ -459,7 +459,7 @@ int main() OCStackResult ret; struct timespec timeout; - OIC_LOG(DEBUG, TAG, "OCServer is starting..."); + D2D_LOGE( "OCServer is starting..."); OCPersistentStorage psPlain = {plain_fopen, fread, NULL, fclose, plain_unlink, NULL, NULL}; OCPersistentStorage psEnc = {encrypted_fopen, fread, fwrite, fclose, @@ -469,20 +469,20 @@ int main() ret = OCSetSecurePSI(key, &psPlain, &psEnc, &psRescue); if (OC_STACK_OK != ret) { - OIC_LOG(ERROR, TAG, "OCSetSecurePSI() error"); + D2D_LOGE( "OCSetSecurePSI() error"); return 1; } ret = OCRegisterPersistentStorageHandler(&psEnc); if (OC_STACK_OK != ret) { - OIC_LOG(ERROR, TAG, "OCRegisterPersistentStorageHandler() error"); + D2D_LOGE( "OCRegisterPersistentStorageHandler() error"); return 1; } if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCStack init error"); + D2D_LOGE( "OCStack init error"); return 1; } @@ -495,23 +495,23 @@ int main() timeout.tv_nsec = 100000000L; // Break from loop with Ctrl-C - OIC_LOG(INFO, TAG, "Entering ocserver main loop..."); + D2D_LOGE( "Entering ocserver main loop..."); signal(SIGINT, handleSigInt); while (!gQuitFlag) { if (OCProcess() != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCStack process error"); + D2D_LOGE( "OCStack process error"); return 1; } nanosleep(&timeout, NULL); } - OIC_LOG(INFO, TAG, "Exiting ocserver main loop..."); + D2D_LOGE( "Exiting ocserver main loop..."); if (OCStop() != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCStack process error"); + D2D_LOGE( "OCStack process error"); } return 0; @@ -521,7 +521,7 @@ int createLEDResource (char *uri, LEDResource *ledResource, bool resourceState, { if (!uri) { - OIC_LOG(ERROR, TAG, "Resource URI cannot be NULL"); + D2D_LOGE( "Resource URI cannot be NULL"); return -1; } @@ -534,7 +534,7 @@ int createLEDResource (char *uri, LEDResource *ledResource, bool resourceState, OCEntityHandlerCb, NULL, OC_DISCOVERABLE|OC_OBSERVABLE | OC_SECURE); - OIC_LOG_V(INFO, TAG, "Created LED resource with result: %s", getResult(res)); + D2D_LOGD( "Created LED resource with result: %s", getResult(res)); return 0; } diff --git a/test/sampleserver_mfg.cpp b/test/sampleserver_mfg.cpp index 431d828..4c12072 100644 --- a/test/sampleserver_mfg.cpp +++ b/test/sampleserver_mfg.cpp @@ -152,7 +152,7 @@ OCRepPayload* getPayload(const char* uri, int64_t power, bool state) OCRepPayload* payload = OCRepPayloadCreate(); if(!payload) { - OIC_LOG(ERROR, TAG, "Failed to allocate Payload"); + D2D_LOGE( "Failed to allocate Payload"); return NULL; } @@ -168,7 +168,7 @@ OCRepPayload* constructResponse (OCEntityHandlerRequest *ehRequest) { if(ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION) { - OIC_LOG(ERROR, TAG, "Incoming payload not a representation"); + D2D_LOGE( "Incoming payload not a representation"); return NULL; } @@ -278,7 +278,7 @@ OCEntityHandlerResult ProcessPostRequest (OCEntityHandlerRequest *ehRequest, if (0 == createLEDResource (newLedUri, &gLedInstance[gCurrLedInstance], false, 0)) { - OIC_LOG (INFO, TAG, "Created new LED instance"); + D2D_LOGE ( "Created new LED instance"); gLedInstance[gCurrLedInstance].state = 0; gLedInstance[gCurrLedInstance].power = 0; gCurrLedInstance++; @@ -317,7 +317,7 @@ OCEntityHandlerResult ProcessPostRequest (OCEntityHandlerRequest *ehRequest, } else { - OIC_LOG_V (INFO, TAG, "Payload was NULL"); + D2D_LOGD ( "Payload was NULL"); ehResult = OC_EH_ERROR; } @@ -329,7 +329,7 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, OCEntityHandlerRequest *entityHandlerRequest, void* callbackParam) { - OIC_LOG_V (INFO, TAG, "Inside entity handler - flags: 0x%x", flag); + D2D_LOGD ( "Inside entity handler - flags: 0x%x", flag); (void)callbackParam; OCEntityHandlerResult ehResult = OC_EH_ERROR; @@ -339,7 +339,7 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, // Validate pointer if (!entityHandlerRequest) { - OIC_LOG (ERROR, TAG, "Invalid request pointer"); + D2D_LOGE ( "Invalid request pointer"); return OC_EH_ERROR; } @@ -347,27 +347,27 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, if (flag & OC_REQUEST_FLAG) { - OIC_LOG (INFO, TAG, "Flag includes OC_REQUEST_FLAG"); + D2D_LOGE ( "Flag includes OC_REQUEST_FLAG"); if (entityHandlerRequest) { if (OC_REST_GET == entityHandlerRequest->method) { - OIC_LOG (INFO, TAG, "Received OC_REST_GET from client"); + D2D_LOGE ( "Received OC_REST_GET from client"); ehResult = ProcessGetRequest (entityHandlerRequest, &payload); } else if (OC_REST_PUT == entityHandlerRequest->method) { - OIC_LOG (INFO, TAG, "Received OC_REST_PUT from client"); + D2D_LOGE ( "Received OC_REST_PUT from client"); ehResult = ProcessPutRequest (entityHandlerRequest, &payload); } else if (OC_REST_POST == entityHandlerRequest->method) { - OIC_LOG (INFO, TAG, "Received OC_REST_POST from client"); + D2D_LOGE ( "Received OC_REST_POST from client"); ehResult = ProcessPostRequest (entityHandlerRequest, &response, &payload); } else { - OIC_LOG_V (INFO, TAG, "Received unsupported method %d from client", + D2D_LOGD ( "Received unsupported method %d from client", entityHandlerRequest->method); ehResult = OC_EH_ERROR; } @@ -389,7 +389,7 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, // Send the response if (OCDoResponse(&response) != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "Error sending response"); + D2D_LOGE( "Error sending response"); ehResult = OC_EH_ERROR; } } @@ -454,7 +454,7 @@ int main(int argc, char **argv) { struct timespec timeout; - OIC_LOG(DEBUG, TAG, "OCServer is starting..."); + D2D_LOGE( "OCServer is starting..."); int opt; char cert_file[4096] = {0,}; @@ -492,7 +492,7 @@ int main(int argc, char **argv) if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCStack init error"); + D2D_LOGE( "OCStack init error"); return 0; } @@ -530,23 +530,23 @@ int main(int argc, char **argv) timeout.tv_nsec = 100000000L; // Break from loop with Ctrl-C - OIC_LOG(INFO, TAG, "Entering ocserver main loop..."); + D2D_LOGE( "Entering ocserver main loop..."); signal(SIGINT, handleSigInt); while (!gQuitFlag) { if (OCProcess() != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCStack process error"); + D2D_LOGE( "OCStack process error"); return 0; } nanosleep(&timeout, NULL); } - OIC_LOG(INFO, TAG, "Exiting ocserver main loop..."); + D2D_LOGE( "Exiting ocserver main loop..."); if (OCStop() != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCStack process error"); + D2D_LOGE( "OCStack process error"); } return 0; @@ -556,7 +556,7 @@ int createLEDResource (char *uri, LEDResource *ledResource, bool resourceState, { if (!uri) { - OIC_LOG(ERROR, TAG, "Resource URI cannot be NULL"); + D2D_LOGE( "Resource URI cannot be NULL"); return -1; } @@ -569,7 +569,7 @@ int createLEDResource (char *uri, LEDResource *ledResource, bool resourceState, OCEntityHandlerCb, NULL, OC_DISCOVERABLE|OC_OBSERVABLE | OC_SECURE); - OIC_LOG_V(INFO, TAG, "Created LED resource with result: %s", getResult(res)); + D2D_LOGD( "Created LED resource with result: %s", getResult(res)); return 0; } diff --git a/test/sampleserver_mvjustworks.cpp b/test/sampleserver_mvjustworks.cpp index 0f0a480..b67e533 100644 --- a/test/sampleserver_mvjustworks.cpp +++ b/test/sampleserver_mvjustworks.cpp @@ -50,8 +50,7 @@ #include "platform_features.h" #include "logger.h" - -#define TAG "SAMPLE_MV_JUSTWORKS" +#include int gQuitFlag = 0; @@ -153,7 +152,7 @@ OCRepPayload* getPayload(const char* uri, int64_t power, bool state) OCRepPayload* payload = OCRepPayloadCreate(); if(!payload) { - OIC_LOG(ERROR, TAG, "Failed to allocate Payload"); + D2D_LOGE( "Failed to allocate Payload"); return NULL; } @@ -169,7 +168,7 @@ OCRepPayload* constructResponse (OCEntityHandlerRequest *ehRequest) { if(ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION) { - OIC_LOG(ERROR, TAG, "Incoming payload not a representation"); + D2D_LOGE( "Incoming payload not a representation"); return NULL; } @@ -279,7 +278,7 @@ OCEntityHandlerResult ProcessPostRequest (OCEntityHandlerRequest *ehRequest, if (0 == createLEDResource (newLedUri, &gLedInstance[gCurrLedInstance], false, 0)) { - OIC_LOG (INFO, TAG, "Created new LED instance"); + D2D_LOGE ( "Created new LED instance"); gLedInstance[gCurrLedInstance].state = 0; gLedInstance[gCurrLedInstance].power = 0; gCurrLedInstance++; @@ -318,7 +317,7 @@ OCEntityHandlerResult ProcessPostRequest (OCEntityHandlerRequest *ehRequest, } else { - OIC_LOG_V (INFO, TAG, "Payload was NULL"); + D2D_LOGD ( "Payload was NULL"); ehResult = OC_EH_ERROR; } @@ -330,7 +329,7 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, OCEntityHandlerRequest *entityHandlerRequest, void* callbackParam) { - OIC_LOG_V (INFO, TAG, "Inside entity handler - flags: 0x%x", flag); + D2D_LOGD ( "Inside entity handler - flags: 0x%x", flag); (void)callbackParam; OCEntityHandlerResult ehResult = OC_EH_ERROR; @@ -340,7 +339,7 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, // Validate pointer if (!entityHandlerRequest) { - OIC_LOG (ERROR, TAG, "Invalid request pointer"); + D2D_LOGE ( "Invalid request pointer"); return OC_EH_ERROR; } @@ -348,27 +347,27 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, if (flag & OC_REQUEST_FLAG) { - OIC_LOG (INFO, TAG, "Flag includes OC_REQUEST_FLAG"); + D2D_LOGE ( "Flag includes OC_REQUEST_FLAG"); if (entityHandlerRequest) { if (OC_REST_GET == entityHandlerRequest->method) { - OIC_LOG (INFO, TAG, "Received OC_REST_GET from client"); + D2D_LOGE ( "Received OC_REST_GET from client"); ehResult = ProcessGetRequest (entityHandlerRequest, &payload); } else if (OC_REST_PUT == entityHandlerRequest->method) { - OIC_LOG (INFO, TAG, "Received OC_REST_PUT from client"); + D2D_LOGE ( "Received OC_REST_PUT from client"); ehResult = ProcessPutRequest (entityHandlerRequest, &payload); } else if (OC_REST_POST == entityHandlerRequest->method) { - OIC_LOG (INFO, TAG, "Received OC_REST_POST from client"); + D2D_LOGE ( "Received OC_REST_POST from client"); ehResult = ProcessPostRequest (entityHandlerRequest, &response, &payload); } else { - OIC_LOG_V (INFO, TAG, "Received unsupported method %d from client", + D2D_LOGD ( "Received unsupported method %d from client", entityHandlerRequest->method); ehResult = OC_EH_ERROR; } @@ -390,7 +389,7 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, // Send the response if (OCDoResponse(&response) != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "Error sending response"); + D2D_LOGE( "Error sending response"); ehResult = OC_EH_ERROR; } } @@ -404,11 +403,11 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, OCStackResult displayNumCB(void * ctx, uint8_t mutualVerifNum[MUTUAL_VERIF_NUM_LEN]) { OC_UNUSED(ctx); - OIC_LOG(INFO, TAG, "IN displayNumCB"); - OIC_LOG(INFO, TAG, "############ mutualVerifNum ############"); - OIC_LOG_BUFFER(INFO, TAG, mutualVerifNum, MUTUAL_VERIF_NUM_LEN); - OIC_LOG(INFO, TAG, "############ mutualVerifNum ############"); - OIC_LOG(INFO, TAG, "OUT displayNumCB"); + D2D_LOGE( "IN displayNumCB"); + D2D_LOGE( "############ mutualVerifNum ############"); + D2D_LOGD( mutualVerifNum, MUTUAL_VERIF_NUM_LEN); + D2D_LOGE( "############ mutualVerifNum ############"); + D2D_LOGE( "OUT displayNumCB"); return OC_STACK_OK; } @@ -466,7 +465,7 @@ int main() { struct timespec timeout; - OIC_LOG(DEBUG, TAG, "OCServer is starting..."); + D2D_LOGE( "OCServer is starting..."); // Set callbacks for verification SetDisplayNumCB(NULL, displayNumCB); @@ -483,7 +482,7 @@ int main() if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCStack init error"); + D2D_LOGE( "OCStack init error"); return 0; } @@ -496,23 +495,23 @@ int main() timeout.tv_nsec = 100000000L; // Break from loop with Ctrl-C - OIC_LOG(INFO, TAG, "Entering ocserver main loop..."); + D2D_LOGE( "Entering ocserver main loop..."); signal(SIGINT, handleSigInt); while (!gQuitFlag) { if (OCProcess() != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCStack process error"); + D2D_LOGE( "OCStack process error"); return 0; } nanosleep(&timeout, NULL); } - OIC_LOG(INFO, TAG, "Exiting ocserver main loop..."); + D2D_LOGE( "Exiting ocserver main loop..."); if (OCStop() != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCStack process error"); + D2D_LOGE( "OCStack process error"); } return 0; @@ -522,7 +521,7 @@ int createLEDResource (char *uri, LEDResource *ledResource, bool resourceState, { if (!uri) { - OIC_LOG(ERROR, TAG, "Resource URI cannot be NULL"); + D2D_LOGE( "Resource URI cannot be NULL"); return -1; } @@ -535,7 +534,7 @@ int createLEDResource (char *uri, LEDResource *ledResource, bool resourceState, OCEntityHandlerCb, NULL, OC_DISCOVERABLE|OC_OBSERVABLE | OC_SECURE); - OIC_LOG_V(INFO, TAG, "Created LED resource with result: %s", getResult(res)); + D2D_LOGD( "Created LED resource with result: %s", getResult(res)); return 0; } diff --git a/test/sampleserver_preconfpin.cpp b/test/sampleserver_preconfpin.cpp index d3d662b..138ed6c 100644 --- a/test/sampleserver_preconfpin.cpp +++ b/test/sampleserver_preconfpin.cpp @@ -152,7 +152,7 @@ OCRepPayload* getPayload(const char* uri, int64_t power, bool state) OCRepPayload* payload = OCRepPayloadCreate(); if(!payload) { - OIC_LOG(ERROR, TAG, "Failed to allocate Payload"); + D2D_LOGE( "Failed to allocate Payload"); return NULL; } @@ -168,7 +168,7 @@ OCRepPayload* constructResponse (OCEntityHandlerRequest *ehRequest) { if(ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION) { - OIC_LOG(ERROR, TAG, "Incoming payload not a representation"); + D2D_LOGE( "Incoming payload not a representation"); return NULL; } @@ -278,7 +278,7 @@ OCEntityHandlerResult ProcessPostRequest (OCEntityHandlerRequest *ehRequest, if (0 == createLEDResource (newLedUri, &gLedInstance[gCurrLedInstance], false, 0)) { - OIC_LOG (INFO, TAG, "Created new LED instance"); + D2D_LOGE ( "Created new LED instance"); gLedInstance[gCurrLedInstance].state = 0; gLedInstance[gCurrLedInstance].power = 0; gCurrLedInstance++; @@ -317,7 +317,7 @@ OCEntityHandlerResult ProcessPostRequest (OCEntityHandlerRequest *ehRequest, } else { - OIC_LOG_V (INFO, TAG, "Payload was NULL"); + D2D_LOGD ( "Payload was NULL"); ehResult = OC_EH_ERROR; } @@ -329,7 +329,7 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, OCEntityHandlerRequest *entityHandlerRequest, void* callbackParam) { - OIC_LOG_V (INFO, TAG, "Inside entity handler - flags: 0x%x", flag); + D2D_LOGD ( "Inside entity handler - flags: 0x%x", flag); (void)callbackParam; OCEntityHandlerResult ehResult = OC_EH_ERROR; @@ -339,7 +339,7 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, // Validate pointer if (!entityHandlerRequest) { - OIC_LOG (ERROR, TAG, "Invalid request pointer"); + D2D_LOGE ( "Invalid request pointer"); return OC_EH_ERROR; } @@ -347,27 +347,27 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, if (flag & OC_REQUEST_FLAG) { - OIC_LOG (INFO, TAG, "Flag includes OC_REQUEST_FLAG"); + D2D_LOGE ( "Flag includes OC_REQUEST_FLAG"); if (entityHandlerRequest) { if (OC_REST_GET == entityHandlerRequest->method) { - OIC_LOG (INFO, TAG, "Received OC_REST_GET from client"); + D2D_LOGE ( "Received OC_REST_GET from client"); ehResult = ProcessGetRequest (entityHandlerRequest, &payload); } else if (OC_REST_PUT == entityHandlerRequest->method) { - OIC_LOG (INFO, TAG, "Received OC_REST_PUT from client"); + D2D_LOGE ( "Received OC_REST_PUT from client"); ehResult = ProcessPutRequest (entityHandlerRequest, &payload); } else if (OC_REST_POST == entityHandlerRequest->method) { - OIC_LOG (INFO, TAG, "Received OC_REST_POST from client"); + D2D_LOGE ( "Received OC_REST_POST from client"); ehResult = ProcessPostRequest (entityHandlerRequest, &response, &payload); } else { - OIC_LOG_V (INFO, TAG, "Received unsupported method %d from client", + D2D_LOGD ( "Received unsupported method %d from client", entityHandlerRequest->method); ehResult = OC_EH_ERROR; } @@ -389,7 +389,7 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, // Send the response if (OCDoResponse(&response) != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "Error sending response"); + D2D_LOGE( "Error sending response"); ehResult = OC_EH_ERROR; } } @@ -424,7 +424,7 @@ int main() { struct timespec timeout; - OIC_LOG(DEBUG, TAG, "OCServer is starting..."); + D2D_LOGE( "OCServer is starting..."); // Initialize Persistent Storage for SVR database OCPersistentStorage ps = {server_fopen, fread, fwrite, fclose, unlink}; @@ -433,7 +433,7 @@ int main() if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCStack init error"); + D2D_LOGE( "OCStack init error"); return 0; } @@ -446,23 +446,23 @@ int main() timeout.tv_nsec = 100000000L; // Break from loop with Ctrl-C - OIC_LOG(INFO, TAG, "Entering ocserver main loop..."); + D2D_LOGE( "Entering ocserver main loop..."); signal(SIGINT, handleSigInt); while (!gQuitFlag) { if (OCProcess() != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCStack process error"); + D2D_LOGE( "OCStack process error"); return 0; } nanosleep(&timeout, NULL); } - OIC_LOG(INFO, TAG, "Exiting ocserver main loop..."); + D2D_LOGE( "Exiting ocserver main loop..."); if (OCStop() != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCStack process error"); + D2D_LOGE( "OCStack process error"); } return 0; @@ -472,7 +472,7 @@ int createLEDResource (char *uri, LEDResource *ledResource, bool resourceState, { if (!uri) { - OIC_LOG(ERROR, TAG, "Resource URI cannot be NULL"); + D2D_LOGE( "Resource URI cannot be NULL"); return -1; } @@ -485,7 +485,7 @@ int createLEDResource (char *uri, LEDResource *ledResource, bool resourceState, OCEntityHandlerCb, NULL, OC_DISCOVERABLE|OC_OBSERVABLE | OC_SECURE); - OIC_LOG_V(INFO, TAG, "Created LED resource with result: %s", getResult(res)); + D2D_LOGD( "Created LED resource with result: %s", getResult(res)); return 0; } diff --git a/test/sampleserver_randompin.cpp b/test/sampleserver_randompin.cpp index 4b94de4..b68994e 100644 --- a/test/sampleserver_randompin.cpp +++ b/test/sampleserver_randompin.cpp @@ -161,7 +161,7 @@ static void oc_process_loop() { if (OCProcess() != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCStack process error"); + D2D_LOGE( "OCStack process error"); g_LoopFlag = false; break; } @@ -188,7 +188,7 @@ OCRepPayload* getPayload(const char* uri, int64_t power, bool state) OCRepPayload* payload = OCRepPayloadCreate(); if(!payload) { - OIC_LOG(ERROR, TAG, "Failed to allocate Payload"); + D2D_LOGE( "Failed to allocate Payload"); return NULL; } @@ -204,7 +204,7 @@ OCRepPayload* constructResponse (OCEntityHandlerRequest *ehRequest) { if(ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION) { - OIC_LOG(ERROR, TAG, "Incoming payload not a representation"); + D2D_LOGE( "Incoming payload not a representation"); return NULL; } @@ -314,7 +314,7 @@ OCEntityHandlerResult ProcessPostRequest (OCEntityHandlerRequest *ehRequest, if (0 == createLEDResource (newLedUri, &gLedInstance[gCurrLedInstance], false, 0)) { - OIC_LOG (INFO, TAG, "Created new LED instance"); + D2D_LOGE ( "Created new LED instance"); gLedInstance[gCurrLedInstance].state = 0; gLedInstance[gCurrLedInstance].power = 0; gCurrLedInstance++; @@ -353,7 +353,7 @@ OCEntityHandlerResult ProcessPostRequest (OCEntityHandlerRequest *ehRequest, } else { - OIC_LOG_V (INFO, TAG, "Payload was NULL"); + D2D_LOGD ( "Payload was NULL"); ehResult = OC_EH_ERROR; } @@ -365,7 +365,7 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, OCEntityHandlerRequest *entityHandlerRequest, void* callbackParam) { - OIC_LOG_V (INFO, TAG, "Inside entity handler - flags: 0x%x", flag); + D2D_LOGD ( "Inside entity handler - flags: 0x%x", flag); (void)callbackParam; OCEntityHandlerResult ehResult = OC_EH_ERROR; @@ -375,7 +375,7 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, // Validate pointer if (!entityHandlerRequest) { - OIC_LOG (ERROR, TAG, "Invalid request pointer"); + D2D_LOGE ( "Invalid request pointer"); return OC_EH_ERROR; } @@ -383,27 +383,27 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, if (flag & OC_REQUEST_FLAG) { - OIC_LOG (INFO, TAG, "Flag includes OC_REQUEST_FLAG"); + D2D_LOGE ( "Flag includes OC_REQUEST_FLAG"); if (entityHandlerRequest) { if (OC_REST_GET == entityHandlerRequest->method) { - OIC_LOG (INFO, TAG, "Received OC_REST_GET from client"); + D2D_LOGE ( "Received OC_REST_GET from client"); ehResult = ProcessGetRequest (entityHandlerRequest, &payload); } else if (OC_REST_PUT == entityHandlerRequest->method) { - OIC_LOG (INFO, TAG, "Received OC_REST_PUT from client"); + D2D_LOGE ( "Received OC_REST_PUT from client"); ehResult = ProcessPutRequest (entityHandlerRequest, &payload); } else if (OC_REST_POST == entityHandlerRequest->method) { - OIC_LOG (INFO, TAG, "Received OC_REST_POST from client"); + D2D_LOGE ( "Received OC_REST_POST from client"); ehResult = ProcessPostRequest (entityHandlerRequest, &response, &payload); } else { - OIC_LOG_V (INFO, TAG, "Received unsupported method %d from client", + D2D_LOGD ( "Received unsupported method %d from client", entityHandlerRequest->method); ehResult = OC_EH_ERROR; } @@ -425,7 +425,7 @@ OCEntityHandlerCb (OCEntityHandlerFlag flag, // Send the response if (OCDoResponse(&response) != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "Error sending response"); + D2D_LOGE( "Error sending response"); ehResult = OC_EH_ERROR; } } @@ -460,25 +460,25 @@ void GeneratePinCB(char* pin, size_t pinSize) { if(NULL == pin || pinSize <= 0) { - OIC_LOG(INFO, TAG, "Invalid PIN"); + D2D_LOGE( "Invalid PIN"); return; } - OIC_LOG(INFO, TAG, "============================"); - OIC_LOG_V(INFO, TAG, " PIN CODE : %s", pin); - OIC_LOG(INFO, TAG, "============================"); + D2D_LOGE( "============================"); + D2D_LOGD( " PIN CODE : %s", pin); + D2D_LOGE( "============================"); } void ClosePinDisplayCB(void) { - OIC_LOG(INFO, TAG, "============================"); - OIC_LOG(INFO, TAG, " PIN DISPLAY CLOSED."); - OIC_LOG(INFO, TAG, "============================"); + D2D_LOGE( "============================"); + D2D_LOGE( " PIN DISPLAY CLOSED."); + D2D_LOGE( "============================"); } int main() { - OIC_LOG(DEBUG, TAG, "OCServer is starting..."); + D2D_LOGE( "OCServer is starting..."); // Initialize Persistent Storage for SVR database OCPersistentStorage ps = {server_fopen, fread, fwrite, fclose, unlink, NULL, NULL}; @@ -486,7 +486,7 @@ int main() if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCStack init error"); + D2D_LOGE( "OCStack init error"); return 0; } @@ -510,7 +510,7 @@ int main() */ if(OC_STACK_OK != SetRandomPinPolicy(8, NUM_PIN)) { - OIC_LOG(ERROR, TAG, "Failed to setting PIN policy"); + D2D_LOGE( "Failed to setting PIN policy"); return 0; } @@ -520,7 +520,7 @@ int main() createLEDResource(gResourceUri, &LED, false, 0); // Break from loop with Ctrl-C - OIC_LOG(INFO, TAG, "Entering ocserver main loop..."); + D2D_LOGE( "Entering ocserver main loop..."); signal(SIGINT, handleSigInt); #ifdef MULTIPLE_OWNER @@ -552,18 +552,18 @@ int main() { if (OCProcess() != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCStack process error"); + D2D_LOGE( "OCStack process error"); return 0; } nanosleep(&timeout, NULL); } #endif //MULTIPLE_OWNER - OIC_LOG(INFO, TAG, "Exiting ocserver main loop..."); + D2D_LOGE( "Exiting ocserver main loop..."); if (OCStop() != OC_STACK_OK) { - OIC_LOG(ERROR, TAG, "OCStack process error"); + D2D_LOGE( "OCStack process error"); } return 0; @@ -573,7 +573,7 @@ int createLEDResource (char *uri, LEDResource *ledResource, bool resourceState, { if (!uri) { - OIC_LOG(ERROR, TAG, "Resource URI cannot be NULL"); + D2D_LOGE( "Resource URI cannot be NULL"); return -1; } @@ -586,7 +586,7 @@ int createLEDResource (char *uri, LEDResource *ledResource, bool resourceState, OCEntityHandlerCb, NULL, OC_DISCOVERABLE|OC_OBSERVABLE | OC_SECURE); - OIC_LOG_V(INFO, TAG, "Created LED resource with result: %s", getResult(res)); + D2D_LOGD( "Created LED resource with result: %s", getResult(res)); return 0; } diff --git a/test/ss_emul.c b/test/ss_emul.c index 8d3a048..3f3564f 100644 --- a/test/ss_emul.c +++ b/test/ss_emul.c @@ -24,9 +24,7 @@ #include "oic_malloc.h" #include "logger.h" #include "hw_emul/ss_emul.h" - - -#define TAG "OIC_SSEMUL" +#include #define HWIF_MAXPATH (4096) static char HWIF_OWNCERT_FILE_NAME[HWIF_MAXPATH] = {0,}; @@ -42,7 +40,7 @@ int LoadCertFile(const char* filepath, uint8_t** cert_chain, size_t* cert_chain_ { if (NULL == filepath || NULL == cert_chain || NULL == cert_chain_len) { - OIC_LOG(ERROR, TAG, "Invalid parameters"); + D2D_LOGE("Invalid parameters"); return -1; } @@ -63,7 +61,7 @@ int LoadCertFile(const char* filepath, uint8_t** cert_chain, size_t* cert_chain_ if (!fsize) { - OIC_LOG(ERROR,TAG,"File is empty"); + D2D_LOGE("File is empty"); fclose(fp); return -1; } @@ -72,7 +70,7 @@ int LoadCertFile(const char* filepath, uint8_t** cert_chain, size_t* cert_chain_ certLen = fsize; if (NULL == certchain) { - OIC_LOG(ERROR,TAG,"Failed to allocate memory"); + D2D_LOGE("Failed to allocate memory"); fclose(fp); return -1; } @@ -80,21 +78,21 @@ int LoadCertFile(const char* filepath, uint8_t** cert_chain, size_t* cert_chain_ rewind(fp); if (fsize != fread(certchain, 1, fsize, fp)) { - OIC_LOG(ERROR, TAG, "Certiface was not read completely"); + D2D_LOGE("Certiface was not read completely"); } fclose(fp); } else { - OIC_LOG_V(ERROR,TAG,"Failed to open cert file : %s", filepath); + D2D_LOGD("Failed to open cert file : %s", filepath); return -1; } *cert_chain = certchain; *cert_chain_len = certLen; - OIC_LOG_V(INFO, TAG, "Loading cert success [%s]", filepath); - OIC_LOG_BUFFER(DEBUG, TAG, certchain, certLen); + D2D_LOGD("Loading cert success [%s]", filepath); + D2D_LOGD("%s %s",certchain, certLen); return 0; } @@ -103,18 +101,18 @@ int LoadKeyFile(mbedtls_pk_context *pkey, const char* filepath, const char* pass { if(!filepath) { - OIC_LOG(ERROR, TAG, "Invalid key file path" ); + D2D_LOGE("Invalid key file path" ); return -1; } int ret = mbedtls_pk_parse_keyfile(pkey, filepath, password); if( ret != 0 ) { - OIC_LOG_V(ERROR, TAG, "Faile to parse key file [0x%x]", ret ); + D2D_LOGD("Faile to parse key file [0x%x]", ret ); return ret; } - OIC_LOG_V(INFO, TAG, "Loading key success [%s]", filepath); + D2D_LOGD( "Loading key success [%s]", filepath); return ret; } @@ -127,7 +125,7 @@ int SSemulSetCertkeyFilepath(const char* cert_filepath, { if (NULL == cert_filepath || NULL == key_filepath) { - OIC_LOG(ERROR, TAG, "Invalid parameters"); + D2D_LOGE("Invalid parameters"); return -1; } @@ -135,7 +133,7 @@ int SSemulSetCertkeyFilepath(const char* cert_filepath, || HWIF_MAXPATH <= strlen(key_filepath) || !strlen(key_filepath) || (pwd && (HWIF_MAXPATH <= strlen(pwd)))) { - OIC_LOG(ERROR, TAG, "Invalid large path length"); + D2D_LOGE( "Invalid large path length"); return -1; } @@ -150,12 +148,12 @@ int SSemulSetCertkeyFilepath(const char* cert_filepath, strncpy(HWIF_KEY_PASS, pwd, strlen(pwd) + 1); } - OIC_LOG(INFO, TAG, "[Configure Secure Storage Emulation files]"); - OIC_LOG_V(INFO, TAG, "OwnCert file[%zu]: %s", strlen(cert_filepath), cert_filepath); - OIC_LOG_V(INFO, TAG, "Key file[%zu]: %s", strlen(key_filepath), key_filepath); + D2D_LOGE("[Configure Secure Storage Emulation files]"); + D2D_LOGD("OwnCert file[%zu]: %s", strlen(cert_filepath), cert_filepath); + D2D_LOGD("Key file[%zu]: %s", strlen(key_filepath), key_filepath); if (pwd) { - OIC_LOG_V(INFO, TAG, "Password[%zu]: %s", strlen(pwd), pwd); + D2D_LOGD("Password[%zu]: %s", strlen(pwd), pwd); } return 0; } @@ -165,7 +163,7 @@ int SSemulGetKeytype(const void* keyContext) (void)keyContext; if (0 == strlen(HWIF_KEY_FILE_NAME)) { - OIC_LOG(ERROR, TAG, "Need to set key file name"); + D2D_LOGE("Need to set key file name"); return KEYTYPE_NONE; } @@ -178,7 +176,7 @@ int SSemulGetKeytype(const void* keyContext) const char* key_pass = !strlen(HWIF_KEY_PASS) ? NULL : HWIF_KEY_PASS; if (0 > LoadKeyFile(&pk, key_file, key_pass)) { - OIC_LOG(ERROR, TAG, "Fail to load key file"); + D2D_LOGE("Fail to load key file"); goto exit; } @@ -205,13 +203,13 @@ int SSemulLoadOwncert(const void* keyContext, (void)keyContext; if (0 == strlen(HWIF_OWNCERT_FILE_NAME)) { - OIC_LOG(ERROR, TAG, "Need to set owncert file name"); + D2D_LOGE("Need to set owncert file name"); return -1; } if (0 != LoadCertFile(HWIF_OWNCERT_FILE_NAME, cert_chain, cert_chain_len)) { - OIC_LOG(ERROR, TAG, "Faile to load the own certificate file"); + D2D_LOGE("Faile to load the own certificate file"); return -1; } @@ -223,7 +221,7 @@ int SSemulGetKeylen(const void* keyContext) (void)keyContext; if (0 == strlen(HWIF_KEY_FILE_NAME)) { - OIC_LOG(ERROR, TAG, "Need to set private key file name"); + D2D_LOGE( "Need to set private key file name"); return -1; } @@ -238,14 +236,14 @@ int SSemulGetKeylen(const void* keyContext) ret = LoadKeyFile(&pk, key_file, key_pass); if (0 > ret) { - OIC_LOG_V(ERROR, TAG, "Fail to load key file [0x%x]", ret); + D2D_LOGD("Fail to load key file [0x%x]", ret); goto exit; } key_len = ( 8 * ((const mbedtls_rsa_context *) pk.pk_ctx)->len ); if(0 >= key_len) { - OIC_LOG(ERROR, TAG, "Invalid key length"); + D2D_LOGE("Invalid key length"); goto exit; } @@ -261,7 +259,7 @@ int SSemulRsaSign(const void *keyContext, { if (0 == strlen(HWIF_KEY_FILE_NAME)) { - OIC_LOG(ERROR, TAG, "Need to set private key file name"); + D2D_LOGE("Need to set private key file name"); return -1; } @@ -278,18 +276,18 @@ int SSemulRsaSign(const void *keyContext, ret = LoadKeyFile(&pk, key_file, key_pass); if (0 > ret) { - OIC_LOG_V(ERROR, TAG, "Fail to load key file [0x%x]", ret); + D2D_LOGD("Fail to load key file [0x%x]", ret); goto exit; } key_len = ( 8 * ((const mbedtls_rsa_context *) pk.pk_ctx)->len ); if(0 >= key_len) { - OIC_LOG(ERROR, TAG, "Invalid key length"); + D2D_LOGE("Invalid key length"); ret = MBEDTLS_ERR_RSA_BAD_INPUT_DATA; goto exit; } - OIC_LOG_V(INFO, TAG, "key name : %s, mode : %d hashlen : %u md_alg : %d keylen : %zu", + D2D_LOGD( "key name : %s, mode : %d hashlen : %u md_alg : %d keylen : %zu", (const char*)(keyContext), mode, hashlen, md_alg, key_len); // 2. sign @@ -297,7 +295,7 @@ int SSemulRsaSign(const void *keyContext, MBEDTLS_RSA_PRIVATE, md_alg, (unsigned int) hashlen, hash, sig); if(0 != ret ) { - OIC_LOG_V(ERROR, TAG, "Fail to sign [0x%x]", ret); + D2D_LOGD("Fail to sign [0x%x]", ret); goto exit; } @@ -314,7 +312,7 @@ int SSemulEcdsaSign( void *ctx, mbedtls_md_type_t md_alg, (void)ctx; if (0 == strlen(HWIF_KEY_FILE_NAME)) { - OIC_LOG(ERROR, TAG, "Need to set private key file name"); + D2D_LOGE("Need to set private key file name"); return -1; } @@ -333,7 +331,7 @@ int SSemulEcdsaSign( void *ctx, mbedtls_md_type_t md_alg, ret = LoadKeyFile(&pk, key_file, key_pass); if (0 > ret) { - OIC_LOG_V(ERROR, TAG, "Fail to load key file [0x%x]", ret); + D2D_LOGD("Fail to load key file [0x%x]", ret); goto exit; } @@ -342,7 +340,7 @@ int SSemulEcdsaSign( void *ctx, mbedtls_md_type_t md_alg, ret = mbedtls_ecdsa_from_keypair(&ecdsa, eckey); if(0 != ret ) { - OIC_LOG_V(ERROR, TAG, "Fail to copy key pair [0x%x]", ret); + D2D_LOGD("Fail to copy key pair [0x%x]", ret); goto exit; } @@ -351,15 +349,15 @@ int SSemulEcdsaSign( void *ctx, mbedtls_md_type_t md_alg, md_alg, hash, hash_len, sig, sig_len, f_rng, p_rng ); if(0 != ret ) { - OIC_LOG_V(ERROR, TAG, "Fail to sign [0x%x]", ret); + D2D_LOGD("Fail to sign [0x%x]", ret); goto exit; } - OIC_LOG_V(INFO, TAG, "Success to sign"); + D2D_LOGD("Success to sign"); exit: mbedtls_ecdsa_free( &ecdsa ); mbedtls_pk_free(&pk); - OIC_LOG_V(INFO, TAG, "Out %s", __func__); + D2D_LOGD( "Out %s", __func__); return ret; } diff --git a/test/subownerclient.c b/test/subownerclient.c index 4e1fa45..fb71434 100644 --- a/test/subownerclient.c +++ b/test/subownerclient.c @@ -40,6 +40,7 @@ #include "pmutility.h" #include +#include #define MAX_FILE_PATH_LEN 1024 @@ -106,11 +107,11 @@ static void multipleOwnershipTransferCB(void* ctx, int nOfRes, OCProvisionResult { if(!hasError) { - OIC_LOG_V(INFO, TAG, "Multiple Ownership Transfer SUCCEEDED - ctx: %s", (char*) ctx); + D2D_LOGD( "Multiple Ownership Transfer SUCCEEDED - ctx: %s", (char*) ctx); } else { - OIC_LOG_V(ERROR, TAG, "Multiple Ownership Transfer FAILED - ctx: %s", (char*) ctx); + D2D_LOGD( "Multiple Ownership Transfer FAILED - ctx: %s", (char*) ctx); printResultList((const OCProvisionResult_t*) arr, nOfRes); } g_doneCB = true; @@ -121,11 +122,11 @@ static void ownershipTransferCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, { if(!hasError) { - OIC_LOG_V(INFO, TAG, "Ownership Transfer SUCCEEDED - ctx: %s", (char*) ctx); + D2D_LOGD( "Ownership Transfer SUCCEEDED - ctx: %s", (char*) ctx); } else { - OIC_LOG_V(ERROR, TAG, "Ownership Transfer FAILED - ctx: %s", (char*) ctx); + D2D_LOGD( "Ownership Transfer FAILED - ctx: %s", (char*) ctx); printResultList((const OCProvisionResult_t*) arr, nOfRes); } g_doneCB = true; @@ -135,11 +136,11 @@ static void updateDoxmForMOTCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, { if(!hasError) { - OIC_LOG_V(INFO, TAG, "POST 'doxm' SUCCEEDED - ctx: %s", (char*) ctx); + D2D_LOGD( "POST 'doxm' SUCCEEDED - ctx: %s", (char*) ctx); } else { - OIC_LOG_V(ERROR, TAG, "POST 'doxm' FAILED - ctx: %s", (char*) ctx); + D2D_LOGD( "POST 'doxm' FAILED - ctx: %s", (char*) ctx); printResultList((const OCProvisionResult_t*) arr, nOfRes); } g_doneCB = true; @@ -149,11 +150,11 @@ static void provisionCredCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, boo { if(!hasError) { - OIC_LOG_V(INFO, TAG, "Provision Credential SUCCEEDED - ctx: %s", (char*) ctx); + D2D_LOGD( "Provision Credential SUCCEEDED - ctx: %s", (char*) ctx); } else { - OIC_LOG_V(ERROR, TAG, "Provision Credential FAILED - ctx: %s", (char*) ctx); + D2D_LOGD( "Provision Credential FAILED - ctx: %s", (char*) ctx); printResultList((const OCProvisionResult_t*) arr, nOfRes); } g_doneCB = true; @@ -163,11 +164,11 @@ static void provisionAclCB(void* ctx, int nOfRes, OCProvisionResult_t* arr, bool { if(!hasError) { - OIC_LOG_V(INFO, TAG, "Provision ACL SUCCEEDED - ctx: %s", (char*) ctx); + D2D_LOGD( "Provision ACL SUCCEEDED - ctx: %s", (char*) ctx); } else { - OIC_LOG_V(ERROR, TAG, "Provision ACL FAILED - ctx: %s", (char*) ctx); + D2D_LOGD( "Provision ACL FAILED - ctx: %s", (char*) ctx); printResultList((const OCProvisionResult_t*) arr, nOfRes); } g_doneCB = true; @@ -208,7 +209,7 @@ static void inputPinCB(char* pin, size_t len) { if(!pin || OXM_RANDOM_PIN_MAX_SIZE>=len) { - OIC_LOG(ERROR, TAG, "inputPinCB invalid parameters"); + D2D_LOGE( "inputPinCB invalid parameters"); return; } @@ -228,14 +229,14 @@ static int initProvisionClient(void) static OCPersistentStorage ps = {fopen_prvnMng, fread, fwrite, fclose, unlink}; if(OC_STACK_OK != OCRegisterPersistentStorageHandler(&ps)) { - OIC_LOG(ERROR, TAG, "OCRegisterPersistentStorageHandler error"); + D2D_LOGE( "OCRegisterPersistentStorageHandler error"); return -1; } // initialize OC stack and provisioning manager if(OC_STACK_OK != OCInit(NULL, 0, OC_CLIENT_SERVER)) { - OIC_LOG(ERROR, TAG, "OCStack init error"); + D2D_LOGE( "OCStack init error"); return -1; } @@ -254,7 +255,7 @@ static int initProvisionClient(void) if(OC_STACK_OK != OCInitPM(PRVN_DB_FILE_NAME)) { - OIC_LOG(ERROR, TAG, "OC_PM init error"); + D2D_LOGE( "OC_PM init error"); return -1; } @@ -276,7 +277,7 @@ static int discoverMotSupportedDevices(void) printf(" Discovering Multiple Ownership Transfer enabled Devices on Network..\n"); if(OC_STACK_OK != OCDiscoverMultipleOwnerEnabledDevices(DISCOVERY_TIMEOUT, &g_motdev_list)) { - OIC_LOG(ERROR, TAG, "OCDiscoverMultipleOwnerEnalbedDevices API error"); + D2D_LOGE( "OCDiscoverMultipleOwnerEnalbedDevices API error"); return -1; } @@ -300,7 +301,7 @@ static int discoverSubOwnerDevices() printf(" Discovering Multiple Owned Devices on Network..\n"); if(OC_STACK_OK != OCDiscoverMultipleOwnedDevices(DISCOVERY_TIMEOUT, &g_mowned_list)) { - OIC_LOG(ERROR, TAG, "OCDiscoverMultipleOwnerEnabledDevices API error"); + D2D_LOGE( "OCDiscoverMultipleOwnerEnabledDevices API error"); return -1; } @@ -346,13 +347,13 @@ static int multipleOwnershipTransfer(void) if(OC_STACK_OK != OCDoMultipleOwnershipTransfer(g_ctx, g_motdev_list, multipleOwnershipTransferCB)) { - OIC_LOG(ERROR, TAG, "_20_PERFORM_MOT_: error"); + D2D_LOGE( "_20_PERFORM_MOT_: error"); return -1; } if(waitCallbackRet()) // input |g_doneCB| flag implicitly { - OIC_LOG(ERROR, TAG, "OCProvisionCredentials callback error"); + D2D_LOGE( "OCProvisionCredentials callback error"); return -1; } @@ -488,20 +489,20 @@ static OicSecAcl_t* createAclForLEDAccess(const OicUuid_t* subject) { if(NULL == subject) { - OIC_LOG(ERROR, TAG, "createAcl: Invalid paramters"); + D2D_LOGE( "createAcl: Invalid paramters"); return NULL; } // allocate memory for |acl| struct OicSecAcl_t* acl = (OicSecAcl_t*) OICCalloc(1, sizeof(OicSecAcl_t)); if(!acl) { - OIC_LOG(ERROR, TAG, "createAcl: OICCalloc error return"); + D2D_LOGE( "createAcl: OICCalloc error return"); return NULL; // not need to 'goto' |ERROR| before allocating |acl| } OicSecAce_t* ace = (OicSecAce_t*) OICCalloc(1, sizeof(OicSecAce_t)); if(!ace) { - OIC_LOG(ERROR, TAG, "createAcl: OICCalloc error return"); + D2D_LOGE( "createAcl: OICCalloc error return"); return NULL; // not need to 'goto' |ERROR| before allocating |acl| } LL_APPEND(acl->aces, ace); @@ -512,7 +513,7 @@ static OicSecAcl_t* createAclForLEDAccess(const OicUuid_t* subject) OicSecRsrc_t* rsrc = (OicSecRsrc_t*)OICCalloc(1, sizeof(OicSecRsrc_t)); if(!rsrc) { - OIC_LOG(ERROR, TAG, "createAcl: OICCalloc error return"); + D2D_LOGE( "createAcl: OICCalloc error return"); goto CRACL_ERROR; } @@ -520,7 +521,7 @@ static OicSecAcl_t* createAclForLEDAccess(const OicUuid_t* subject) rsrc->href = (char*) OICCalloc(len, sizeof(char)); if(!rsrc->href) { - OIC_LOG(ERROR, TAG, "createAcl: OICCalloc error return"); + D2D_LOGE( "createAcl: OICCalloc error return"); goto CRACL_ERROR; } OICStrcpy(rsrc->href, len, rsrc_in); @@ -530,13 +531,13 @@ static OicSecAcl_t* createAclForLEDAccess(const OicUuid_t* subject) rsrc->types = (char**)OICCalloc(1, sizeof(char*)); if(!rsrc->types) { - OIC_LOG(ERROR, TAG, "createAcl: OICCalloc error return"); + D2D_LOGE( "createAcl: OICCalloc error return"); goto CRACL_ERROR; } rsrc->types[0] = OICStrdup("oic.r.core"); if(!rsrc->types[0]) { - OIC_LOG(ERROR, TAG, "createAcl: OICStrdup error return"); + D2D_LOGE( "createAcl: OICStrdup error return"); goto CRACL_ERROR; } @@ -545,13 +546,13 @@ static OicSecAcl_t* createAclForLEDAccess(const OicUuid_t* subject) rsrc->interfaces = (char**)OICCalloc(1, sizeof(char*)); if(!rsrc->interfaces) { - OIC_LOG(ERROR, TAG, "createAcl: OICCalloc error return"); + D2D_LOGE( "createAcl: OICCalloc error return"); goto CRACL_ERROR; } rsrc->interfaces[0] = OICStrdup("oic.if.baseline"); if(!rsrc->interfaces[0]) { - OIC_LOG(ERROR, TAG, "createAcl: OICStrdup error return"); + D2D_LOGE( "createAcl: OICStrdup error return"); goto CRACL_ERROR; } @@ -563,7 +564,7 @@ static OicSecAcl_t* createAclForLEDAccess(const OicUuid_t* subject) ace->eownerID = (OicUuid_t*)OICCalloc(1, sizeof(OicUuid_t)); if(NULL == ace->eownerID) { - OIC_LOG(ERROR, TAG, "createAcl: OICCalloc error return"); + D2D_LOGE( "createAcl: OICCalloc error return"); goto CRACL_ERROR; } @@ -615,26 +616,26 @@ static int provisionAclForLed() OCProvisionDev_t* dev = getDevInst((const OCProvisionDev_t*) g_mowned_list, dev_num); if(!dev) { - OIC_LOG(ERROR, TAG, "provisionAcl: device instance empty"); + D2D_LOGE( "provisionAcl: device instance empty"); goto PVACL_ERROR; } acl = createAclForLEDAccess(&dev->doxm->subOwners->uuid); if(NULL == acl) { - OIC_LOG(ERROR, TAG, "provisionAcl: Failed to create ACL for LED"); + D2D_LOGE( "provisionAcl: Failed to create ACL for LED"); return -1; } OCStackResult rst = OCProvisionACL((void*) g_ctx, dev, acl, provisionAclCB); if(OC_STACK_OK != rst) { - OIC_LOG_V(ERROR, TAG, "OCProvisionACL API error: %d", rst); + D2D_LOGD( "OCProvisionACL API error: %d", rst); goto PVACL_ERROR; } if(waitCallbackRet()) // input |g_doneCB| flag implicitly { - OIC_LOG(ERROR, TAG, "OCProvisionCredentials callback error"); + D2D_LOGE( "OCProvisionCredentials callback error"); goto PVACL_ERROR; } // display the ACL-provisioned result @@ -682,7 +683,7 @@ static int provisionCred() OCProvisionDev_t* motDev = getDevInst(g_mowned_list, dev_num); if(NULL == motDev) { - OIC_LOG(ERROR, TAG, "Failed to getDevInst()"); + D2D_LOGE( "Failed to getDevInst()"); return -1; } @@ -709,7 +710,7 @@ static int provisionCred() OCProvisionDev_t* ownDev = getDevInst(g_own_list, dev_num); if(NULL == ownDev) { - OIC_LOG(ERROR, TAG, "Failed to getDevInst()"); + D2D_LOGE( "Failed to getDevInst()"); return -1; } @@ -723,12 +724,12 @@ static int provisionCred() ownDev, motDev, provisionCredCB); if(OC_STACK_OK != rst) { - OIC_LOG_V(ERROR, TAG, "OCProvisionPairwiseDevices API error: %d", rst); + D2D_LOGD( "OCProvisionPairwiseDevices API error: %d", rst); goto PVPWS_ERROR; } if(waitCallbackRet()) // input |g_doneCB| flag implicitly { - OIC_LOG(ERROR, TAG, "OCProvisionCredentials callback error"); + D2D_LOGE( "OCProvisionCredentials callback error"); goto PVPWS_ERROR; } @@ -859,7 +860,7 @@ static int waitCallbackRet(void) sleep(1); if(OC_STACK_OK != OCProcess()) { - OIC_LOG(ERROR, TAG, "OCStack process error"); + D2D_LOGE( "OCStack process error"); return -1; } } @@ -943,7 +944,7 @@ int main() // initialize provisioning client if(initProvisionClient()) { - OIC_LOG(ERROR, TAG, "ProvisionClient init error"); + D2D_LOGE( "ProvisionClient init error"); goto PMCLT_ERROR; } @@ -967,46 +968,46 @@ int main() case _10_DISCOV_MOT_ENABLED_DEV_: if(discoverMotSupportedDevices()) { - OIC_LOG(ERROR, TAG, "_12_MOT_DISCOV_DEV_: error"); + D2D_LOGE( "_12_MOT_DISCOV_DEV_: error"); } break; case _11_DISCOV_MULTIPLE_OWNED_DEV_: if(discoverSubOwnerDevices()) { - OIC_LOG(ERROR, TAG, "_13_DISCOV_MULTIPLE_OWNED_DEV_: error"); + D2D_LOGE( "_13_DISCOV_MULTIPLE_OWNED_DEV_: error"); } break; case _20_PERFORM_MOT_: if(multipleOwnershipTransfer()) { - OIC_LOG(ERROR, TAG, "_21_PERFORM_MOT_: error"); + D2D_LOGE( "_21_PERFORM_MOT_: error"); } break; case _30_GET_LED_RESOURCE_: if(sendGetLed()) { - OIC_LOG(ERROR, TAG, "_30_GET_LED_RESOURCE_: error"); + D2D_LOGE( "_30_GET_LED_RESOURCE_: error"); } break; case _31_PUT_LED_RESOURCE_: if(sendPutLed()) { - OIC_LOG(ERROR, TAG, "_31_PUT_LED_RESOURCE_: error"); + D2D_LOGE( "_31_PUT_LED_RESOURCE_: error"); } break; case _40_PROVISION_ACL_: if(provisionAclForLed()) { - OIC_LOG(ERROR, TAG, "_40_PROVISION_ACL_: error"); + D2D_LOGE( "_40_PROVISION_ACL_: error"); } break; case _41_PROVISION_CRED_: - OIC_LOG(ERROR, TAG, "NOT SUPPORTED YET."); + D2D_LOGE( "NOT SUPPORTED YET."); break; /* if(provisionCred()) { - OIC_LOG(ERROR, TAG, "_41_PROVISION_CRED_: error"); + D2D_LOGE( "_41_PROVISION_CRED_: error"); } break; */ @@ -1021,7 +1022,7 @@ int main() PMCLT_ERROR: if(OC_STACK_OK != OCStop()) { - OIC_LOG(ERROR, TAG, "OCStack stop error"); + D2D_LOGE( "OCStack stop error"); } OCDeleteDiscoveredDevices(g_own_list); // after here |g_own_list| points nothing OCDeleteDiscoveredDevices(g_unown_list); // after here |g_unown_list| points nothing diff --git a/test/test.c b/test/test.c deleted file mode 100644 index 44d67bd..0000000 --- a/test/test.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -int main(void) { - printf("Hello World\n"); - return 0; -} -- 2.7.4