diff --git a/recipes-webpa/ccsp/ccsp-common-library.bb b/recipes-webpa/ccsp/ccsp-common-library.bb new file mode 100644 index 00000000..f791fbe6 --- /dev/null +++ b/recipes-webpa/ccsp/ccsp-common-library.bb @@ -0,0 +1,69 @@ +SUMMARY = "CCSP libccsp_common component" +HOMEPAGE = "http://github.com/belvedere-yocto/CcspCommonLibrary" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=19774cd4dd519f099bc404798ceeab19" + +DEPENDS_append = " dbus openssl rbus rbus-core zlib" + +require ccsp_common.inc + +RECIPE_BRANCH ?= "rdk-next" +SRC_URI = "\ + git://github.com/rdkcmf/rdkb-CcspCommonLibrary.git;protocol=https;branch=${RECIPE_BRANCH} \ + file://0001-DBusLoop-SSL_state-TLS_ST_OK.patch \ + file://0001-SSLeay_add_all_algorithms-remove-in-openssl-1.1.patch \ + file://0003-support-to-build-for-non-rdk-platform.patch \ +" + +SRCREV = "6432e257aa30bdf766db16a0db83394801bc4708" +PV = "git${SRCPV}" + +S = "${WORKDIR}/git" + +inherit autotools systemd pkgconfig + +SECURITY_STRINGFORMAT = "" + +CFLAGS_append += " \ + -DSAFEC_DUMMY_API \ + -D_GNU_SOURCE -D__USE_XOPEN \ + -I${STAGING_INCDIR}/dbus-1.0 \ + -I${STAGING_LIBDIR}/dbus-1.0/include \ + -I${STAGING_INCDIR}/rbus \ + -I${STAGING_INCDIR}/rtmessage \ +" + +LDFLAGS_append = " -ldbus-1 -lrbus-core -lrtMessage -lrbus" + +do_install_append_class-target () { + install -d ${D}/usr/include/ccsp + install -d ${D}/usr/include/ccsp/linux + install -m 644 ${S}/source/debug_api/include/*.h ${D}/usr/include/ccsp + install -m 644 ${S}/source/util_api/ansc/include/*.h ${D}/usr/include/ccsp + install -m 644 ${S}/source/util_api/asn.1/include/*.h ${D}/usr/include/ccsp + install -m 644 ${S}/source/util_api/http/include/*.h ${D}/usr/include/ccsp + install -m 644 ${S}/source/util_api/slap/components/SlapVarConverter/*.h ${D}/usr/include/ccsp + install -m 644 ${S}/source/util_api/stun/include/*.h ${D}/usr/include/ccsp + install -m 644 ${S}/source/util_api/tls/include/*.h ${D}/usr/include/ccsp + install -m 644 ${S}/source/util_api/web/include/*.h ${D}/usr/include/ccsp + install -m 644 ${S}/source/cosa/include/*.h ${D}/usr/include/ccsp + install -m 644 ${S}/source/cosa/package/slap/include/*.h ${D}/usr/include/ccsp + install -m 644 ${S}/source/cosa/package/system/include/*.h ${D}/usr/include/ccsp + install -m 644 ${S}/source/cosa/include/linux/*.h ${D}/usr/include/ccsp/linux + install -m 644 ${S}/source/cosa/include/linux/*.h ${D}/usr/include/ccsp + install -m 644 ${S}/source/ccsp/include/*.h ${D}/usr/include/ccsp + install -m 644 ${S}/source/ccsp/custom/*.h ${D}/usr/include/ccsp + install -m 644 ${S}/source/ccsp/components/include/*.h ${D}/usr/include/ccsp + install -m 644 ${S}/source/ccsp/components/common/MessageBusHelper/include/*.h ${D}/usr/include/ccsp + install -m 644 ${S}/source/ccsp/components/common/PoamIrepFolder/*.h ${D}/usr/include/ccsp + install -m 644 ${S}/source/dm_pack/dm_pack_create_func.h ${D}/usr/include/ccsp + install -m 644 ${S}/source/dm_pack/dm_pack_xml_helper.h ${D}/usr/include/ccsp + + # Config files + install -d ${D}/usr/ccsp + install -m 644 ${S}/config/ccsp_msg.cfg ${D}/usr/ccsp +} + +FILES_${PN} += " /usr/ccsp ${libdir}" + diff --git a/recipes-webpa/ccsp/ccsp-common-library/0001-DBusLoop-SSL_state-TLS_ST_OK.patch b/recipes-webpa/ccsp/ccsp-common-library/0001-DBusLoop-SSL_state-TLS_ST_OK.patch new file mode 100644 index 00000000..770abffa --- /dev/null +++ b/recipes-webpa/ccsp/ccsp-common-library/0001-DBusLoop-SSL_state-TLS_ST_OK.patch @@ -0,0 +1,52 @@ +From d69f7dc3304bb5dd8803cef63a1a96e7c102e153 Mon Sep 17 00:00:00 2001 +From: Jaga +Date: Mon, 6 Apr 2020 17:29:42 +0000 +Subject: [PATCH] DBusLoop-SSL_state-TLS_ST_OK + +Reason for change: typedef DBusLoop struct, changed ssl->state +to SSL_state(ssl) for openssl > 1.1 and SSL_get_state(ssl) for openssl > +1.1.1 + +Source: COMCAST +License: Apache-2.0 +Upstream-Status: Pending +Signed-off-by: Jaga +--- + source/ccsp/include/ccsp_message_bus.h | 2 ++ + source/util_api/ansc/AnscPlatform/user_openssl.c | 10 +++++++++- + 2 files changed, 11 insertions(+), 1 deletion(-) + +diff --git a/source/ccsp/include/ccsp_message_bus.h b/source/ccsp/include/ccsp_message_bus.h +index 9fb9aae9..7c315be0 100644 +--- a/source/ccsp/include/ccsp_message_bus.h ++++ b/source/ccsp/include/ccsp_message_bus.h +@@ -153,6 +153,8 @@ typedef struct _CCSP_MESSAGE_FILTER + + } CCSP_MESSAGE_FILTER; + ++typedef struct DBusLoop DBusLoop; ++ + typedef struct _CCSP_MESSAGE_BUS_CONNECTION + { + DBusConnection *conn; +diff --git a/source/util_api/ansc/AnscPlatform/user_openssl.c b/source/util_api/ansc/AnscPlatform/user_openssl.c +index 7e5c2c7d..6d1f4f51 100644 +--- a/source/util_api/ansc/AnscPlatform/user_openssl.c ++++ b/source/util_api/ansc/AnscPlatform/user_openssl.c +@@ -392,7 +392,15 @@ SSL * openssl_connect (int fd) + + SSL_set_connect_state (ssl); + +- if (SSL_connect (ssl) <= 0 || ssl->state != SSL_ST_OK) ++ if (SSL_connect (ssl) <= 0 || ++#if (OPENSSL_VERSION_NUMBER >= 0x10101000L) ++ SSL_get_state(ssl) != TLS_ST_OK) ++#elif (OPENSSL_VERSION_NUMBER >= 0x10100000L) ++ SSL_state(ssl) != TLS_ST_OK) ++#else ++ ssl->state != SSL_ST_OK) ++#endif ++ + { + AnscTraceWarning(("openssl_connect - failed in SSL_set_connect_state \n")); + goto error; diff --git a/recipes-webpa/ccsp/ccsp-common-library/0001-SSLeay_add_all_algorithms-remove-in-openssl-1.1.patch b/recipes-webpa/ccsp/ccsp-common-library/0001-SSLeay_add_all_algorithms-remove-in-openssl-1.1.patch new file mode 100644 index 00000000..2cca4be5 --- /dev/null +++ b/recipes-webpa/ccsp/ccsp-common-library/0001-SSLeay_add_all_algorithms-remove-in-openssl-1.1.patch @@ -0,0 +1,30 @@ +From d1b13416095d4fe513ee739de179913222539993 Mon Sep 17 00:00:00 2001 +From: Jaga +Date: Mon, 6 Apr 2020 18:35:17 +0000 +Subject: [PATCH] SSLeay_add_all_algorithms remove in openssl 1.1 + +Reason for change: Remove deprecated API SSLeay_add_all_algorithms for +openssl 1.1 and above + +Source: COMCAST +License: Apache-2.0 +Upstream-Status: Pending +Signed-off-by: Jaga +--- + source/util_api/ansc/AnscPlatform/user_openssl.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/source/util_api/ansc/AnscPlatform/user_openssl.c b/source/util_api/ansc/AnscPlatform/user_openssl.c +index 0d74871f..4cac8483 100644 +--- a/source/util_api/ansc/AnscPlatform/user_openssl.c ++++ b/source/util_api/ansc/AnscPlatform/user_openssl.c +@@ -68,7 +68,9 @@ void initialize_openssl_lib() + + SSL_library_init (); + SSL_load_error_strings (); ++#if OPENSSL_VERSION_NUMBER < 0x10100000L + SSLeay_add_all_algorithms (); ++#endif + SSLeay_add_ssl_algorithms (); + } + diff --git a/recipes-webpa/ccsp/ccsp-common-library/0003-support-to-build-for-non-rdk-platform.patch b/recipes-webpa/ccsp/ccsp-common-library/0003-support-to-build-for-non-rdk-platform.patch new file mode 100644 index 00000000..fa6fb37f --- /dev/null +++ b/recipes-webpa/ccsp/ccsp-common-library/0003-support-to-build-for-non-rdk-platform.patch @@ -0,0 +1,17 @@ +diff --git a/source/debug_api/ansc_debug.c b/source/debug_api/ansc_debug.c +index 7945da13..b6a47d42 100644 +--- a/source/debug_api/ansc_debug.c ++++ b/source/debug_api/ansc_debug.c +@@ -534,10 +534,12 @@ void CcspTraceLogAPI(char *fileName, char *pComponentName, int level, const char + char sfn[32]; + va_list args; + ++#if FEATURE_SUPPORT_RDKLOG + CcspTraceShortenFileName(sfn, 32, fileName); + va_start(args, format); + RDK_LOG1(level, ComponentName, format, args); + va_end(args); ++#endif + } + } + } diff --git a/recipes-webpa/ccsp/ccsp-cr.bb b/recipes-webpa/ccsp/ccsp-cr.bb new file mode 100644 index 00000000..e2a664cd --- /dev/null +++ b/recipes-webpa/ccsp/ccsp-cr.bb @@ -0,0 +1,61 @@ +SUMMARY = "CCSP CcspCrSsp component" +HOMEPAGE = "http://github.com/belvedere-yocto/CcspCr" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=175792518e4ac015ab6696d16c4f607e" +FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" + +DEPENDS_append = " ccsp-common-library dbus telemetry libunpriv rbus libxml2 utopia" + +require ccsp_common.inc + +RECIPE_BRANCH ?= "rdk-next" +SRC_URI = "\ + git://code.rdkcentral.com/r/rdkb/components/opensource/ccsp/CcspCr.git;protocol=https;branch=${RECIPE_BRANCH} \ + file://0001-ccspcr-build-support.patch \ + file://ccspcr-init \ +" + +SRCREV = "7054041df8817aa0e019a41363520ffeff9dcf91" +PV = "git${SRCPV}" + +S = "${WORKDIR}/git" + +inherit autotools systemd update-rc.d + +EXTRA_OECONF_append = " --with-rbus-build=only" +CFLAGS_append = " \ + -DDISABLE_RDK_LOGGER \ + -I=${includedir}/dbus-1.0 \ + -I=${libdir}/dbus-1.0/include \ + -I=${includedir}/ccsp \ + -I${STAGING_INCDIR}/syscfg \ + -I${STAGING_INCDIR}/utapi \ + -I${STAGING_INCDIR}/utctx \ + -I${STAGING_INCDIR}/ulog \ + -I${STAGING_INCDIR}/rbus \ + -I${STAGING_INCDIR}/rtmessage \ + -I${STAGING_INCDIR}/libxml2 \ +" + +LDFLAGS_append = " -ldbus-1 -ltelemetry_msgsender -lprivilege -lsyscfg -lcjson -lmsgpackc" + +do_install_append () { + install -d ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/ccspcr-init ${D}${sysconfdir}/init.d/ccspcr + + if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then + install -d ${D}${systemd_unitdir}/system + install -m 644 ${WORKDIR}/ccspcr.service ${D}${systemd_unitdir}/system + fi +} + +PACKAGES =+ "${PN}-initscript" +INITSCRIPT_PACKAGES = "${PN}-initscript" +INITSCRIPT_NAME_${PN}-initscript = "ccspcr" +INITSCRIPT_PARAMS_${PN}-initscript = "defaults 35 25" +RRECOMMENDS_${PN} = "${PN}-initscript" + +FILES_${PN}-initscript = "${sysconfdir}/init.d/ccspcr" +FILES_${PN} += " ${bindir}/CcspCrSsp" + diff --git a/recipes-webpa/ccsp/ccsp-cr/0001-ccspcr-build-support.patch b/recipes-webpa/ccsp/ccsp-cr/0001-ccspcr-build-support.patch new file mode 100644 index 00000000..f9d295ba --- /dev/null +++ b/recipes-webpa/ccsp/ccsp-cr/0001-ccspcr-build-support.patch @@ -0,0 +1,51 @@ +diff --git a/source/CCSP_CR/ccsp_cr_exportDM.c b/source/CCSP_CR/ccsp_cr_exportDM.c +index 4b41ecb..088ffcd 100644 +--- a/source/CCSP_CR/ccsp_cr_exportDM.c ++++ b/source/CCSP_CR/ccsp_cr_exportDM.c +@@ -135,6 +135,7 @@ static void WriteXmlHead(FILE *file) + if(NULL == g_pDbusHandle) + printf("g_pDbusHanle is NULL\n"); + /* CID 57006 - Unchecked return value */ ++#ifdef RDK_BUILD + ret = CcspBaseIf_getParameterValues(g_pDbusHandle, "com.cisco.spvtg.ccsp.tdm", "/com/cisco/spvtg/ccsp/tdm", pParamNames, 5, &valCount, &ppReturnVal); + if (CCSP_Message_Bus_OK != ret) + { +@@ -154,7 +155,8 @@ static void WriteXmlHead(FILE *file) + fprintf(file, "%s%s%s\n", "",ppReturnVal[4]->parameterValue, ""); + free_parameterValStruct_t(g_pDbusHandle, valCount, ppReturnVal); + } +- ++#endif ++ + fprintf(file, "%s", ATTRIBUTE_STR); + } + +diff --git a/source/CrSsp/ssp_main.c b/source/CrSsp/ssp_main.c +index 9320169..a1639ff 100644 +--- a/source/CrSsp/ssp_main.c ++++ b/source/CrSsp/ssp_main.c +@@ -48,7 +48,9 @@ + #endif + + #include "ssp_global.h" ++#ifdef RDK_BUILD + #include "syscfg/syscfg.h" ++#endif + #include "cap.h" + #include "telemetry_busmessage_sender.h" + +@@ -456,6 +458,7 @@ static void* waitforsyscfgReady(void *arg) + #define MAX_WAIT_TIME 90 + int times = 0; + pthread_detach(pthread_self()); ++#ifdef RDK_BUILD + while(times++ < MAX_WAIT_TIME) { + if ( 0 != syscfg_init( ) ) { + CCSP_Msg_SleepInMilliSeconds(TIME_INTERVAL); +@@ -465,6 +468,7 @@ static void* waitforsyscfgReady(void *arg) + break; + } + } ++#endif + pthread_exit(NULL); + } diff --git a/recipes-webpa/ccsp/ccsp-cr/ccspcr-init b/recipes-webpa/ccsp/ccsp-cr/ccspcr-init new file mode 100755 index 00000000..22084bde --- /dev/null +++ b/recipes-webpa/ccsp/ccsp-cr/ccspcr-init @@ -0,0 +1,38 @@ +#!/bin/sh + +start() { + printf "Starting WebPA CcspCR module: " + + ln -sf /usr/ccsp/ccsp_msg.cfg /tmp/ccsp_msg.cfg + rm -rf /tmp/syscfg.shmid + syscfg_create -f /usr/ccsp/syscfg.db + start-stop-daemon -S -q -b --exec /usr/bin/CcspCrSsp -- -subsys eRT. /dev/nul + [ $? == 0 ] && echo "OK" || echo "FAIL" +} + +stop() { + printf "Stopping WebPA CcspCR module: " + start-stop-daemon -K -q --exec /usr/bin/CcspCrSsp + [ $? == 0 ] && echo "OK" || echo "FAIL" +} + +restart() { + stop + start +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart|reload) + restart + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac +exit $? diff --git a/recipes-webpa/ccsp/ccsp-cr/ccspcr.service b/recipes-webpa/ccsp/ccsp-cr/ccspcr.service new file mode 100644 index 00000000..bc8c909c --- /dev/null +++ b/recipes-webpa/ccsp/ccsp-cr/ccspcr.service @@ -0,0 +1,13 @@ +[Unit] +Description=CCSP CR Service +Before=wpeframework.service +After=rbuscore.service + +[Service] +ExecStart=/etc/init.d/ccspcr start +ExecStop=/etc/init.d/ccspcr stop +ExecReload=/etc/init.d/ccspcr reload +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/recipes-webpa/ccsp/ccsp_common.inc b/recipes-webpa/ccsp/ccsp_common.inc new file mode 100644 index 00000000..6cf0ca3a --- /dev/null +++ b/recipes-webpa/ccsp/ccsp_common.inc @@ -0,0 +1,16 @@ +SUMMARY = "common inc for ccsp modules." + +inherit pkgconfig + +CFLAGS_append = "\ + -D_COSA_HAL_ -U_COSA_SIM_ -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-strict-aliasing \ + -DCONFIG_SYSTEM_MOCA -D_ANSC_LINUX -D_ANSC_USER -D_ANSC_LITTLE_ENDIAN_ -D_CCSP_CWMP_TCP_CONNREQ_HANDLER \ + -D_DSLH_STUN_ -D_NO_PKI_KB5_SUPPORT -D_BBHM_SSE_FILE_IO -D_ANSC_USE_OPENSSL_ -DENABLE_SA_KEY \ + -D_ANSC_AES_USED_ -D_COSA_INTEL_USG_ARM_ -D_COSA_FOR_COMCAST_ -D_NO_EXECINFO_H_ -DFEATURE_SUPPORT_SYSLOG \ + -DBUILD_WEB -D_NO_ANSC_ZLIB_ -D_DEBUG -U_ANSC_IPV6_COMPATIBLE_ -DUSE_NOTIFY_COMPONENT -DNTPD_ENABLE \ + -DUTC_ENABLE -DXDNS_ENABLE -DMOCA_HOME_ISOLATION -DCCSP_SUPPORT_ENABLED \ +" + +FILES_${PN} += "${libdir}/*.so" +FILES_SOLIBSDEV = "" +INSANE_SKIP_${PN} += "dev-so" diff --git a/recipes-webpa/ccsp/parodus2ccsp.bb b/recipes-webpa/ccsp/parodus2ccsp.bb new file mode 100644 index 00000000..341740e6 --- /dev/null +++ b/recipes-webpa/ccsp/parodus2ccsp.bb @@ -0,0 +1,49 @@ +SUMMARY = "parodus2ccsp client library" +SECTION = "libs" +DESCRIPTION = "C client library for parodus2ccsp" +HOMEPAGE = "https://github.com/Comcast/parodus2ccsp" + +DEPENDS_append = " cjson msgpack-c dbus ccsp-common-library trower-base64 cimplog wdmp-c nanomsg wrp-c libparodus libunpriv util-linux utopia" +RDEPENDS_${PN} = "cjson msgpack-c trower-base64 cimplog wdmp-c nanomsg wrp-c libparodus bash utopia" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e" + +SRCREV = "2fdffe0b783cef4beb5ca0232b4def4d63c87c45" + +RECIPE_BRANCH ?= "master" +SRC_URI = "\ + git://github.com/xmidt-org/parodus2ccsp.git;branch=${RECIPE_BRANCH} \ + file://0001-parodus2ccp-app-to-lib.patch \ + file://0002-build-for-non-rdk-platform.patch \ + file://0003-enable-sysconfig-for-non-rdk-build.patch \ +" + +PV = "git+${SRCPV}" +S = "${WORKDIR}/git" +require ccsp_common.inc + +inherit pythonnative + +CFLAGS_append = " \ + -I${STAGING_INCDIR}/ccsp \ + -I${STAGING_INCDIR}/wdmp-c \ + -I${STAGING_INCDIR}/libparodus \ + -I${STAGING_INCDIR}/dbus-1.0 \ + -I${STAGING_LIBDIR}/dbus-1.0/include \ + -I${STAGING_INCDIR}/cimplog \ + -I${STAGING_INCDIR}/trower-base64 \ + " + +inherit pkgconfig cmake +EXTRA_OECMAKE_append = " -DBUILD_TESTING=OFF -DBUILD_YOCTO=true" + +do_install_append() { + install -d ${D}/usr/ccsp/webpa + install -m 644 ${S}/source/arch/intel_usg/boards/rdkb_atom/config/comcast/WebpaAgent.xml ${D}/usr/ccsp/webpa +} + +FILES_${PN} += " \ + ${exec_prefix}/ccsp/webpa \ + ${libdir}/*.so \ +" diff --git a/recipes-webpa/ccsp/parodus2ccsp/0001-parodus2ccp-app-to-lib.patch b/recipes-webpa/ccsp/parodus2ccsp/0001-parodus2ccp-app-to-lib.patch new file mode 100644 index 00000000..0eda0fe3 --- /dev/null +++ b/recipes-webpa/ccsp/parodus2ccsp/0001-parodus2ccp-app-to-lib.patch @@ -0,0 +1,136 @@ +diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt +index 3302bfd..14ec8fa 100644 +--- a/source/CMakeLists.txt ++++ b/source/CMakeLists.txt +@@ -16,7 +16,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_ANSC_LINUX ") + set(WEBCONFIG_PATCH "${PATCHES_DIR}/Web_config_XML.patch") + set(SOURCES broadband/ssp_messagebus_interface.c broadband/ssp_main.c broadband/ssp_action.c broadband/cosa_webpa_dml.c broadband/cosa_webpa_internal.c broadband/cosa_webpa_apis.c broadband/plugin_main.c broadband/plugin_main_apis.c broadband/webpa_adapter.c broadband/webpa_internal.c broadband/webpa_table.c broadband/webpa_replace.c broadband/webpa_parameter.c broadband/webpa_attribute.c broadband/webpa_notification.c app/main.c app/libpd.c app/privilege.c) + +-if (BUILD_YOCTO) ++if (BUILD_YOCTO AND RDK_BUILD) + set(SOURCES ${SOURCES} broadband/dm_pack_datamodel.c) + endif() + +@@ -36,13 +36,28 @@ else() + endif() + endif() + set(HEADERS app/libpd.h) ++ ++if (PARODUS2CCSP_APP) ++ + add_executable(webpa ${SOURCES} ${HEADERS}) ++set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPARODUS2CCSP_APP ") ++else () ++ ++add_library(webpa SHARED ${SOURCES} ${HEADERS}) ++endif (PARODUS2CCSP_APP) ++ + set(COMMON_LIBS -ldbus-1 -lccsp_common -lwrp-c -lpthread -lwdmp-c -lmsgpackc -ltrower-base64 -lm -lnanomsg -lcjson -lrt -luuid -llibparodus -lcimplog) +-if (BUILD_YOCTO) ++if (BUILD_YOCTO AND RDK_BUILD) + set(COMMON_LIBS "${COMMON_LIBS} -llog4c -lrdkloggers -lprint_uptime") + endif() + if (FEATURE_SUPPORT_WEBCONFIG) + set(COMMON_LIBS "${COMMON_LIBS} -lcurl -lwebcfg") + endif() + target_link_libraries (webpa ${CMAKE_THREAD_LIBS_INIT} ${COMMON_LIBS}) +-install (TARGETS webpa DESTINATION bin) ++ ++if (PARODUS2CCSP_APP) ++set (INSTALL_DIR bin) ++else () ++set (INSTALL_DIR lib) ++endif () ++install (TARGETS webpa DESTINATION ${INSTALL_DIR}) +diff --git a/source/app/libpd.c b/source/app/libpd.c +index 800a630..17e75d5 100644 +--- a/source/app/libpd.c ++++ b/source/app/libpd.c +@@ -39,9 +39,16 @@ char *cloud_status = "offline"; + int wakeUpFlag = 0; + pthread_mutex_t cloud_mut=PTHREAD_MUTEX_INITIALIZER; + pthread_cond_t cloud_con=PTHREAD_COND_INITIALIZER; ++bool receive_data = true; ++ ++void shutdown_connection() ++{ ++ receive_data = false; ++} + + static void connect_parodus() + { ++ receive_data = true; + int backoffRetryTime = 0; + int backoff_max_time = 5; + int max_retry_sleep; +@@ -247,7 +254,7 @@ void *parallelProcessTask(void *id) + WalPrint("Detaching parallelProcess thread\n"); + pthread_detach(pthread_self()); + } +- while( FOREVER() ) ++ while( receive_data == true ) + { + parodus_receive(); + } +diff --git a/source/app/libpd.h b/source/app/libpd.h +index e6d8b49..634ddf6 100644 +--- a/source/app/libpd.h ++++ b/source/app/libpd.h +@@ -7,3 +7,4 @@ + */ + + void libpd_client_mgr(); ++void shutdownConnection(); +diff --git a/source/app/main.c b/source/app/main.c +index 7bd7b14..d34a696 100644 +--- a/source/app/main.c ++++ b/source/app/main.c +@@ -27,8 +27,13 @@ static void sig_handler(int sig); + /* External Functions */ + /*----------------------------------------------------------------------------*/ + ++#if (PARODUS2CCSP_APP) + int main() + { ++#else ++int Parodus2CCSPMain() ++{ ++#endif + int ret = -1; + + #ifdef INCLUDE_BREAKPAD +@@ -82,7 +87,7 @@ curl_global_cleanup(); + #ifndef INCLUDE_BREAKPAD + static void sig_handler(int sig) + { +- ++ shutdown_connection(); + if ( sig == SIGINT ) + { + signal(SIGINT, sig_handler); /* reset it to this function */ +diff --git a/source/broadband/ssp_main.c b/source/broadband/ssp_main.c +index 48b76be..6a3a249 100755 +--- a/source/broadband/ssp_main.c ++++ b/source/broadband/ssp_main.c +@@ -116,9 +116,10 @@ WDMP_STATUS msgBusInit(const char *pComponentName) + AnscCopyString(g_Subsystem, ""); + #endif + +- if ( bRunAsDaemon ) ++ if ( bRunAsDaemon ) ++#if (PARODUS2CCSP_APP) + daemonize(); +- ++#endif + cmd_dispatch('e'); + + subSys = NULL; /* use default sub-system */ +@@ -130,7 +131,7 @@ WDMP_STATUS msgBusInit(const char *pComponentName) + exit(1); + } + system("touch /tmp/webpa_initialized"); +-if ( bRunAsDaemon ) ++ if ( bRunAsDaemon ) + { + return WDMP_FAILURE; + } diff --git a/recipes-webpa/ccsp/parodus2ccsp/0002-build-for-non-rdk-platform.patch b/recipes-webpa/ccsp/parodus2ccsp/0002-build-for-non-rdk-platform.patch new file mode 100644 index 00000000..910ab619 --- /dev/null +++ b/recipes-webpa/ccsp/parodus2ccsp/0002-build-for-non-rdk-platform.patch @@ -0,0 +1,59 @@ +diff --git a/source/broadband/webpa_internal.c b/source/broadband/webpa_internal.c +index 88c3dc7..a6990ec 100644 +--- a/source/broadband/webpa_internal.c ++++ b/source/broadband/webpa_internal.c +@@ -173,6 +173,7 @@ void initComponentCaching(int status) + + int waitForOperationalReadyCondition() + { ++#ifdef RDK_BUILD + // Wait till PAM, CM, PSM, WiFi components are ready on the stack. + if(waitForComponentReady(RDKB_PAM_COMPONENT_NAME,RDKB_PAM_DBUS_PATH) != CCSP_SUCCESS) + { +@@ -200,6 +201,7 @@ int waitForOperationalReadyCondition() + { + return WIFI_FAILED; + } ++#endif + return 0; + } + +diff --git a/source/broadband/webpa_notification.c b/source/broadband/webpa_notification.c +index b48de11..6d2953d 100644 +--- a/source/broadband/webpa_notification.c ++++ b/source/broadband/webpa_notification.c +@@ -66,6 +66,7 @@ pthread_cond_t con=PTHREAD_COND_INITIALIZER; + pthread_mutex_t device_mac_mutex = PTHREAD_MUTEX_INITIALIZER; + + const char * notifyparameters[]={ ++#ifdef RDK_BUILD + "Device.NotifyComponent.X_RDKCENTRAL-COM_Connected-Client", + "Device.Bridging.Bridge.1.Port.8.Enable", + "Device.Bridging.Bridge.2.Port.2.Enable", +@@ -166,6 +167,7 @@ const char * notifyparameters[]={ + /* Always keep AdvancedSecurity parameters as the last parameters in notify list as these have to be removed if cujo/fp is not enabled. */ + "Device.DeviceInfo.X_RDKCENTRAL-COM_AdvancedSecurity.SafeBrowsing.Enable", + "Device.DeviceInfo.X_RDKCENTRAL-COM_AdvancedSecurity.Softflowd.Enable" ++#endif + }; + /*----------------------------------------------------------------------------*/ + /* Function Prototypes */ +@@ -800,13 +802,17 @@ void getDeviceMac() + static void *notifyTask(void *status) + { + pthread_detach(pthread_self()); +- getDeviceMac(); + loadCfgFile(); ++#ifdef RDK_BUILD ++ getDeviceMac(); + processDeviceStatusNotification(*(int *)status); ++#endif + RegisterNotifyCB(¬ifyCallback); + sendNotificationForFactoryReset(); ++#ifdef RDK_BUILD + FactoryResetCloudSyncTask(); + sendNotificationForFirmwareUpgrade(); ++#endif + setInitialNotify(); + handleNotificationEvents(); + WAL_FREE(status); diff --git a/recipes-webpa/ccsp/parodus2ccsp/0003-enable-sysconfig-for-non-rdk-build.patch b/recipes-webpa/ccsp/parodus2ccsp/0003-enable-sysconfig-for-non-rdk-build.patch new file mode 100644 index 00000000..f3b377ae --- /dev/null +++ b/recipes-webpa/ccsp/parodus2ccsp/0003-enable-sysconfig-for-non-rdk-build.patch @@ -0,0 +1,16 @@ +diff --git a/source/broadband/cosa_webpa_apis.c b/source/broadband/cosa_webpa_apis.c +index 6515f64..7fb2928 100644 +--- a/source/broadband/cosa_webpa_apis.c ++++ b/source/broadband/cosa_webpa_apis.c +@@ -16,7 +16,10 @@ + * To enable when all webpa params getting from syscfg.db file otherwise keep + * it disable. + */ +-//#define WEBPA_PARAMS_VIA_SYSCFG ++#ifndef RDK_BUILD ++#include ++#define WEBPA_PARAMS_VIA_SYSCFG ++#endif + + extern ANSC_HANDLE bus_handle; + extern char g_Subsystem[32]; diff --git a/recipes-webpa/cimplog/cimplog/0001-adjust-log-level-to-avoid-unnecessary-logs.patch b/recipes-webpa/cimplog/cimplog/0001-adjust-log-level-to-avoid-unnecessary-logs.patch new file mode 100644 index 00000000..7dd21489 --- /dev/null +++ b/recipes-webpa/cimplog/cimplog/0001-adjust-log-level-to-avoid-unnecessary-logs.patch @@ -0,0 +1,33 @@ +diff --git a/src/cimplog.c b/src/cimplog.c +index 4880c20..8491a4e 100644 +--- a/src/cimplog.c ++++ b/src/cimplog.c +@@ -26,7 +26,7 @@ + #if defined(LEVEL_DEFAULT) + int cimplog_debug_level = LEVEL_DEFAULT; + #else +-int cimplog_debug_level = LEVEL_INFO; ++int cimplog_debug_level = LEVEL_CRITICAL; + #endif + + void __cimplog(const char *module, int level, const char *msg, ...) +diff --git a/src/cimplog.h b/src/cimplog.h +index 630275b..c2d6338 100644 +--- a/src/cimplog.h ++++ b/src/cimplog.h +@@ -19,10 +19,12 @@ + + #include + +-#define LEVEL_ERROR 0 +-#define LEVEL_INFO 1 +-#define LEVEL_DEBUG 2 ++#define LEVEL_CRITICAL 0 ++#define LEVEL_ERROR 1 ++#define LEVEL_INFO 2 ++#define LEVEL_DEBUG 3 + ++#define cimplog_critical(module, ...) __cimplog(module, LEVEL_CRITICAL, __VA_ARGS__) + #define cimplog_error(module, ...) __cimplog(module, LEVEL_ERROR, __VA_ARGS__) + #define cimplog_info(module, ...) __cimplog(module, LEVEL_INFO, __VA_ARGS__) + #define cimplog_debug(module, ...) __cimplog(module, LEVEL_DEBUG, __VA_ARGS__) diff --git a/recipes-webpa/cimplog/cimplog_1.0.bb b/recipes-webpa/cimplog/cimplog_1.0.bb new file mode 100644 index 00000000..b4d5f564 --- /dev/null +++ b/recipes-webpa/cimplog/cimplog_1.0.bb @@ -0,0 +1,23 @@ +SUMMARY = "Simple logging library for rdklogger" +HOMEPAGE = "https://github.com/Comcast/cimplog" +SECTION = "libs" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e" + +SRCREV = "4d96629b8e04230549cd2bee36bc4419a6e5aecc" +SRC_URI = " \ + git://github.com/xmidt-org/cimplog.git \ + file://0001-adjust-log-level-to-avoid-unnecessary-logs.patch \ +" +PV = "git+${SRCPV}" + +S = "${WORKDIR}/git" +inherit pkgconfig cmake + +CIMP_LOG_LEVEL ??= "3" +EXTRA_OECMAKE_append = "\ + -DBUILD_TESTING=OFF \ + -DBUILD_YOCTO=true \ + -DLEVEL_DEFAULT=${CIMP_LOG_LEVEL} \ +" + diff --git a/recipes-webpa/cjwt/cjwt_1.0.bb b/recipes-webpa/cjwt/cjwt_1.0.bb new file mode 100644 index 00000000..7898b82f --- /dev/null +++ b/recipes-webpa/cjwt/cjwt_1.0.bb @@ -0,0 +1,30 @@ +SUMMARY = "cjwt library" +DESCRIPTION = "Recipe to build c library for processing jwt token" +HOMEPAGE = "https://github.com/Comcast/cjwt" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e" + +DEPENDS_append = " trower-base64 cjson openssl" + +SRCREV = "51714cf769c046ca454ebdf0ae2bc542a3d8b376" +SRC_URI = "git://github.com/Comcast/cjwt.git" +PV = "git+${SRCPV}" +PR = "r1" +S = "${WORKDIR}/git" + +LDFLAGS_append = " -lm -lcjson -ltrower-base64" + +CFLAGS_append = "\ + -I${STAGING_INCDIR} \ + -I${STAGING_INCDIR}/cjson \ + -I${STAGING_INCDIR}/trower-base64 \ +" + +inherit cmake pkgconfig +EXTRA_OECMAKE_append = " -DBUILD_TESTING=OFF -DBUILD_YOCTO=true" + +FILES_${PN} += "${libdir}/*" + +FILES_SOLIBSDEV = "" +INSANE_SKIP_${PN} += "dev-so" diff --git a/recipes-webpa/dbus/dbus/0001-close-the-fds-did-receive.patch b/recipes-webpa/dbus/dbus/0001-close-the-fds-did-receive.patch new file mode 100644 index 00000000..ac7a4b7a --- /dev/null +++ b/recipes-webpa/dbus/dbus/0001-close-the-fds-did-receive.patch @@ -0,0 +1,78 @@ +From 872b085f12f56da25a2dbd9bd0b2dff31d5aea63 Mon Sep 17 00:00:00 2001 +From: Simon McVittie +Date: Thu, 16 Apr 2020 14:45:11 +0100 +Subject: [PATCH] sysdeps-unix: On MSG_CTRUNC, close the fds we did receive + +MSG_CTRUNC indicates that we have received fewer fds that we should +have done because the buffer was too small, but we were treating it +as though it indicated that we received *no* fds. If we received any, +we still have to make sure we close them, otherwise they will be leaked. + +On the system bus, if an attacker can induce us to leak fds in this +way, that's a local denial of service via resource exhaustion. + +Reported-by: Kevin Backhouse, GitHub Security Lab +Fixes: dbus#294 +Fixes: CVE-2020-12049 +Fixes: GHSL-2020-057 + +Upstream-Status: Backport [https://gitlab.freedesktop.org/dbus/dbus/-/commit/872b085f12f56da25a2dbd9bd0b2dff31d5aea63] +CVE: CVE-2020-12049 +Signed-off-by: Lee Chee Yang +--- + dbus/dbus-sysdeps-unix.c | 32 ++++++++++++++++++++------------ + 1 file changed, 20 insertions(+), 12 deletions(-) + +diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c +index b5fc2466..b176dae1 100644 +--- a/dbus/dbus-sysdeps-unix.c ++++ b/dbus/dbus-sysdeps-unix.c +@@ -435,18 +435,6 @@ _dbus_read_socket_with_unix_fds (DBusSocket fd, + struct cmsghdr *cm; + dbus_bool_t found = FALSE; + +- if (m.msg_flags & MSG_CTRUNC) +- { +- /* Hmm, apparently the control data was truncated. The bad +- thing is that we might have completely lost a couple of fds +- without chance to recover them. Hence let's treat this as a +- serious error. */ +- +- errno = ENOSPC; +- _dbus_string_set_length (buffer, start); +- return -1; +- } +- + for (cm = CMSG_FIRSTHDR(&m); cm; cm = CMSG_NXTHDR(&m, cm)) + if (cm->cmsg_level == SOL_SOCKET && cm->cmsg_type == SCM_RIGHTS) + { +@@ -501,6 +489,26 @@ _dbus_read_socket_with_unix_fds (DBusSocket fd, + if (!found) + *n_fds = 0; + ++ if (m.msg_flags & MSG_CTRUNC) ++ { ++ unsigned int i; ++ ++ /* Hmm, apparently the control data was truncated. The bad ++ thing is that we might have completely lost a couple of fds ++ without chance to recover them. Hence let's treat this as a ++ serious error. */ ++ ++ /* We still need to close whatever fds we *did* receive, ++ * otherwise they'll never get closed. (CVE-2020-12049) */ ++ for (i = 0; i < *n_fds; i++) ++ close (fds[i]); ++ ++ *n_fds = 0; ++ errno = ENOSPC; ++ _dbus_string_set_length (buffer, start); ++ return -1; ++ } ++ + /* put length back (doesn't actually realloc) */ + _dbus_string_set_length (buffer, start + bytes_read); + +-- +2.25.1 + diff --git a/recipes-webpa/dbus/dbus/0001-dbus-include-ccsp-support.patch b/recipes-webpa/dbus/dbus/0001-dbus-include-ccsp-support.patch new file mode 100644 index 00000000..55aa1c07 --- /dev/null +++ b/recipes-webpa/dbus/dbus/0001-dbus-include-ccsp-support.patch @@ -0,0 +1,902 @@ +From 3a5270c11950265878dea94020fa86d9a9dd337c Mon Sep 17 00:00:00 2001 +From: Jaga +Date: Mon, 9 Mar 2020 14:19:03 +0000 +Subject: [PATCH] RDKB-27908: dbus: add CCSP APIs patch for dbus 1.12.16 (required for RDK-B with OE 3.1) + +Reason for Change: + When building RDK-B, the meta-rdk dbus .bbappend applies a version + specific patch to dbus to enable support for CCSP APIs. Currently no + patch exists for dbus 1.12.16 (ie the OE 3.1 version), which causes + OE 3.1 based RDK-B builds to fail during boot-up. + + To unblock development and testing of OE 3.1, copy the existing CCSP + APIs patch for dbus 1.10.10 and apply it to dbus 1.12.16. Note that + the patch has been build tested only and further updates may still be + required to fully support dbus 1.12.16. + +Source: COMCAST +License: AFL-2.1 | GPLv2+ + +Upstream-Status: Pending + +Signed-off-by: Jaga + +--- + bus/activation.c | 12 ++-- + bus/bus.c | 14 ++-- + bus/connection.c | 28 ++++---- + bus/dir-watch-inotify.c | 8 +-- + bus/dispatch.c | 28 ++++---- + bus/expirelist.c | 6 +- + bus/main.c | 10 +-- + bus/utils.c | 2 +- + dbus/Makefile.am | 20 +++--- + dbus/dbus-ccsp-apis.c | 141 ++++++++++++++++++++++++++++++++++++++++ + dbus/dbus-ccsp-apis.h | 112 +++++++++++++++++++++++++++++++ + dbus/dbus.h | 1 + + 12 files changed, 319 insertions(+), 63 deletions(-) + create mode 100644 dbus/dbus-ccsp-apis.c + create mode 100644 dbus/dbus-ccsp-apis.h + +diff --git a/bus/activation.c b/bus/activation.c +index 99404b9..7cfdec0 100644 +--- a/bus/activation.c ++++ b/bus/activation.c +@@ -178,7 +178,7 @@ bus_pending_activation_unref (BusPendingActivation *pending_activation) + + if (pending_activation->timeout_added) + { +- _dbus_loop_remove_timeout (bus_context_get_loop (pending_activation->activation->context), ++ dbus_loop_remove_timeout (bus_context_get_loop (pending_activation->activation->context), + pending_activation->timeout); + pending_activation->timeout_added = FALSE; + } +@@ -1348,7 +1348,7 @@ pending_activation_failed (BusPendingActivation *pending_activation, + { + /* FIXME use preallocated OOM messages instead of bus_wait_for_memory() */ + while (!try_send_activation_failure (pending_activation, how)) +- _dbus_wait_for_memory (); ++ dbus_wait_for_memory (); + + /* Destroy this pending activation */ + _dbus_hash_table_remove_string (pending_activation->activation->pending_activations, +@@ -1501,7 +1501,7 @@ add_babysitter_watch (DBusWatch *watch, + { + BusPendingActivation *pending_activation = data; + +- return _dbus_loop_add_watch ( ++ return dbus_loop_add_watch ( + bus_context_get_loop (pending_activation->activation->context), + watch); + } +@@ -1512,7 +1512,7 @@ remove_babysitter_watch (DBusWatch *watch, + { + BusPendingActivation *pending_activation = data; + +- _dbus_loop_remove_watch (bus_context_get_loop (pending_activation->activation->context), ++ dbus_loop_remove_watch (bus_context_get_loop (pending_activation->activation->context), + watch); + } + +@@ -1522,7 +1522,7 @@ toggle_babysitter_watch (DBusWatch *watch, + { + BusPendingActivation *pending_activation = data; + +- _dbus_loop_toggle_watch (bus_context_get_loop (pending_activation->activation->context), ++ dbus_loop_toggle_watch (bus_context_get_loop (pending_activation->activation->context), + watch); + } + +@@ -1951,7 +1951,7 @@ bus_activation_activate_service (BusActivation *activation, + return FALSE; + } + +- if (!_dbus_loop_add_timeout (bus_context_get_loop (activation->context), ++ if (!dbus_loop_add_timeout (bus_context_get_loop (activation->context), + pending_activation->timeout)) + { + _dbus_verbose ("Failed to add timeout for pending activation\n"); +diff --git a/bus/bus.c b/bus/bus.c +index 2ad8e78..82ff921 100644 +--- a/bus/bus.c ++++ b/bus/bus.c +@@ -114,7 +114,7 @@ add_server_watch (DBusWatch *watch, + + context = server_get_context (server); + +- return _dbus_loop_add_watch (context->loop, watch); ++ return dbus_loop_add_watch (context->loop, watch); + } + + static void +@@ -126,7 +126,7 @@ remove_server_watch (DBusWatch *watch, + + context = server_get_context (server); + +- _dbus_loop_remove_watch (context->loop, watch); ++ dbus_loop_remove_watch (context->loop, watch); + } + + static void +@@ -138,7 +138,7 @@ toggle_server_watch (DBusWatch *watch, + + context = server_get_context (server); + +- _dbus_loop_toggle_watch (context->loop, watch); ++ dbus_loop_toggle_watch (context->loop, watch); + } + + static dbus_bool_t +@@ -150,7 +150,7 @@ add_server_timeout (DBusTimeout *timeout, + + context = server_get_context (server); + +- return _dbus_loop_add_timeout (context->loop, timeout); ++ return dbus_loop_add_timeout (context->loop, timeout); + } + + static void +@@ -162,7 +162,7 @@ remove_server_timeout (DBusTimeout *timeout, + + context = server_get_context (server); + +- _dbus_loop_remove_timeout (context->loop, timeout); ++ dbus_loop_remove_timeout (context->loop, timeout); + } + + static void +@@ -783,7 +783,7 @@ bus_context_new (const DBusString *config_file, + goto failed; + } + +- context->loop = _dbus_loop_new (); ++ context->loop = dbus_loop_new (); + if (context->loop == NULL) + { + BUS_SET_OOM (error); +@@ -1162,7 +1162,7 @@ bus_context_unref (BusContext *context) + + if (context->loop) + { +- _dbus_loop_unref (context->loop); ++ dbus_loop_unref (context->loop); + context->loop = NULL; + } + +diff --git a/bus/connection.c b/bus/connection.c +index 53605fa..74acd65 100644 +--- a/bus/connection.c ++++ b/bus/connection.c +@@ -236,7 +236,7 @@ bus_connection_disconnected (DBusConnection *connection) + dbus_error_init (&error); + + while ((transaction = bus_transaction_new (d->connections->context)) == NULL) +- _dbus_wait_for_memory (); ++ dbus_wait_for_memory (); + + if (!bus_service_remove_owner (service, connection, + transaction, &error)) +@@ -247,7 +247,7 @@ bus_connection_disconnected (DBusConnection *connection) + { + dbus_error_free (&error); + bus_transaction_cancel_and_free (transaction); +- _dbus_wait_for_memory (); ++ dbus_wait_for_memory (); + goto retry; + } + else +@@ -286,7 +286,7 @@ bus_connection_disconnected (DBusConnection *connection) + + if (d->pending_unix_fds_timeout) + { +- _dbus_loop_remove_timeout (bus_context_get_loop (d->connections->context), ++ dbus_loop_remove_timeout (bus_context_get_loop (d->connections->context), + d->pending_unix_fds_timeout); + _dbus_timeout_unref (d->pending_unix_fds_timeout); + } +@@ -354,7 +354,7 @@ add_connection_watch (DBusWatch *watch, + { + DBusConnection *connection = data; + +- return _dbus_loop_add_watch (connection_get_loop (connection), watch); ++ return dbus_loop_add_watch (connection_get_loop (connection), watch); + } + + static void +@@ -363,7 +363,7 @@ remove_connection_watch (DBusWatch *watch, + { + DBusConnection *connection = data; + +- _dbus_loop_remove_watch (connection_get_loop (connection), watch); ++ dbus_loop_remove_watch (connection_get_loop (connection), watch); + } + + static void +@@ -372,7 +372,7 @@ toggle_connection_watch (DBusWatch *watch, + { + DBusConnection *connection = data; + +- _dbus_loop_toggle_watch (connection_get_loop (connection), watch); ++ dbus_loop_toggle_watch (connection_get_loop (connection), watch); + } + + static dbus_bool_t +@@ -381,7 +381,7 @@ add_connection_timeout (DBusTimeout *timeout, + { + DBusConnection *connection = data; + +- return _dbus_loop_add_timeout (connection_get_loop (connection), timeout); ++ return dbus_loop_add_timeout (connection_get_loop (connection), timeout); + } + + static void +@@ -390,7 +390,7 @@ remove_connection_timeout (DBusTimeout *timeout, + { + DBusConnection *connection = data; + +- _dbus_loop_remove_timeout (connection_get_loop (connection), timeout); ++ dbus_loop_remove_timeout (connection_get_loop (connection), timeout); + } + + static void +@@ -402,8 +402,8 @@ dispatch_status_function (DBusConnection *connection, + + if (new_status != DBUS_DISPATCH_COMPLETE) + { +- while (!_dbus_loop_queue_dispatch (loop, connection)) +- _dbus_wait_for_memory (); ++ while (!dbus_loop_queue_dispatch (loop, connection)) ++ dbus_wait_for_memory (); + } + } + +@@ -483,7 +483,7 @@ bus_connections_new (BusContext *context) + if (connections->pending_replies == NULL) + goto failed_4; + +- if (!_dbus_loop_add_timeout (bus_context_get_loop (context), ++ if (!dbus_loop_add_timeout (bus_context_get_loop (context), + connections->expire_timeout)) + goto failed_5; + +@@ -557,7 +557,7 @@ bus_connections_unref (BusConnections *connections) + + bus_expire_list_free (connections->pending_replies); + +- _dbus_loop_remove_timeout (bus_context_get_loop (connections->context), ++ dbus_loop_remove_timeout (bus_context_get_loop (connections->context), + connections->expire_timeout); + + _dbus_timeout_unref (connections->expire_timeout); +@@ -815,7 +815,7 @@ bus_connections_setup_connection (BusConnections *connections, + + if (dbus_connection_get_dispatch_status (connection) != DBUS_DISPATCH_COMPLETE) + { +- if (!_dbus_loop_queue_dispatch (bus_context_get_loop (connections->context), connection)) ++ if (!dbus_loop_queue_dispatch (bus_context_get_loop (connections->context), connection)) + { + bus_dispatch_remove_connection (connection); + goto oom; +@@ -830,7 +830,7 @@ bus_connections_setup_connection (BusConnections *connections, + goto oom; + + _dbus_timeout_disable (d->pending_unix_fds_timeout); +- if (!_dbus_loop_add_timeout (bus_context_get_loop (connections->context), ++ if (!dbus_loop_add_timeout (bus_context_get_loop (connections->context), + d->pending_unix_fds_timeout)) + goto oom; + +diff --git a/bus/dir-watch-inotify.c b/bus/dir-watch-inotify.c +index 447dc2d..7ddfd64 100644 +--- a/bus/dir-watch-inotify.c ++++ b/bus/dir-watch-inotify.c +@@ -205,10 +205,10 @@ _shutdown_inotify (void *data) + + if (watch != NULL) + { +- _dbus_loop_remove_watch (loop, watch); ++ dbus_loop_remove_watch (loop, watch); + _dbus_watch_invalidate (watch); + _dbus_watch_unref (watch); +- _dbus_loop_unref (loop); ++ dbus_loop_unref (loop); + } + watch = NULL; + loop = NULL; +@@ -245,7 +245,7 @@ _init_inotify (BusContext *context) + _dbus_fd_set_close_on_exec (inotify_fd); + + loop = bus_context_get_loop (context); +- _dbus_loop_ref (loop); ++ dbus_loop_ref (loop); + + watch = _dbus_watch_new (inotify_fd, DBUS_WATCH_READABLE, TRUE, + _handle_inotify_watch, NULL, NULL); +@@ -256,7 +256,7 @@ _init_inotify (BusContext *context) + goto out; + } + +- if (!_dbus_loop_add_watch (loop, watch)) ++ if (!dbus_loop_add_watch (loop, watch)) + { + _dbus_warn ("Unable to add reload watch to main loop"); + _dbus_watch_unref (watch); +diff --git a/bus/dispatch.c b/bus/dispatch.c +index 19228be..27bc02e 100644 +--- a/bus/dispatch.c ++++ b/bus/dispatch.c +@@ -233,7 +233,7 @@ bus_dispatch (DBusConnection *connection, + * until we can. + */ + while (!bus_connection_preallocate_oom_error (connection)) +- _dbus_wait_for_memory (); ++ dbus_wait_for_memory (); + + /* Ref connection in case we disconnect it at some point in here */ + dbus_connection_ref (connection); +@@ -624,7 +624,7 @@ pop_message_waiting_for_memory (DBusConnection *connection) + { + while (dbus_connection_get_dispatch_status (connection) == + DBUS_DISPATCH_NEED_MEMORY) +- _dbus_wait_for_memory (); ++ dbus_wait_for_memory (); + + return dbus_connection_pop_message (connection); + } +@@ -634,7 +634,7 @@ borrow_message_waiting_for_memory (DBusConnection *connection) + { + while (dbus_connection_get_dispatch_status (connection) == + DBUS_DISPATCH_NEED_MEMORY) +- _dbus_wait_for_memory (); ++ dbus_wait_for_memory (); + + return dbus_connection_borrow_message (connection); + } +@@ -749,7 +749,7 @@ check_service_owner_changed_foreach (DBusConnection *connection, + if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY)) + { + dbus_error_free (&error); +- _dbus_wait_for_memory (); ++ dbus_wait_for_memory (); + goto reget_service_info_data; + } + else +@@ -810,7 +810,7 @@ kill_client_connection (BusContext *context, + _dbus_assert (s != NULL); + + while ((base_service = _dbus_strdup (s)) == NULL) +- _dbus_wait_for_memory (); ++ dbus_wait_for_memory (); + + dbus_connection_ref (connection); + +@@ -1043,7 +1043,7 @@ check_hello_message (BusContext *context, + { + _dbus_verbose ("no memory to get service name arg from hello\n"); + dbus_error_free (&error); +- _dbus_wait_for_memory (); ++ dbus_wait_for_memory (); + goto retry_get_hello_name; + } + else +@@ -1057,7 +1057,7 @@ check_hello_message (BusContext *context, + _dbus_verbose ("Got hello name: %s\n", name); + + while (!dbus_bus_set_unique_name (connection, name)) +- _dbus_wait_for_memory (); ++ dbus_wait_for_memory (); + + socd.expected_kind = SERVICE_CREATED; + socd.expected_service_name = name; +@@ -1103,7 +1103,7 @@ check_hello_message (BusContext *context, + { + _dbus_verbose ("no memory to get service name arg from acquired\n"); + dbus_error_free (&error); +- _dbus_wait_for_memory (); ++ dbus_wait_for_memory (); + goto retry_get_acquired_name; + } + else +@@ -1353,7 +1353,7 @@ check_get_connection_unix_user (BusContext *context, + { + _dbus_verbose ("no memory to get uid by GetConnectionUnixUser\n"); + dbus_error_free (&error); +- _dbus_wait_for_memory (); ++ dbus_wait_for_memory (); + goto retry_get_property; + } + else +@@ -1516,7 +1516,7 @@ check_get_connection_unix_process_id (BusContext *context, + { + _dbus_verbose ("no memory to get pid by GetConnectionUnixProcessID\n"); + dbus_error_free (&error); +- _dbus_wait_for_memory (); ++ dbus_wait_for_memory (); + goto retry_get_property; + } + else +@@ -2108,7 +2108,7 @@ check_base_service_activated (BusContext *context, + if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY)) + { + dbus_error_free (&error); +- _dbus_wait_for_memory (); ++ dbus_wait_for_memory (); + goto reget_service_name_arg; + } + else +@@ -2213,7 +2213,7 @@ check_service_activated (BusContext *context, + if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY)) + { + dbus_error_free (&error); +- _dbus_wait_for_memory (); ++ dbus_wait_for_memory (); + goto reget_service_name_arg; + } + else +@@ -2366,7 +2366,7 @@ check_service_auto_activated (BusContext *context, + if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY)) + { + dbus_error_free (&error); +- _dbus_wait_for_memory (); ++ dbus_wait_for_memory (); + goto reget_service_name_arg; + } + else +@@ -4502,7 +4502,7 @@ check_get_services (BusContext *context, + { + _dbus_verbose ("no memory to list services by %s\n", method); + dbus_error_free (&error); +- _dbus_wait_for_memory (); ++ dbus_wait_for_memory (); + goto retry_get_property; + } + else +diff --git a/bus/expirelist.c b/bus/expirelist.c +index 4a39752..f800ca6 100644 +--- a/bus/expirelist.c ++++ b/bus/expirelist.c +@@ -65,7 +65,7 @@ bus_expire_list_new (DBusLoop *loop, + + _dbus_timeout_disable (list->timeout); + +- if (!_dbus_loop_add_timeout (list->loop, list->timeout)) ++ if (!dbus_loop_add_timeout (list->loop, list->timeout)) + goto failed; + + return list; +@@ -84,7 +84,7 @@ bus_expire_list_free (BusExpireList *list) + { + _dbus_assert (list->items == NULL); + +- _dbus_loop_remove_timeout (list->loop, list->timeout); ++ dbus_loop_remove_timeout (list->loop, list->timeout); + + _dbus_timeout_unref (list->timeout); + +@@ -158,7 +158,7 @@ do_expiration_with_monotonic_time (BusExpireList *list, + */ + if (!(* list->expire_func) (list, link, list->data)) + { +- next_interval = _dbus_get_oom_wait (); ++ next_interval = dbus_get_oom_wait (); + break; + } + } +diff --git a/bus/main.c b/bus/main.c +index 4ee3f75..eb9de0f 100644 +--- a/bus/main.c ++++ b/bus/main.c +@@ -271,7 +271,7 @@ handle_reload_watch (DBusWatch *watch, + char action = '\0'; + + while (!_dbus_string_init (&str)) +- _dbus_wait_for_memory (); ++ dbus_wait_for_memory (); + + if ((reload_pipe[RELOAD_READ_END].fd > 0) && + _dbus_read_socket (reload_pipe[RELOAD_READ_END], &str, 1) != 1) +@@ -320,7 +320,7 @@ handle_reload_watch (DBusWatch *watch, + loop = bus_context_get_loop (context); + if (loop != NULL) + { +- _dbus_loop_quit (loop); ++ dbus_loop_quit (loop); + } + } + break; +@@ -361,7 +361,7 @@ setup_reload_pipe (DBusLoop *loop) + exit (1); + } + +- if (!_dbus_loop_add_watch (loop, watch)) ++ if (!dbus_loop_add_watch (loop, watch)) + { + _dbus_warn ("Unable to add reload watch to main loop: %s", + error.message); +@@ -374,7 +374,7 @@ setup_reload_pipe (DBusLoop *loop) + static void + close_reload_pipe (DBusWatch **watch) + { +- _dbus_loop_remove_watch (bus_context_get_loop (context), *watch); ++ dbus_loop_remove_watch (bus_context_get_loop (context), *watch); + _dbus_watch_invalidate (*watch); + _dbus_watch_unref (*watch); + *watch = NULL; +@@ -717,7 +717,7 @@ main (int argc, char **argv) + #endif /* DBUS_UNIX */ + + _dbus_verbose ("We are on D-Bus...\n"); +- _dbus_loop_run (bus_context_get_loop (context)); ++ dbus_loop_run (bus_context_get_loop (context)); + + bus_context_shutdown (context); + bus_context_unref (context); +diff --git a/bus/utils.c b/bus/utils.c +index 7d24872..4442a74 100644 +--- a/bus/utils.c ++++ b/bus/utils.c +@@ -42,7 +42,7 @@ bus_connection_dispatch_one_message (DBusConnection *connection) + DBusDispatchStatus status; + + while ((status = dbus_connection_dispatch (connection)) == DBUS_DISPATCH_NEED_MEMORY) +- _dbus_wait_for_memory (); ++ dbus_wait_for_memory (); + + return status == DBUS_DISPATCH_DATA_REMAINS; + } +diff --git a/dbus/Makefile.am b/dbus/Makefile.am +index ec8e2a5..f519d8b 100644 +--- a/dbus/Makefile.am ++++ b/dbus/Makefile.am +@@ -120,13 +120,14 @@ DBUS_UTIL_arch_sources = \ + endif + + if HAVE_LINUX_EPOLL +-DBUS_UTIL_arch_sources += dbus-socket-set-epoll.c ++DBUS_SHARED_arch_sources += dbus-socket-set-epoll.c + endif + + dbusinclude_HEADERS= \ + dbus.h \ + dbus-address.h \ + dbus-bus.h \ ++ dbus-ccsp-apis.h \ + dbus-connection.h \ + dbus-errors.h \ + dbus-macros.h \ +@@ -153,6 +154,7 @@ DBUS_LIB_SOURCES= \ + dbus-auth.c \ + dbus-auth.h \ + dbus-bus.c \ ++ dbus-ccsp-apis.c \ + dbus-connection.c \ + dbus-connection-internal.h \ + dbus-credentials.c \ +@@ -199,9 +201,7 @@ DBUS_LIB_SOURCES= \ + dbus-transport.h \ + dbus-transport-protected.h \ + dbus-transport-socket.c \ +- dbus-transport-socket.h \ +- dbus-watch.c \ +- dbus-watch.h ++ dbus-transport-socket.h + + ### source code that goes in the installed client library + ### AND is generic utility functionality used by the +@@ -218,6 +218,8 @@ DBUS_SHARED_SOURCES= \ + dbus-internals.h \ + dbus-list.c \ + dbus-list.h \ ++ dbus-mainloop.c \ ++ dbus-mainloop.h \ + dbus-marshal-basic.c \ + dbus-marshal-basic.h \ + dbus-memory.c \ +@@ -225,6 +227,11 @@ DBUS_SHARED_SOURCES= \ + dbus-mempool.h \ + dbus-pipe.c \ + dbus-pipe.h \ ++ dbus-socket-set.h \ ++ dbus-socket-set.c \ ++ dbus-socket-set-poll.c \ ++ dbus-watch.c \ ++ dbus-watch.h \ + dbus-string.c \ + dbus-string.h \ + dbus-string-private.h \ +@@ -245,8 +252,6 @@ DBUS_UTIL_SOURCES= \ + dbus-auth-script.h \ + dbus-auth-util.c \ + dbus-credentials-util.c \ +- dbus-mainloop.c \ +- dbus-mainloop.h \ + dbus-marshal-byteswap-util.c \ + dbus-marshal-recursive-util.c \ + dbus-marshal-validate-util.c \ +@@ -256,9 +261,6 @@ DBUS_UTIL_SOURCES= \ + dbus-shell.c \ + dbus-shell.h \ + $(DBUS_UTIL_arch_sources) \ +- dbus-socket-set.h \ +- dbus-socket-set.c \ +- dbus-socket-set-poll.c \ + dbus-spawn.h \ + dbus-string-util.c \ + dbus-sysdeps-util.c \ +diff --git a/dbus/dbus-ccsp-apis.c b/dbus/dbus-ccsp-apis.c +new file mode 100644 +index 0000000..20ff316 +--- /dev/null ++++ b/dbus/dbus-ccsp-apis.c +@@ -0,0 +1,141 @@ ++/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ ++/* dbus-ccsp-apis.c ++ * ++ * Copyright (C) 2003 Red Hat, Inc. ++ * ++ * Licensed under the Academic Free License version 2.1 ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ * ++ */ ++ ++#include ++#include ++#include ++#ifdef DBUS_UNIX ++#include ++#endif ++ ++/* Handle the loop wakeup watch */ ++dbus_bool_t wake_handler(DBusWatch *watch, unsigned int flags, void *data) ++{ ++ char ch; ++ int fd = (int)data; ++ /* Read and discard */ ++ while(read(fd, &ch, 1) == 1); ++} ++ ++/* We only need 1 wake watch per mainloop process */ ++DBusWatch *wake_watch = NULL; ++ ++/* From dbus-mainloop */ ++DBusLoop* dbus_loop_new(void) ++{ ++ return _dbus_loop_new(); ++} ++ ++DBusLoop* dbus_loop_ref(DBusLoop *loop) ++{ ++ return _dbus_loop_ref(loop); ++} ++ ++void dbus_loop_unref(DBusLoop *loop) { _dbus_loop_unref(loop); } ++ ++dbus_bool_t dbus_loop_add_watch(DBusLoop *loop, DBusWatch *watch) ++{ ++ return _dbus_loop_add_watch(loop, watch); ++} ++ ++void dbus_loop_remove_watch(DBusLoop *loop, DBusWatch *watch) ++{ ++ _dbus_loop_remove_watch(loop, watch); ++} ++ ++void dbus_loop_toggle_watch(DBusLoop *loop, DBusWatch *watch) ++{ ++ _dbus_loop_toggle_watch(loop, watch); ++} ++ ++dbus_bool_t dbus_loop_add_timeout(DBusLoop *loop, DBusTimeout *timeout) ++{ ++ return _dbus_loop_add_timeout(loop, timeout); ++} ++ ++void dbus_loop_remove_timeout(DBusLoop *loop, DBusTimeout *timeout) ++{ ++ _dbus_loop_remove_timeout(loop, timeout); ++} ++ ++dbus_bool_t dbus_loop_queue_dispatch(DBusLoop *loop, DBusConnection *connection) ++{ ++ return _dbus_loop_queue_dispatch(loop, connection); ++} ++ ++void dbus_loop_run(DBusLoop *loop) ++{ ++ _dbus_loop_run(loop); ++} ++ ++void dbus_loop_quit(DBusLoop *loop) ++{ ++ _dbus_loop_quit(loop); ++} ++ ++dbus_bool_t dbus_loop_iterate(DBusLoop *loop, dbus_bool_t block) ++{ ++ return _dbus_loop_iterate(loop, block); ++} ++ ++dbus_bool_t dbus_loop_dispatch(DBusLoop *loop) ++{ ++ return _dbus_loop_dispatch(loop); ++} ++ ++void dbus_wait_for_memory(void) ++{ ++ _dbus_wait_for_memory(); ++} ++ ++/* From dbus-connection */ ++void dbus_connection_lock(DBusConnection *connection) ++{ ++ _dbus_connection_lock(connection); ++} ++ ++void dbus_connection_unlock(DBusConnection *connection) ++{ ++ _dbus_connection_unlock(connection); ++} ++ ++int dbus_get_oom_wait (void) ++{ ++ return _dbus_get_oom_wait(); ++} ++ ++dbus_bool_t dbus_loop_add_wake(DBusLoop *loop, int fd) ++{ ++ wake_watch = _dbus_watch_new(fd, DBUS_WATCH_READABLE, TRUE, wake_handler, (void *)fd, NULL); ++ return dbus_loop_add_watch(loop, wake_watch); ++} ++ ++void dbus_loop_remove_wake(DBusLoop *loop) ++{ ++ if (wake_watch) ++ { ++ dbus_loop_remove_watch(loop, wake_watch); ++ _dbus_watch_unref(wake_watch); ++ wake_watch = NULL; ++ } ++} +diff --git a/dbus/dbus-ccsp-apis.h b/dbus/dbus-ccsp-apis.h +new file mode 100644 +index 0000000..aec0806 +--- /dev/null ++++ b/dbus/dbus-ccsp-apis.h +@@ -0,0 +1,112 @@ ++/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ ++/* dbus-ccsp-apis.h ++ * ++ * Copyright (C) 2003 Red Hat, Inc. ++ * ++ * Licensed under the Academic Free License version 2.1 ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ * ++ */ ++#if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION) ++#error "Only can be included directly, this file may disappear or change contents." ++#endif ++ ++#ifndef DBUS_CCSP_APIS_H ++#define DBUS_CCSP_APIS_H ++ ++#include ++#include ++ ++typedef struct DBusLoop DBusLoop; ++ ++DBUS_BEGIN_DECLS ++ ++/** ++ * @addtogroup DBusCcspApis ++ * @{ ++ */ ++ ++/* From dbus-mainloop */ ++DBUS_EXPORT ++DBusLoop* dbus_loop_new (void); ++ ++DBUS_EXPORT ++DBusLoop* dbus_loop_ref (DBusLoop *loop); ++ ++DBUS_EXPORT ++void dbus_loop_unref (DBusLoop *loop); ++ ++DBUS_EXPORT ++dbus_bool_t dbus_loop_add_watch (DBusLoop *loop, ++ DBusWatch *watch); ++ ++DBUS_EXPORT ++void dbus_loop_remove_watch (DBusLoop *loop, ++ DBusWatch *watch); ++DBUS_EXPORT ++void dbus_loop_toggle_watch (DBusLoop *loop, ++ DBusWatch *watch); ++DBUS_EXPORT ++dbus_bool_t dbus_loop_add_timeout (DBusLoop *loop, ++ DBusTimeout *timeout); ++ ++DBUS_EXPORT ++void dbus_loop_remove_timeout (DBusLoop *loop, ++ DBusTimeout *timeout); ++ ++DBUS_EXPORT ++dbus_bool_t dbus_loop_queue_dispatch (DBusLoop *loop, ++ DBusConnection *connection); ++ ++DBUS_EXPORT ++void dbus_loop_run (DBusLoop *loop); ++ ++DBUS_EXPORT ++void dbus_loop_quit (DBusLoop *loop); ++ ++DBUS_EXPORT ++dbus_bool_t dbus_loop_iterate (DBusLoop *loop, ++ dbus_bool_t block); ++ ++DBUS_EXPORT ++dbus_bool_t dbus_loop_dispatch (DBusLoop *loop); ++ ++DBUS_EXPORT ++void dbus_wait_for_memory(void); ++ ++DBUS_EXPORT ++int dbus_get_oom_wait(void); ++ ++/* From dbus-connection */ ++DBUS_EXPORT ++void dbus_connection_lock(DBusConnection *connection); ++ ++DBUS_EXPORT ++void dbus_connection_unlock(DBusConnection *connection); ++ ++DBUS_EXPORT ++dbus_bool_t dbus_loop_add_wake (DBusLoop *loop, ++ int fd); ++ ++DBUS_EXPORT ++void dbus_loop_remove_wake (DBusLoop *loop); ++ ++/** @} */ ++ ++DBUS_END_DECLS ++ ++#endif /* DBUS_CCSP_APIS_H */ ++ +diff --git a/dbus/dbus.h b/dbus/dbus.h +index 31aa4d1..c42ed98 100644 +--- a/dbus/dbus.h ++++ b/dbus/dbus.h +@@ -29,6 +29,7 @@ + #include + #include + #include ++#include + #include + #include + #include diff --git a/recipes-webpa/dbus/dbus/0002-clear-guid_from_server-if-send_negotiate_unix_f.patch b/recipes-webpa/dbus/dbus/0002-clear-guid_from_server-if-send_negotiate_unix_f.patch new file mode 100644 index 00000000..6bb6d9c8 --- /dev/null +++ b/recipes-webpa/dbus/dbus/0002-clear-guid_from_server-if-send_negotiate_unix_f.patch @@ -0,0 +1,104 @@ +From b8f84bd39485d3977625c9a8b8e8cff5d23be56f Mon Sep 17 00:00:00 2001 +From: Roy Li +Date: Thu, 27 Feb 2014 09:05:02 +0800 +Subject: [PATCH] dbus: clear guid_from_server if send_negotiate_unix_fd + failed + +Upstream-Status: Submitted + +bus-test dispatch test failed with below information: + ./bus/bus-test: Running message dispatch test + Activating service name='org.freedesktop.DBus.TestSuiteEchoService' + Successfully activated service 'org.freedesktop.DBus.TestSuiteEchoService' + 6363: assertion failed "_dbus_string_get_length (& DBUS_AUTH_CLIENT (auth)->guid_from_server) == 0" file "dbus-auth.c" line 1545 function process_ok + ./bus/bus-test(_dbus_print_backtrace+0x29) [0x80cb969] + ./bus/bus-test(_dbus_abort+0x14) [0x80cfb44] + ./bus/bus-test(_dbus_real_assert+0x53) [0x80b52c3] + ./bus/bus-test() [0x80e24da] + ./bus/bus-test(_dbus_auth_do_work+0x388) [0x80e3848] + ./bus/bus-test() [0x80aea49] + ./bus/bus-test() [0x80affde] + ./bus/bus-test(_dbus_transport_handle_watch+0xb1) [0x80ad841] + ./bus/bus-test(_dbus_connection_handle_watch+0x104) [0x8089174] + ./bus/bus-test(dbus_watch_handle+0xd8) [0x80b15e8] + ./bus/bus-test(_dbus_loop_iterate+0x4a9) [0x80d1509] + ./bus/bus-test(bus_test_run_clients_loop+0x5d) [0x808129d] + ./bus/bus-test() [0x806cab0] + ./bus/bus-test() [0x806e0ca] + ./bus/bus-test() [0x806da6f] + ./bus/bus-test(_dbus_test_oom_handling+0x18c) [0x80b5c8c] + ./bus/bus-test() [0x806f723] + ./bus/bus-test(bus_dispatch_test+0x3c) [0x8071aac] + ./bus/bus-test(main+0x1b7) [0x805acc7] + /lib/libc.so.6(__libc_start_main+0xf3) [0x45f919b3] + ./bus/bus-test() [0x805ae39] + +The stack is below: + #0 0xffffe425 in __kernel_vsyscall () + #1 0x45fa62d6 in raise () from /lib/libc.so.6 + #2 0x45fa9653 in abort () from /lib/libc.so.6 + #3 0x080cfb65 in _dbus_abort () at dbus-sysdeps.c:94 + #4 0x080b52c3 in _dbus_real_assert (condition=0, + condition_text=condition_text@entry=0x8117a38 "_dbus_string_get_length (& DBUS_AUTH_CLIENT (auth)->guid_from_server) == 0", + file=file@entry=0x8117273 "dbus-auth.c", line=line@entry=1545, + func=func@entry=0x8117f8e <__FUNCTION__.3492> "process_ok") + data=0x8157290) at dbus-connection.c:1515 + #0 0x00000033fee353e9 in raise () from /lib64/libc.so.6 + #1 0x00000033fee38508 in abort () from /lib64/libc.so.6 + #2 0x000000000047d585 in _dbus_abort () at dbus-sysdeps.c:94 + #3 0x0000000000466486 in _dbus_real_assert (condition=, + condition_text=condition_text@entry=0x4c2988 "_dbus_string_get_length (& DBUS_AUTH_CLIENT (auth)->guid_from_server) == 0", + file=file@entry=0x4c21a5 "dbus-auth.c", line=line@entry=1546, + func=func@entry=0x4c2fce <__FUNCTION__.3845> "process_ok") + at dbus-internals.c:931 + #4 0x000000000048d424 in process_ok (args_from_ok=0x7fffffffe480, + auth=0x6ff340) at dbus-auth.c:1546 + #5 handle_client_state_waiting_for_data (auth=0x6ff340, + command=, args=0x7fffffffe480) at dbus-auth.c:1996 + #6 0x000000000048e789 in process_command (auth=0x6ff340) at dbus-auth.c:2208 + #7 _dbus_auth_do_work (auth=0x6ff340) at dbus-auth.c:2458 + #8 0x000000000046091d in do_authentication ( + transport=transport@entry=0x6ffaa0, do_reading=do_reading@entry=1, + do_writing=do_writing@entry=0, + auth_completed=auth_completed@entry=0x7fffffffe55c) + at dbus-transport-socket.c:442 + #9 0x0000000000461d08 in socket_handle_watch (transport=0x6ffaa0, + watch=0x6f4190, flags=1) at dbus-transport-socket.c:921 + #10 0x000000000045fa3a in _dbus_transport_handle_watch (transport=0x6ffaa0, + +Once send_negotiate_unix_fd failed, this failure will happen, since +auth->guid_from_server has been set to some value before +send_negotiate_unix_fd. send_negotiate_unix_fd failure will lead to +this auth be handled by process_ok again, but this auth->guid_from_server +is not zero. + +So we should clear auth->guid_from_server if send_negotiate_unix_fd failed + +Signed-off-by: Roy Li +--- + dbus/dbus-auth.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/dbus/dbus-auth.c b/dbus/dbus-auth.c +index d2c37a7..37b45c6 100644 +--- a/dbus/dbus-auth.c ++++ b/dbus/dbus-auth.c +@@ -1571,8 +1571,13 @@ process_ok(DBusAuth *auth, + _dbus_verbose ("Got GUID '%s' from the server\n", + _dbus_string_get_const_data (& DBUS_AUTH_CLIENT (auth)->guid_from_server)); + +- if (auth->unix_fd_possible) +- return send_negotiate_unix_fd(auth); ++ if (auth->unix_fd_possible) { ++ if (!send_negotiate_unix_fd(auth)) { ++ _dbus_string_set_length (& DBUS_AUTH_CLIENT (auth)->guid_from_server, 0); ++ return FALSE; ++ } ++ return TRUE; ++ } + + _dbus_verbose("Not negotiating unix fd passing, since not possible\n"); + return send_begin (auth); +-- +1.7.10.4 + diff --git a/recipes-webpa/dbus/dbus/0003-dbus_rdk_system_configuration.patch b/recipes-webpa/dbus/dbus/0003-dbus_rdk_system_configuration.patch new file mode 100644 index 00000000..c860a737 --- /dev/null +++ b/recipes-webpa/dbus/dbus/0003-dbus_rdk_system_configuration.patch @@ -0,0 +1,34 @@ +Date: Jun 23 18:59:49 2014 + +From: 5fee2e840b33c83e5b72ebfc59438fede4900fd2 Jun 29 19:48:28 2014 + +Subject: [PATCH] RDKSYSINTSW-948: Moved iamrbus implementation from fusiondale to dbus + + Added rdk dbus configuration so wrote a bbappend to apply this + as a patch to system.conf. + + Modified iarmbus, iarmmgrs recipe to include dbus as a dependency. + + Modified rdkbrowser recipe to link libdbus-1.so through a patch. + +Source: COMCAST + +Upstream-Status: Pending + +Signed-off-by: rra +--- + +diff -urN dbus-1.6.18.orig/bus/system.conf.in dbus-1.6.18/bus/system.conf.in +--- dbus-1.6.18.orig/bus/system.conf.in 2014-06-23 17:19:37.479688002 +0000 ++++ dbus-1.6.18/bus/system.conf.in 2014-06-23 17:20:02.159688723 +0000 +@@ -47,8 +47,8 @@ + + +- +- ++ ++ + + diff --git a/recipes-webpa/dbus/dbus_%.bbappend b/recipes-webpa/dbus/dbus_%.bbappend new file mode 100644 index 00000000..89518932 --- /dev/null +++ b/recipes-webpa/dbus/dbus_%.bbappend @@ -0,0 +1,4 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:" + +SRC_URI_append = " file://0001-dbus-include-ccsp-support.patch" + diff --git a/recipes-webpa/libtinyxml/libtinyxml/tinyxml.pc b/recipes-webpa/libtinyxml/libtinyxml/tinyxml.pc new file mode 100644 index 00000000..684b090c --- /dev/null +++ b/recipes-webpa/libtinyxml/libtinyxml/tinyxml.pc @@ -0,0 +1,10 @@ +prefix=/usr +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + +Name: TinyXml +Description: simple, small, C++ XML parser +Version: 2.6.2 +Libs: -L${libdir} -ltinyxml +Cflags: -I${includedir} diff --git a/recipes-webpa/libtinyxml/libtinyxml_2.6.2.bbappend b/recipes-webpa/libtinyxml/libtinyxml_2.6.2.bbappend new file mode 100644 index 00000000..704b2e3c --- /dev/null +++ b/recipes-webpa/libtinyxml/libtinyxml_2.6.2.bbappend @@ -0,0 +1,15 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:" + +SRC_URI_remove = "file://enforce-use-stl.patch" +SRC_URI_append = " file://tinyxml.pc " + +LDFLAGS_append = " tinystr.o" + +do_compile_prepend() { + ${CXX} ${CXXFLAGS} ${EXTRA_CXXFLAGS} -c -o tinystr.o tinystr.cpp +} + +do_install_append() { + install -m 0644 ${S}/tinystr.h ${D}${includedir} + install -Dm 644 ${B}/../tinyxml.pc ${D}${libdir}/pkgconfig/tinyxml.pc +} diff --git a/recipes-webpa/libunpriv/libunpriv.bb b/recipes-webpa/libunpriv/libunpriv.bb new file mode 100644 index 00000000..818c6c38 --- /dev/null +++ b/recipes-webpa/libunpriv/libunpriv.bb @@ -0,0 +1,17 @@ +SUMMARY = "libcap wrapper " +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=175792518e4ac015ab6696d16c4f607e" + +DEPENDS_append = " libcap jsoncpp" +S = "${WORKDIR}/git" +RECIPE_BRANCH ?= "rdk-next" +SRC_URI = "git://code.rdkcentral.com/r/rdk/components/generic/libunpriv.git;protocol=https;branch=${RECIPE_BRANCH}" +SRCREV = "10cb90eaa07788081d9bf629573a093cd106dc70" + +CXXFLAGS_append = "\ + -I${STAGING_INCDIR} \ + -I${STAGING_INCDIR}/jsoncpp \ +" + +inherit autotools pkgconfig + diff --git a/recipes-webpa/linenoise/files/001-linenoise-history.patch b/recipes-webpa/linenoise/files/001-linenoise-history.patch new file mode 100644 index 00000000..56d16d17 --- /dev/null +++ b/recipes-webpa/linenoise/files/001-linenoise-history.patch @@ -0,0 +1,42 @@ +From 97d2850af13c339369093b78abe5265845d78220 Thu Mar 12 15:51:45 2020 +0100 +From: Thomas Lea +Date: Mon, 21 Sep 2020 08:56:02 -0500 +Subject: [PATCH] Added history print +Source: COMCAST +License: BSD-2-Clause +Upstream-Status: Pending +Signed-off-by: Thomas Lea +--- +Index: git/linenoise.c +=================================================================== +--- git.orig/linenoise.c ++++ git/linenoise.c +@@ -1152,6 +1152,16 @@ int linenoiseHistoryAdd(const char *line + return 1; + } + ++int linenoiseHistoryPrint(void) ++{ ++ int i = 0; ++ for (i = 0; i < history_len; i++) ++ { ++ printf("%s\n", history[i]); ++ } ++ return 0; ++} ++ + /* Set the maximum length for the history. This function can be called even + * if there is already some history, the function will make sure to retain + * just the latest 'len' elements if the new history length value is smaller +Index: git/linenoise.h +=================================================================== +--- git.orig/linenoise.h ++++ git/linenoise.h +@@ -62,6 +62,7 @@ int linenoiseHistoryAdd(const char *line + int linenoiseHistorySetMaxLen(int len); + int linenoiseHistorySave(const char *filename); + int linenoiseHistoryLoad(const char *filename); ++int linenoiseHistoryPrint(void); + void linenoiseClearScreen(void); + void linenoiseSetMultiLine(int ml); + void linenoisePrintKeyCodes(void); diff --git a/recipes-webpa/linenoise/files/002-linenoise-cmakelists.patch b/recipes-webpa/linenoise/files/002-linenoise-cmakelists.patch new file mode 100644 index 00000000..5d81cba3 --- /dev/null +++ b/recipes-webpa/linenoise/files/002-linenoise-cmakelists.patch @@ -0,0 +1,35 @@ +From 97d2850af13c339369093b78abe5265845d78220 Thu Mar 12 15:51:45 2020 +0100 +From: Thomas Lea +Date: Mon, 21 Sep 2020 08:56:02 -0500 +Subject: [PATCH] Added CMakeLists.txt +Source: COMCAST +License: BSD-2-Clause +Upstream-Status: Pending +Signed-off-by: Thomas Lea +--- +Index: git/CMakeLists.txt +=================================================================== +--- /dev/null ++++ git/CMakeLists.txt +@@ -0,0 +1,21 @@ ++cmake_minimum_required(VERSION 2.8.12) ++project(linenoise) ++ ++set(CMAKE_DEBUG_POSTFIX d) ++add_library(linenoise SHARED linenoise.c) ++ ++target_include_directories(linenoise PUBLIC ++ $ ++ $ ++) ++ ++set_property(TARGET linenoise PROPERTY VERSION "1.0") ++ ++install(TARGETS linenoise ++ ARCHIVE DESTINATION lib ++ LIBRARY DESTINATION lib ++ RUNTIME DESTINATION bin ++) ++ ++install(FILES linenoise.h DESTINATION include) ++ diff --git a/recipes-webpa/linenoise/linenoise.bb b/recipes-webpa/linenoise/linenoise.bb new file mode 100644 index 00000000..073786ab --- /dev/null +++ b/recipes-webpa/linenoise/linenoise.bb @@ -0,0 +1,19 @@ +SUMMARY = "linenoise library" +DESCRIPTION = "Recipe to build library for linenoise" +SECTION = "libs" +HOMEPAGE = "https://github.com/antirez/linenoise" + +LICENSE = "BSD-2-Clause" +LIC_FILES_CHKSUM = "file://LICENSE;md5=faa55ac8cbebebcb4a84fe1ea2879578" + +PR="r1" + +SRC_URI = "\ + git://github.com/antirez/linenoise.git;protocol=https \ + file://001-linenoise-history.patch \ + file://002-linenoise-cmakelists.patch \ +" +SRCREV = "97d2850af13c339369093b78abe5265845d78220" +S = "${WORKDIR}/git" + +inherit cmake pkgconfig diff --git a/recipes-webpa/msgpack/files/0001-Comment-intentional-fallthrough-in-case-statements.patch b/recipes-webpa/msgpack/files/0001-Comment-intentional-fallthrough-in-case-statements.patch new file mode 100644 index 00000000..a388297a --- /dev/null +++ b/recipes-webpa/msgpack/files/0001-Comment-intentional-fallthrough-in-case-statements.patch @@ -0,0 +1,39 @@ +From 15d8bb6792c9639d85a9ffe2ac81431f1b986c21 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Sat, 22 Apr 2017 08:53:50 -0700 +Subject: [PATCH] Comment intentional fallthrough in case statements + +Fixes build with gcc7 + +Signed-off-by: Khem Raj +--- + include/msgpack/v1/adaptor/detail/cpp03_define_array.hpp | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/include/msgpack/v1/adaptor/detail/cpp03_define_array.hpp b/include/msgpack/v1/adaptor/detail/cpp03_define_array.hpp +index b35c21a7..4c463a90 100644 +--- a/include/msgpack/v1/adaptor/detail/cpp03_define_array.hpp ++++ b/include/msgpack/v1/adaptor/detail/cpp03_define_array.hpp +@@ -105,6 +105,7 @@ struct define_array { + switch(size) { + default: + case 2: ptr[1].convert(a1); ++ //fallthrough + case 1: ptr[0].convert(a0); + } + } +@@ -193,8 +194,11 @@ struct define_array { + switch(size) { + default: + case 4: ptr[3].convert(a3); ++ //fallthrough + case 3: ptr[2].convert(a2); ++ //fallthrough + case 2: ptr[1].convert(a1); ++ //fallthrough + case 1: ptr[0].convert(a0); + } + } +-- +2.12.2 + diff --git a/recipes-webpa/msgpack/files/0002-Fix-Werror-class-memaccess.patch b/recipes-webpa/msgpack/files/0002-Fix-Werror-class-memaccess.patch new file mode 100644 index 00000000..6fe01674 --- /dev/null +++ b/recipes-webpa/msgpack/files/0002-Fix-Werror-class-memaccess.patch @@ -0,0 +1,33 @@ +From a05d92ae85024d0648f69f95307a1d3e8e51109c Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Sun, 1 Apr 2018 19:55:38 -0700 +Subject: [PATCH] Fix -Werror=class-memaccess + +Casting to void* make gcc happy since its upset about +object types and rightly so + +Fixes + +'void* memcpy(void*, const void*, size_t)' copying an object of non-trivial type 'struct msgpack::v2::object' from an array of 'const msgpack_object' {aka 'const struct msgpack_object'} [-Werror=class-memaccess] + +Signed-off-by: Khem Raj +--- + include/msgpack/v1/object.hpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/include/msgpack/v1/object.hpp b/include/msgpack/v1/object.hpp +index 64da8c53..9721f705 100644 +--- a/include/msgpack/v1/object.hpp ++++ b/include/msgpack/v1/object.hpp +@@ -661,7 +661,7 @@ inline object::object(const msgpack_object& o) + inline void operator<< (msgpack::object& o, const msgpack_object& v) + { + // FIXME beter way? +- std::memcpy(&o, &v, sizeof(v)); ++ std::memcpy(static_cast(&o), &v, sizeof(v)); + } + + inline object::operator msgpack_object() const +-- +2.17.1 + diff --git a/recipes-webpa/msgpack/msgpack-c_2.1.1.bb b/recipes-webpa/msgpack/msgpack-c_2.1.1.bb new file mode 100644 index 00000000..a8f6d4b2 --- /dev/null +++ b/recipes-webpa/msgpack/msgpack-c_2.1.1.bb @@ -0,0 +1,25 @@ +SUMMARY = "MessagePack implementation for C and C++" +DESCRIPTION = "MessagePack is an efficient binary serialization format. It's like JSON. but fast and small" +HOMEPAGE = "http://msgpack.org/index.html" +LICENSE = "BSL-1.0" +LIC_FILES_CHKSUM = " \ + file://NOTICE;md5=7a858c074723608e08614061dc044352 \ + file://COPYING;md5=0639c4209b6f2abf1437c813b208f2d3 \ + file://LICENSE_1_0.txt;md5=e4224ccaecb14d942c71d31bef20d78c \ +" + +PV .= "+git${SRCPV}" + +SRCREV = "20ef1f925b007f170ab1c257e4aa61fdd0927773" + +SRC_URI = "\ + git://github.com/msgpack/msgpack-c \ + file://0001-Comment-intentional-fallthrough-in-case-statements.patch \ + file://0002-Fix-Werror-class-memaccess.patch \ +" + +inherit cmake pkgconfig + +EXTRA_OECMAKE_append = " -DMSGPACK_BUILD_TESTS=OFF " +S = "${WORKDIR}/git" + diff --git a/recipes-webpa/nanomsg/files/nanomsg-size.patch b/recipes-webpa/nanomsg/files/nanomsg-size.patch new file mode 100644 index 00000000..e11906e6 --- /dev/null +++ b/recipes-webpa/nanomsg/files/nanomsg-size.patch @@ -0,0 +1,337 @@ +"nanomsg" is a trademark of Martin Sustrik + +Date: Apr 07 16:11:19 2017 + +From: 288253c94d1c6d63d14db90cb362d23db3710720 Apr 11 01:51:30 2017 + +Subject: [PATCH] WEBPA-1980 : Nanomsg size reduction to bring parodus to Cisco + + Created new nanomsg patch to reduce libnanomsg.so size and to fit parodus on cisco image. + +Source: COMCAST + +Upstream-Status: Pending + +Signed-off-by: Sadhyama Vengilat + +--- + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 308268f5..4b5b1086 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -95,14 +95,15 @@ else () + endif() + + # User-defined options. ++# Commenting out few code to reduce libnanomsg size for yocto environment. + + option (NN_STATIC_LIB "Build static library instead of shared library." OFF) + option (NN_ENABLE_DOC "Enable building documentation." ON) + option (NN_ENABLE_COVERAGE "Enable coverage reporting." OFF) + option (NN_ENABLE_GETADDRINFO_A "Enable/disable use of getaddrinfo_a in place of getaddrinfo." ON) +-option (NN_TESTS "Build and run nanomsg tests" ON) +-option (NN_TOOLS "Build nanomsg tools" ON) +-option (NN_ENABLE_NANOCAT "Enable building nanocat utility." ${NN_TOOLS}) ++option (NN_TESTS "Build and run nanomsg tests" OFF) ++option (NN_TOOLS "Build nanomsg tools" OFF) ++#option (NN_ENABLE_NANOCAT "Enable building nanocat utility." ${NN_TOOLS}) + set (NN_MAX_SOCKETS 512 CACHE STRING "max number of nanomsg sockets that can be created") + + # Platform checks. +@@ -471,16 +472,16 @@ endif () + install (TARGETS LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install (TARGETS ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install (FILES src/nn.h DESTINATION include/nanomsg) +-install (FILES src/inproc.h DESTINATION include/nanomsg) +-install (FILES src/ipc.h DESTINATION include/nanomsg) ++#install (FILES src/inproc.h DESTINATION include/nanomsg) ++#install (FILES src/ipc.h DESTINATION include/nanomsg) + install (FILES src/tcp.h DESTINATION include/nanomsg) +-install (FILES src/ws.h DESTINATION include/nanomsg) +-install (FILES src/pair.h DESTINATION include/nanomsg) +-install (FILES src/pubsub.h DESTINATION include/nanomsg) ++#install (FILES src/ws.h DESTINATION include/nanomsg) ++#install (FILES src/pair.h DESTINATION include/nanomsg) ++#install (FILES src/pubsub.h DESTINATION include/nanomsg) + install (FILES src/reqrep.h DESTINATION include/nanomsg) + install (FILES src/pipeline.h DESTINATION include/nanomsg) +-install (FILES src/survey.h DESTINATION include/nanomsg) +-install (FILES src/bus.h DESTINATION include/nanomsg) ++#install (FILES src/survey.h DESTINATION include/nanomsg) ++#install (FILES src/bus.h DESTINATION include/nanomsg) + + if (NN_ENABLE_NANOCAT) + install (TARGETS nanocat RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 96b1b6be..887542e8 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -23,18 +23,20 @@ + # IN THE SOFTWARE. + # + ++# /* Commenting out few code to reduce libnanomsg size for yocto environment. */ ++ + set (NN_SOURCES + nn.h +- inproc.h +- ipc.h ++# inproc.h ++# ipc.h + tcp.h +- ws.h +- pair.h +- pubsub.h ++# ws.h ++# pair.h ++# pubsub.h + reqrep.h + pipeline.h +- survey.h +- bus.h ++# survey.h ++# bus.h + + core/ep.h + core/ep.c +@@ -127,9 +129,9 @@ set (NN_SOURCES + protocols/utils/priolist.h + protocols/utils/priolist.c + +- protocols/bus/bus.c +- protocols/bus/xbus.h +- protocols/bus/xbus.c ++# protocols/bus/bus.c ++# protocols/bus/xbus.h ++# protocols/bus/xbus.c + + protocols/pipeline/push.c + protocols/pipeline/pull.c +@@ -138,18 +140,18 @@ set (NN_SOURCES + protocols/pipeline/xpush.h + protocols/pipeline/xpush.c + +- protocols/pair/pair.c +- protocols/pair/xpair.h +- protocols/pair/xpair.c ++# protocols/pair/pair.c ++# protocols/pair/xpair.h ++# protocols/pair/xpair.c + +- protocols/pubsub/pub.c +- protocols/pubsub/sub.c +- protocols/pubsub/trie.h +- protocols/pubsub/trie.c +- protocols/pubsub/xpub.h +- protocols/pubsub/xpub.c +- protocols/pubsub/xsub.h +- protocols/pubsub/xsub.c ++# protocols/pubsub/pub.c ++# protocols/pubsub/sub.c ++# protocols/pubsub/trie.h ++# protocols/pubsub/trie.c ++# protocols/pubsub/xpub.h ++# protocols/pubsub/xpub.c ++# protocols/pubsub/xsub.h ++# protocols/pubsub/xsub.c + + protocols/reqrep/req.h + protocols/reqrep/req.c +@@ -162,12 +164,12 @@ set (NN_SOURCES + protocols/reqrep/xreq.h + protocols/reqrep/xreq.c + +- protocols/survey/respondent.c +- protocols/survey/surveyor.c +- protocols/survey/xrespondent.h +- protocols/survey/xrespondent.c +- protocols/survey/xsurveyor.h +- protocols/survey/xsurveyor.c ++# protocols/survey/respondent.c ++# protocols/survey/surveyor.c ++# protocols/survey/xrespondent.h ++# protocols/survey/xrespondent.c ++# protocols/survey/xsurveyor.h ++# protocols/survey/xsurveyor.c + + transports/utils/backoff.h + transports/utils/backoff.c +@@ -188,27 +190,27 @@ set (NN_SOURCES + transports/utils/base64.h + transports/utils/base64.c + +- transports/inproc/binproc.h +- transports/inproc/binproc.c +- transports/inproc/cinproc.h +- transports/inproc/cinproc.c +- transports/inproc/inproc.c +- transports/inproc/ins.h +- transports/inproc/ins.c +- transports/inproc/msgqueue.h +- transports/inproc/msgqueue.c +- transports/inproc/sinproc.h +- transports/inproc/sinproc.c ++# transports/inproc/binproc.h ++# transports/inproc/binproc.c ++# transports/inproc/cinproc.h ++# transports/inproc/cinproc.c ++# transports/inproc/inproc.c ++# transports/inproc/ins.h ++# transports/inproc/ins.c ++# transports/inproc/msgqueue.h ++# transports/inproc/msgqueue.c ++# transports/inproc/sinproc.h ++# transports/inproc/sinproc.c + +- transports/ipc/aipc.h +- transports/ipc/aipc.c +- transports/ipc/bipc.h +- transports/ipc/bipc.c +- transports/ipc/cipc.h +- transports/ipc/cipc.c +- transports/ipc/ipc.c +- transports/ipc/sipc.h +- transports/ipc/sipc.c ++# transports/ipc/aipc.h ++# transports/ipc/aipc.c ++# transports/ipc/bipc.h ++# transports/ipc/bipc.c ++# transports/ipc/cipc.h ++# transports/ipc/cipc.c ++# transports/ipc/ipc.c ++# transports/ipc/sipc.h ++# transports/ipc/sipc.c + + transports/tcp/atcp.h + transports/tcp/atcp.c +@@ -220,19 +222,19 @@ set (NN_SOURCES + transports/tcp/stcp.c + transports/tcp/tcp.c + +- transports/ws/aws.h +- transports/ws/aws.c +- transports/ws/bws.h +- transports/ws/bws.c +- transports/ws/cws.h +- transports/ws/cws.c +- transports/ws/sws.h +- transports/ws/sws.c +- transports/ws/ws.c +- transports/ws/ws_handshake.h +- transports/ws/ws_handshake.c +- transports/ws/sha1.h +- transports/ws/sha1.c ++# transports/ws/aws.h ++# transports/ws/aws.c ++# transports/ws/bws.h ++# transports/ws/bws.c ++# transports/ws/cws.h ++# transports/ws/cws.c ++# transports/ws/sws.h ++# transports/ws/sws.c ++# transports/ws/ws.c ++# transports/ws/ws_handshake.h ++# transports/ws/ws_handshake.c ++# transports/ws/sha1.h ++# transports/ws/sha1.c + ) + + if (WIN32) +diff --git a/src/core/global.c b/src/core/global.c +index 6fbf0032..5d683811 100644 +--- a/src/core/global.c ++++ b/src/core/global.c +@@ -45,7 +45,9 @@ + #include "../utils/msg.h" + #include "../utils/attr.h" + +-#include "../pubsub.h" ++/* Commenting out few code to reduce libnanomsg size for yocto environment. */ ++ ++//#include "../pubsub.h" + #include "../pipeline.h" + + #include +@@ -81,12 +83,13 @@ CT_ASSERT (NN_MAX_SOCKETS <= 0x10000); + + /* We could put these in an external header file, but there really is + need to. We are the only thing that needs them. */ +-extern struct nn_socktype nn_pair_socktype; ++ ++/*extern struct nn_socktype nn_pair_socktype; + extern struct nn_socktype nn_xpair_socktype; + extern struct nn_socktype nn_pub_socktype; + extern struct nn_socktype nn_sub_socktype; + extern struct nn_socktype nn_xpub_socktype; +-extern struct nn_socktype nn_xsub_socktype; ++extern struct nn_socktype nn_xsub_socktype;*/ + extern struct nn_socktype nn_rep_socktype; + extern struct nn_socktype nn_req_socktype; + extern struct nn_socktype nn_xrep_socktype; +@@ -95,21 +98,24 @@ extern struct nn_socktype nn_push_socktype; + extern struct nn_socktype nn_xpush_socktype; + extern struct nn_socktype nn_pull_socktype; + extern struct nn_socktype nn_xpull_socktype; +-extern struct nn_socktype nn_respondent_socktype; ++ ++/*extern struct nn_socktype nn_respondent_socktype; + extern struct nn_socktype nn_surveyor_socktype; + extern struct nn_socktype nn_xrespondent_socktype; + extern struct nn_socktype nn_xsurveyor_socktype; + extern struct nn_socktype nn_bus_socktype; +-extern struct nn_socktype nn_xbus_socktype; ++extern struct nn_socktype nn_xbus_socktype;*/ + + /* Array of known socket types. */ + const struct nn_socktype *nn_socktypes[] = { ++/* + &nn_pair_socktype, + &nn_xpair_socktype, + &nn_pub_socktype, + &nn_sub_socktype, + &nn_xpub_socktype, + &nn_xsub_socktype, ++*/ + &nn_rep_socktype, + &nn_req_socktype, + &nn_xrep_socktype, +@@ -118,28 +124,38 @@ const struct nn_socktype *nn_socktypes[] = { + &nn_xpush_socktype, + &nn_pull_socktype, + &nn_xpull_socktype, ++/* + &nn_respondent_socktype, + &nn_surveyor_socktype, + &nn_xrespondent_socktype, + &nn_xsurveyor_socktype, + &nn_bus_socktype, + &nn_xbus_socktype, ++*/ + NULL, + }; + + /* As with protocols, we could have these in a header file, but we are the + only consumer, so just declare them inline. */ + ++/* + extern struct nn_transport nn_inproc; + extern struct nn_transport nn_ipc; ++*/ + extern struct nn_transport nn_tcp; ++/* + extern struct nn_transport nn_ws; ++*/ + + const struct nn_transport *nn_transports[] = { ++/* + &nn_inproc, + &nn_ipc, ++*/ + &nn_tcp, ++/* + &nn_ws, ++*/ + NULL, + }; + diff --git a/recipes-webpa/nanomsg/nanomsg_1.0.bb b/recipes-webpa/nanomsg/nanomsg_1.0.bb new file mode 100644 index 00000000..54763cc6 --- /dev/null +++ b/recipes-webpa/nanomsg/nanomsg_1.0.bb @@ -0,0 +1,16 @@ +SUMMARY = "Socket library that provides several common communication patterns" +HOMEPAGE = "http://nanomsg.org/" +SECTION = "libs" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://COPYING;md5=587b3fd7fd291e418ff4d2b8f3904755" + +SRCREV = "1.1.4" +SRC_URI = "\ + git://github.com/nanomsg/nanomsg.git \ + file://nanomsg-size.patch \ +" + +PV = "git+${SRCPV}" +S = "${WORKDIR}/git" + +inherit pkgconfig cmake diff --git a/recipes-webpa/nopoll/files/libnopoll.pc b/recipes-webpa/nopoll/files/libnopoll.pc new file mode 100644 index 00000000..e82fc8e4 --- /dev/null +++ b/recipes-webpa/nopoll/files/libnopoll.pc @@ -0,0 +1,11 @@ +prefix=/usr +exec_prefix=/usr +libdir=/lib +includedir=/usr/include + +Name: nopoll +Description: nopoll package config +Version: 0.2.7 +Requires: +Libs: -L${libdir} -lnopoll +Cflags: -I${includedir} diff --git a/recipes-webpa/nopoll/files/nopoll-0.3.2.b232.patch b/recipes-webpa/nopoll/files/nopoll-0.3.2.b232.patch new file mode 100644 index 00000000..895b4afe --- /dev/null +++ b/recipes-webpa/nopoll/files/nopoll-0.3.2.b232.patch @@ -0,0 +1,2666 @@ +Date: Mon, 21 Mar 2016 16:59:46 + +From: c3db2d05b19323c98ccc546aadb5886f2177f245 Mon Sep 17 00:00:00 2001 + +Subject: [PATCH] RDK-13925: Integrate WebPA with yocto framework + + Patch for nopoll including changes for ipMgr + updated to latest nopoll 0.3.2.b232 + +Source: COMCAST + +License: LGPL-2.1-or-later + +Upstream-Status: Pending + +Signed-off-by: tsilveria +Signed-off-by: chter + +--- + src/Makefile.am | 12 +- + src/nopoll.h | 1 + + src/nopoll_conn.c | 483 ++++++++++++++++++++++++++++++++------- + src/nopoll_conn.h | 26 ++- + src/nopoll_conn_opts.c | 20 ++ + src/nopoll_conn_opts.h | 2 + + src/nopoll_ctx.c | 17 +- + src/nopoll_ctx.h | 4 + + src/nopoll_decl.h | 15 +- + src/nopoll_hostcheck.c | 124 ++++++++++ + src/nopoll_hostcheck.h | 27 +++ + src/nopoll_hostname_validation.c | 151 ++++++++++++ + src/nopoll_hostname_validation.h | 57 +++++ + src/nopoll_inet_pton.c | 207 +++++++++++++++++ + src/nopoll_inet_pton.h | 29 +++ + src/nopoll_log.c | 6 + + src/nopoll_loop.c | 93 +++++++- + src/nopoll_loop.h | 2 + + src/nopoll_private.h | 12 +- + src/nopoll_strcase.c | 61 +++++ + src/nopoll_strcase.h | 33 +++ + test/nopoll-regression-client.c | 278 ++++++++++++++++++---- + 22 files changed, 1507 insertions(+), 153 deletions(-) + +diff --git a/src/Makefile.am b/src/Makefile.am +index 601744f..32d043e 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -23,7 +23,11 @@ libnopoll_la_SOURCES = \ + nopoll_io.c \ + nopoll_msg.c \ + nopoll_win32.c \ +- nopoll_conn_opts.c ++ nopoll_conn_opts.c \ ++ nopoll_hostname_validation.c \ ++ nopoll_inet_pton.c \ ++ nopoll_strcase.c \ ++ nopoll_hostcheck.c + + libnopollinclude_HEADERS = \ + nopoll.h \ +@@ -39,7 +43,11 @@ libnopollinclude_HEADERS = \ + nopoll_io.h \ + nopoll_msg.h \ + nopoll_win32.h \ +- nopoll_conn_opts.h ++ nopoll_conn_opts.h \ ++ nopoll_hostname_validation.h \ ++ nopoll_inet_pton.h \ ++ nopoll_strcase.h \ ++ nopoll_hostcheck.h + + libnopoll_la_LDFLAGS = -no-undefined -export-symbols-regex '^(nopoll|__nopoll|_nopoll).*' + +diff --git a/src/nopoll.h b/src/nopoll.h +index c483e4b..3ef08da 100644 +--- a/src/nopoll.h ++++ b/src/nopoll.h +@@ -57,6 +57,7 @@ BEGIN_C_DECLS + #include + #include + #include ++#include + + /** + * \addtogroup nopoll_module +diff --git a/src/nopoll_conn.c b/src/nopoll_conn.c +index 8612bfd..b4c4ba0 100644 +--- a/src/nopoll_conn.c ++++ b/src/nopoll_conn.c +@@ -48,7 +48,8 @@ + + #include + #include +- ++#include ++#include + #if defined(NOPOLL_OS_UNIX) + # include + #endif +@@ -193,6 +194,37 @@ nopoll_bool nopoll_conn_set_sock_tcp_nodelay (NOPOLL_SOCKET so + return nopoll_true; + } /* end */ + ++/** ++ * @brief Allows to bind device ++ * ++ * @param socket The socket to be configured. ++ * ++ * @param outbound_interface The bind device name value to be configured ++ * ++ * @return nopoll_true if the operation is completed. ++ */ ++nopoll_bool nopoll_conn_set_outbound_interface (noPollCtx * ctx, NOPOLL_SOCKET socket, ++ const char * outbound_interface) ++{ ++ if(outbound_interface != NULL) { ++ /* local variables */ ++ int result = nopoll_false; ++ nopoll_log (ctx, NOPOLL_LEVEL_INFO, "Nopoll, Outbound Interface %s",outbound_interface); ++ ++ result = setsockopt(socket, SOL_SOCKET, SO_BINDTODEVICE, ++ outbound_interface, strlen(outbound_interface)+1); ++ ++ nopoll_log (ctx, NOPOLL_LEVEL_INFO, " setsockopt result: %d",result); ++ if (result < 0) { ++ nopoll_log (ctx, NOPOLL_LEVEL_CRITICAL, "Error inside nopoll set socket opt"); ++ return nopoll_false; ++ } ++ } ++ ++ /* properly configured */ ++ return nopoll_true; ++} /* end */ ++ + /** + * @internal Allows to create a plain socket connection against the + * host and port provided. +@@ -207,69 +239,144 @@ nopoll_bool nopoll_conn_set_sock_tcp_nodelay (NOPOLL_SOCKET so + */ + NOPOLL_SOCKET nopoll_conn_sock_connect (noPollCtx * ctx, + const char * host, +- const char * port) ++ const char * port, ++ const char * outbound_interface) + { +- struct hostent * hostent; +- struct sockaddr_in saddr; + NOPOLL_SOCKET session; +- +- /* resolve hosting name */ +- hostent = gethostbyname (host); +- if (hostent == NULL) { +- nopoll_log (ctx, NOPOLL_LEVEL_DEBUG, "unable to resolve host name %s", host); +- return -1; +- } /* end if */ +- +- /* create the socket and check if it */ +- session = socket (AF_INET, SOCK_STREAM, 0); +- if (session == NOPOLL_INVALID_SOCKET) { +- nopoll_log (ctx, NOPOLL_LEVEL_CRITICAL, "unable to create socket"); ++ int retVal; ++ char addrstr[100]; ++ void *ptr = NULL; ++ char *localIp = "10.0.0.1"; ++ struct addrinfo *result, *rp; ++ struct addrinfo hints = {}; ++ ++ memset(&hints,0,sizeof(hints)); ++ hints.ai_family = AF_UNSPEC; ++ hints.ai_socktype = SOCK_STREAM; ++ hints.ai_protocol = 0; ++ hints.ai_flags = AI_ADDRCONFIG; ++ /* resolving host name */ ++ retVal = getaddrinfo(host, port, &hints, &result); ++ if (retVal != 0){ ++ nopoll_log (ctx, NOPOLL_LEVEL_CRITICAL, "unable to resolve host name %s, error: %s", host, gai_strerror(retVal)); + return -1; +- } /* end if */ +- +- /* disable nagle */ +- nopoll_conn_set_sock_tcp_nodelay (session, nopoll_true); +- +- /* prepare socket configuration to operate using TCP/IP +- * socket */ +- memset(&saddr, 0, sizeof(saddr)); +- saddr.sin_addr.s_addr = ((struct in_addr *)(hostent->h_addr))->s_addr; +- saddr.sin_family = AF_INET; +- saddr.sin_port = htons((uint16_t) strtod (port, NULL)); +- +- /* set non blocking status */ +- nopoll_conn_set_sock_block (session, nopoll_false); +- +- /* do a tcp connect */ +- if (connect (session, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) { +- if(errno != NOPOLL_EINPROGRESS && errno != NOPOLL_EWOULDBLOCK && errno != NOPOLL_ENOTCONN) { +- shutdown (session, SHUT_RDWR); +- nopoll_close_socket (session); +- +- nopoll_log (ctx, NOPOLL_LEVEL_WARNING, "unable to connect to remote host %s:%s errno=%d", +- host, port, errno); +- return -1; +- } /* end if */ +- } /* end if */ +- +- /* return socket created */ +- return session; ++ } ++ else ++ { ++ for (rp = result; rp != NULL; rp = rp->ai_next) ++ { ++ nopoll_log (ctx, NOPOLL_LEVEL_DEBUG, "rp->ai_family %d ", rp->ai_family); ++ nopoll_log (ctx, NOPOLL_LEVEL_DEBUG, "rp->ai_socktype %d", rp->ai_socktype); ++ nopoll_log (ctx, NOPOLL_LEVEL_DEBUG, "rp->ai_protocol %d", rp->ai_protocol); ++ ++ if(rp->ai_family == AF_INET) ++ { ++ ptr = &((struct sockaddr_in *) rp->ai_addr)->sin_addr; ++ inet_ntop (rp->ai_family, ptr, addrstr, 100); ++ nopoll_log (ctx, NOPOLL_LEVEL_INFO, "IPv4 address of %s is %s \n", host, addrstr); ++ ++ if (strcmp(localIp,addrstr) == 0) ++ { ++ /* If Host DNS is resolved to 10.0.0.1 which means there is problem and client should not connect to this address */ ++ nopoll_log (ctx, NOPOLL_LEVEL_DEBUG, "Host Ip resolved to 10.0.0.1"); ++ nopoll_log (ctx, NOPOLL_LEVEL_CRITICAL, "unable to connect to remote host %s:%s as IP resolved to 10.0.0.1", host, port); ++ freeaddrinfo(result); ++ return -1; ++ ++ } ++ } ++ else if(rp->ai_family == AF_INET6) ++ { ++ ptr = &((struct sockaddr_in6 *) rp->ai_addr)->sin6_addr; ++ inet_ntop (rp->ai_family, ptr, addrstr, 100); ++ nopoll_log (ctx, NOPOLL_LEVEL_INFO, "IPv6 address of %s is %s \n", host, addrstr); ++ } ++ ++ session = socket(rp->ai_family, rp->ai_socktype, 0); ++ if (session == NOPOLL_INVALID_SOCKET) ++ { ++ nopoll_log (ctx, NOPOLL_LEVEL_CRITICAL, "unable to create socket"); ++ continue; ++ } ++ else ++ { ++ nopoll_log (ctx, NOPOLL_LEVEL_DEBUG, "Socket Creation Successful"); ++ } ++ ++ nopoll_conn_set_sock_tcp_nodelay (session, nopoll_true); ++ ++ nopoll_conn_set_outbound_interface(ctx,session, outbound_interface); ++ ++ if (connect(session, rp->ai_addr, rp->ai_addrlen) < 0) ++ { ++ /*Remove if condition check, as we are trying to connect in blocking mode, we should proceed to connection only when connect returns 0 which is success, or else continue with other address returned from getaddrinfo list */ ++ nopoll_log (ctx, NOPOLL_LEVEL_WARNING, "unable to connect to remote host %s:%s errno=%d", ++ host, port, errno); ++ } ++ else ++ { ++ nopoll_log (ctx, NOPOLL_LEVEL_DEBUG, "Socket Connect successful"); ++ break; ++ } ++ close(session); ++ } ++ ++ if (rp == NULL) { /* No address succeeded */ ++ nopoll_log (ctx, NOPOLL_LEVEL_CRITICAL, "Could not connect. No valid IP resolved, Returning -1"); ++ freeaddrinfo(result); ++ return -1; ++ } ++ freeaddrinfo(result); ++ return session; ++ } + } + + ++/** ++ * @internal Function that builds the header string with multiple header ++ * header names and values passed as input. ++ */ ++char * getHeaderString(const char *headerNames[], const char *headerValues[], const int headerCount) ++{ ++ int index=0; ++ char *tempString = NULL; ++ char *headerString = NULL; ++ int size = 0; ++ for(index=0; index < headerCount; index++) ++ { ++ size = 4 + strlen(headerNames[index]) + strlen(headerValues[index]) + 1; /* "\r\n: " + headername + headervalue + '\0' */ ++ tempString = (char *)malloc(sizeof(char) * size); ++ sprintf(tempString, "\r\n%s: %s", headerNames[index],headerValues[index]); ++ ++ if(headerString) ++ { ++ headerString = (char *) realloc(headerString, sizeof(char) * (strlen(headerString) + size)); ++ headerString = strcat(headerString,tempString); ++ } ++ else ++ { ++ headerString = (char *) malloc(sizeof(char) * size); ++ strcpy(headerString,tempString); ++ } ++ free(tempString); ++ } ++ return headerString; ++} + + + /** + * @internal Function that builds the client init greetings that will + * be send to the server according to registered implementation. + */ +-char * __nopoll_conn_get_client_init (noPollConn * conn, noPollConnOpts * opts) ++char * __nopoll_conn_get_client_init (noPollConn * conn,noPollConnOpts * opts, const char * headerNames[], const char * headerValues[], const int headerCount) + { + /* build sec-websocket-key */ + char key[50]; + int key_size = 50; + char nonce[17]; ++ char *request; + ++ char *headerString = NULL; + /* get the nonce */ + if (! nopoll_nonce (nonce, 16)) { + nopoll_log (conn->ctx, NOPOLL_LEVEL_CRITICAL, "Failed to get nonce, unable to produce Sec-WebSocket-Key."); +@@ -287,9 +394,15 @@ char * __nopoll_conn_get_client_init (noPollConn * conn, noPollConnOpts * opts) + /* create accept and store */ + conn->handshake = nopoll_new (noPollHandShake, 1); + conn->handshake->expected_accept = nopoll_strdup (key); +- +- /* send initial handshake |cookie |prot | */ +- return nopoll_strdup_printf ("GET %s HTTP/1.1\r\nHost: %s\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Key: %s\r\nOrigin: %s\r\n%s%s%s%s%s%s%s%sSec-WebSocket-Version: %d\r\n\r\n", ++ ++ if(headerNames != NULL && headerValues != NULL && headerCount > 0) ++ { ++ headerString = getHeaderString(headerNames, headerValues, headerCount); ++ } ++ ++ /* send initial handshake */ ++ ++ request = nopoll_strdup_printf ("GET %s HTTP/1.1\r\nHost: %s\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Key: %s\r\nOrigin: %s\r\n%s%s%s%s%s%s%s%sSec-WebSocket-Version: %d%s\r\n\r\n", + conn->get_url, conn->host_name, + /* sec-websocket-key */ + key, +@@ -305,7 +418,15 @@ char * __nopoll_conn_get_client_init (noPollConn * conn, noPollConnOpts * opts) + conn->protocols ? ": " : "", + conn->protocols ? conn->protocols : "", + conn->protocols ? "\r\n" : "", +- conn->ctx->protocol_version); ++ conn->ctx->protocol_version, (headerString != NULL) ? headerString : ""); ++ ++ if(headerString != NULL) ++ { ++ free(headerString); ++ headerString = NULL; ++ } ++ ++ return request; + } + + +@@ -438,10 +559,17 @@ int nopoll_conn_tls_send (noPollConn * conn, char * buffer, int buffer_size) + int res; + nopoll_bool needs_retry; + int tries = 0; +- ++ int ret = 0; ++ static pthread_mutex_t mut = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; ++ ++ ret = pthread_mutex_lock (&mut); ++ if(ret != 0) ++ { ++ nopoll_log (conn->ctx, NOPOLL_LEVEL_CRITICAL, "mutex failed to lock ( ret = %d) ( errno = %d)",ret, errno); ++ } + /* call to read content */ + while (tries < 50) { +- res = SSL_write (conn->ssl, buffer, buffer_size); ++ res = SSL_write (conn->ssl, buffer, buffer_size); + nopoll_log (conn->ctx, NOPOLL_LEVEL_DEBUG, "SSL: sent %d bytes (requested: %d)..", res, buffer_size); + + /* call to handle error */ +@@ -449,12 +577,17 @@ int nopoll_conn_tls_send (noPollConn * conn, char * buffer, int buffer_size) + /* nopoll_log (conn->ctx, NOPOLL_LEVEL_DEBUG, " SSL: after processing error, sent %d bytes (requested: %d)..", res, buffer_size); */ + + if (! needs_retry) +- break; ++ break; + + /* next operation */ + nopoll_sleep (tries * 10000); + tries++; + } ++ ret = pthread_mutex_unlock (&mut); ++ if(ret != 0) ++ { ++ nopoll_log (conn->ctx, NOPOLL_LEVEL_CRITICAL, "mutex failed to unlock ( ret = %d) ( errno = %d)",ret, errno); ++ } + return res; + } + +@@ -478,6 +611,9 @@ SSL_CTX * __nopoll_conn_get_ssl_context (noPollCtx * ctx, noPollConn * conn, noP + /* printf ("**** REPORTING TLSv1.1 ****\n"); */ + return SSL_CTX_new (is_client ? TLSv1_1_client_method () : TLSv1_1_server_method ()); + #endif ++ case NOPOLL_METHOD_TLSV1_2: ++ nopoll_log (conn->ctx, NOPOLL_LEVEL_DEBUG, "**** REPORTING TLSv1.2 ****\n"); ++ return SSL_CTX_new (is_client ? TLSv1_2_client_method () : TLSv1_2_server_method ()); + case NOPOLL_METHOD_SSLV3: + /* printf ("**** REPORTING SSLv3 ****\n"); */ + return SSL_CTX_new (is_client ? SSLv3_client_method () : SSLv3_server_method ()); +@@ -533,12 +669,14 @@ nopoll_bool __nopoll_conn_set_ssl_client_options (noPollCtx * ctx, noPollConn * + } /* end if */ + + } /* end if */ +- +- /* enable default verification paths */ +- if (SSL_CTX_set_default_verify_paths (conn->ssl_ctx) != 1) { +- nopoll_log (ctx, NOPOLL_LEVEL_CRITICAL, "Unable to configure default verification paths, SSL_CTX_set_default_verify_paths () failed"); +- return nopoll_false; +- } /* end if */ ++ else /* enable default verification paths only when load verify paths are not available */ ++ { ++ /* enable default verification paths */ ++ if (SSL_CTX_set_default_verify_paths (conn->ssl_ctx) != 1) { ++ nopoll_log (ctx, NOPOLL_LEVEL_CRITICAL, "Unable to configure default verification paths, SSL_CTX_set_default_verify_paths () failed"); ++ return nopoll_false; ++ } /* end if */ ++ } + + if (options && options->chain_certificate) { + nopoll_log (ctx, NOPOLL_LEVEL_DEBUG, "Setting chain certificate: %s", options->chain_certificate); +@@ -574,7 +712,7 @@ nopoll_bool __nopoll_conn_set_ssl_client_options (noPollCtx * ctx, noPollConn * + + /* if no option and it is not disabled */ + if (options == NULL || ! options->disable_ssl_verify) { +- nopoll_log (ctx, NOPOLL_LEVEL_DEBUG, "Enabling certificate peer verification"); ++ nopoll_log (ctx, NOPOLL_LEVEL_INFO, "Enabling certificate peer verification"); + /** really, really ugly hack to let + * __nopoll_conn_ssl_verify_callback to be able to get + * access to the context required to drop some logs */ +@@ -598,7 +736,11 @@ noPollConn * __nopoll_conn_new_common (noPollCtx * ctx, + const char * host_name, + const char * get_url, + const char * protocols, +- const char * origin) ++ const char * origin, ++ const char * outbound_interface, ++ const char * headerNames[], ++ const char * headerValues[], ++ const int headerCount) + { + noPollConn * conn; + NOPOLL_SOCKET session; +@@ -620,11 +762,12 @@ noPollConn * __nopoll_conn_new_common (noPollCtx * ctx, + host_port = "80"; + + /* create socket connection in a non block manner */ +- session = nopoll_conn_sock_connect (ctx, host_ip, host_port); ++ session = nopoll_conn_sock_connect (ctx, host_ip, host_port, outbound_interface); ++ + if (session == NOPOLL_INVALID_SOCKET) { + /* release connection options */ + __nopoll_conn_opts_release_if_needed (options); +- nopoll_log (ctx, NOPOLL_LEVEL_CRITICAL, "Failed to connect to remote host %s:%s", host_ip, host_port); ++ nopoll_log (ctx, NOPOLL_LEVEL_DEBUG, "Failed to connect to remote host %s:%s", host_ip, host_port); + return NULL; + } /* end if */ + +@@ -691,7 +834,7 @@ noPollConn * __nopoll_conn_new_common (noPollCtx * ctx, + + + /* get client init payload */ +- content = __nopoll_conn_get_client_init (conn, options); ++ content = __nopoll_conn_get_client_init (conn, options,headerNames, headerValues, headerCount); + + if (content == NULL) { + nopoll_log (ctx, NOPOLL_LEVEL_CRITICAL, "Failed to build client init message, unable to connect"); +@@ -807,6 +950,28 @@ noPollConn * __nopoll_conn_new_common (noPollCtx * ctx, + + return conn; + } ++ ++ /* Check for opts to verify hostname validation during conn handshake */ ++ if (options == NULL || options->host_verify) ++ { ++ HostnameValidationResult status = Error; ++ /* hostname should be validated without http/https, so pass conn->host_name */ ++ status = nopoll_validate_hostname(conn->host_name,server_cert); ++ if( status == MatchFound ) ++ { ++ nopoll_log (ctx, NOPOLL_LEVEL_INFO, "Hostname validation SUCCESS, done as part of client \n"); ++ } ++ else ++ { ++ nopoll_log (ctx, NOPOLL_LEVEL_CRITICAL,"Hostname validation FAILED with errno %d \n",status); ++ /* release connection options */ ++ nopoll_free (content); ++ nopoll_conn_shutdown (conn); ++ __nopoll_conn_opts_release_if_needed (options); ++ X509_free (server_cert); ++ return NULL; ++ } ++ } + X509_free (server_cert); + + /* call to check post ssl checks after SSL finalization */ +@@ -905,12 +1070,16 @@ noPollConn * nopoll_conn_new (noPollCtx * ctx, + const char * host_name, + const char * get_url, + const char * protocols, +- const char * origin) ++ const char * origin, ++ const char * outbound_interface, ++ const char * headerNames[], ++ const char * headerValues[], ++ const int headerCount) + { + /* call common implementation */ + return __nopoll_conn_new_common (ctx, NULL, nopoll_false, + host_ip, host_port, host_name, +- get_url, protocols, origin); ++ get_url, protocols, origin, outbound_interface, headerNames, headerValues, headerCount); + } + + /** +@@ -961,12 +1130,16 @@ noPollConn * nopoll_conn_new_opts (noPollCtx * ctx, + const char * host_name, + const char * get_url, + const char * protocols, +- const char * origin) ++ const char * origin, ++ const char * outbound_interface, ++ const char * headerNames[], ++ const char * headerValues[], ++ const int headerCount) + { + /* call common implementation */ + return __nopoll_conn_new_common (ctx, opts, nopoll_false, + host_ip, host_port, host_name, +- get_url, protocols, origin); ++ get_url, protocols, origin, outbound_interface, headerNames, headerValues, headerCount); + } + + nopoll_bool __nopoll_tls_was_init = nopoll_false; +@@ -1021,7 +1194,11 @@ noPollConn * nopoll_conn_tls_new (noPollCtx * ctx, + const char * host_name, + const char * get_url, + const char * protocols, +- const char * origin) ++ const char * origin, ++ const char * outbound_interface, ++ const char * headerNames[], ++ const char * headerValues[], ++ const int headerCount) + { + /* init ssl ciphers and engines */ + if (! __nopoll_tls_was_init) { +@@ -1032,7 +1209,7 @@ noPollConn * nopoll_conn_tls_new (noPollCtx * ctx, + /* call common implementation */ + return __nopoll_conn_new_common (ctx, options, nopoll_true, + host_ip, host_port, host_name, +- get_url, protocols, origin); ++ get_url, protocols, origin, outbound_interface, headerNames, headerValues, headerCount); + } + + /** +@@ -1128,7 +1305,9 @@ nopoll_bool nopoll_conn_is_ready (noPollConn * conn) + return nopoll_false; + if (conn->session == NOPOLL_INVALID_SOCKET) + return nopoll_false; +- if (! conn->handshake_ok) { ++ ++ /* conn->handshake->received_307 will always be false other than http redirect */ ++ if (! conn->handshake_ok && !conn->handshake->received_307) { + /* acquire here handshake mutex */ + nopoll_mutex_lock (conn->ref_mutex); + +@@ -1138,6 +1317,11 @@ nopoll_bool nopoll_conn_is_ready (noPollConn * conn) + /* release here handshake mutex */ + nopoll_mutex_unlock (conn->ref_mutex); + } ++ ++ if(conn->handshake->received_307) ++ { ++ return nopoll_true; /* in case of http redirection, conn->handshake_ok will never be true as the response buffer from the server will never have "Sec-Websocket-Accept". Consequently, we have to return true to break the loop inside nopoll_conn_wait_until_connection_ready() */ ++ } + return conn->handshake_ok; + } + +@@ -1202,6 +1386,22 @@ int nopoll_conn_get_id (noPollConn * conn) + return conn->id; + } + ++/** ++ * @brief Allows to get the get_url from the connection ++ * ++ * @param conn The websocket connection where the operation takes place. ++ * ++ * @return The get_url provided be the client ++ * ++ */ ++const char * nopoll_conn_get_requested_url (noPollConn * conn) ++{ ++ if (conn->get_url == NULL) ++ return "/"; ++ else ++ return conn->get_url; ++} ++ + /** + * @brief Allows to get the noPollCtx context object associated to the + * connection (or where the connection is working). +@@ -1440,6 +1640,13 @@ void nopoll_conn_shutdown (noPollConn * conn) + if (conn->session != NOPOLL_INVALID_SOCKET && conn->on_close) + conn->on_close (conn->ctx, conn, conn->on_close_data); + ++ if(conn->on_close_data != NULL) ++ { ++ nopoll_log(conn->ctx, NOPOLL_LEVEL_DEBUG,"freeing conn->on_close_data from shutdown...\n"); ++ nopoll_free(conn->on_close_data); ++ conn->on_close_data = NULL; ++ } ++ + /* shutdown connection here */ + if (conn->session != NOPOLL_INVALID_SOCKET) { + shutdown (conn->session, SHUT_RDWR); +@@ -1819,6 +2026,32 @@ void __nopoll_pack_content (char * buffer, int start, int bytes) + return; + } + ++/** ++ * @internal Function to delay ++ * @note delay goes up by factor of .125 each time ++ * @note up to 1 sec max ++*/ ++static void __nopoll_receive_delay (long *wait_usecs) ++{ ++ long rem; ++ long t = *wait_usecs; ++ ++ nopoll_sleep (t); ++ ++ if (t == 1000000) { ++ return; ++ } ++ ++ rem = t >> 3; ++ t += rem; ++ if (t > 1000000) { ++ t = 1000000; ++ } ++ ++ *wait_usecs = t; ++} ++ ++ + /** + * @internal Function used to read bytes from the wire. + * +@@ -1828,6 +2061,7 @@ void __nopoll_pack_content (char * buffer, int start, int bytes) + int __nopoll_conn_receive (noPollConn * conn, char * buffer, int maxlen) + { + int nread; ++ long wait_usecs = 500; + + if (conn->pending_buf_bytes > 0) { + nopoll_log (conn->ctx, NOPOLL_LEVEL_DEBUG, "Calling with bytes we can reuse (%d), requested: %d", +@@ -1864,14 +2098,21 @@ int __nopoll_conn_receive (noPollConn * conn, char * buffer, int maxl + #if defined(NOPOLL_OS_UNIX) + errno = 0; + #endif +- if ((nread = conn->receive (conn, buffer, maxlen)) == NOPOLL_SOCKET_ERROR) { +- /* nopoll_log (conn->ctx, NOPOLL_LEVEL_DEBUG, " returning errno=%d (%s)", errno, strerror (errno)); */ +- if (errno == NOPOLL_EAGAIN) +- return 0; +- if (errno == NOPOLL_EWOULDBLOCK) ++ /* if ((nread = conn->receive (conn, buffer, maxlen)) == NOPOLL_SOCKET_ERROR) { */ ++ if ((nread = conn->receive (conn, buffer, maxlen)) < 0) { ++ nopoll_log (conn->ctx, NOPOLL_LEVEL_CRITICAL, " conn receive nread=%d, errno=%d (%s)", nread,errno, strerror (errno)); ++ if (errno == NOPOLL_EAGAIN) { ++ __nopoll_receive_delay (&wait_usecs); ++ goto keep_reading; ++ /* return 0; */ ++ } ++ if (errno == NOPOLL_EWOULDBLOCK) { + return 0; +- if (errno == NOPOLL_EINTR) ++ } ++ if (errno == NOPOLL_EINTR) { ++ __nopoll_receive_delay (&wait_usecs); + goto keep_reading; ++ } + + nopoll_log (conn->ctx, NOPOLL_LEVEL_CRITICAL, "unable to readn=%d, error code was: %d (%s) (shutting down connection)", maxlen, errno, strerror (errno)); + nopoll_conn_shutdown (conn); +@@ -1881,6 +2122,12 @@ int __nopoll_conn_receive (noPollConn * conn, char * buffer, int maxl + /* nopoll_log (conn->ctx, NOPOLL_LEVEL_DEBUG, " returning bytes read = %d", nread); */ + if (nread == 0) { + /* check for blocking operations */ ++ if (errno == NOPOLL_EAGAIN) { ++ __nopoll_receive_delay (&wait_usecs); ++ goto keep_reading; ++ /* return 0; */ ++ } ++ nopoll_log (conn->ctx, NOPOLL_LEVEL_CRITICAL, "conn receive zero bytes, errno=%d (%s)", errno, strerror (errno)); + if (errno == NOPOLL_EAGAIN || errno == NOPOLL_EWOULDBLOCK) { + nopoll_log (conn->ctx, NOPOLL_LEVEL_WARNING, "unable to read from conn-id=%d (%s:%s), connection is not ready (errno: %d : %s)", + conn->id, conn->host, conn->port, errno, strerror (errno)); +@@ -1890,12 +2137,15 @@ int __nopoll_conn_receive (noPollConn * conn, char * buffer, int maxl + nopoll_log (conn->ctx, NOPOLL_LEVEL_CRITICAL, "received connection close while reading from conn id %d (errno=%d : %s) (%d, %d, %d), shutting down connection..", + conn->id, errno, strerror (errno), + NOPOLL_EAGAIN, NOPOLL_EWOULDBLOCK, NOPOLL_EINTR); ++ conn->on_close_data = nopoll_strdup ("SSL_Socket_Close:received connection close while reading from conn: shutting down connection"); + nopoll_conn_shutdown (conn); + } /* end if */ + + /* ensure we don't access outside the array */ +- if (nread < 0) ++ if (nread < 0) { ++ nopoll_log (conn->ctx, NOPOLL_LEVEL_CRITICAL, "** nread < 0 (%d)", nread); + nread = 0; ++ } + + buffer[nread] = 0; + return nread; +@@ -2350,6 +2600,13 @@ int nopoll_conn_complete_handshake_client (noPollCtx * ctx, noPollConn * conn, c + iterator++; + if (! nopoll_ncmp (buffer + iterator, "101", 3)) { + nopoll_log (ctx, NOPOLL_LEVEL_CRITICAL, "websocket server denied connection with: %s", buffer + iterator); ++ if(nopoll_ncmp (buffer + iterator, "307", 3)|| nopoll_ncmp (buffer + iterator, "302", 3) || nopoll_ncmp (buffer + iterator, "303", 3) ) ++ { ++ nopoll_log (ctx, NOPOLL_LEVEL_INFO, "Received HTTP 30x response from server"); ++ /* Mark 307 flag as true */ ++ conn->handshake->received_307 = nopoll_true; ++ return 1; /* continue to read next lines for redirect Location */ ++ } + return 0; /* do not continue */ + } /* end if */ + +@@ -2387,7 +2644,14 @@ int nopoll_conn_complete_handshake_client (noPollCtx * ctx, noPollConn * conn, c + } else if (strcasecmp (header, "Connection") == 0) { + conn->handshake->connection_upgrade = 1; + nopoll_free (value); +- } else { ++ } else if (strcasecmp (header, "Location") == 0) { ++ if(conn->handshake->received_307) ++ { ++ conn->handshake->redirectURL = value; ++ nopoll_log (ctx, NOPOLL_LEVEL_INFO, "nopoll_conn_complete_handshake_client: conn->handshake->redirectURL: %s",conn->handshake->redirectURL); ++ } ++ } ++ else { + /* release value, no body claimed it */ + nopoll_free (value); + } /* end if */ +@@ -2606,7 +2870,7 @@ noPollMsg * nopoll_conn_get_msg (noPollConn * conn) + if (conn->previous_msg) { + nopoll_log (conn->ctx, NOPOLL_LEVEL_WARNING, "Reading bytes (previously read %d) from a previous unfinished frame (pending: %d) over conn-id=%d", + conn->previous_msg->payload_size, conn->previous_msg->remain_bytes, conn->id); +- ++ + /* build next message holder to continue with this content */ + if (conn->previous_msg->payload_size > 0) { + msg = nopoll_msg_new (); +@@ -2702,7 +2966,7 @@ noPollMsg * nopoll_conn_get_msg (noPollConn * conn) + memcpy (conn->pending_buf + conn->pending_buf_bytes, buffer, bytes); + conn->pending_buf_bytes += bytes; + +- nopoll_log (conn->ctx, NOPOLL_LEVEL_WARNING, ++ nopoll_log (conn->ctx, NOPOLL_LEVEL_DEBUG, + "Expected to receive complete websocket frame header but found only %d bytes over conn-id=%d, saving to reuse later", + bytes, conn->id); + return NULL; +@@ -2810,7 +3074,7 @@ noPollMsg * nopoll_conn_get_msg (noPollConn * conn) + /* nothing more to add here, close frame + without content received, so we have no + reason to keep on reading */ +- nopoll_log (conn->ctx, NOPOLL_LEVEL_DEBUG, "Proper connection close frame received id=%d, shutting down", conn->id); ++ nopoll_log (conn->ctx, NOPOLL_LEVEL_INFO, "Proper connection close frame received id=%d, shutting down", conn->id); + nopoll_msg_unref (msg); + nopoll_conn_shutdown (conn); + return NULL; +@@ -2823,12 +3087,12 @@ noPollMsg * nopoll_conn_get_msg (noPollConn * conn) + + if (msg->op_code == NOPOLL_PING_FRAME) { + nopoll_log (conn->ctx, NOPOLL_LEVEL_DEBUG, "PING received over connection id=%d, replying PONG", conn->id); +- nopoll_msg_unref (msg); ++ /*nopoll_msg_unref (msg); + +- /* call to send pong */ +- nopoll_conn_send_pong (conn); ++ call to send pong */ ++ /*nopoll_conn_send_pong (conn); + +- return NULL; ++ return NULL;*/ + } /* end if */ + + /* get more bytes */ +@@ -2930,6 +3194,8 @@ read_payload: + /* update was a fragment */ + conn->previous_was_fragment = msg->is_fragment && msg->has_fin == 0; + ++ nopoll_log(conn->ctx, NOPOLL_LEVEL_DEBUG, "bytes %d, msg->payload_size %d, msg->remain_bytes %d, msg->has_fin %d, msg->op_code %d\n",bytes,msg->payload_size,msg->remain_bytes,msg->has_fin,msg->op_code); ++ + /* do not notify any frame since no content was found */ + if (bytes == 0 && msg == conn->previous_msg) { + nopoll_log (conn->ctx, NOPOLL_LEVEL_DEBUG, "bytes == %d, msg (%p) == conn->previous_msg (%p)", +@@ -3370,6 +3636,20 @@ void nopoll_conn_set_on_msg (noPollConn * conn, + + return; + } ++void nopoll_conn_set_on_ping_msg (noPollConn * conn, ++ noPollOnMessageHandler on_ping_msg, ++ noPollPtr user_data) ++{ ++ if (conn == NULL) ++ return; ++ ++ /* configure on message handler */ ++ conn->on_ping_msg = on_ping_msg; ++ conn->on_ping_msg_data = user_data; ++ ++ return; ++} ++ + + /** + * @brief Allows to configure a handler that is called when the +@@ -4129,14 +4409,18 @@ nopoll_bool nopoll_conn_accept_complete (noPollCtx * ctx, noPollConn * listener, + * @param timeout The timeout operation to limit the wait + * operation. Timeout is provided in seconds. + * ++ * @param message in-out parameter of 64 byte. The response message string description indicating ++ * "Success", "Failure" or "Redirect: Redirect_URL". Caller needs to allocate memory for this. ++ * + * @return The function returns when the timeout was reached or the + * connection is ready. In the case the connection is ready when the + * function finished nopoll_true is returned, otherwise nopoll_false. + */ + nopoll_bool nopoll_conn_wait_until_connection_ready (noPollConn * conn, +- int timeout) ++ int timeout, char * message) + { + long int total_timeout = timeout * 1000000; ++ nopoll_bool result = nopoll_false; + + /* check if the connection already finished its connection + handshake */ +@@ -4153,8 +4437,31 @@ nopoll_bool nopoll_conn_wait_until_connection_ready (noPollConn * conn, + total_timeout = total_timeout - 500; + } /* end if */ + ++ result = nopoll_conn_is_ok (conn) && nopoll_conn_is_ready (conn); ++ ++ if(conn->handshake->received_307 == nopoll_true && (conn->handshake->redirectURL != NULL)) ++ { ++ if(message != NULL) ++ { ++ snprintf(message, strlen(conn->handshake->redirectURL) + 10, "Redirect:%s", conn->handshake->redirectURL); ++ nopoll_free (conn->handshake->redirectURL); ++ } ++ conn->handshake->received_307 = nopoll_false; ++ nopoll_log (conn->ctx, NOPOLL_LEVEL_INFO, "nopoll_conn_wait_until_connection_ready() response: message: %s" ,message ); ++ return nopoll_false; /* retry with redirection URLs */ ++ } ++ else if(result && message != NULL) ++ { ++ strncpy(message, "Success", strlen("Success")+1); ++ } ++ else if(message != NULL) ++ { ++ strncpy(message, "Failure", strlen("Failure")+1); ++ } ++ nopoll_log (conn->ctx, NOPOLL_LEVEL_INFO, "*****End nopoll_conn_wait_until_connection_ready ****"); ++ + /* report if the connection is ok */ +- return nopoll_conn_is_ok (conn) && nopoll_conn_is_ready (conn); ++ return result; + } + + /* @} */ +diff --git a/src/nopoll_conn.h b/src/nopoll_conn.h +index aff440f..8beeb32 100644 +--- a/src/nopoll_conn.h ++++ b/src/nopoll_conn.h +@@ -49,7 +49,11 @@ noPollConn * nopoll_conn_new (noPollCtx * ctx, + const char * host_name, + const char * get_url, + const char * protocols, +- const char * origin); ++ const char * origin, ++ const char * outbound_interface, ++ const char * headerNames[], ++ const char * headerValues[], ++ const int headerCount); + + noPollConn * nopoll_conn_new_opts (noPollCtx * ctx, + noPollConnOpts * opts, +@@ -58,8 +62,12 @@ noPollConn * nopoll_conn_new_opts (noPollCtx * ctx, + const char * host_name, + const char * get_url, + const char * protocols, +- const char * origin); +- ++ const char * origin, ++ const char * outbound_interface, ++ const char * headerNames[], ++ const char * headerValues[], ++ const int headerCount); ++ + noPollConn * nopoll_conn_tls_new (noPollCtx * ctx, + noPollConnOpts * options, + const char * host_ip, +@@ -67,12 +75,18 @@ noPollConn * nopoll_conn_tls_new (noPollCtx * ctx, + const char * host_name, + const char * get_url, + const char * protocols, +- const char * origin); ++ const char * origin, ++ const char * outbound_interface, ++ const char * headerNames[], ++ const char * headerValues[], ++ const int headerCount); + + noPollConn * nopoll_conn_accept (noPollCtx * ctx, noPollConn * listener); + + noPollConn * nopoll_conn_accept_socket (noPollCtx * ctx, noPollConn * listener, NOPOLL_SOCKET session); + ++void nopoll_conn_set_on_ping_msg (noPollConn * conn, noPollOnMessageHandler on_ping_msg, noPollPtr user_data); ++ + nopoll_bool nopoll_conn_accept_complete (noPollCtx * ctx, + noPollConn * listener, + noPollConn * conn, +@@ -97,6 +111,8 @@ void nopoll_conn_set_socket (noPollConn * conn, NOPOLL_SOCKET _socket) + + int nopoll_conn_get_id (noPollConn * conn); + ++const char * nopoll_conn_get_requested_url (noPollConn * conn); ++ + noPollCtx * nopoll_conn_ctx (noPollConn * conn); + + noPollRole nopoll_conn_role (noPollConn * conn); +@@ -182,7 +198,7 @@ int __nopoll_conn_send_common (noPollConn * conn, + noPollOpCode frame_type); + + nopoll_bool nopoll_conn_wait_until_connection_ready (noPollConn * conn, +- int timeout); ++ int timeout, char * message); + + /** internal api **/ + void nopoll_conn_complete_handshake (noPollConn * conn); +diff --git a/src/nopoll_conn_opts.c b/src/nopoll_conn_opts.c +index 142402e..438274c 100644 +--- a/src/nopoll_conn_opts.c ++++ b/src/nopoll_conn_opts.c +@@ -70,6 +70,8 @@ noPollConnOpts * nopoll_conn_opts_new (void) + + /* by default, disable ssl peer verification */ + result->disable_ssl_verify = nopoll_true; ++ /* by default, enable hostname validation */ ++ result->host_verify = nopoll_true; + + return result; + } +@@ -169,6 +171,24 @@ void nopoll_conn_opts_ssl_peer_verify (noPollConnOpts * opts, nopoll_bool verify + return; + } + ++/** ++ * @brief Allows to enable hostname validation ++ * ++ * @param opts The connection option to configure. ++ * ++ * @param hostVerify nopoll_true to enable hostname validation ++ * otherwise, nopoll_false should be used. By default hostname validation ++ * is enabled. ++ */ ++ ++void nopoll_conn_opts_ssl_host_verify (noPollConnOpts * opts, nopoll_bool hostVerify) ++{ ++ if (opts == NULL) ++ return; ++ opts->host_verify = hostVerify; ++ return; ++} ++ + /** + * @brief Allows to set Cookie header content to be sent during the + * connection handshake. If configured and the remote side server is a +diff --git a/src/nopoll_conn_opts.h b/src/nopoll_conn_opts.h +index 5aeb571..d57f82f 100644 +--- a/src/nopoll_conn_opts.h ++++ b/src/nopoll_conn_opts.h +@@ -64,6 +64,8 @@ void nopoll_conn_opts_unref (noPollConnOpts * opts); + void nopoll_conn_opts_set_reuse (noPollConnOpts * opts, nopoll_bool reuse); + + void nopoll_conn_opts_free (noPollConnOpts * opts); ++/* hostname validation */ ++void nopoll_conn_opts_ssl_host_verify (noPollConnOpts * opts, nopoll_bool verify); + + /** internal API **/ + void __nopoll_conn_opts_release_if_needed (noPollConnOpts * options); +diff --git a/src/nopoll_ctx.c b/src/nopoll_ctx.c +index de01024..84ab438 100644 +--- a/src/nopoll_ctx.c ++++ b/src/nopoll_ctx.c +@@ -334,8 +334,8 @@ void nopoll_ctx_unregister_conn (noPollCtx * ctx, + + /* acquire a reference to the conection */ + nopoll_conn_unref (conn); +- +- break; ++ nopoll_log (ctx, NOPOLL_LEVEL_INFO, "Returning, unlock of mutex is not required "); ++ return; + } /* end if */ + + iterator++; +@@ -650,6 +650,19 @@ void nopoll_ctx_set_on_msg (noPollCtx * ctx, + return; + } + ++void nopoll_ctx_set_on_ping_msg (noPollCtx * ctx, ++ noPollOnMessageHandler on_ping_msg, ++ noPollPtr user_data) ++{ ++ nopoll_return_if_fail (ctx, ctx); ++ ++ /* set new handler */ ++ ctx->on_ping_msg = on_ping_msg; ++ ctx->on_ping_msg_data = user_data; ++ ++ return; ++} ++ + /** + * @brief Allows to configure the handler that will be used to let + * user land code to define OpenSSL SSL_CTX object. +diff --git a/src/nopoll_ctx.h b/src/nopoll_ctx.h +index a9e4154..0ef8e42 100644 +--- a/src/nopoll_ctx.h ++++ b/src/nopoll_ctx.h +@@ -87,6 +87,10 @@ void nopoll_ctx_set_on_msg (noPollCtx * ctx, + noPollOnMessageHandler on_msg, + noPollPtr user_data); + ++void nopoll_ctx_set_on_ping_msg (noPollCtx * ctx, ++ noPollOnMessageHandler on_ping_msg, ++ noPollPtr user_data); ++ + void nopoll_ctx_set_ssl_context_creator (noPollCtx * ctx, + noPollSslContextCreator context_creator, + noPollPtr user_data); +diff --git a/src/nopoll_decl.h b/src/nopoll_decl.h +index 72fe194..0b7be76 100644 +--- a/src/nopoll_decl.h ++++ b/src/nopoll_decl.h +@@ -95,6 +95,7 @@ + * @brief Portable definition for EWOULDBLOCK errno code. + */ + #define NOPOLL_EWOULDBLOCK EWOULDBLOCK ++#define NOPOLL_ETIMEDOUT ETIMEDOUT + #define NOPOLL_EINPROGRESS EINPROGRESS + #define NOPOLL_ENOTCONN ENOTCONN + #define NOPOLL_EAGAIN EAGAIN +@@ -255,7 +256,12 @@ typedef enum { + * @brief Debug level. Only used to report common + * circumstances that represent the proper functionality. + */ +- NOPOLL_LEVEL_DEBUG, ++ NOPOLL_LEVEL_DEBUG, ++ /** ++ * @brief Info level. Only used to report information for debugging, common ++ * circumstances that represent the proper functionality. ++ */ ++ NOPOLL_LEVEL_INFO, + /** + * @brief Warning level. Only used to report that an internal + * issue have happend that could be interesting while +@@ -447,6 +453,13 @@ typedef enum { + */ + NOPOLL_METHOD_TLSV1_1 = 5 + #endif ++ /** ++ * @brief Allows to define TLSv1.2 as SSL protocol used by the ++ * client or server connection. A connection/listener ++ * established with this method will only understand this ++ * method. ++ */ ++ NOPOLL_METHOD_TLSV1_2 = 6 + } noPollSslProtocol ; + + BEGIN_C_DECLS +diff --git a/src/nopoll_hostcheck.c b/src/nopoll_hostcheck.c +new file mode 100644 +index 0000000..140b62f +--- /dev/null ++++ b/src/nopoll_hostcheck.c +@@ -0,0 +1,124 @@ ++/*************************************************************************** ++ * ++ * Copyright (C) 1998 - 2017, Daniel Stenberg, , et al. ++ * ++ * This software is licensed as described in the file COPYING, which ++ * you should have received as part of this distribution. The terms ++ * are also available at https://curl.haxx.se/docs/copyright.html. ++ * ++ * You may opt to use, copy, modify, merge, publish, distribute and/or sell ++ * copies of the Software, and permit persons to whom the Software is ++ * furnished to do so, under the terms of the COPYING file. ++ * ++ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY ++ * KIND, either express or implied. ++ * ++ ***************************************************************************/ ++ ++#include ++ ++static int hostmatch(char *hostname, char *pattern); ++ ++/* ++ * Match a hostname against a wildcard pattern. ++ * E.g. ++ * "foo.host.com" matches "*.host.com". ++ * ++ * We use the matching rule described in RFC6125, section 6.4.3. ++ * https://tools.ietf.org/html/rfc6125#section-6.4.3 ++ * ++ * In addition: ignore trailing dots in the host names and wildcards, so that ++ * the names are used normalized. This is what the browsers do. ++ * ++ * Do not allow wildcard matching on IP numbers. There are apparently ++ * certificates being used with an IP address in the CN field, thus making no ++ * apparent distinction between a name and an IP. We need to detect the use of ++ * an IP address and not wildcard match on such names. ++ * ++ * NOTE: hostmatch() gets called with copied buffers so that it can modify the ++ * contents at will. ++ */ ++ ++static int hostmatch(char *hostname, char *pattern) ++{ ++ const char *pattern_label_end, *pattern_wildcard, *hostname_label_end; ++ int wildcard_enabled; ++ size_t prefixlen, suffixlen; ++ struct in_addr ignored; ++ struct sockaddr_in6 si6; ++ ++ /* normalize pattern and hostname by stripping off trailing dots */ ++ size_t len = strlen(hostname); ++ if(hostname[len-1]=='.') ++ hostname[len-1]=0; ++ len = strlen(pattern); ++ if(pattern[len-1]=='.') ++ pattern[len-1]=0; ++ ++ pattern_wildcard = strchr(pattern, '*'); ++ if(pattern_wildcard == NULL) ++ return nopoll_strcasecompare(pattern, hostname) ? ++ NOPOLL_HOST_MATCH : NOPOLL_HOST_NOMATCH; ++ ++ /* detect IP address as hostname and fail the match if so */ ++ if(nopoll_inet_pton(AF_INET, hostname, &ignored) > 0) ++ return NOPOLL_HOST_NOMATCH; ++ else if(nopoll_inet_pton(AF_INET6, hostname, &si6.sin6_addr) > 0) ++ return NOPOLL_HOST_NOMATCH; ++ ++ /* We require at least 2 dots in pattern to avoid too wide wildcard ++ match. */ ++ wildcard_enabled = 1; ++ pattern_label_end = strchr(pattern, '.'); ++ if(pattern_label_end == NULL || strchr(pattern_label_end+1, '.') == NULL || ++ pattern_wildcard > pattern_label_end || ++ nopoll_strncasecompare(pattern, "xn--", 4)) { ++ wildcard_enabled = 0; ++ } ++ if(!wildcard_enabled) ++ return nopoll_strcasecompare(pattern, hostname) ? ++ NOPOLL_HOST_MATCH : NOPOLL_HOST_NOMATCH; ++ ++ hostname_label_end = strchr(hostname, '.'); ++ if(hostname_label_end == NULL || ++ !nopoll_strcasecompare(pattern_label_end, hostname_label_end)) ++ return NOPOLL_HOST_NOMATCH; ++ ++ /* The wildcard must match at least one character, so the left-most ++ label of the hostname is at least as large as the left-most label ++ of the pattern. */ ++ if(hostname_label_end - hostname < pattern_label_end - pattern) ++ return NOPOLL_HOST_NOMATCH; ++ ++ prefixlen = pattern_wildcard - pattern; ++ suffixlen = pattern_label_end - (pattern_wildcard+1); ++ return nopoll_strncasecompare(pattern, hostname, prefixlen) && ++ nopoll_strncasecompare(pattern_wildcard+1, hostname_label_end - suffixlen, ++ suffixlen) ? ++ NOPOLL_HOST_MATCH : NOPOLL_HOST_NOMATCH; ++} ++ ++int nopoll_cert_hostcheck(const char *match_pattern, const char *hostname) ++{ ++ char *matchp; ++ char *hostp; ++ int res = 0; ++ if(!match_pattern || !*match_pattern || ++ !hostname || !*hostname) ++ ; ++ else { ++ matchp = strdup(match_pattern); ++ if(matchp) { ++ hostp = strdup(hostname); ++ if(hostp) { ++ if(hostmatch(hostp, matchp) == NOPOLL_HOST_MATCH) ++ res= 1; ++ free(hostp); ++ } ++ free(matchp); ++ } ++ } ++ ++ return res; ++} ++ +diff --git a/src/nopoll_hostcheck.h b/src/nopoll_hostcheck.h +new file mode 100644 +index 0000000..52f9b1f +--- /dev/null ++++ b/src/nopoll_hostcheck.h +@@ -0,0 +1,27 @@ ++/*************************************************************************** ++ * ++ * Copyright (C) 1998 - 2017, Daniel Stenberg, , et al. ++ * ++ * This software is licensed as described in the file COPYING, which ++ * you should have received as part of this distribution. The terms ++ * are also available at https://curl.haxx.se/docs/copyright.html. ++ * ++ * You may opt to use, copy, modify, merge, publish, distribute and/or sell ++ * copies of the Software, and permit persons to whom the Software is ++ * furnished to do so, under the terms of the COPYING file. ++ * ++ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY ++ * KIND, either express or implied. ++ * ++ ***************************************************************************/ ++ ++#ifndef __NOPOLL_HOSTCHECK_H__ ++#define __NOPOLL_HOSTCHECK_H__ ++ ++#define NOPOLL_HOST_NOMATCH 0 ++#define NOPOLL_HOST_MATCH 1 ++ ++int nopoll_cert_hostcheck(const char *match_pattern, const char *hostname); ++ ++#endif /* __NOPOLL_HOSTCHECK_H__ */ ++ +diff --git a/src/nopoll_hostname_validation.c b/src/nopoll_hostname_validation.c +new file mode 100644 +index 0000000..bf4f0d9 +--- /dev/null ++++ b/src/nopoll_hostname_validation.c +@@ -0,0 +1,151 @@ ++/* ++*Copyright (C) 2012, iSEC Partners. ++ ++* Permission is hereby granted, free of charge, to any person obtaining a copy of ++* this software and associated documentation files (the "Software"), to deal in ++* the Software without restriction, including without limitation the rights to ++* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies ++* of the Software, and to permit persons to whom the Software is furnished to do ++* so, subject to the following conditions: ++ ++* The above copyright notice and this permission notice shall be included in all ++* copies or substantial portions of the Software. ++ ++* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ++* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ++* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ++* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ++* SOFTWARE. ++* ++*/ ++ ++#include ++ ++static HostnameValidationResult matches_common_name(const char *hostname, const X509 *server_cert); ++static HostnameValidationResult matches_subject_alternative_name(const char *hostname, const X509 *server_cert); ++ ++/** ++* Tries to find a match for hostname in the certificate's Common Name field. ++* ++* Returns MatchFound if a match was found. ++* Returns MatchNotFound if no matches were found. ++* Returns MalformedCertificate if the Common Name had a NUL character embedded in it. ++* Returns Error if the Common Name could not be extracted. ++*/ ++static HostnameValidationResult matches_common_name(const char *hostname, const X509 *server_cert) ++{ ++ int common_name_loc = -1; ++ X509_NAME_ENTRY *common_name_entry = NULL; ++ ASN1_STRING *common_name_asn1 = NULL; ++ char *common_name_str = NULL; ++ ++ /* Find the position of the CN field in the Subject field of the certificate*/ ++ common_name_loc = X509_NAME_get_index_by_NID(X509_get_subject_name((X509 *) server_cert), NID_commonName, -1); ++ if (common_name_loc < 0) { ++ return Error; ++ } ++ ++ /* Extract the CN field*/ ++ common_name_entry = X509_NAME_get_entry(X509_get_subject_name((X509 *) server_cert), common_name_loc); ++ if (common_name_entry == NULL) { ++ return Error; ++ } ++ ++ /* Convert the CN field to a C string*/ ++ common_name_asn1 = X509_NAME_ENTRY_get_data(common_name_entry); ++ if (common_name_asn1 == NULL) { ++ return Error; ++ } ++ common_name_str = (char *) ASN1_STRING_data(common_name_asn1); ++ ++ /* Make sure there isn't an embedded NUL character in the CN*/ ++ if (ASN1_STRING_length(common_name_asn1) != strlen(common_name_str)) { ++ return MalformedCertificate; ++ } ++ ++ /* Compare expected hostname with the CN*/ ++ if (nopoll_cert_hostcheck(common_name_str, hostname) == NOPOLL_HOST_MATCH) { ++ return MatchFound; ++ } ++ else { ++ return MatchNotFound; ++ } ++} ++ ++ ++/** ++* Tries to find a match for hostname in the certificate's Subject Alternative Name extension. ++* ++* Returns MatchFound if a match was found. ++* Returns MatchNotFound if no matches were found. ++* Returns MalformedCertificate if any of the hostnames had a NUL character embedded in it. ++* Returns NoSANPresent if the SAN extension was not present in the certificate. ++*/ ++static HostnameValidationResult matches_subject_alternative_name(const char *hostname, const X509 *server_cert) { ++ HostnameValidationResult result = MatchNotFound; ++ int i; ++ int san_names_nb = -1; ++ STACK_OF(GENERAL_NAME) *san_names = NULL; ++ ++ /* Try to extract the names within the SAN extension from the certificate*/ ++ san_names = X509_get_ext_d2i((X509 *) server_cert, NID_subject_alt_name, NULL, NULL); ++ if (san_names == NULL) { ++ return NoSANPresent; ++ } ++ san_names_nb = sk_GENERAL_NAME_num(san_names); ++ ++ /* Check each name within the extension*/ ++ for (i=0; itype == GEN_DNS) { ++ /* Current name is a DNS name, let's check it*/ ++ char *dns_name = (char *) ASN1_STRING_data(current_name->d.dNSName); ++ ++ /* Make sure there isn't an embedded NUL character in the DNS name*/ ++ if ((size_t)ASN1_STRING_length(current_name->d.dNSName) != strlen(dns_name)) { ++ result = MalformedCertificate; ++ break; ++ } ++ else { /* Compare expected hostname with the DNS name*/ ++ if (nopoll_cert_hostcheck(dns_name, hostname) == NOPOLL_HOST_MATCH) { ++ result = MatchFound; ++ break; ++ } ++ } ++ } ++ } ++ sk_GENERAL_NAME_pop_free(san_names, GENERAL_NAME_free); ++ ++ return result; ++} ++ ++ ++/** ++* Validates the server's identity by looking for the expected hostname in the ++* server's certificate. As described in RFC 6125, it first tries to find a match ++* in the Subject Alternative Name extension. If the extension is not present in ++* the certificate, it checks the Common Name instead. ++* ++* Returns MatchFound if a match was found. ++* Returns MatchNotFound if no matches were found. ++* Returns MalformedCertificate if any of the hostnames had a NUL character embedded in it. ++* Returns Error if there was an error. ++*/ ++HostnameValidationResult nopoll_validate_hostname(const char *hostname, const X509 *server_cert) { ++ HostnameValidationResult result; ++ ++ if((hostname == NULL) || (server_cert == NULL)) ++ return Error; ++ ++ /* First try the Subject Alternative Names extension*/ ++ result = matches_subject_alternative_name(hostname, server_cert); ++ if (result == NoSANPresent) { ++ /* Extension was not found: try the Common Name*/ ++ result = matches_common_name(hostname, server_cert); ++ } ++ ++ return result; ++} +diff --git a/src/nopoll_hostname_validation.h b/src/nopoll_hostname_validation.h +new file mode 100644 +index 0000000..afd0555 +--- /dev/null ++++ b/src/nopoll_hostname_validation.h +@@ -0,0 +1,57 @@ ++/* ++*Copyright (C) 2012, iSEC Partners. ++ ++* Permission is hereby granted, free of charge, to any person obtaining a copy of ++* this software and associated documentation files (the "Software"), to deal in ++* the Software without restriction, including without limitation the rights to ++* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies ++* of the Software, and to permit persons to whom the Software is furnished to do ++* so, subject to the following conditions: ++ ++* The above copyright notice and this permission notice shall be included in all ++* copies or substantial portions of the Software. ++ ++* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ++* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ++* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ++* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ++* SOFTWARE. ++* ++*/ ++ ++#ifndef __NOPOLL_HOSTNAME_VALIDATION_H__ ++#define __NOPOLL_HOSTNAME_VALIDATION_H__ ++ ++#include ++#include ++ ++BEGIN_C_DECLS ++ ++#include ++#include ++#include ++ ++typedef enum { ++ MatchFound, ++ MatchNotFound, ++ NoSANPresent, ++ MalformedCertificate, ++ Error ++} HostnameValidationResult; ++ ++/** ++* Validates the server's identity by looking for the expected hostname in the ++* server's certificate. As described in RFC 6125, it first tries to find a match ++* in the Subject Alternative Name extension. If the extension is not present in ++* the certificate, it checks the Common Name instead. ++* ++* Returns MatchFound if a match was found. ++* Returns MatchNotFound if no matches were found. ++* Returns MalformedCertificate if any of the hostnames had a NULL character embedded in it. ++* Returns Error if there was an error. ++*/ ++HostnameValidationResult nopoll_validate_hostname(const char *hostname, const X509 *server_cert); ++END_C_DECLS ++#endif /* __NOPOLL_HOSTNAME_VALIDATION_H__ */ +diff --git a/src/nopoll_inet_pton.c b/src/nopoll_inet_pton.c +new file mode 100644 +index 0000000..70cc4a4 +--- /dev/null ++++ b/src/nopoll_inet_pton.c +@@ -0,0 +1,207 @@ ++/* This is from the BIND 4.9.4 release, modified to compile by itself */ ++ ++/* Copyright (c) 1996 by Internet Software Consortium. ++ * ++ * Permission to use, copy, modify, and distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS ++ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES ++ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE ++ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL ++ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR ++ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ++ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS ++ * SOFTWARE. ++ */ ++ ++#include ++ ++/* ++ * WARNING: Don't even consider trying to compile this on a system where ++ * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. ++ */ ++ ++static int inet_pton4(const char *src, unsigned char *dst); ++static int inet_pton6(const char *src, unsigned char *dst); ++ ++/* int ++ * inet_pton(af, src, dst) ++ * convert from presentation format (which usually means ASCII printable) ++ * to network format (which is usually some kind of binary format). ++ * return: ++ * 1 if the address was valid for the specified address family ++ * 0 if the address wasn't valid (`dst' is untouched in this case) ++ * -1 if some other error occurred (`dst' is untouched in this case, too) ++ * notice: ++ * On Windows we store the error in the thread errno, not ++ * in the winsock error code. This is to avoid losing the ++ * actual last winsock error. So use macro ERRNO to fetch the ++ * errno this function sets when returning (-1), not SOCKERRNO. ++ * author: ++ * Paul Vixie, 1996. ++ */ ++int nopoll_inet_pton(int af, const char *src, void *dst) ++{ ++ switch(af) { ++ case AF_INET: ++ return (inet_pton4(src, (unsigned char *)dst)); ++ case AF_INET6: ++ return (inet_pton6(src, (unsigned char *)dst)); ++ default: ++ errno = EAFNOSUPPORT; ++ return (-1); ++ } ++ /* NOTREACHED */ ++} ++ ++/* int ++ * inet_pton4(src, dst) ++ * like inet_aton() but without all the hexadecimal and shorthand. ++ * return: ++ * 1 if `src' is a valid dotted quad, else 0. ++ * notice: ++ * does not touch `dst' unless it's returning 1. ++ * author: ++ * Paul Vixie, 1996. ++ */ ++static int inet_pton4(const char *src, unsigned char *dst) ++{ ++ static const char digits[] = "0123456789"; ++ int saw_digit, octets, ch; ++ unsigned char tmp[INTADDRSZ], *tp; ++ ++ saw_digit = 0; ++ octets = 0; ++ tp = tmp; ++ *tp = 0; ++ while((ch = *src++) != '\0') { ++ const char *pch; ++ ++ pch = strchr(digits, ch); ++ if(pch) { ++ unsigned int val = *tp * 10 + (unsigned int)(pch - digits); ++ ++ if(saw_digit && *tp == 0) ++ return (0); ++ if(val > 255) ++ return (0); ++ *tp = (unsigned char)val; ++ if(! saw_digit) { ++ if(++octets > 4) ++ return (0); ++ saw_digit = 1; ++ } ++ } ++ else if(ch == '.' && saw_digit) { ++ if(octets == 4) ++ return (0); ++ *++tp = 0; ++ saw_digit = 0; ++ } ++ else ++ return (0); ++ } ++ if(octets < 4) ++ return (0); ++ memcpy(dst, tmp, INTADDRSZ); ++ return (1); ++} ++ ++/* int ++ * inet_pton6(src, dst) ++ * convert presentation level address to network order binary form. ++ * return: ++ * 1 if `src' is a valid [RFC1884 2.2] address, else 0. ++ * notice: ++ * (1) does not touch `dst' unless it's returning 1. ++ * (2) :: in a full address is silently ignored. ++ * credit: ++ * inspired by Mark Andrews. ++ * author: ++ * Paul Vixie, 1996. ++ */ ++static int inet_pton6(const char *src, unsigned char *dst) ++{ ++ static const char xdigits_l[] = "0123456789abcdef", ++ xdigits_u[] = "0123456789ABCDEF"; ++ unsigned char tmp[INT6ADDRSZ], *tp, *endp, *colonp; ++ const char *xdigits, *curtok; ++ int ch, saw_xdigit; ++ size_t val; ++ ++ memset((tp = tmp), 0, INT6ADDRSZ); ++ endp = tp + INT6ADDRSZ; ++ colonp = NULL; ++ /* Leading :: requires some special handling. */ ++ if(*src == ':') ++ if(*++src != ':') ++ return (0); ++ curtok = src; ++ saw_xdigit = 0; ++ val = 0; ++ while((ch = *src++) != '\0') { ++ const char *pch; ++ ++ pch = strchr((xdigits = xdigits_l), ch); ++ if(!pch) ++ pch = strchr((xdigits = xdigits_u), ch); ++ if(pch != NULL) { ++ val <<= 4; ++ val |= (pch - xdigits); ++ if(++saw_xdigit > 4) ++ return (0); ++ continue; ++ } ++ if(ch == ':') { ++ curtok = src; ++ if(!saw_xdigit) { ++ if(colonp) ++ return (0); ++ colonp = tp; ++ continue; ++ } ++ if(tp + INT16SIZE > endp) ++ return (0); ++ *tp++ = (unsigned char) ((val >> 8) & 0xff); ++ *tp++ = (unsigned char) (val & 0xff); ++ saw_xdigit = 0; ++ val = 0; ++ continue; ++ } ++ if(ch == '.' && ((tp + INTADDRSZ) <= endp) && ++ inet_pton4(curtok, tp) > 0) { ++ tp += INTADDRSZ; ++ saw_xdigit = 0; ++ break; /* '\0' was seen by inet_pton4(). */ ++ } ++ return (0); ++ } ++ if(saw_xdigit) { ++ if(tp + INT16SIZE > endp) ++ return (0); ++ *tp++ = (unsigned char) ((val >> 8) & 0xff); ++ *tp++ = (unsigned char) (val & 0xff); ++ } ++ if(colonp != NULL) { ++ /* ++ * Since some memmove()'s erroneously fail to handle ++ * overlapping regions, we'll do the shift by hand. ++ */ ++ const ssize_t n = tp - colonp; ++ ssize_t i; ++ ++ if(tp == endp) ++ return (0); ++ for(i = 1; i <= n; i++) { ++ *(endp - i) = *(colonp + n - i); ++ *(colonp + n - i) = 0; ++ } ++ tp = endp; ++ } ++ if(tp != endp) ++ return (0); ++ memcpy(dst, tmp, INT6ADDRSZ); ++ return (1); ++} +diff --git a/src/nopoll_inet_pton.h b/src/nopoll_inet_pton.h +new file mode 100644 +index 0000000..09b2904 +--- /dev/null ++++ b/src/nopoll_inet_pton.h +@@ -0,0 +1,29 @@ ++/*************************************************************************** ++ * Copyright (C) 1998 - 2017, Daniel Stenberg, , et al. ++ * ++ * This software is licensed as described in the file COPYING, which ++ * you should have received as part of this distribution. The terms ++ * are also available at https://curl.haxx.se/docs/copyright.html. ++ * ++ * You may opt to use, copy, modify, merge, publish, distribute and/or sell ++ * copies of the Software, and permit persons to whom the Software is ++ * furnished to do so, under the terms of the COPYING file. ++ * ++ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY ++ * KIND, either express or implied. ++ * ++ ***************************************************************************/ ++ ++#ifndef __NOPOLL_INET_PTON_H__ ++#define __NOPOLL_INET_PTON_H__ ++ ++#include ++ ++#define INT6ADDRSZ 16 ++#define INTADDRSZ 4 ++#define INT16SIZE 2 ++ ++int nopoll_inet_pton(int, const char *, void *); ++ ++#endif /* __NOPOLL_INET_PTON_H__ */ ++ +diff --git a/src/nopoll_log.c b/src/nopoll_log.c +index d05fc5c..7f5a01c 100644 +--- a/src/nopoll_log.c ++++ b/src/nopoll_log.c +@@ -203,6 +203,9 @@ void __nopoll_log (noPollCtx * ctx, const char * function_name, const char * fil + case NOPOLL_LEVEL_DEBUG: + printf ("(\e[1;32mdebug\e[0m) "); + break; ++ case NOPOLL_LEVEL_INFO: ++ printf ("(\e[1;32minfo\e[0m) "); ++ break; + case NOPOLL_LEVEL_WARNING: + printf ("(\e[1;33mwarning\e[0m) "); + break; +@@ -215,6 +218,9 @@ void __nopoll_log (noPollCtx * ctx, const char * function_name, const char * fil + case NOPOLL_LEVEL_DEBUG: + printf ("(debug)"); + break; ++ case NOPOLL_LEVEL_INFO: ++ printf ("(info)"); ++ break; + case NOPOLL_LEVEL_WARNING: + printf ("(warning)"); + break; +diff --git a/src/nopoll_loop.c b/src/nopoll_loop.c +index fb142ff..08e44e5 100644 +--- a/src/nopoll_loop.c ++++ b/src/nopoll_loop.c +@@ -48,6 +48,12 @@ + * @{ + */ + ++/*----------------------------------------------------------------------------*/ ++/* File Scoped Variables */ ++/*----------------------------------------------------------------------------*/ ++noPollMsg * fragMsg; ++int isPreviousMsgFragment = 0; ++ + /** + * @internal Function used by nopoll_loop_wait to register all + * connections into the io waiting object. +@@ -72,6 +78,15 @@ nopoll_bool nopoll_loop_register (noPollCtx * ctx, noPollConn * conn, noPollPtr + return nopoll_false; /* keep foreach, don't stop */ + } + ++noPollMsg * __nopoll_msg_join(noPollMsg *fragMsg, noPollMsg *msg) ++{ ++ noPollMsg *tempMsg = nopoll_msg_join(fragMsg,msg); ++ nopoll_msg_unref (fragMsg); ++ nopoll_msg_unref (msg); ++ ++ return tempMsg; ++} ++ + /** + * @internal Function used to handle incoming data from from the + * connection and to notify this data on the connection. +@@ -85,11 +100,64 @@ void nopoll_loop_process_data (noPollCtx * ctx, noPollConn * conn) + if (msg == NULL) + return; + +- /* found message, notify it */ +- if (conn->on_msg) +- conn->on_msg (ctx, conn, msg, conn->on_msg_data); +- else if (ctx->on_msg) +- ctx->on_msg (ctx, conn, msg, ctx->on_msg_data); ++ if(msg->op_code == NOPOLL_PING_FRAME) ++ { ++ /* Initialized ping msg handler */ ++ if (conn->on_ping_msg) ++ conn->on_ping_msg (ctx, conn, msg, conn->on_ping_msg_data); ++ else if (ctx->on_ping_msg) ++ ctx->on_ping_msg (ctx, conn, msg, ctx->on_ping_msg_data); ++ } ++ else { ++ /* found message, notify it */ ++ /* Initialized msg handler */ ++ ++ if(msg->has_fin == 0) ++ { ++ nopoll_log(ctx, NOPOLL_LEVEL_INFO, "Received Fragment - FIN: %d, Opcode: %d, payload size: %d, Remaining bytes: %d",msg->has_fin,msg->op_code,nopoll_msg_get_payload_size(msg),msg->remain_bytes); ++ isPreviousMsgFragment = 1; ++ if(fragMsg == NULL) ++ { ++ fragMsg = msg; ++ nopoll_log(ctx, NOPOLL_LEVEL_INFO, "Received fragment, joined the message, waiting for last fragment"); ++ return; ++ } ++ else ++ { ++ if(nopoll_msg_get_payload_size(msg) == msg->remain_bytes) ++ { ++ nopoll_log(ctx, NOPOLL_LEVEL_DEBUG,"nopoll_msg_ref_count(fragMsg) %d, nopoll_msg_ref_count(msg) %d\n",nopoll_msg_ref_count(fragMsg),nopoll_msg_ref_count(msg)); ++ msg = __nopoll_msg_join(fragMsg,msg); ++ nopoll_log(ctx, NOPOLL_LEVEL_INFO,"Received all the pending bytes, hence which means the complete message is received"); ++ fragMsg = NULL; ++ isPreviousMsgFragment = 0; ++ nopoll_log(ctx, NOPOLL_LEVEL_INFO,"Received last fragment payload size %d, joined the old fragment messages",msg->payload_size); ++ } ++ else ++ { ++ nopoll_log(ctx, NOPOLL_LEVEL_DEBUG,"nopoll_msg_ref_count(fragMsg) %d, nopoll_msg_ref_count(msg) %d\n",nopoll_msg_ref_count(fragMsg),nopoll_msg_ref_count(msg)); ++ fragMsg = __nopoll_msg_join(fragMsg,msg); ++ nopoll_log(ctx, NOPOLL_LEVEL_INFO, "Received fragment, joined the message, waiting for last fragment"); ++ return; ++ } ++ ++ } ++ } ++ else if(msg->has_fin == 1 && isPreviousMsgFragment && msg->op_code == NOPOLL_CONTINUATION_FRAME) ++ { ++ nopoll_log(ctx, NOPOLL_LEVEL_INFO, "Received Fragment - FIN: %d, Opcode: %d, payload size: %d, Remaining bytes: %d",msg->has_fin,msg->op_code,nopoll_msg_get_payload_size(msg),msg->remain_bytes); ++ nopoll_log(ctx, NOPOLL_LEVEL_DEBUG,"nopoll_msg_ref_count(fragMsg) %d, nopoll_msg_ref_count(msg) %d\n",nopoll_msg_ref_count(fragMsg),nopoll_msg_ref_count(msg)); ++ msg = __nopoll_msg_join(fragMsg,msg); ++ fragMsg = NULL; ++ isPreviousMsgFragment = 0; ++ nopoll_log(ctx, NOPOLL_LEVEL_INFO,"Received last fragment payload size %d, joined the old fragment messages",msg->payload_size); ++ } ++ ++ if (conn->on_msg) ++ conn->on_msg (ctx, conn, msg, conn->on_msg_data); ++ else if (ctx->on_msg) ++ ctx->on_msg (ctx, conn, msg, ctx->on_msg_data); ++ } + + /* release message */ + nopoll_msg_unref (msg); +@@ -264,6 +332,21 @@ int nopoll_loop_wait (noPollCtx * ctx, long timeout) + return 0; + } + ++/** ++ * @brief To determine if nopoll loop wait has ended/terminated. ++ * This is to identify termination i.e. when the nopoll loop wait stops and ++ * there are no connections then this returns 1 else 0. ++ * ++ * @param ctx The context object. ++ * ++ * @return The function returns 0 nopoll loop wait is running and ++ * 1 when the nopoll loop wait has ended/terminatedss ++ */ ++int nopoll_loop_ended (noPollCtx * ctx) ++{ ++ return (NULL == ctx->io_engine); ++} ++ + /* @} */ + + +diff --git a/src/nopoll_loop.h b/src/nopoll_loop.h +index 245d973..338e71a 100644 +--- a/src/nopoll_loop.h ++++ b/src/nopoll_loop.h +@@ -47,6 +47,8 @@ int nopoll_loop_wait (noPollCtx * ctx, long timeout); + + void nopoll_loop_stop (noPollCtx * ctx); + ++int nopoll_loop_ended (noPollCtx * ctx); ++ + END_C_DECLS + + #endif +diff --git a/src/nopoll_private.h b/src/nopoll_private.h +index 847e0cf..9570cb1 100644 +--- a/src/nopoll_private.h ++++ b/src/nopoll_private.h +@@ -123,7 +123,9 @@ struct _noPollCtx { + */ + noPollOnMessageHandler on_msg; + noPollPtr on_msg_data; +- ++ ++ noPollOnMessageHandler on_ping_msg; ++ noPollPtr on_ping_msg_data; + /** + * @internal Basic fake support for protocol version, by + * default: 13, due to RFC6455 standard +@@ -231,7 +233,9 @@ struct _noPollConn { + */ + noPollOnMessageHandler on_msg; + noPollPtr on_msg_data; +- ++ ++ noPollOnMessageHandler on_ping_msg; ++ noPollPtr on_ping_msg_data; + /** + * @internal Reference to defined on ready handling. + */ +@@ -357,6 +361,7 @@ struct _noPollHandshake { + nopoll_bool upgrade_websocket; + nopoll_bool connection_upgrade; + nopoll_bool received_101; ++ nopoll_bool received_307; + char * websocket_key; + char * websocket_version; + char * websocket_accept; +@@ -364,6 +369,8 @@ struct _noPollHandshake { + + /* reference to cookie header */ + char * cookie; ++ /* redirect Location URL */ ++ char * redirectURL; + }; + + struct _noPollConnOpts { +@@ -384,6 +391,7 @@ struct _noPollConnOpts { + char * ca_certificate; + + nopoll_bool disable_ssl_verify; ++ nopoll_bool host_verify; + + /* cookie support */ + char * cookie; +diff --git a/src/nopoll_strcase.c b/src/nopoll_strcase.c +new file mode 100644 +index 0000000..8bdf2e3 +--- /dev/null ++++ b/src/nopoll_strcase.c +@@ -0,0 +1,61 @@ ++/*************************************************************************** ++ * ++ * Copyright (C) 1998 - 2017, Daniel Stenberg, , et al. ++ * ++ * This software is licensed as described in the file COPYING, which ++ * you should have received as part of this distribution. The terms ++ * are also available at https://curl.haxx.se/docs/copyright.html. ++ * ++ * You may opt to use, copy, modify, merge, publish, distribute and/or sell ++ * copies of the Software, and permit persons to whom the Software is ++ * furnished to do so, under the terms of the COPYING file. ++ * ++ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY ++ * KIND, either express or implied. ++ * ++ ***************************************************************************/ ++ ++ ++#include ++ ++/* Portable, consistent toupper (remember EBCDIC). Do not use toupper() because ++ its behavior is altered by the current locale. */ ++char nopoll_raw_toupper(char in) ++{ ++ if(in >= 'a' && in <= 'z') ++ return (char)('A' + in - 'a'); ++ return in; ++} ++ ++int nopoll_strcasecompare(const char *first, const char *second) ++{ ++ while(*first && *second) { ++ if(nopoll_raw_toupper(*first) != nopoll_raw_toupper(*second)) ++ /* get out of the loop as soon as they don't match */ ++ break; ++ first++; ++ second++; ++ } ++ /* we do the comparison here (possibly again), just to make sure that if the ++ loop above is skipped because one of the strings reached zero, we must not ++ return this as a successful match */ ++ return (nopoll_raw_toupper(*first) == nopoll_raw_toupper(*second)); ++} ++ ++ ++int nopoll_strncasecompare(const char *first, const char *second, size_t max) ++{ ++ while(*first && *second && max) { ++ if(nopoll_raw_toupper(*first) != nopoll_raw_toupper(*second)) { ++ break; ++ } ++ max--; ++ first++; ++ second++; ++ } ++ if(0 == max) ++ return 1; /* they are equal this far */ ++ ++ return nopoll_raw_toupper(*first) == nopoll_raw_toupper(*second); ++} ++ +diff --git a/src/nopoll_strcase.h b/src/nopoll_strcase.h +new file mode 100644 +index 0000000..15ec7ca +--- /dev/null ++++ b/src/nopoll_strcase.h +@@ -0,0 +1,33 @@ ++/*************************************************************************** ++ * ++ * Copyright (C) 1998 - 2017, Daniel Stenberg, , et al. ++ * ++ * This software is licensed as described in the file COPYING, which ++ * you should have received as part of this distribution. The terms ++ * are also available at https://curl.haxx.se/docs/copyright.html. ++ * ++ * You may opt to use, copy, modify, merge, publish, distribute and/or sell ++ * copies of the Software, and permit persons to whom the Software is ++ * furnished to do so, under the terms of the COPYING file. ++ * ++ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY ++ * KIND, either express or implied. ++ * ++ ***************************************************************************/ ++ ++#ifndef __NOPOLL_STRCASE_H__ ++#define __NOPOLL_STRCASE_H__ ++ ++/* ++ * Only "raw" case insensitive strings. This is meant to be locale independent ++ * and only compare strings we know are safe for this. ++ * ++ * The function is capable of comparing a-z case insensitively even for ++ * non-ascii. ++ */ ++int nopoll_strcasecompare(const char *first, const char *second); ++int nopoll_strncasecompare(const char *first, const char *second, size_t max); ++ ++char nopoll_raw_toupper(char in); ++ ++#endif /* __NOPOLL_STRCASE_H__ */ +diff --git a/test/nopoll-regression-client.c b/test/nopoll-regression-client.c +index bd68694..5e56a7e 100644 +--- a/test/nopoll-regression-client.c ++++ b/test/nopoll-regression-client.c +@@ -267,6 +267,122 @@ nopoll_bool test_01_masking (void) { + return nopoll_true; + } + ++ ++nopoll_bool test_01_hostname_check (void) { ++ ++ /*success case*/ ++ if(! nopoll_cert_hostcheck("www.example.com", "www.example.com")) ++ { ++ printf ("ERROR (1): expected to match hostname validation www.example.com..\n"); ++ return nopoll_false; ++ } ++ if(! nopoll_cert_hostcheck("*.example.com", "www.example.com")) ++ { ++ printf ("ERROR (1): expected to match hostname validation *.example.com..\n"); ++ return nopoll_false; ++ } ++ if(! nopoll_cert_hostcheck("xxx*.example.com", "xxxwww.example.com")) ++ { ++ printf ("ERROR (1): expected to match hostname validation xxx*.example.com..\n"); ++ return nopoll_false; ++ } ++ if(! nopoll_cert_hostcheck("f*.example.com", "foo.example.com")) ++ { ++ printf ("ERROR (1): expected to match hostname validation f*.example.com..\n"); ++ return nopoll_false; ++ } ++ if(! nopoll_cert_hostcheck("192.168.0.0", "192.168.0.0")) ++ { ++ printf ("ERROR (1): expected to match hostname validation 192.168.0.0..\n"); ++ return nopoll_false; ++ } ++ if(! nopoll_cert_hostcheck("example.com","example.com")) ++ { ++ printf ("ERROR (1): expected to match hostname validation example.com..\n"); ++ return nopoll_false; ++ } ++ if(! nopoll_cert_hostcheck("fe80::3285:a9ff:fe46:b619","fe80::3285:a9ff:fe46:b619")) ++ { ++ printf ("ERROR (1): expected to match hostname validation fe80::3285:a9ff:fe46:b619..\n"); ++ return nopoll_false; ++ } ++ ++ /*Failure case*/ ++ ++ if(nopoll_cert_hostcheck("xxx.example.com", "www.example.com")) ++ { ++ printf ("ERROR (1): expected not to match hostname validation xxx.example.com\n"); ++ return nopoll_false; ++ } ++ if(nopoll_cert_hostcheck("*", "www.example.com")) ++ { ++ printf ("ERROR (1): expected not to match hostname validation for * with www.example.com\n"); ++ return nopoll_false; ++ } ++ if(nopoll_cert_hostcheck("*.*.com", "www.example.com")) ++ { ++ printf ("ERROR (1): expected to not match hostname validation *.*.com\n"); ++ return nopoll_false; ++ } ++ if(nopoll_cert_hostcheck("*.example.com", "baa.foo.example.com")) ++ { ++ printf ("ERROR (1): expected to not match hostname validation *.example.com with baa.foo.example.com..\n"); ++ return nopoll_false; ++ } ++ if(nopoll_cert_hostcheck("f*.example.com", "baa.example.com")) ++ { ++ printf ("ERROR (1): expected to not match hostname validation f*.example.com with baa.example.com\n"); ++ return nopoll_false; ++ } ++ if(nopoll_cert_hostcheck("*.com", "example.com")) ++ { ++ printf ("ERROR (1): expected to not match hostname validation *.com with example.com.\n"); ++ return nopoll_false; ++ } ++ if(nopoll_cert_hostcheck("*fail.com", "example.com")) ++ { ++ printf ("ERROR (1): expected to not match hostname validation for *fail.com with example.com\n"); ++ return nopoll_false; ++ } ++ if(nopoll_cert_hostcheck("*.example.", "www.example.")) ++ { ++ printf ("ERROR (1): expected to not match hostname validation for *.example. with www.example.\n"); ++ return nopoll_false; ++ } ++ if(nopoll_cert_hostcheck("*.example.", "www.example")) ++ { ++ printf ("ERROR (1): expected to not match hostname validation for *.example. with www.example\n"); ++ return nopoll_false; ++ } ++ if(nopoll_cert_hostcheck("", "www")) ++ { ++ printf ("ERROR (1): expected to not match hostname validation NULL with www \n"); ++ return nopoll_false; ++ } ++ if(nopoll_cert_hostcheck("*", "www")) ++ { ++ printf ("ERROR (1): expected to not match hostname validation * with www\n"); ++ return nopoll_false; ++ } ++ if(nopoll_cert_hostcheck("*::3285:a9ff:fe46:b619","fe80::3285:a9ff:fe46:b619")) ++ { ++ printf ("ERROR (1): expected to not match hostname validation *::3285:a9ff:fe46:b619 with fe80::3285:a9ff:fe46:b619 \n"); ++ return nopoll_false; ++ } ++ if(nopoll_cert_hostcheck("*.168.0.0", "192.168.0.0")) ++ { ++ printf ("ERROR (1): expected to not match hostname validation *.168.0.0 with 192.168.0.0\n"); ++ return nopoll_false; ++ } ++ if(nopoll_cert_hostcheck("www.example.com", "192.168.0.0")) ++ { ++ printf ("ERROR (1): expected to not match hostname validation for www.example.com with 192.168.0.0\n"); ++ return nopoll_false; ++ } ++ return nopoll_true; ++} ++ ++ + nopoll_bool test_01 (void) { + noPollCtx * ctx; + noPollConn * conn; +@@ -286,7 +402,7 @@ nopoll_bool test_01 (void) { + ctx = create_ctx (); + + /* call to create a connection */ +- conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error (conn=%p, conn->session=%d, NOPOLL_INVALID_SOCKET=%d)..\n", + conn, (int) nopoll_conn_socket (conn), (int) NOPOLL_INVALID_SOCKET); +@@ -352,7 +468,7 @@ nopoll_bool test_02 (void) { + ctx = create_ctx (); + + /* call to create a connection */ +- conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error.. (conn=%p, conn->session=%d, NOPOLL_INVALID_SOCKET=%d, errno=%d, strerr=%s)..\n", + conn, (int) nopoll_conn_socket (conn), (int) NOPOLL_INVALID_SOCKET, errno, strerror (errno)); +@@ -424,7 +540,7 @@ nopoll_bool test_03 (void) { + ctx = create_ctx (); + + /* call to create a connection */ +- conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; +@@ -493,7 +609,7 @@ nopoll_bool test_04 (int chunk_size) { + ctx = create_ctx (); + + /* call to create a connection */ +- conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL,NULL, NULL,NULL,0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; +@@ -584,7 +700,7 @@ nopoll_bool test_04a (void) { + ctx = create_ctx (); + + /* call to create a connection */ +- conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL,NULL, NULL,NULL,0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; +@@ -642,14 +758,14 @@ nopoll_bool test_04b (void) { + ctx = create_ctx (); + + /* call to create a connection */ +- conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL,NULL, NULL,NULL,0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; + } + + printf ("Test 04-b: waiting until connection is ok\n"); +- nopoll_conn_wait_until_connection_ready (conn, 5); ++ nopoll_conn_wait_until_connection_ready (conn, 5, NULL); + + printf ("Test 04-b: sending was quick as possible to flood local buffers..\n"); + +@@ -709,14 +825,14 @@ nopoll_bool test_04b (void) { + nopoll_conn_close (conn); + + /* call to create a connection */ +- conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL,NULL, NULL,NULL,0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; + } + + printf ("Test 04-b: waiting until connection is ok\n"); +- nopoll_conn_wait_until_connection_ready (conn, 5); ++ nopoll_conn_wait_until_connection_ready (conn, 5, NULL); + + /* send a cleanup message */ + bytes_written = nopoll_conn_send_text (conn, "release-message", 15); +@@ -757,14 +873,14 @@ nopoll_bool test_04c (void) { + ctx = create_ctx (); + + /* call to create a connection */ +- conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL,NULL, NULL,NULL,0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; + } + + printf ("Test 04-c: waiting until connection is ok\n"); +- nopoll_conn_wait_until_connection_ready (conn, 5); ++ nopoll_conn_wait_until_connection_ready (conn, 5, NULL); + + /* remove local file */ + if (stat ("copy-test-04c.txt", &file_info) == 0) { +@@ -920,7 +1036,7 @@ nopoll_bool test_05 (void) { + ctx = create_ctx (); + + /* call to create a connection */ +- conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL,NULL, NULL,NULL,0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; +@@ -958,6 +1074,50 @@ nopoll_bool test_05 (void) { + return nopoll_true; + } + ++ ++nopoll_bool test_05_hostname_validation (void) { ++ ++ char * fileName = "hostname-check.pem"; ++ char *hostname_valid = "test.nopoll.com"; ++ char *hostname_invalid = "invalid.com"; ++ FILE *fp = NULL; ++ ++ #if defined(NOPOLL_OS_WIN32) ++ fp = fopen (fileName, "rb"); ++ #else ++ fp = fopen (fileName, "r"); ++ #endif ++ ++ if(!fp) ++ { ++ printf("unable to open cert file for hostname validation: %s\n", fileName); ++ return nopoll_false; ++ } ++ ++ X509 *cert = PEM_read_X509(fp, NULL, NULL, NULL); ++ if(!cert) ++ { ++ printf("unable to parse certificate for hostname validation : %s\n", fileName); ++ fclose(fp); ++ return nopoll_false; ++ } ++ ++ if(nopoll_validate_hostname(hostname_valid, cert)) ++ { ++ printf("hostname %s doesn't match with dnsname \n",hostname_valid); ++ return nopoll_false; ++ } ++ ++ if(!nopoll_validate_hostname(hostname_invalid, cert)) ++ { ++ printf("hostname %s matched with dnsname \n",hostname_invalid); ++ return nopoll_false; ++ } ++ X509_free(cert); ++ fclose(fp); ++ return nopoll_true; ++} ++ + nopoll_bool test_06 (void) { + + noPollCtx * ctx; +@@ -972,7 +1132,7 @@ nopoll_bool test_06 (void) { + nopoll_conn_opts_ssl_peer_verify (opts, nopoll_false); + + /* call to create a connection */ +- conn = nopoll_conn_tls_new (ctx, opts, "localhost", "1235", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_tls_new (ctx, opts, "localhost", "1235", NULL, NULL, NULL, NULL,NULL,NULL,NULL,0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; +@@ -1018,9 +1178,10 @@ nopoll_bool test_07 (void) { + /* disable verification */ + opts = nopoll_conn_opts_new (); + nopoll_conn_opts_ssl_peer_verify (opts, nopoll_false); ++ nopoll_conn_opts_ssl_host_verify (opts, nopoll_false); + + /* call to create a connection */ +- conn = nopoll_conn_tls_new (ctx, opts, "localhost", "1235", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_tls_new (ctx, opts, "localhost", "1235", NULL, NULL, NULL, NULL,NULL,NULL,NULL,0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; +@@ -1062,7 +1223,7 @@ nopoll_bool test_08 (void) { + ctx = create_ctx (); + + /* call to connect to TLS port expecting non-TLS protocol */ +- conn = nopoll_conn_new (ctx, "localhost", "1235", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_new (ctx, "localhost", "1235", NULL, NULL, NULL, NULL,NULL, NULL,NULL,0); + + /* wait a bit 100ms */ + nopoll_sleep (100000); +@@ -1093,7 +1254,7 @@ nopoll_bool test_09 (void) { + nopoll_ctx_set_protocol_version (ctx, 12); + + /* call to connect to TLS port expecting non-TLS protocol */ +- conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL,NULL, NULL,NULL,0); + + /* wait a bit 100ms */ + nopoll_sleep (100000); +@@ -1121,7 +1282,7 @@ nopoll_bool test_10 (void) { + ctx = create_ctx (); + + /* call to connect from an origining that shouldn't be allowed */ +- conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, "http://deny.aspl.es"); ++ conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, "http://deny.aspl.es",NULL, NULL,NULL,0); + + /* wait a bit 100ms */ + nopoll_sleep (100000); +@@ -1149,9 +1310,9 @@ nopoll_bool test_11 (void) { + ctx = create_ctx (); + + /* create a working connection */ +- conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL,NULL, NULL,NULL,0); + +- if (! nopoll_conn_wait_until_connection_ready (conn, 5)) { ++ if (! nopoll_conn_wait_until_connection_ready (conn, 5, NULL)) { + printf ("ERROR: Expected a FAILING connection status due to origing denied, but it working..\n"); + return nopoll_false; + } /* end if */ +@@ -1191,9 +1352,9 @@ nopoll_bool test_12 (void) { + iterator = 0; + while (iterator < 1000) { + /* create a working connection */ +- conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL,NULL, NULL,NULL,0); + +- if (! nopoll_conn_wait_until_connection_ready (conn, 5)) { ++ if (! nopoll_conn_wait_until_connection_ready (conn, 5, NULL)) { + printf ("ERROR: Expected NOT to find a FAILING connection status, errno is=%d..\n", errno); + return nopoll_false; + } /* end if */ +@@ -1325,7 +1486,7 @@ nopoll_bool test_14 (void) { + ctx = create_ctx (); + + /* call to create a connection */ +- conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL,NULL, NULL,NULL,0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; +@@ -1395,7 +1556,7 @@ nopoll_bool test_15 (void) { + ctx = create_ctx (); + + /* call to create a connection */ +- conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL,NULL, NULL,NULL,0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; +@@ -1469,7 +1630,7 @@ nopoll_bool test_16 (void) { + ctx = create_ctx (); + + /* call to create a connection */ +- conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL,NULL, NULL,NULL,0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; +@@ -1627,7 +1788,7 @@ nopoll_bool test_17 (void) { + } /* end if */ + + /* call to create a connection */ +- conn = nopoll_conn_new (ctx, "localhost", "22351", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_new (ctx, "localhost", "22351", NULL, NULL, NULL, NULL,NULL, NULL,NULL,0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; +@@ -1709,9 +1870,10 @@ nopoll_bool test_18 (void) { + /* disable verification */ + opts = nopoll_conn_opts_new (); + nopoll_conn_opts_ssl_peer_verify (opts, nopoll_false); ++ nopoll_conn_opts_ssl_host_verify (opts, nopoll_false); + + /* call to create a connection */ +- conn = nopoll_conn_tls_new (ctx, opts, "localhost", "1235", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_tls_new (ctx, opts, "localhost", "1235", NULL, NULL, NULL, NULL,NULL,NULL,NULL,0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; +@@ -1746,9 +1908,10 @@ nopoll_bool test_19 (void) { + /* create options */ + opts = nopoll_conn_opts_new (); + nopoll_conn_opts_set_ssl_protocol (opts, NOPOLL_METHOD_SSLV23); ++ nopoll_conn_opts_ssl_host_verify (opts, nopoll_false); + + /* create connection */ +- conn = nopoll_conn_tls_new (ctx, opts, "localhost", "1236", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_tls_new (ctx, opts, "localhost", "1236", NULL, NULL, NULL, NULL,NULL,NULL,NULL,0); + + /* check connection */ + if (! nopoll_conn_is_ok (conn)) { +@@ -1767,9 +1930,10 @@ nopoll_bool test_19 (void) { + /* create options */ + opts = nopoll_conn_opts_new (); + nopoll_conn_opts_set_ssl_protocol (opts, NOPOLL_METHOD_SSLV23); ++ nopoll_conn_opts_ssl_host_verify (opts, nopoll_false); + + /* create connection */ +- conn = nopoll_conn_tls_new (ctx, opts, "localhost", "1235", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_tls_new (ctx, opts, "localhost", "1235", NULL, NULL, NULL, NULL,NULL,NULL,NULL,0); + + /* check connection */ + if (! nopoll_conn_is_ok (conn)) { +@@ -1786,10 +1950,11 @@ nopoll_bool test_19 (void) { + /* create options */ + opts = nopoll_conn_opts_new (); + nopoll_conn_opts_set_ssl_protocol (opts, NOPOLL_METHOD_SSLV3); ++ nopoll_conn_opts_ssl_host_verify (opts, nopoll_false); + + /* create connection */ + printf ("Test 19: checking SSLv3 with TLSv1..\n"); +- conn = nopoll_conn_tls_new (ctx, opts, "localhost", "1234", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_tls_new (ctx, opts, "localhost", "1234", NULL, NULL, NULL, NULL,NULL,NULL,NULL,0); + + /* check connection */ + if (nopoll_conn_is_ok (conn)) { +@@ -1850,7 +2015,7 @@ nopoll_bool test_21 (void) { + + /* call to create a connection */ + printf ("Test 21: check ssl connection (with auth certificate)..\n"); +- conn = nopoll_conn_tls_new (ctx, NULL, "localhost", "1239", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_tls_new (ctx, NULL, "localhost", "1239", NULL, NULL, NULL, NULL,NULL,NULL,NULL,0); + if (nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to FAILURE client connection status, but ok..\n"); + return nopoll_false; +@@ -1868,7 +2033,8 @@ nopoll_bool test_21 (void) { + NULL, + /* ca certificate */ + "root.pem"); +- conn = nopoll_conn_tls_new (ctx, opts, "localhost", "1239", NULL, NULL, NULL, NULL); ++ nopoll_conn_opts_ssl_host_verify (opts, nopoll_false); ++ conn = nopoll_conn_tls_new (ctx, opts, "localhost", "1239", NULL, NULL, NULL, NULL,NULL,NULL,NULL,0); + if (! test_sending_and_check_echo (conn, "Test 21", "This is a test")) { + printf ("ERROR: it should WORK, client certificate isn't working..\n"); + return nopoll_false; +@@ -1908,7 +2074,7 @@ nopoll_bool test_22 (void) { + ctx = create_ctx (); + + /* create connection */ +- conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL,NULL,NULL,NULL,0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; +@@ -1947,9 +2113,9 @@ nopoll_bool test_22 (void) { + /* disable verification */ + opts = nopoll_conn_opts_new (); + nopoll_conn_opts_ssl_peer_verify (opts, nopoll_false); +- ++ nopoll_conn_opts_ssl_host_verify (opts, nopoll_false); + /* call to create a connection */ +- conn = nopoll_conn_tls_new (ctx, opts, "localhost", "1235", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_tls_new (ctx, opts, "localhost", "1235", NULL, NULL, NULL, NULL,NULL,NULL,NULL,0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; +@@ -2037,7 +2203,7 @@ nopoll_bool test_23 (void) { + ctx = create_ctx (); + + /* create connection */ +- conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL,NULL,NULL,NULL,0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; +@@ -2052,7 +2218,7 @@ nopoll_bool test_23 (void) { + nopoll_conn_close (conn); + + /* create connection */ +- conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL,NULL,NULL,NULL,0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; +@@ -2075,9 +2241,9 @@ nopoll_bool test_23 (void) { + /* disable verification */ + opts = nopoll_conn_opts_new (); + nopoll_conn_opts_ssl_peer_verify (opts, nopoll_false); +- ++ nopoll_conn_opts_ssl_host_verify (opts, nopoll_false); + /* call to create a connection */ +- conn = nopoll_conn_tls_new (ctx, opts, "localhost", "1235", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_tls_new (ctx, opts, "localhost", "1235", NULL, NULL, NULL, NULL,NULL,NULL,NULL,0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; +@@ -2093,7 +2259,8 @@ nopoll_bool test_23 (void) { + /* call to create a connection second connection */ + opts = nopoll_conn_opts_new (); + nopoll_conn_opts_ssl_peer_verify (opts, nopoll_false); +- conn = nopoll_conn_tls_new (ctx, opts, "localhost", "1235", NULL, NULL, NULL, NULL); ++ nopoll_conn_opts_ssl_host_verify (opts, nopoll_false); ++ conn = nopoll_conn_tls_new (ctx, opts, "localhost", "1235", NULL, NULL, NULL, NULL,NULL,NULL,NULL,0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; +@@ -2129,9 +2296,10 @@ nopoll_bool test_24 (void) { + /* configure cookie */ + opts = nopoll_conn_opts_new (); + nopoll_conn_opts_set_cookie (opts, "theme=light; sessionToken=abc123"); +- ++ nopoll_conn_opts_ssl_host_verify (opts, nopoll_false); ++ + /* create connection */ +- conn = nopoll_conn_new_opts (ctx, opts, "localhost", "1234", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_new_opts (ctx, opts, "localhost", "1234", NULL, NULL, NULL, NULL,NULL,NULL,NULL,0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; +@@ -2184,9 +2352,9 @@ nopoll_bool test_25_check_cookie (noPollCtx * ctx, const char * cookie) { + + /* set a cookie bigger than 1044 */ + nopoll_conn_opts_set_cookie (opts, cookie); +- ++ nopoll_conn_opts_ssl_host_verify (opts, nopoll_false); + /* create connection */ +- conn = nopoll_conn_new_opts (ctx, opts, "localhost", "1234", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_new_opts (ctx, opts, "localhost", "1234", NULL, NULL, NULL, NULL,NULL,NULL,NULL,0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; +@@ -2237,7 +2405,7 @@ nopoll_bool test_26 (void) { + ctx = create_ctx (); + + /* create connection */ +- conn = nopoll_conn_new (ctx, "echo.websocket.org", "80", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_new (ctx, "echo.websocket.org", "80", NULL, NULL, NULL, NULL,NULL,NULL,NULL,0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; +@@ -2265,7 +2433,7 @@ nopoll_bool test_27 (void) { + ctx = create_ctx (); + + /* create connection */ +- conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, "/", "chat-protocol", "http://www.aspl.es"); ++ conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, "/", "chat-protocol", "http://www.aspl.es",NULL,NULL,NULL,0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; +@@ -2288,7 +2456,7 @@ nopoll_bool test_27 (void) { + nopoll_conn_close (conn); + + /* create connection */ +- conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, "/", "hello-protocol", "http://www.aspl.es"); ++ conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, "/", "hello-protocol", "http://www.aspl.es",NULL,NULL,NULL,0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; +@@ -2328,14 +2496,14 @@ nopoll_bool test_28 (void) { + ctx = create_ctx (); + + /* create connection */ +- conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL); ++ conn = nopoll_conn_new (ctx, "localhost", "1234", NULL, NULL, NULL, NULL,NULL,NULL,NULL,0); + if (! nopoll_conn_is_ok (conn)) { + printf ("ERROR: Expected to find proper client connection status, but found error..\n"); + return nopoll_false; + } /* end if */ + + /* wait until it is connected */ +- nopoll_conn_wait_until_connection_ready (conn, 5); ++ nopoll_conn_wait_until_connection_ready (conn, 5, NULL); + + /* send a message to request connection close with a particular message */ + if (nopoll_conn_send_text (conn, "close with message", 18) != 18) { +@@ -2431,6 +2599,13 @@ int main (int argc, char ** argv) + printf ("Test 01-masking: Library websocket content masking support [ FAILED ]\n"); + return -1; + } ++ ++ if (test_01_hostname_check ()) { ++ printf ("Test 01_hostname_check: Library websocket hostname validation [ OK ]\n"); ++ }else { ++ printf ("Test 01_hostname_check: Library websocket hostname validation [ FAILED ]\n"); ++ return -1; ++ } + + if (test_01 ()) { + printf ("Test 01: Simple connect and disconnect [ OK ]\n"); +@@ -2510,6 +2685,13 @@ int main (int argc, char ** argv) + return -1; + } + ++ if (test_05_hostname_validation()) { ++ printf ("Test 05 hostname_validation: testing basic TLS connect with hostname validation [ OK ]\n"); ++ } else { ++ printf ("Test 05 hostname_validation: testing basic TLS connect with hostname validation[ FAILED ]\n"); ++ return -1; ++ } ++ + if (test_06 ()) { + printf ("Test 06: testing basic TLS connect [ OK ]\n"); + } else { +-- +1.9.1 + + diff --git a/recipes-webpa/nopoll/nopoll_0.3.2.b232.bb b/recipes-webpa/nopoll/nopoll_0.3.2.b232.bb new file mode 100644 index 00000000..5ed118e4 --- /dev/null +++ b/recipes-webpa/nopoll/nopoll_0.3.2.b232.bb @@ -0,0 +1,25 @@ +DESCRIPTION = "Recipe to build nopoll" +HOMEPAGE = "http://www.aspl.es/nopoll/" +LICENSE = "LGPL-2.1" +LIC_FILES_CHKSUM = "file://COPYING;md5=f0504124678c1b3158146e0630229298" + +DEPENDS_append = " openssl" +LDFLAGS_append = " -pthread" +SRCREV = "41f9cd37cf3bf657a598e2330d99aad316f8d0dd" + +SRC_URI[md5sum] = "0f1ee40491e69d09b354771c6d44bb34" +SRC_URI[sha256sum] = "a1a25dcfe8406fcd355568ab0331f24eeec011a7b272df7b34a16db4a283b834" + +SRC_URI = "git://github.com/Comcast/nopoll.git;branch=nopoll_yocto" +SRC_URI_append_morty = " file://libnopoll.pc" + +inherit autotools pkgconfig + +S = "${WORKDIR}/git" + +do_install_append_morty() { + install -Dm644 ${S}/../libnopoll.pc ${D}${libdir}/pkgconfig/libnopoll.pc +} + +FILES_${PN} = "${bindir} ${libdir}/lib*${SOLIBS}" + diff --git a/recipes-webpa/parodus/files/0001-external-deps-removal.patch b/recipes-webpa/parodus/files/0001-external-deps-removal.patch new file mode 100644 index 00000000..39297eba --- /dev/null +++ b/recipes-webpa/parodus/files/0001-external-deps-removal.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 2958f1c..7d5ff1e 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -74,7 +74,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall") + #------------------------------------------------------------------------------- + find_package (Threads) + +-if (NOT BUILD_YOCTO) ++if (NOT BUILD_YOCTO AND NOT BUILD_BR) + + # base64 external dependency + #------------------------------------------------------------------------------- diff --git a/recipes-webpa/parodus/files/0002-parodus-service-to-lib.patch b/recipes-webpa/parodus/files/0002-parodus-service-to-lib.patch new file mode 100644 index 00000000..fb1073e7 --- /dev/null +++ b/recipes-webpa/parodus/files/0002-parodus-service-to-lib.patch @@ -0,0 +1,46 @@ +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 8138ca6..a02d27d 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -27,7 +27,12 @@ if (ENABLE_WEBCFGBIN) + set(SOURCES ${SOURCES} upstream_rbus.c) + endif (ENABLE_WEBCFGBIN) + ++if (PARODUS_SERVICE_APP) + add_executable(parodus ${SOURCES}) ++set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPARODUS_SERVICE_APP ") ++else () ++add_library(parodus SHARED ${SOURCES}) ++endif (PARODUS_SERVICE_APP) + + target_link_libraries (parodus + ${CMAKE_THREAD_LIBS_INIT} +@@ -59,4 +64,11 @@ endif (ENABLE_SESHAT) + if (ENABLE_WEBCFGBIN) + target_link_libraries (parodus -lrbus -lrbus-core) + endif (ENABLE_WEBCFGBIN) +-install (TARGETS parodus DESTINATION bin) ++ ++if (PARODUS_SERVICE_APP) ++set (INSTALL_DIR bin) ++else () ++set (INSTALL_DIR lib) ++endif () ++ ++install (TARGETS parodus DESTINATION ${INSTALL_DIR}) +diff --git a/src/main.c b/src/main.c +index b97a471..f56549b 100644 +--- a/src/main.c ++++ b/src/main.c +@@ -76,7 +76,11 @@ signal (int signo, Sigfunc *func) + /*----------------------------------------------------------------------------*/ + /* External Functions */ + /*----------------------------------------------------------------------------*/ ++#ifdef PARODUS_SERVICE_APP + int main( int argc, char **argv) ++#else ++int ParodusServiceMain( int argc, char **argv) ++#endif + { + set_global_shutdown_reason (SHUTDOWN_REASON_PARODUS_STOP); + signal(SIGTERM, sig_handler); diff --git a/recipes-webpa/parodus/files/0003-disable-Werror-Wall.patch b/recipes-webpa/parodus/files/0003-disable-Werror-Wall.patch new file mode 100644 index 00000000..eb75ffe2 --- /dev/null +++ b/recipes-webpa/parodus/files/0003-disable-Werror-Wall.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7d5ff1e..717502e 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -66,7 +66,7 @@ add_definitions("-DGIT_COMMIT_TAG=\"${GIT_COMMIT_TAG}\"") + add_definitions(-std=c99) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE -DNOPOLL_LOGGER ") + +-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wall -Wno-missing-field-initializers") ++set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=all -Wno-missing-field-initializers") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall") + + diff --git a/recipes-webpa/parodus/libparodus_1.0.bb b/recipes-webpa/parodus/libparodus_1.0.bb new file mode 100644 index 00000000..28c502f5 --- /dev/null +++ b/recipes-webpa/parodus/libparodus_1.0.bb @@ -0,0 +1,31 @@ +SUMMARY = "C implementation of the WebPA client coordinator" +HOMEPAGE = "https://github.com/Comcast/parodus" +SECTION = "libs" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e" + +DEPENDS_append = " cjson nopoll wrp-c wdmp-c trower-base64 nanomsg msgpack-c" + +SRCREV = "8263bb06c8c16dc114c800a3d29d0c8252f15619" +SRC_URI = "git://github.com/Comcast/libparodus.git" +PV = "git+${SRCPV}" + +S = "${WORKDIR}/git" + +inherit pkgconfig cmake + +CFLAGS_append = " \ + -I${STAGING_INCDIR} \ + -I${STAGING_INCDIR}/cjson \ + -I${STAGING_INCDIR}/nopoll \ + -I${STAGING_INCDIR}/wdmp-c \ + -I${STAGING_INCDIR}/wrp-c \ + -I${STAGING_INCDIR}/nanomsg \ + -I${STAGING_INCDIR}/trower-base64 \ + " + +EXTRA_OECMAKE_append = " -DBUILD_TESTING=OFF -DBUILD_YOCTO=true" + +FILES_SOLIBSDEV = "" +FILES_${PN} += "${libdir}/*.so" + diff --git a/recipes-webpa/parodus/parodus_1.0.bb b/recipes-webpa/parodus/parodus_1.0.bb new file mode 100644 index 00000000..8d7818e8 --- /dev/null +++ b/recipes-webpa/parodus/parodus_1.0.bb @@ -0,0 +1,46 @@ +SUMMARY = "parodus client library" +SECTION = "libs" +DESCRIPTION = "C client library for parodus" +HOMEPAGE = "https://github.com/Comcast/parodus" + +DEPENDS_append = " cjson nopoll wrp-c wdmp-c trower-base64 nanomsg msgpack-c util-linux cjwt ucresolv curl" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e" + +SRCREV="becacd899082f8c3eceacfa35f7475759060fc07" +SRC_URI = "\ + git://github.com/xmidt-org/parodus.git \ + file://0001-external-deps-removal.patch \ + file://0002-parodus-service-to-lib.patch \ + file://0003-disable-Werror-Wall.patch \ +" + +RDEPENDS_${PN} += "util-linux-uuidgen" +RDEPENDS_${PN}_append_dunfell = " bash" + +PV = "git+${SRCPV}" +S = "${WORKDIR}/git" + +LDFLAGS_append = " -lm -lcjson -lnopoll -lwrp-c -lwdmp-c -lmsgpackc -ltrower-base64 -luuid -lnanomsg -lcjwt -lucresolv -lresolv" + +CFLAGS_append = " \ + -I${STAGING_INCDIR} \ + -I${STAGING_INCDIR}/cjson \ + -I${STAGING_INCDIR}/nopoll \ + -I${STAGING_INCDIR}/wdmp-c \ + -I${STAGING_INCDIR}/wrp-c \ + -I${STAGING_INCDIR}/cimplog \ + -I${STAGING_INCDIR}/nanomsg \ + -I${STAGING_INCDIR}/trower-base64 \ + -I${STAGING_INCDIR}/cjwt \ + -I${STAGING_INCDIR}/ucresolv \ + -DFEATURE_DNS_QUERY \ +" + +inherit pkgconfig cmake +EXTRA_OECMAKE_append = " -DBUILD_TESTING=OFF -DBUILD_YOCTO=true -DFEATURE_DNS_QUERY=true" + +FILES_SOLIBSDEV = "" +FILES_${PN} += "${libdir}/*" + diff --git a/recipes-webpa/rbus-core/files/rbuscore-init b/recipes-webpa/rbus-core/files/rbuscore-init new file mode 100755 index 00000000..f3a1d2a3 --- /dev/null +++ b/recipes-webpa/rbus-core/files/rbuscore-init @@ -0,0 +1,37 @@ +#!/bin/sh + +start() { + printf "Starting RBusCore module: " + + start-stop-daemon -S -b -m -p /var/run/rbus_session_mgr.pid --exec /usr/bin/rbus_session_mgr /dev/nul + [ $? == 0 ] && echo "OK" || echo "FAIL" +} + +stop() { + printf "Stopping RBusCore module: " + + start-stop-daemon -K -q -p /var/run/rbus_session_mgr.pid + [ $? == 0 ] && echo "OK" || echo "FAIL" + rm -rf /var/run/rbus_session_mgr.pid +} + +restart() { + stop + start +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart|reload) + restart + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac +exit $? diff --git a/recipes-webpa/rbus-core/files/rbuscore.service b/recipes-webpa/rbus-core/files/rbuscore.service new file mode 100644 index 00000000..8698a2fd --- /dev/null +++ b/recipes-webpa/rbus-core/files/rbuscore.service @@ -0,0 +1,13 @@ +[Unit] +Description=RBus Core Service +After=rbus.service +Before=wpeframework.service + +[Service] +ExecStart=/etc/init.d/rbuscore start +ExecStop=/etc/init.d/rbuscore stop +ExecReload=/etc/init.d/rbuscore reload +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/recipes-webpa/rbus-core/rbus-core.bb b/recipes-webpa/rbus-core/rbus-core.bb new file mode 100644 index 00000000..80b9e170 --- /dev/null +++ b/recipes-webpa/rbus-core/rbus-core.bb @@ -0,0 +1,34 @@ +SUMMARY = "IPC bus powering RDK unified bus framework" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=075c59e772e98d304efd052108da3bd7" + +DEPENDS_append = " rtmessage msgpack-c" +S = "${WORKDIR}/git" +RECIPE_BRANCH ?= "rdk-next" +SRC_URI = "\ + git://code.rdkcentral.com/r/components/opensource/rbuscore.git;protocol=https;branch=${RECIPE_BRANCH} \ + file://rbuscore-init \ + file://rbuscore.service \ +" +SRCREV = "1ab589a0aaa70b10afb21fa135683fcbbb704964" + +inherit cmake pkgconfig systemd update-rc.d + +do_install_append() { + install -d ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/rbuscore-init ${D}${sysconfdir}/init.d/rbuscore + + if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then + install -d ${D}${systemd_unitdir}/system + install -m 644 ${WORKDIR}/rbuscore.service ${D}${systemd_unitdir}/system + fi +} + +PACKAGES =+ "${PN}-initscript" +INITSCRIPT_PACKAGES = "${PN}-initscript" +INITSCRIPT_NAME_${PN}-initscript = "rbuscore" +INITSCRIPT_PARAMS_${PN}-initscript = "defaults 30 24" +RRECOMMENDS_${PN} = "${PN}-initscript" + +FILES_${PN}-initscript = "${sysconfdir}/init.d/rbuscore" + diff --git a/recipes-webpa/rbus/files/rbus-init b/recipes-webpa/rbus/files/rbus-init new file mode 100755 index 00000000..62f53c17 --- /dev/null +++ b/recipes-webpa/rbus/files/rbus-init @@ -0,0 +1,39 @@ +#!/bin/sh + +start() { + printf "Starting RBus module: " + + mkdir /nvram + touch /nvram/rbus_support + start-stop-daemon -S -q -b -m -p /var/run/rtrouted.pid --exec /usr/bin/rtrouted /dev/nul + [ $? == 0 ] && echo "OK" || echo "FAIL" +} + +stop() { + printf "Stopping RBus module: " + + start-stop-daemon -K -q -p /var/run/rtrouted.pid + [ $? == 0 ] && echo "OK" || echo "FAIL" + rm -rf /var/run/rtrouted.pid +} + +restart() { + stop + start +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart|reload) + restart + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac +exit $? diff --git a/recipes-webpa/rbus/files/rbus.service b/recipes-webpa/rbus/files/rbus.service new file mode 100644 index 00000000..b240e8c4 --- /dev/null +++ b/recipes-webpa/rbus/files/rbus.service @@ -0,0 +1,12 @@ +[Unit] +Description=RBus Service +Before=wpeframework.service + +[Service] +ExecStart=/etc/init.d/rbus start +ExecStop=/etc/init.d/rbus stop +ExecReload=/etc/init.d/rbus reload +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/recipes-webpa/rbus/rbus.bb b/recipes-webpa/rbus/rbus.bb new file mode 100644 index 00000000..d351253d --- /dev/null +++ b/recipes-webpa/rbus/rbus.bb @@ -0,0 +1,37 @@ +SUMMARY = "rbus library component" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=ed63516ecab9f06e324238dd2b259549" + +DEPENDS_append = " rbus-core rtmessage linenoise" +S = "${WORKDIR}/git" +RECIPE_BRANCH ?= "rdk-next" +SRC_URI = "\ + git://code.rdkcentral.com/r/components/opensource/rbus.git;protocol=https;branch=${RECIPE_BRANCH} \ + file://rbus-init \ + file://rbus.service \ +" +SRCREV = "0e79c34e5faae52f77e7a196c5eae7595c1cdca4" + +inherit cmake pkgconfig systemd update-rc.d + +CFLAGS_append = " -Wno-unused-result" + +do_install_append() { + install -d ${D}${sysconfdir}/init.d + install -m 0755 ${WORKDIR}/rbus-init ${D}${sysconfdir}/init.d/rbus + + if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then + install -d ${D}${systemd_unitdir}/system + install -m 644 ${WORKDIR}/rbus.service ${D}${systemd_unitdir}/system + fi +} + +PACKAGES =+ "${PN}-initscript" +INITSCRIPT_PACKAGES = "${PN}-initscript" +INITSCRIPT_NAME_${PN}-initscript = "rbus" +INITSCRIPT_PARAMS_${PN}-initscript = "defaults 25 24" +RRECOMMENDS_${PN} = "${PN}-initscript" + +FILES_${PN}-initscript = "${sysconfdir}/init.d/rbus" + diff --git a/recipes-webpa/rtmessage/rtmessage.bb b/recipes-webpa/rtmessage/rtmessage.bb new file mode 100644 index 00000000..26a8ec6d --- /dev/null +++ b/recipes-webpa/rtmessage/rtmessage.bb @@ -0,0 +1,28 @@ +SUMMARY = "This recipes is used to compile and install rtmessage component" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=175792518e4ac015ab6696d16c4f607e" + +DEPENDS_append = " cjson" +S = "${WORKDIR}/git" +RECIPE_BRANCH ?= "rdk-next" +SRC_URI = "git://code.rdkcentral.com/r/rdk/components/opensource/rtmessage.git;protocol=https;branch=${RECIPE_BRANCH}" + +SRCREV ?= "94efc5bdf544b015fad9a8928e535a00ad59549d" + +EXTRA_OECMAKE_append = "\ + -DRDKC_BUILD=OFF \ + -DENABLE_RDKLOGGER=OFF \ + -DBUILD_DATAPROVIDER_LIB=OFF \ + -DBUILD_DMCLI=OFF \ + -DBUILD_DMCLI_SAMPLE_APP=OFF \ +" + +inherit cmake + +lcl_maybe_fortify = "" +FILES_${PN}-dev = "${includedir}/" +FILES_${PN} += "${libdir}/" +FILES_${PN} += "${bindir}/" +FILES_${PN}-dev += "${libdir}/cmake" + diff --git a/recipes-webpa/telemetry/files/0001-compile-telemetry-for-non-rdk-build.patch b/recipes-webpa/telemetry/files/0001-compile-telemetry-for-non-rdk-build.patch new file mode 100644 index 00000000..9cb8d334 --- /dev/null +++ b/recipes-webpa/telemetry/files/0001-compile-telemetry-for-non-rdk-build.patch @@ -0,0 +1,159 @@ +diff --git a/source/Makefile.am b/source/Makefile.am +index 7eb16df..a9aac9a 100644 +--- a/source/Makefile.am ++++ b/source/Makefile.am +@@ -54,7 +54,7 @@ telemetry2_0_CPPFLAGS = -fPIC -I${PKG_CONFIG_SYSROOT_DIR}$(includedir)/dbus-1.0 + -I${top_srcdir}/source/utils \ + -I${top_srcdir}/source/xconf-client \ + -I${top_srcdir}/source/interChipHelper +-telemetry2_0_LDFLAGS = -lrdkloggers -lcjson ++telemetry2_0_LDFLAGS = -lcjson + if ENABLE_CCSP_SUPPORT + telemetry2_0_LDFLAGS+=-lccsp_common -lwebconfig_framework + telemetry2_0_SOURCES += t2ssp/ssp_main.c t2ssp/ssp_action.c t2ssp/ssp_messagebus_interface.c t2ssp/dm_pack_datamodel.c +diff --git a/source/telemetry2_0.c b/source/telemetry2_0.c +index 9cb1e4a..85c5d26 100644 +--- a/source/telemetry2_0.c ++++ b/source/telemetry2_0.c +@@ -86,7 +86,9 @@ T2ERROR initTelemetry() + static void terminate() { + uninitXConfClient(); + ReportProfiles_uninit(); ++#ifdef RDK_BUILD + rdk_logger_deinit(); ++#endif + if(0 != remove("/tmp/.t2ReadyToReceiveEvents")){ + T2Info("%s Unable to remove ready to receive event flag \n", __FUNCTION__); + } +diff --git a/source/utils/Makefile.am b/source/utils/Makefile.am +index 3c11351..aadb953 100644 +--- a/source/utils/Makefile.am ++++ b/source/utils/Makefile.am +@@ -22,7 +22,7 @@ AM_CFLAGS += -D_ANSC_LITTLE_ENDIAN_ + + lib_LTLIBRARIES = libutils.la + libutils_la_SOURCES = vector.c t2collection.c t2log_wrapper.c t2MtlsUtils.c +-libutils_la_LDFLAGS = -shared -fPIC -lrdkloggers -lsecure_wrapper ++libutils_la_LDFLAGS = -shared -fPIC + libutils_la_CPPFLAGS = -fPIC -I${PKG_CONFIG_SYSROOT_DIR}$(includedir)/dbus-1.0 \ + -I${PKG_CONFIG_SYSROOT_DIR}$(libdir)/dbus-1.0/include \ + -I${PKG_CONFIG_SYSROOT_DIR}$(includedir) \ +diff --git a/source/utils/t2MtlsUtils.c b/source/utils/t2MtlsUtils.c +index 419bc5b..2b7f60d 100644 +--- a/source/utils/t2MtlsUtils.c ++++ b/source/utils/t2MtlsUtils.c +@@ -23,7 +23,9 @@ + #include + #include + #include ++#ifdef ENABLE_RDKB_SUPPORT + #include ++#endif + #include + + #include "t2log_wrapper.h" +@@ -46,17 +48,20 @@ void initMtls() { + T2Debug("%s ++in\n", __FUNCTION__); + // Prepare certs required for mTls commmunication + // CPG doesn't support api's - will have to use v_secure_system calls ++#ifdef ENABLE_RDKB_SUPPORT + v_secure_system("/usr/bin/GetConfigFile %s", staticMtlsDestFile); + v_secure_system("/usr/bin/GetConfigFile %s", dynamicMtlsDestFile); + T2Debug("%s --out\n", __FUNCTION__); +- ++#endif + } + + void uninitMtls() { ++#ifdef ENABLE_RDKB_SUPPORT + T2Debug("%s ++in\n", __FUNCTION__); + v_secure_system("rm -f %s", staticMtlsDestFile); + v_secure_system("rm -f %s", dynamicMtlsDestFile); + T2Debug("%s --out\n", __FUNCTION__); ++#endif + + } + +@@ -66,7 +71,7 @@ void uninitMtls() { + T2ERROR getMtlsCerts(char **certName, char **phrase) { + + T2ERROR ret = T2ERROR_FAILURE; +- ++#if 0 + T2Debug("%s ++in\n", __FUNCTION__); + char buf[124]; + memset(buf, 0, sizeof(buf)); +@@ -125,6 +130,7 @@ T2ERROR getMtlsCerts(char **certName, char **phrase) { + T2Debug("Using Cert = %s Pass = %s \n", *certName, *phrase); + + T2Debug("%s --out\n", __FUNCTION__); ++#endif + return ret; + } + +diff --git a/source/utils/t2log_wrapper.c b/source/utils/t2log_wrapper.c +index e547d2e..c1ba77d 100644 +--- a/source/utils/t2log_wrapper.c ++++ b/source/utils/t2log_wrapper.c +@@ -24,15 +24,22 @@ + #include + #include "t2log_wrapper.h" + ++#ifdef ENABLE_RDKB_SUPPORT + unsigned int rdkLogLevel = RDK_LOG_INFO; ++#else ++unsigned int rdkLogLevel = 0; ++#endif + + void LOGInit() + { ++#ifdef ENABLE_RDKB_SUPPORT + rdk_logger_init(DEBUG_INI_NAME); ++#endif + } + + void T2Log(unsigned int level, const char *msg, ...) + { ++#ifdef ENABLE_RDKB_SUPPORT + va_list arg; + char *pTempChar = NULL; + int ret = 0; +@@ -84,4 +91,5 @@ void T2Log(unsigned int level, const char *msg, ...) + } + } + va_end(arg); ++#endif + } +diff --git a/source/utils/t2log_wrapper.h b/source/utils/t2log_wrapper.h +index e63d857..2989da1 100644 +--- a/source/utils/t2log_wrapper.h ++++ b/source/utils/t2log_wrapper.h +@@ -20,7 +20,9 @@ + #ifndef _CCSP_T2LOG_WRPPER_H_ + #define _CCSP_T2LOG_WRPPER_H_ + ++#ifdef ENABLE_RDKB_SUPPORT + #include "rdk_debug.h" ++#endif + + #define DEBUG_INI_NAME "/etc/debug.ini" + +@@ -30,11 +32,17 @@ + #define ENABLE_DEBUG_FLAG "/opt/enable_t2_debug" + #endif + ++#ifdef ENABLE_RDKB_SUPPORT + #define T2Error(...) T2Log(RDK_LOG_ERROR, __VA_ARGS__) + #define T2Info(...) T2Log(RDK_LOG_INFO, __VA_ARGS__) + #define T2Warning(...) T2Log(RDK_LOG_WARN, __VA_ARGS__) + #define T2Debug(...) T2Log(RDK_LOG_DEBUG, __VA_ARGS__) +- ++#else ++#define T2Error(...) ++#define T2Info(...) ++#define T2Warning(...) ++#define T2Debug(...) ++#endif + + void LOGInit(); + diff --git a/recipes-webpa/telemetry/telemetry.bb b/recipes-webpa/telemetry/telemetry.bb new file mode 100644 index 00000000..d5138ed4 --- /dev/null +++ b/recipes-webpa/telemetry/telemetry.bb @@ -0,0 +1,48 @@ +SUMMARY = "This recipe compiles Telemetry" +SECTION = "console/utils" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=175792518e4ac015ab6696d16c4f607e" + +DEPENDS_append = " curl cjson glib-2.0 rbus" +S = "${WORKDIR}/git" +RECIPE_BRANCH ?= "rdk-next" +SRC_URI = "\ + git://code.rdkcentral.com/r/rdk/components/generic/telemetry.git;protocol=https;branch=${RECIPE_BRANCH} \ + file://0001-compile-telemetry-for-non-rdk-build.patch \ +" +SRCREV ?= "36e2d55d36242dd716eeb607667c90247cc8fa51" + +PV = "git${SRCPV}" + +RDEPENDS_${PN} += "curl cjson glib-2.0 rbus" + +inherit pkgconfig autotools systemd pythonnative + +LDFLAGS_append = "\ + -lpthread \ + -lstdc++ \ +" + +do_install_append () { + install -d ${D}/usr/include/ + install -d ${D}/lib/rdk/ + install -d ${D}${systemd_unitdir}/system + install -m 644 ${S}/include/telemetry_busmessage_sender.h ${D}/usr/include/ + install -m 644 ${S}/include/telemetry2_0.h ${D}/usr/include/ + install -m 0755 ${S}/source/commonlib/t2Shared_api.sh ${D}${base_libdir}/rdk + rm -fr ${D}/usr/lib/libtelemetry_msgsender.la +} + +FILES_${PN} = "\ + ${bindir}/telemetry2_0 \ + ${bindir}/t2rbusMethodSimulator \ + ${bindir}/telemetry2_0_client \ + ${systemd_unitdir}/system \ +" +FILES_${PN} += "${libdir}/*.so*" +FILES_${PN} += "${base_libdir}/rdk/*" + +FILES_SOLIBSDEV = "" +INSANE_SKIP_${PN} += "dev-so" + diff --git a/recipes-webpa/trower-base64/trower-base64_1.0.bb b/recipes-webpa/trower-base64/trower-base64_1.0.bb new file mode 100644 index 00000000..f35e4b09 --- /dev/null +++ b/recipes-webpa/trower-base64/trower-base64_1.0.bb @@ -0,0 +1,15 @@ +SUMMARY = "C implementation of base64 encode/decode" +HOMEPAGE = "https://github.com/Comcast/trower-base64" +SECTION = "libs" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=b1e01b26bacfc2232046c90a330332b3" + +SRCREV = "fbb9440ae2bc1118866baefcea7ff814f16613dd" +SRC_URI = "git://github.com/Comcast/trower-base64.git;branch=main" +PV = "git+${SRCPV}" + +S = "${WORKDIR}/git" + +inherit pkgconfig cmake + +EXTRA_OECMAKE_append = " -DBUILD_TESTING=OFF" diff --git a/recipes-webpa/ucresolv/files/0001-use-headers-from-sysroot.patch b/recipes-webpa/ucresolv/files/0001-use-headers-from-sysroot.patch new file mode 100644 index 00000000..0e40b665 --- /dev/null +++ b/recipes-webpa/ucresolv/files/0001-use-headers-from-sysroot.patch @@ -0,0 +1,195 @@ +Date: Thu, 11 Jun 2020 12:10:40 +0500 + +From: 8d286900729068b07216e9c8541380054315c03f Mon Sep 17 00:00:00 2001 + +Subject: [PATCH] Use embedded gconv.h during compilation + +Source: OPENSOURCE + +License: LGPL-2.1-or-later + +Upstream-Status: pending + +Signed-off-by: Nikolai Merinov +--- + include/sysdeps/generic/_G_config.h | 2 +- + include/sysdeps/generic/gconv.h | 154 ++++++++++++++++++++++++++++ + 2 files changed, 155 insertions(+), 1 deletion(-) + create mode 100644 include/sysdeps/generic/gconv.h + +diff --git a/include/sysdeps/generic/_G_config.h b/include/sysdeps/generic/_G_config.h +index c34cea8..f44a3d4 100644 +--- a/include/sysdeps/generic/_G_config.h ++++ b/include/sysdeps/generic/_G_config.h +@@ -29,7 +29,7 @@ typedef struct + __mbstate_t __state; + } _G_fpos64_t; + #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T +-# include "/usr/include/gconv.h" ++# include + typedef union + { + struct __gconv_info __cd; +diff --git a/include/sysdeps/generic/gconv.h b/include/sysdeps/generic/gconv.h +new file mode 100644 +index 0000000..8d8ce58 +--- /dev/null ++++ b/include/sysdeps/generic/gconv.h +@@ -0,0 +1,154 @@ ++/* Copyright (C) 1997-2016 Free Software Foundation, Inc. ++ This file is part of the GNU C Library. ++ ++ The GNU C Library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 2.1 of the License, or (at your option) any later version. ++ ++ The GNU C Library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with the GNU C Library; if not, see ++ . */ ++ ++/* This header provides no interface for a user to the internals of ++ the gconv implementation in the libc. Therefore there is no use ++ for these definitions beside for writing additional gconv modules. */ ++ ++#ifndef _GCONV_H ++#define _GCONV_H 1 ++ ++#include ++#define __need_mbstate_t ++#define __need_wint_t ++#include ++#define __need_size_t ++#define __need_wchar_t ++#include ++ ++/* ISO 10646 value used to signal invalid value. */ ++#define __UNKNOWN_10646_CHAR ((wchar_t) 0xfffd) ++ ++/* Error codes for gconv functions. */ ++enum ++{ ++ __GCONV_OK = 0, ++ __GCONV_NOCONV, ++ __GCONV_NODB, ++ __GCONV_NOMEM, ++ ++ __GCONV_EMPTY_INPUT, ++ __GCONV_FULL_OUTPUT, ++ __GCONV_ILLEGAL_INPUT, ++ __GCONV_INCOMPLETE_INPUT, ++ ++ __GCONV_ILLEGAL_DESCRIPTOR, ++ __GCONV_INTERNAL_ERROR ++}; ++ ++ ++/* Flags the `__gconv_open' function can set. */ ++enum ++{ ++ __GCONV_IS_LAST = 0x0001, ++ __GCONV_IGNORE_ERRORS = 0x0002, ++ __GCONV_SWAP = 0x0004, ++ __GCONV_TRANSLIT = 0x0008 ++}; ++ ++ ++/* Forward declarations. */ ++struct __gconv_step; ++struct __gconv_step_data; ++struct __gconv_loaded_object; ++ ++ ++/* Type of a conversion function. */ ++typedef int (*__gconv_fct) (struct __gconv_step *, struct __gconv_step_data *, ++ const unsigned char **, const unsigned char *, ++ unsigned char **, size_t *, int, int); ++ ++/* Type of a specialized conversion function for a single byte to INTERNAL. */ ++typedef wint_t (*__gconv_btowc_fct) (struct __gconv_step *, unsigned char); ++ ++/* Constructor and destructor for local data for conversion step. */ ++typedef int (*__gconv_init_fct) (struct __gconv_step *); ++typedef void (*__gconv_end_fct) (struct __gconv_step *); ++ ++ ++/* Description of a conversion step. */ ++struct __gconv_step ++{ ++ struct __gconv_loaded_object *__shlib_handle; ++ const char *__modname; ++ ++ int __counter; ++ ++ char *__from_name; ++ char *__to_name; ++ ++ __gconv_fct __fct; ++ __gconv_btowc_fct __btowc_fct; ++ __gconv_init_fct __init_fct; ++ __gconv_end_fct __end_fct; ++ ++ /* Information about the number of bytes needed or produced in this ++ step. This helps optimizing the buffer sizes. */ ++ int __min_needed_from; ++ int __max_needed_from; ++ int __min_needed_to; ++ int __max_needed_to; ++ ++ /* Flag whether this is a stateful encoding or not. */ ++ int __stateful; ++ ++ void *__data; /* Pointer to step-local data. */ ++}; ++ ++/* Additional data for steps in use of conversion descriptor. This is ++ allocated by the `init' function. */ ++struct __gconv_step_data ++{ ++ unsigned char *__outbuf; /* Output buffer for this step. */ ++ unsigned char *__outbufend; /* Address of first byte after the output ++ buffer. */ ++ ++ /* Is this the last module in the chain. */ ++ int __flags; ++ ++ /* Counter for number of invocations of the module function for this ++ descriptor. */ ++ int __invocation_counter; ++ ++ /* Flag whether this is an internal use of the module (in the mb*towc* ++ and wc*tomb* functions) or regular with iconv(3). */ ++ int __internal_use; ++ ++ __mbstate_t *__statep; ++ __mbstate_t __state; /* This element must not be used directly by ++ any module; always use STATEP! */ ++}; ++ ++ ++/* Combine conversion step description with data. */ ++typedef struct __gconv_info ++{ ++ size_t __nsteps; ++ struct __gconv_step *__steps; ++ __extension__ struct __gconv_step_data __data __flexarr; ++} *__gconv_t; ++ ++/* Transliteration using the locale's data. */ ++extern int __gconv_transliterate (struct __gconv_step *step, ++ struct __gconv_step_data *step_data, ++ const unsigned char *inbufstart, ++ const unsigned char **inbufp, ++ const unsigned char *inbufend, ++ unsigned char **outbufstart, ++ size_t *irreversible); ++ ++#endif /* gconv.h */ +-- +2.17.1 + diff --git a/recipes-webpa/ucresolv/files/0002-ucresolv_error.patch b/recipes-webpa/ucresolv/files/0002-ucresolv_error.patch new file mode 100644 index 00000000..91345875 --- /dev/null +++ b/recipes-webpa/ucresolv/files/0002-ucresolv_error.patch @@ -0,0 +1,20 @@ +diff --git a/src/res_send.c b/src/res_send.c +index 8fa6caa..fa34a73 100644 +--- a/src/res_send.c ++++ b/src/res_send.c +@@ -953,7 +953,7 @@ reopen (res_state statp, int *terrno, int ns) + ucresolv_debug("UCLIBC reopen\n"); + if (EXT(statp).nssocks[ns] == -1) { + struct sockaddr *nsap = get_nsaddr (statp, ns); +- socklen_t slen; ++ socklen_t slen=0; + + /* only try IPv6 if IPv6 NS and if not failed before */ + if (nsap->sa_family == AF_INET6 && !statp->ipv6_unavail) { +diff --git a/include/bits/string2.h b/include/bits/string2.h +index e4c4c70..e998cdc 100644 +--- a/include/bits/string2.h ++++ b/include/bits/string2.h +@@ -1 +1 @@ +-#include ++//#include diff --git a/recipes-webpa/ucresolv/ucresolv_1.0.bb b/recipes-webpa/ucresolv/ucresolv_1.0.bb new file mode 100644 index 00000000..7e235156 --- /dev/null +++ b/recipes-webpa/ucresolv/ucresolv_1.0.bb @@ -0,0 +1,30 @@ +SUMMARY = "ucresolv library" +DESCRIPTION = "Recipe to build library for uclibc resolver missing features" +HOMEPAGE = "https://github.com/Comcast/libucresolv" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e" + +SRCREV = "996c3778b14936c26b49e30f8dbb4933cb2df49a" +SRC_URI = "\ + git://github.com/Comcast/libucresolv.git \ + file://0001-use-headers-from-sysroot.patch \ + file://0002-ucresolv_error.patch \ +" +PV = "git+${SRCPV}" +S = "${WORKDIR}/git" +PR = "r1" + +inherit cmake pkgconfig +lcl_maybe_fortify = "" +EXTRA_OECMAKE_append = "\ + -DBUILD_TESTING=OFF \ + -DBUILD_YOCTO=true \ + -D_FORTIFY_SOURCE=0 \ +" +CFLAGS_append = " -I${S}/include/wcsmbs" + +FILES_${PN} += "${libdir}/*" +FILES_SOLIBSDEV = "" +INSANE_SKIP_${PN} += "dev-so" + diff --git a/recipes-webpa/util/files/0001-support-non-rdk-build-with-syscfg-alone.patch b/recipes-webpa/util/files/0001-support-non-rdk-build-with-syscfg-alone.patch new file mode 100644 index 00000000..06b2ada7 --- /dev/null +++ b/recipes-webpa/util/files/0001-support-non-rdk-build-with-syscfg-alone.patch @@ -0,0 +1,81 @@ +diff --git a/configure.ac b/configure.ac +index ab515d19..0573c0f9 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -146,9 +146,18 @@ AC_CONFIG_FILES([ + source/service_dslite/Makefile + ])] ) + +-AC_CONFIG_FILES( +- Makefile +- source/Makefile ++# Checks for RDK Feature Support ++AC_ARG_ENABLE([rdk_feature_support], ++[ --enable-rdk_feature_support=val Turn on RDK Feature, val=true or false], ++[case "${enableval}" in ++ yes) rdk_feature_support=true ;; ++ no) rdk_feature_support=false ;; ++ *) AC_MSG_ERROR([bad value ${enableval} for --enable-rdk_feature_support]) ;; ++esac],[rdk_feature_support=true]) ++AM_CONDITIONAL(RDK_FEATURE_SUPPORT, test x"$rdk_feature_support" = x"true") ++ ++AM_COND_IF( [RDK_FEATURE_SUPPORT], [ ++AC_CONFIG_FILES([ + source/dhcpproxy/Makefile + source/firewall/Makefile + source/firewall_log/Makefile +@@ -172,9 +181,6 @@ AC_CONFIG_FILES( + source/service_routed/Makefile + source/service_udhcpc/Makefile + source/service_wan/Makefile +- source/syscfg/Makefile +- source/syscfg/cmd/Makefile +- source/syscfg/lib/Makefile + source/sysevent/Makefile + source/sysevent/control/Makefile + source/sysevent/fork_helper/Makefile +@@ -182,7 +188,6 @@ AC_CONFIG_FILES( + source/sysevent/proxy/Makefile + source/sysevent/server/Makefile + source/trigger/Makefile +- source/ulog/Makefile + source/utapi/Makefile + source/utapi/cmd/Makefile + source/utapi/lib/Makefile +@@ -195,6 +200,17 @@ AC_CONFIG_FILES( + source/util/rpc/client/Makefile + source/util/rpc/server/Makefile + source/util/utils/Makefile ++ ++])] ) ++ ++ ++AC_CONFIG_FILES( ++ Makefile ++ source/Makefile ++ source/syscfg/Makefile ++ source/syscfg/cmd/Makefile ++ source/syscfg/lib/Makefile ++ source/ulog/Makefile + ) + + AC_SUBST(GTEST_ENABLE_FLAG) +diff --git a/source/Makefile.am b/source/Makefile.am +index 1d20ee6d..8fef129f 100644 +--- a/source/Makefile.am ++++ b/source/Makefile.am +@@ -16,10 +16,13 @@ + # See the License for the specific language governing permissions and + # limitations under the License. + ########################################################################## +-SUBDIRS = ulog syscfg sysevent services utctx utapi firewall firewall_log dhcpproxy newhost macclone util pal pmon services service_wan trigger igd service_routed service_ipv6 scripts service_multinet service_dhcp service_udhcpc ++SUBDIRS = ulog syscfg ++if RDK_FEATURE_SUPPORT ++SUBDIRS += sysevent services utctx utapi firewall firewall_log dhcpproxy newhost macclone util pal pmon services service_wan trigger igd service_routed service_ipv6 scripts service_multinet service_dhcp service_udhcpc + if DSLITE_FEATURE_SUPPORT + SUBDIRS += service_dslite + endif + if WITH_GTEST_SUPPORT + SUBDIRS += test + endif ++endif diff --git a/recipes-webpa/util/files/syscfg.db b/recipes-webpa/util/files/syscfg.db new file mode 100644 index 00000000..93e51893 --- /dev/null +++ b/recipes-webpa/util/files/syscfg.db @@ -0,0 +1,3 @@ +X_COMCAST-COM_CID=0 +X_COMCAST-COM_CMC=123457 +X_COMCAST-COM_SyncProtocolVersion=TestVersion diff --git a/recipes-webpa/util/utopia.bb b/recipes-webpa/util/utopia.bb new file mode 100644 index 00000000..5b301c87 --- /dev/null +++ b/recipes-webpa/util/utopia.bb @@ -0,0 +1,52 @@ +SUMMARY = "CCSP Utopia" +HOMEPAGE = "http://github.com/belvedere-yocto/Utopia" + +LICENSE = "Apache-2.0 & BSD-3-Clause" +LIC_FILES_CHKSUM = "file://LICENSE;md5=baa21dec03307f641a150889224a157f" + + +DEPENDS_append = " ccsp-common-library telemetry" + +RDEPENDS_${PN}_append_dunfell = " bash" + +require recipes-webpa/ccsp/ccsp_common.inc +RECIPE_BRANCH ?= "rdk-next" +SRC_URI = "\ + git://code.rdkcentral.com/r/rdkb/components/opensource/ccsp/Utopia.git;protocol=https;branch=${RECIPE_BRANCH} \ + file://0001-support-non-rdk-build-with-syscfg-alone.patch \ + file://syscfg.db \ +" + +SRCREV = "2173ef621df472162671f5ed8d0878df28fc112c" +PV = "git${SRCPV}" +S = "${WORKDIR}/git" + + +inherit autotools pkgconfig + +SECURITY_STRINGFORMAT = "" + +CFLAGS_append = " \ + -DSAFEC_DUMMY_API \ + -I${STAGING_INCDIR}/ccsp \ + -I${STAGING_INCDIR}/tirpc \ +" + +LDFLAGS_append = " -ltirpc -lrt -lpthread" +EXTRA_OECONF_append = " --enable-rdk_feature_support=no" + +do_install_append () { + install -D -m 0644 ${S}/source/syscfg/lib/syscfg.h ${D}${includedir}/syscfg/syscfg.h + + # Creating symbolic links to install files in specific directory as in legacy builds + ln -sf /usr/bin/syscfg ${D}${bindir}/syscfg_create + ln -sf /usr/bin/syscfg ${D}${bindir}/syscfg_destroy + ln -sf /usr/bin/syscfg ${D}${bindir}/syscfg_format + ln -sf /usr/bin/syscfg ${D}${bindir}/syscfg_check + + install -d ${D}/usr/ccsp + install -m 644 ${S}/../syscfg.db ${D}/usr/ccsp +} + +FILES_${PN} += " /usr/ccsp ${libdir} ${bindir}" + diff --git a/recipes-webpa/wdmp-c/wdmp-c_1.0.bb b/recipes-webpa/wdmp-c/wdmp-c_1.0.bb new file mode 100644 index 00000000..094f3924 --- /dev/null +++ b/recipes-webpa/wdmp-c/wdmp-c_1.0.bb @@ -0,0 +1,25 @@ +SUMMARY = "C library for WebPA Data Model Parser (WDMP)" +HOMEPAGE = "https://github.com/Comcast/wdmp-c" +SECTION = "libs" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e" + +DEPENDS_append = " cjson cimplog" + +SRCREV = "9a4b0e031cab6c3be96a18a31f2e4217b6fd14e2" +SRC_URI = "git://github.com/xmidt-org/wdmp-c.git" +PV = "git+${SRCPV}" + +S = "${WORKDIR}/git" + +inherit pkgconfig cmake + +EXTRA_OECMAKE_append = " -DBUILD_TESTING=OFF -DBUILD_YOCTO=true" + +LDFLAGS_append = " -lm" + +# The libwdmp-c.so shared lib isn't versioned, so force the .so file into the +# run-time package (and keep it out of the -dev package). + +FILES_SOLIBSDEV = "" +FILES_${PN} += "${libdir}/*.so" diff --git a/recipes-webpa/wrp-c/wrp-c_1.0.bb b/recipes-webpa/wrp-c/wrp-c_1.0.bb new file mode 100644 index 00000000..ca59c19c --- /dev/null +++ b/recipes-webpa/wrp-c/wrp-c_1.0.bb @@ -0,0 +1,23 @@ +SUMMARY = "C library for Web Routing Protocol (WRP)" +HOMEPAGE = "https://github.com/Comcast/wrp-c" +SECTION = "libs" +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e" + +DEPENDS_append = " trower-base64 msgpack-c cimplog" + +SRCREV = "71f8a39fe39f98da007ed4cdabbb192be1da1685" +SRC_URI = "git://github.com/xmidt-org/wrp-c.git" +PV = "git+${SRCPV}" + +S = "${WORKDIR}/git" + +inherit pkgconfig cmake + +EXTRA_OECMAKE_append = " -DBUILD_TESTING=OFF -DBUILD_YOCTO=true" + +LDFLAGS_append = " -lcimplog -lmsgpackc -ltrower-base64" + +FILES_SOLIBSDEV = "" +FILES_${PN} += "${libdir}/*.so" + diff --git a/recipes-wpe/wpeframework/include/webpa.inc b/recipes-wpe/wpeframework/include/webpa.inc new file mode 100644 index 00000000..62410d37 --- /dev/null +++ b/recipes-wpe/wpeframework/include/webpa.inc @@ -0,0 +1,46 @@ +# Provides configuration for the WebPA Plugin +WPE_WEBPA_AUTOSTART ??= "true" +WPE_WEBPA_PINGWAITTIME ??= "60" +WPE_WEBPA_WEBPAURL ??= "http://192.168.1.1" +WPE_WEBPA_PARODUSLOCALURL ??= "tcp://127.0.0.1:6666" +WPE_WEBPA_PARTENRID ??= "Metrological" +WPE_WEBPA_BACKOFFMAX ??= "9" +WPE_WEBPA_CERTPATH ??= "/etc/ssl/certs/ca-certificates.crt" +WPE_WEBPA_DEPENDENCIES ??= "parodus libparodus libtinyxml wdmp-c wrp-c" + +PACKAGECONFIG[webpa] = "\ + -DPLUGIN_WEBPA=ON \ + -DPLUGIN_WEBPA_AUTOSTART="${WPE_WEBPA_AUTOSTART}" \ + -DPLUGIN_WEBPA_PINGWAITTIME="${WPE_WEBPA_PINGWAITTIME}" \ + -DPLUGIN_WEBPA_WEBPAURL="${WPE_WEBPA_WEBPAURL}" \ + -DPLUGIN_WEBPA_PARODUSLOCALURL="${WPE_WEBPA_PARODUSLOCALURL}" \ + -DPLUGIN_WEBPA_PARTENRID="${WPE_WEBPA_PARTENRID}" \ + -DPLUGIN_WEBPA_BACKOFFMAX="${WPE_WEBPA_BACKOFFMAX}" \ + -DPLUGIN_WEBPA_CERTPATH="${WPE_WEBPA_CERTPATH}" \ + ,-DPLUGIN_WEBPA=OFF,${WPE_WEBPA_DEPENDENCIES},${WPE_WEBPA_DEPENDENCIES} \ +" + +WPE_WEBPA_GENERICCLIENTURL = "tcp://127.0.0.1:6667" +WPE_WEBPA_DATAMODELFILE = "/usr/share/WPEFramework/WebPA/data-model.xml" +WPE_WEBPA_NOTIFYCONFIGFILE = "/usr/share/WPEFramework/WebPA/notify_webpa_cfg.json" + +PACKAGECONFIG[webpa_generic] = "\ + -DPLUGIN_WEBPA_GENERIC_ADAPTER=ON \ + -DPLUGIN_WEBPA_GENERICCLIENTURL="${WPE_WEBPA_GENERICCLIENTURL}" \ + -DPLUGIN_WEBPA_DATAMODELFILE="${WPE_WEBPA_DATAMODELFILE}" \ + -DPLUGIN_WEBPA_NOTIFYCONFIGFILE="${WPE_WEBPA_NOTIFYCONFIGFILE}" \ + ,-DPLUGIN_WEBPA_GENERIC_ADAPTER=OFF, \ +" + +PACKAGECONFIG[webpa_generic_deviceinfo] = "\ + -DPLUGIN_WEBPA_DEVICE_INFO=ON \ + ,-DPLUGIN_WEBPA_DEVICE_INFO=OFF,procps,procps \ +" + +PACKAGECONFIG[webpa_ccsp] = "\ + -DPLUGIN_WEBPA_CCSP=ON \ + -DPLUGIN_WEBPA_CCSP_CLIENTURL="${WPE_WEBPA_CCSPCLIENTURL}" \ + -DPLUGIN_WEBPA_CCSP_CONFIGFILE="${WPE_WEBPA_CCSP_CONFIGFILE}" \ + -DPLUGIN_WEBPA_CCSP_DATAFILE="${WPE_WEBPA_CCSP_DATAFILE}" \ + , -DPLUGIN_WEBPA_CCSP=OFF,\ +"