From: Yu Date: Mon, 29 Jun 2020 04:58:19 +0000 (+0900) Subject: Replace codes that repeat several times X-Git-Tag: submit/tizen/20200713.070339~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F08%2F237308%2F1;p=platform%2Fcore%2Fapi%2Fnsd.git Replace codes that repeat several times Change-Id: Idf4e6bbaaae9e8ff5ef5e89d81fa13bc65d9cf7e Signed-off-by: Yu jiung --- diff --git a/packaging/capi-network-nsd.spec b/packaging/capi-network-nsd.spec index ea04c1c..827609a 100644 --- a/packaging/capi-network-nsd.spec +++ b/packaging/capi-network-nsd.spec @@ -18,6 +18,7 @@ BuildRequires: pkgconfig(dns_sd) BuildRequires: pkgconfig(gssdp-1.0) BuildRequires: pkgconfig(cynara-client) %if 0%{?gcov:1} +BuildRequires: tar BuildRequires: lcov %endif @@ -92,19 +93,15 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` -DDATA_ROOT_DIR:PATH=%{_datadir} \ -DFULLVER=%{version} \ -DMAJORVER=${MAJORVER} -make %{?jobs:-j%jobs} - -%if 0%{?gcov:1} -mkdir -p gcov-obj -find . -name '*.gcno' -exec cp '{}' gcov-obj ';' -%endif +make %{?_smp_mflags} %install -rm -rf %{buildroot} + %make_install %if 0%{?gcov:1} -mkdir -p %{buildroot}%{_datadir}/gcov/obj -install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj +find .. -name '*.gcno' | tar cf %{name}-gcov.tar -T - +install -d -m 755 %{buildroot}%{_datadir}/gcov/obj +tar xf %{name}-gcov.tar -C %{buildroot}%{_datadir}/gcov/obj %endif %post -n libnsd-dns-sd -p /sbin/ldconfig @@ -141,5 +138,5 @@ install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj %if 0%{?gcov:1} %files gcov -%{_datadir}/gcov/obj/* +%{_datadir}/gcov/* %endif diff --git a/src/dns-sd/dns-sd.c b/src/dns-sd/dns-sd.c index 31e11d4..66b0bc8 100644 --- a/src/dns-sd/dns-sd.c +++ b/src/dns-sd/dns-sd.c @@ -38,11 +38,30 @@ #define SMACK_LABEL_LEN 255 +#define CHECK_INITIALIZED()\ + do {\ + if (__dnssd_is_init() == false) {\ + DNSSD_LOGE("Not initialized");\ + __DNSSD_LOG_FUNC_EXIT__;\ + return DNSSD_ERROR_NOT_INITIALIZED;\ + } \ + } while (0) + +#define CHECK_PERMISSION()\ + do {\ + if (__dnssd_check_permission() == false) {\ + DNSSD_LOGE("Permission denied");\ + __DNSSD_LOG_FUNC_EXIT__;\ + return DNSSD_ERROR_PERMISSION_DENIED;\ + } \ + } while (0) + static __thread GSList *dnssd_handle_list = NULL; static __thread GSList *resolve_handle_list = NULL; static __thread bool g_is_init = false; static __thread GDBusConnection *netconfig_bus = NULL; +//LCOV_EXCL_START static const char *dnssd_error_to_string(DNSServiceErrorType dnssd_service_error) { switch (dnssd_service_error) { @@ -108,6 +127,8 @@ static const char *dnssd_error_to_string(DNSServiceErrorType dnssd_service_error return "UNSUPPORTED_ERROR"; } } +//LCOV_EXCL_STOP + static dnssd_handle_s *__dnssd_check_handle_validity(dnssd_handle_s *handle) { __DNSSD_LOG_FUNC_ENTER__; @@ -167,7 +188,6 @@ static resolve_reply_data *__dnssd_check_resolve_reply_data_validity( return NULL; } -//LCOV_EXCL_START static bool __dnssd_check_permission() { FILE *fd; @@ -211,15 +231,18 @@ static bool __dnssd_check_permission() return (ret == CYNARA_API_ACCESS_ALLOWED) ? true : false; } -//LCOV_EXCL_STOP static bool __dnssd_is_init(void) { return g_is_init; } -//LCOV_EXCL_START -static int __dnssd_launch_mdns_dbus(void) +static void __dnssd_set_initialized(bool initialized) +{ + g_is_init = initialized; +} + +static int __connect_netconfig_gdbus(void) { GError *g_error = NULL; GVariant *params; @@ -266,22 +289,13 @@ static int __dnssd_launch_mdns_dbus(void) DNSSD_LOGD("Successfully launched mdnsresponder"); return DNSSD_ERROR_NONE; } -//LCOV_EXCL_STOP -//LCOV_EXCL_START -static int __dnssd_launch_mdns() +static void __disconnect_netconfig_gdbus(void) { - __DNSSD_LOG_FUNC_ENTER__; - int res = DNSSD_ERROR_NONE; - res = __dnssd_launch_mdns_dbus(); - if (res != DNSSD_ERROR_NONE) - DNSSD_LOGE("Fail to send dbus msg"); - __DNSSD_LOG_FUNC_EXIT__; - return res; + g_object_unref(netconfig_bus); + netconfig_bus = NULL; } -//LCOV_EXCL_STOP -//LCOV_EXCL_START static gboolean __dnssd_process_result(GIOCondition condition, DNSServiceRef sd_ref) { DNSServiceErrorType err; @@ -299,6 +313,7 @@ static gboolean __dnssd_process_result(GIOCondition condition, DNSServiceRef sd_ return FALSE; } return TRUE; +//LCOV_EXCL_START case G_IO_HUP: DNSSD_LOGE("G_IO_HUP event received."); break; @@ -312,6 +327,7 @@ static gboolean __dnssd_process_result(GIOCondition condition, DNSServiceRef sd_ DNSSD_LOGE("Unknown event received."); break; } +//LCOV_EXCL_STOP return FALSE; } @@ -352,7 +368,6 @@ static gboolean __dnssd_resolve_data_io_events(GIOChannel *source, return __dnssd_process_result(condition, reply->sd_ref); } -//LCOV_EXCL_STOP static guint __dnssd_io_add_watch(int fd, GIOFunc func, gpointer data) { @@ -399,20 +414,19 @@ int dnssd_initialize(void) CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); if (__dnssd_is_init() == true) { - DNSSD_LOGE("Already initialized"); //LCOV_EXCL_LINE - __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE - return DNSSD_ERROR_INVALID_OPERATION; //LCOV_EXCL_LINE + DNSSD_LOGE("Already initialized"); + __DNSSD_LOG_FUNC_EXIT__; + return DNSSD_ERROR_INVALID_OPERATION; } - res = __dnssd_launch_mdns(); - + res = __connect_netconfig_gdbus(); if (res != DNSSD_ERROR_NONE) { DNSSD_LOGE("Failed to launch mdnsresponder"); __DNSSD_LOG_FUNC_EXIT__; return res; } - g_is_init = true; + __dnssd_set_initialized(true); __DNSSD_LOG_FUNC_EXIT__; return DNSSD_ERROR_NONE; @@ -424,16 +438,11 @@ int dnssd_deinitialize(void) CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); - if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_NOT_INITIALIZED; - } + CHECK_INITIALIZED(); - g_is_init = false; + __dnssd_set_initialized(false); - g_object_unref(netconfig_bus); - netconfig_bus = NULL; + __disconnect_netconfig_gdbus(); __DNSSD_LOG_FUNC_EXIT__; return DNSSD_ERROR_NONE; @@ -449,11 +458,7 @@ int dnssd_create_local_service(const char *service_type, CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); - if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE - __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE - return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE - } + CHECK_INITIALIZED(); if (dnssd_service == NULL || service_type == NULL || __dnssd_get_struct_from_handle(*dnssd_service) != NULL) { @@ -490,18 +495,11 @@ int dnssd_create_local_service(const char *service_type, return DNSSD_ERROR_NONE; } -int dnssd_destroy_local_service(dnssd_service_h dnssd_service) +static int __get_valid_registered_handle(dnssd_service_h dnssd_service, dnssd_handle_s **handle) { - __DNSSD_LOG_FUNC_ENTER__; - dnssd_handle_s *local_handle = NULL; - - CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); + dnssd_handle_s *local_handle; - if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE - __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE - return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE - } + CHECK_INITIALIZED(); local_handle = __dnssd_get_struct_from_handle(dnssd_service); if (local_handle == NULL) { @@ -516,6 +514,23 @@ int dnssd_destroy_local_service(dnssd_service_h dnssd_service) return DNSSD_ERROR_SERVICE_NOT_FOUND; } + *handle = local_handle; + + return DNSSD_ERROR_NONE; +} + +int dnssd_destroy_local_service(dnssd_service_h dnssd_service) +{ + __DNSSD_LOG_FUNC_ENTER__; + dnssd_handle_s *local_handle = NULL; + int res; + + CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); + + res = __get_valid_registered_handle(dnssd_service, &local_handle); + if (res != DNSSD_ERROR_NONE) + return res; + DNSSD_LOGD("Destroy handle: [%p]->[%u]", local_handle, dnssd_service); dnssd_handle_list = g_slist_remove(dnssd_handle_list, local_handle); @@ -525,6 +540,7 @@ int dnssd_destroy_local_service(dnssd_service_h dnssd_service) g_free(local_handle); local_handle = NULL; + DNSSD_LOGD("g_slist length [%d]", g_slist_length(dnssd_handle_list)); __DNSSD_LOG_FUNC_EXIT__; return DNSSD_ERROR_NONE; } @@ -535,14 +551,13 @@ int dnssd_service_set_name(dnssd_service_h local_service, __DNSSD_LOG_FUNC_ENTER__; dnssd_handle_s *local_handle = NULL; dnssd_register_data_s *reg = NULL; + int res; CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); - if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE - __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE - return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE - } + res = __get_valid_registered_handle(local_service, &local_handle); + if (res != DNSSD_ERROR_NONE) + return res; if (service_name == NULL) { DNSSD_LOGD("Service name is NULL"); @@ -550,19 +565,6 @@ int dnssd_service_set_name(dnssd_service_h local_service, return DNSSD_ERROR_INVALID_PARAMETER; } - local_handle = __dnssd_get_struct_from_handle(local_service); - if (local_handle == NULL) { - DNSSD_LOGD("Service Handler not found"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_SERVICE_NOT_FOUND; - } - - if (local_handle->op_type != DNSSD_TYPE_REGISTER) { - DNSSD_LOGD("DNSSD service is not a local service"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_SERVICE_NOT_FOUND; - } - reg = GET_REG_DATA_P(local_handle); g_free(reg->service_name); reg->service_name = g_strdup(service_name); @@ -578,14 +580,13 @@ int dnssd_service_set_port(dnssd_service_h local_service, int port) __DNSSD_LOG_FUNC_ENTER__; dnssd_handle_s *local_handle = NULL; dnssd_register_data_s *reg = NULL; + int res; CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); - if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE - __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE - return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE - } + res = __get_valid_registered_handle(local_service, &local_handle); + if (res != DNSSD_ERROR_NONE) + return res; if (port < 0 || port > 65535) { DNSSD_LOGD("Invalid port range"); @@ -593,19 +594,6 @@ int dnssd_service_set_port(dnssd_service_h local_service, int port) return DNSSD_ERROR_INVALID_PARAMETER; } - local_handle = __dnssd_get_struct_from_handle(local_service); - if (local_handle == NULL) { - DNSSD_LOGD("Service Handler not found"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_SERVICE_NOT_FOUND; - } - - if (local_handle->op_type != DNSSD_TYPE_REGISTER) { - DNSSD_LOGD("DNSSD service is not a local service"); //LCOV_EXCL_LINE - __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE - return DNSSD_ERROR_SERVICE_NOT_FOUND; //LCOV_EXCL_LINE - } - reg = GET_REG_DATA_P(local_handle); reg->port = port; @@ -615,21 +603,19 @@ int dnssd_service_set_port(dnssd_service_h local_service, int port) return DNSSD_ERROR_NONE; } -//LCOV_EXCL_START int dnssd_service_set_interface(dnssd_service_h local_service, const char *interface) { __DNSSD_LOG_FUNC_ENTER__; dnssd_handle_s *local_handle = NULL; dnssd_register_data_s *reg = NULL; unsigned int if_index = 0; + int res; CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); - if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE - __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE - return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE - } + res = __get_valid_registered_handle(local_service, &local_handle); + if (res != DNSSD_ERROR_NONE) + return res; if ((if_index = if_nametoindex(interface)) == 0) { DNSSD_LOGE("Invalid interface name"); @@ -638,19 +624,6 @@ int dnssd_service_set_interface(dnssd_service_h local_service, const char *inter } DNSSD_LOGD("Interface index: %u", if_index); - local_handle = __dnssd_get_struct_from_handle(local_service); - if (local_handle == NULL) { - DNSSD_LOGD("Service Handler not found"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_SERVICE_NOT_FOUND; - } - - if (local_handle->op_type != DNSSD_TYPE_REGISTER) { - DNSSD_LOGD("DNSSD service is not a local service"); //LCOV_EXCL_LINE - __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE - return DNSSD_ERROR_SERVICE_NOT_FOUND; //LCOV_EXCL_LINE - } - reg = GET_REG_DATA_P(local_handle); reg->if_index = if_index; @@ -659,7 +632,7 @@ int dnssd_service_set_interface(dnssd_service_h local_service, const char *inter __DNSSD_LOG_FUNC_EXIT__; return DNSSD_ERROR_NONE; } -//LCOV_EXCL_STOP + int dnssd_service_add_txt_record(dnssd_service_h local_service, const char *key, unsigned short length, const void *value) @@ -669,27 +642,13 @@ int dnssd_service_add_txt_record(dnssd_service_h local_service, TXTRecordRef *txt_record; dnssd_handle_s *local_handle = NULL; dnssd_register_data_s *reg = NULL; + int res; CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); - if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE - __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE - return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE - } - - local_handle = __dnssd_get_struct_from_handle(local_service); - if (local_handle == NULL) { - DNSSD_LOGD("Service Handler not found"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_SERVICE_NOT_FOUND; - } - - if (local_handle->op_type != DNSSD_TYPE_REGISTER) { - DNSSD_LOGD("DNSSD service is not a local service"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_SERVICE_NOT_FOUND; - } + res = __get_valid_registered_handle(local_service, &local_handle); + if (res != DNSSD_ERROR_NONE) + return res; if (key == NULL) { DNSSD_LOGE("key is NULL"); @@ -738,14 +697,13 @@ int dnssd_service_remove_txt_record(dnssd_service_h local_service, dnssd_handle_s *local_handle; dnssd_register_data_s *reg = NULL; unsigned short txt_len; + int res; CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); - if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE - __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE - return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE - } + res = __get_valid_registered_handle(local_service, &local_handle); + if (res != DNSSD_ERROR_NONE) + return res; if (key == NULL) { DNSSD_LOGE("key is NULL"); @@ -753,19 +711,6 @@ int dnssd_service_remove_txt_record(dnssd_service_h local_service, return DNSSD_ERROR_INVALID_PARAMETER; } - local_handle = __dnssd_get_struct_from_handle(local_service); - if (local_handle == NULL) { - DNSSD_LOGD("Service Handler not found"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_SERVICE_NOT_FOUND; - } - - if (local_handle->op_type != DNSSD_TYPE_REGISTER) { - DNSSD_LOGD("DNSSD service is not a local service"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_SERVICE_NOT_FOUND; - } - reg = GET_REG_DATA_P(local_handle); txt_record = &(reg->txt_ref); @@ -799,27 +744,13 @@ int dnssd_service_set_record(dnssd_service_h local_service, unsigned short type, DNSServiceErrorType ret; dnssd_handle_s *local_handle = NULL; dnssd_register_data_s *reg; + int res; CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); - if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE - __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE - return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE - } - - local_handle = __dnssd_get_struct_from_handle(local_service); - if (local_handle == NULL) { - DNSSD_LOGD("Service Handler not found"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_SERVICE_NOT_FOUND; - } - - if (local_handle->op_type != DNSSD_TYPE_REGISTER) { - DNSSD_LOGD("DNSSD service is not a local service"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_SERVICE_NOT_FOUND; - } + res = __get_valid_registered_handle(local_service, &local_handle); + if (res != DNSSD_ERROR_NONE) + return res; reg = GET_REG_DATA_P(local_handle); DNSSD_LOGD("Record Type %d Record len %d", type, length); @@ -829,9 +760,9 @@ int dnssd_service_set_record(dnssd_service_h local_service, unsigned short type, ret = DNSServiceAddRecord(local_handle->sd_ref, &(reg->record_ref), local_handle->flags, type, length, data, 0); } else { - DNSSD_LOGD("Updating DNS Service Record"); //LCOV_EXCL_LINE - ret = DNSServiceUpdateRecord(local_handle->sd_ref, reg->record_ref, //LCOV_EXCL_LINE - local_handle->flags, length, data, 0); //LCOV_EXCL_LINE + DNSSD_LOGD("Updating DNS Service Record"); + ret = DNSServiceUpdateRecord(local_handle->sd_ref, reg->record_ref, + local_handle->flags, length, data, 0); } if (ret != kDNSServiceErr_NoError) { @@ -857,27 +788,13 @@ int dnssd_service_unset_record(dnssd_service_h local_service, DNSServiceErrorType dnssd_err = 0; uint32_t version = 0; uint32_t size = sizeof(version); + int res; CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); - if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE - __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE - return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE - } - - local_handle = __dnssd_get_struct_from_handle(local_service); - if (local_handle == NULL) { - DNSSD_LOGD("Service Handler not found"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_SERVICE_NOT_FOUND; - } - - if (local_handle->op_type != DNSSD_TYPE_REGISTER) { - DNSSD_LOGD("DNSSD service is not a local service"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_SERVICE_NOT_FOUND; - } + res = __get_valid_registered_handle(local_service, &local_handle); + if (res != DNSSD_ERROR_NONE) + return res; reg = GET_REG_DATA_P(local_handle); @@ -961,26 +878,15 @@ int dnssd_register_local_service(dnssd_service_h local_service, dnssd_register_data_s *reg = NULL; void *data; unsigned short length; + int res; CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); - if (__dnssd_check_permission() == false) { - DNSSD_LOGE("Permission denied"); //LCOV_EXCL_LINE - return DNSSD_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } - - if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE - __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE - return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE - } + CHECK_PERMISSION(); - local_handle = __dnssd_get_struct_from_handle(local_service); - if (local_handle == NULL) { - DNSSD_LOGD("Service Handler not found"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_SERVICE_NOT_FOUND; - } + res = __get_valid_registered_handle(local_service, &local_handle); + if (res != DNSSD_ERROR_NONE) + return res; if (register_cb == NULL) { DNSSD_LOGE("No callback provided"); @@ -988,12 +894,6 @@ int dnssd_register_local_service(dnssd_service_h local_service, return DNSSD_ERROR_INVALID_PARAMETER; } - if (local_handle->op_type != DNSSD_TYPE_REGISTER) { - DNSSD_LOGD("DNSSD service is not a local service"); //LCOV_EXCL_LINE - __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE - return DNSSD_ERROR_SERVICE_NOT_FOUND; //LCOV_EXCL_LINE - } - reg = GET_REG_DATA_P(local_handle); if (reg->service_name == NULL) { @@ -1033,30 +933,16 @@ int dnssd_register_local_service(dnssd_service_h local_service, int dnssd_deregister_local_service(dnssd_service_h local_service) { __DNSSD_LOG_FUNC_ENTER__; + DNSServiceErrorType ret; dnssd_handle_s *local_handle = NULL; dnssd_register_data_s *reg; - int ret; + int res; CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); - if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE - __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE - return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE - } - - local_handle = __dnssd_get_struct_from_handle(local_service); - if (local_handle == NULL) { - DNSSD_LOGD("Service Handler not found"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_SERVICE_NOT_FOUND; - } - - if (local_handle->op_type != DNSSD_TYPE_REGISTER) { - DNSSD_LOGD("DNSSD service is not a local service"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_SERVICE_NOT_FOUND; - } + res = __get_valid_registered_handle(local_service, &local_handle); + if (res != DNSSD_ERROR_NONE) + return res; if (local_handle->sd_ref == NULL) { DNSSD_LOGE("Invalid DNS SD Client"); @@ -1087,7 +973,6 @@ int dnssd_deregister_local_service(dnssd_service_h local_service) return DNSSD_ERROR_NONE; } -//LCOV_EXCL_START static gboolean __remove_service_getaddrinfo_socket(gpointer user_data) { DNSSD_LOGD("Remove DNSServiceGetAddrInfo socket"); @@ -1099,9 +984,7 @@ static gboolean __remove_service_getaddrinfo_socket(gpointer user_data) local_handle->sd_ref = NULL; return FALSE; } -//LCOV_EXCL_STOP -//LCOV_EXCL_START static void __dnssd_getaddrinfo_reply_cb(DNSServiceRef sd_ref, unsigned int flags, unsigned int if_index, DNSServiceErrorType error_code, const char *host_name, @@ -1179,9 +1062,7 @@ static void __dnssd_getaddrinfo_reply_cb(DNSServiceRef sd_ref, g_idle_add_full(G_PRIORITY_HIGH, __remove_service_getaddrinfo_socket, local_handle, NULL); } -//LCOV_EXCL_STOP -//LCOV_EXCL_START static int __dnssd_getaddrinfo(dnssd_handle_s *dnssd_handle, unsigned int flags, unsigned int if_index, const char *host_name, char *service_name, const char *fullname, const char *txt_record, @@ -1264,9 +1145,7 @@ static int __dnssd_getaddrinfo(dnssd_handle_s *dnssd_handle, unsigned int flags, return DNSSD_ERROR_NONE; } -//LCOV_EXCL_STOP -//LCOV_EXCL_START static gboolean __remove_service_resolve_socket(gpointer user_data) { DNSSD_LOGD("Remove DNSServiceResolve socket"); @@ -1278,9 +1157,7 @@ static gboolean __remove_service_resolve_socket(gpointer user_data) resolve_data->sd_ref = NULL; return FALSE; } -//LCOV_EXCL_STOP -//LCOV_EXCL_START static void __dnssd_resolve_reply_cb(DNSServiceRef sd_ref, unsigned int flags, unsigned int if_index, DNSServiceErrorType error_code, const char *fullname, const char *host_name, @@ -1299,12 +1176,11 @@ static void __dnssd_resolve_reply_cb(DNSServiceRef sd_ref, unsigned int flags, __dnssd_getaddrinfo(resolve_data->dnssd_handle, flags, if_index, host_name, resolve_data->service_name, fullname, (const char *) txt_record, txt_len, port); + g_idle_add_full(G_PRIORITY_HIGH, __remove_service_resolve_socket, resolve_data, NULL); } -//LCOV_EXCL_STOP -//LCOV_EXCL_START static int __dnssd_resolve_dns_service(dnssd_handle_s *dnssd_handle, unsigned int flags, unsigned int if_index, const char *service_name, const char *type, const char *domain) @@ -1342,9 +1218,7 @@ static int __dnssd_resolve_dns_service(dnssd_handle_s *dnssd_handle, __DNSSD_LOG_FUNC_EXIT__; return DNSSD_ERROR_NONE; } -//LCOV_EXCL_STOP -//LCOV_EXCL_START static dnssd_handle_s *__dnssd_get_found_handle(dnssd_service_h browse_service, const char *service_name) { @@ -1377,9 +1251,7 @@ static dnssd_handle_s *__dnssd_get_found_handle(dnssd_service_h browse_service, __DNSSD_LOG_FUNC_EXIT__; return NULL; } -//LCOV_EXCL_STOP -//LCOV_EXCL_START static void __dnssd_browse_reply_cb(DNSServiceRef sd_ref, unsigned int flags, unsigned int if_index, DNSServiceErrorType error_code, const char *service_name, const char *service_type, @@ -1445,7 +1317,6 @@ static void __dnssd_browse_reply_cb(DNSServiceRef sd_ref, unsigned int flags, } __DNSSD_LOG_FUNC_EXIT__; } -//LCOV_EXCL_STOP int dnssd_start_browsing_service(const char *service_type, dnssd_browser_h *dnssd_service, dnssd_found_cb found_cb, @@ -1459,30 +1330,17 @@ int dnssd_start_browsing_service(const char *service_type, CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); - if (__dnssd_check_permission() == false) { - DNSSD_LOGE("Permission denied"); //LCOV_EXCL_LINE - return DNSSD_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE - } + CHECK_PERMISSION(); - if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE - __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE - return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE - } + CHECK_INITIALIZED(); - if (dnssd_service == NULL || service_type == NULL || + if (found_cb == NULL || dnssd_service == NULL || service_type == NULL || __dnssd_get_struct_from_handle(*dnssd_service) != NULL) { DNSSD_LOGE("Invalid Parameter"); __DNSSD_LOG_FUNC_EXIT__; return DNSSD_ERROR_INVALID_PARAMETER; } - if (found_cb == NULL) { - DNSSD_LOGE("Callback Not Provided"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_INVALID_PARAMETER; - } - local_handle = (dnssd_handle_s *)g_try_malloc0(BROWSE_SIZE); if (local_handle == NULL) { DNSSD_LOGE("Failed to Allocate Memory"); //LCOV_EXCL_LINE @@ -1526,7 +1384,6 @@ int dnssd_start_browsing_service(const char *service_type, return DNSSD_ERROR_NONE; } -//LCOV_EXCL_START int dnssd_start_browsing_service_on_interface(const char *service_type, const char *interface, dnssd_browser_h *dnssd_service, dnssd_found_cb found_cb, void *user_data) @@ -1540,25 +1397,17 @@ int dnssd_start_browsing_service_on_interface(const char *service_type, const ch CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); - if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE - __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE - return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE - } + CHECK_PERMISSION(); - if (dnssd_service == NULL || service_type == NULL || + CHECK_INITIALIZED(); + + if (found_cb == NULL || dnssd_service == NULL || service_type == NULL || __dnssd_get_struct_from_handle(*dnssd_service) != NULL) { DNSSD_LOGE("Invalid Parameter"); __DNSSD_LOG_FUNC_EXIT__; return DNSSD_ERROR_INVALID_PARAMETER; } - if (found_cb == NULL) { - DNSSD_LOGE("Callback Not Provided"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_INVALID_PARAMETER; - } - local_handle = (dnssd_handle_s *)g_try_malloc0(BROWSE_SIZE); if (local_handle == NULL) { DNSSD_LOGE("Failed to Allocate Memory"); //LCOV_EXCL_LINE @@ -1568,7 +1417,7 @@ int dnssd_start_browsing_service_on_interface(const char *service_type, const ch if ((if_index = if_nametoindex(interface)) == 0) { DNSSD_LOGE("Invalid interface name"); - g_free(local_handle); //LCOV_EXCL_LINE + g_free(local_handle); __DNSSD_LOG_FUNC_EXIT__; return DNSSD_ERROR_INVALID_PARAMETER; } @@ -1609,7 +1458,36 @@ int dnssd_start_browsing_service_on_interface(const char *service_type, const ch __DNSSD_LOG_FUNC_EXIT__; return DNSSD_ERROR_NONE; } -//LCOV_EXCL_STOP + +static int __get_valid_browsing_handle(dnssd_service_h dnssd_service, dnssd_handle_s **handle) +{ + dnssd_handle_s *local_handle; + + CHECK_INITIALIZED(); + + local_handle = __dnssd_get_struct_from_handle(dnssd_service); + if (local_handle == NULL) { + DNSSD_LOGD("Service Handler not found"); + __DNSSD_LOG_FUNC_EXIT__; + return DNSSD_ERROR_SERVICE_NOT_FOUND; + } + + if (local_handle->op_type != DNSSD_TYPE_BROWSE) { + DNSSD_LOGD("DNSSD service is not a local service"); + __DNSSD_LOG_FUNC_EXIT__; + return DNSSD_ERROR_SERVICE_NOT_FOUND; + } + + if (local_handle->sd_ref == NULL) { + DNSSD_LOGE("Invalid DNS SD Client"); //LCOV_EXCL_LINE + __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return DNSSD_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE + } + + *handle = local_handle; + + return DNSSD_ERROR_NONE; +} static void __dnssd_remove_found_service(gpointer data, gpointer user_data) { @@ -1624,7 +1502,6 @@ static void __dnssd_remove_found_service(gpointer data, gpointer user_data) if (found_handle->op_type != DNSSD_TYPE_FOUND) return; - //LCOV_EXCL_START found_data = GET_FOUND_DATA_P(found_handle); if (found_data->browse_handler != *handler) return; @@ -1644,87 +1521,103 @@ static void __dnssd_remove_found_service(gpointer data, gpointer user_data) __DNSSD_LOG_FUNC_EXIT__; return; - //LCOV_EXCL_STOP } -int dnssd_stop_browsing_service(dnssd_browser_h dnssd_service) +static void __destroy_resolve_data(dnssd_handle_s *browsing_handle, + resolve_reply_data *resolve_data) { - __DNSSD_LOG_FUNC_ENTER__; - dnssd_handle_s *local_handle; - GSList *list; - resolve_reply_data *resolve_data; - - CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); - - if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE - __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE - return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE - } + if (resolve_data->dnssd_handle != browsing_handle) + return; - local_handle = __dnssd_get_struct_from_handle(dnssd_service); - if (local_handle == NULL) { - DNSSD_LOGD("Service Handler 0x%x not found", dnssd_service); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_SERVICE_NOT_FOUND; - } + resolve_handle_list = g_slist_remove(resolve_handle_list, + resolve_data); + if (resolve_data->watch_id > 0) + __remove_service_resolve_socket(resolve_data); - if (local_handle->op_type != DNSSD_TYPE_BROWSE) { - DNSSD_LOGD("DNS SD service is not browser service"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_INVALID_PARAMETER; - } + g_free(resolve_data->service_name); + g_free(resolve_data); +} - if (local_handle->sd_ref == NULL) { - DNSSD_LOGE("Invalid DNS SD Client"); //LCOV_EXCL_LINE - __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE - return DNSSD_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE - } +static void __remove_related_handles(dnssd_handle_s *browsing_handle) +{ + GSList *list; g_slist_foreach(dnssd_handle_list, (GFunc)__dnssd_remove_found_service, - &(local_handle->service_handler)); + &(browsing_handle->service_handler)); list = resolve_handle_list; while (list) { - //LCOV_EXCL_START - resolve_data = list->data; + __destroy_resolve_data(browsing_handle, (resolve_reply_data *)list->data); list = list->next; - - if (resolve_data->dnssd_handle == local_handle) { - resolve_handle_list = g_slist_remove(resolve_handle_list, - resolve_data); - if (resolve_data->watch_id > 0) - __remove_service_resolve_socket(resolve_data); - - g_free(resolve_data->service_name); - g_free(resolve_data); - } - //LCOV_EXCL_STOP } - if (local_handle->watch_id > 0) - g_source_remove(local_handle->watch_id); + return; +} - DNSServiceRefDeallocate(local_handle->sd_ref); - local_handle->sd_ref = NULL; +void __destroy_browsing_handle(dnssd_handle_s *browsing_handle) +{ + if (browsing_handle->watch_id > 0) + g_source_remove(browsing_handle->watch_id); + DNSServiceRefDeallocate(browsing_handle->sd_ref); + browsing_handle->sd_ref = NULL; + + dnssd_handle_list = g_slist_remove(dnssd_handle_list, browsing_handle); + g_free(browsing_handle->service_type); + g_free(browsing_handle); DNSSD_LOGD("g_slist length [%d]", g_slist_length(dnssd_handle_list)); + + return; +} + +int dnssd_stop_browsing_service(dnssd_browser_h dnssd_service) +{ + __DNSSD_LOG_FUNC_ENTER__; + dnssd_handle_s *local_handle; + int res; + + CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); + + res = __get_valid_browsing_handle(dnssd_service, &local_handle); + if (res != DNSSD_ERROR_NONE) + return res; + + __remove_related_handles(local_handle); + __destroy_browsing_handle(local_handle); + __DNSSD_LOG_FUNC_EXIT__; return DNSSD_ERROR_NONE; } +static int __get_valid_handle(dnssd_service_h dnssd_service, dnssd_handle_s **handle) +{ + dnssd_handle_s *local_handle; + + CHECK_INITIALIZED(); + + local_handle = __dnssd_get_struct_from_handle(dnssd_service); + if (local_handle == NULL) { + DNSSD_LOGD("Service Handler not found"); + __DNSSD_LOG_FUNC_EXIT__; + return DNSSD_ERROR_SERVICE_NOT_FOUND; + } + + *handle = local_handle; + + return DNSSD_ERROR_NONE; +} + int dnssd_service_get_type(dnssd_service_h dnssd_service, char **service_type) { __DNSSD_LOG_FUNC_ENTER__; dnssd_handle_s *local_handle = NULL; + int res; CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); - if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE - __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE - return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE - } + res = __get_valid_handle(dnssd_service, &local_handle); + if (res != DNSSD_ERROR_NONE) + return res; if (service_type == NULL) { DNSSD_LOGE("Invalid Parameter"); @@ -1732,15 +1625,8 @@ int dnssd_service_get_type(dnssd_service_h dnssd_service, char **service_type) return DNSSD_ERROR_INVALID_PARAMETER; } - local_handle = __dnssd_get_struct_from_handle(dnssd_service); - if (local_handle == NULL) { - DNSSD_LOGD("Service Handler not found"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_SERVICE_NOT_FOUND; - } else { - *service_type = g_strdup(local_handle->service_type); - DNSSD_LOGD("Service Type %s", *service_type); - } + *service_type = g_strdup(local_handle->service_type); + DNSSD_LOGD("Service Type %s", *service_type); __DNSSD_LOG_FUNC_EXIT__; return DNSSD_ERROR_NONE; @@ -1750,14 +1636,13 @@ int dnssd_service_get_name(dnssd_service_h dnssd_service, char **service_name) { __DNSSD_LOG_FUNC_ENTER__; dnssd_handle_s *local_handle = NULL; + int res; CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); - if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE - __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE - return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE - } + res = __get_valid_handle(dnssd_service, &local_handle); + if (res != DNSSD_ERROR_NONE) + return res; if (service_name == NULL) { DNSSD_LOGE("Invalid Parameter"); @@ -1765,17 +1650,10 @@ int dnssd_service_get_name(dnssd_service_h dnssd_service, char **service_name) return DNSSD_ERROR_INVALID_PARAMETER; } - local_handle = __dnssd_get_struct_from_handle(dnssd_service); - if (local_handle == NULL) { - DNSSD_LOGD("Service Handler not found"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_SERVICE_NOT_FOUND; - } - if (local_handle->op_type == DNSSD_TYPE_FOUND) { - dnssd_found_data_s *found = NULL; //LCOV_EXCL_LINE - found = GET_FOUND_DATA_P(local_handle); //LCOV_EXCL_LINE - *service_name = g_strdup(found->service_name); //LCOV_EXCL_LINE + dnssd_found_data_s *found = NULL; + found = GET_FOUND_DATA_P(local_handle); + *service_name = g_strdup(found->service_name); } else if (local_handle->op_type == DNSSD_TYPE_REGISTER) { dnssd_register_data_s *reg = NULL; reg = GET_REG_DATA_P(local_handle); @@ -1800,29 +1678,20 @@ int dnssd_service_get_ip(dnssd_service_h dnssd_service, char **ip_v4_address, dnssd_handle_s *local_handle = NULL; dnssd_found_data_s *found = NULL; unsigned char *addr = NULL; + int res; CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); - if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_NOT_INITIALIZED; - } - if (ip_v4_address == NULL && ip_v6_address == NULL) { DNSSD_LOGE("Invalid Parameter"); __DNSSD_LOG_FUNC_EXIT__; return DNSSD_ERROR_INVALID_PARAMETER; } - local_handle = __dnssd_get_struct_from_handle(dnssd_service); - if (local_handle == NULL) { - DNSSD_LOGD("Service Handler not found"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_SERVICE_NOT_FOUND; - } + res = __get_valid_handle(dnssd_service, &local_handle); + if (res != DNSSD_ERROR_NONE) + return res; -//LCOV_EXCL_START if (local_handle->op_type != DNSSD_TYPE_FOUND) { DNSSD_LOGD("Invalid DNS SD Service"); __DNSSD_LOG_FUNC_EXIT__; @@ -1852,21 +1721,19 @@ int dnssd_service_get_ip(dnssd_service_h dnssd_service, char **ip_v4_address, __DNSSD_LOG_FUNC_EXIT__; return DNSSD_ERROR_NONE; -//LCOV_EXCL_STOP } int dnssd_service_get_port(dnssd_service_h dnssd_service, int *port) { __DNSSD_LOG_FUNC_ENTER__; dnssd_handle_s *local_handle = NULL; + int res; CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); - if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE - __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE - return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE - } + res = __get_valid_handle(dnssd_service, &local_handle); + if (res != DNSSD_ERROR_NONE) + return res; if (port == NULL) { DNSSD_LOGE("Invalid Parameter"); @@ -1874,17 +1741,10 @@ int dnssd_service_get_port(dnssd_service_h dnssd_service, int *port) return DNSSD_ERROR_INVALID_PARAMETER; } - local_handle = __dnssd_get_struct_from_handle(dnssd_service); - if (local_handle == NULL) { - DNSSD_LOGD("Service Handler not found"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_SERVICE_NOT_FOUND; - } - if (local_handle->op_type == DNSSD_TYPE_FOUND) { - dnssd_found_data_s *found = NULL; //LCOV_EXCL_LINE - found = GET_FOUND_DATA_P(local_handle); //LCOV_EXCL_LINE - *port = found->port; //LCOV_EXCL_LINE + dnssd_found_data_s *found = NULL; + found = GET_FOUND_DATA_P(local_handle); + *port = found->port; } else if (local_handle->op_type == DNSSD_TYPE_REGISTER) { dnssd_register_data_s *reg = NULL; reg = GET_REG_DATA_P(local_handle); @@ -1907,21 +1767,13 @@ int dnssd_service_get_all_txt_record(dnssd_service_h dnssd_service, __DNSSD_LOG_FUNC_ENTER__; TXTRecordRef *txt_record; dnssd_handle_s *local_handle; + int res; CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE); - if (__dnssd_is_init() == false) { - DNSSD_LOGE("Not initialized"); //LCOV_EXCL_LINE - __DNSSD_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE - return DNSSD_ERROR_NOT_INITIALIZED; //LCOV_EXCL_LINE - } - - local_handle = __dnssd_get_struct_from_handle(dnssd_service); - if (local_handle == NULL) { - DNSSD_LOGE("Service Handler not found"); - __DNSSD_LOG_FUNC_EXIT__; - return DNSSD_ERROR_SERVICE_NOT_FOUND; - } + res = __get_valid_handle(dnssd_service, &local_handle); + if (res != DNSSD_ERROR_NONE) + return res; if (value == NULL || length == NULL) { DNSSD_LOGE("Invalid Parameter"); @@ -1931,11 +1783,11 @@ int dnssd_service_get_all_txt_record(dnssd_service_h dnssd_service, if (local_handle->op_type == DNSSD_TYPE_FOUND) { - dnssd_found_data_s *found = NULL; //LCOV_EXCL_LINE - found = GET_FOUND_DATA_P(local_handle); //LCOV_EXCL_LINE + dnssd_found_data_s *found = NULL; + found = GET_FOUND_DATA_P(local_handle); - *value = g_strndup(found->txt_record, found->txt_len); //LCOV_EXCL_LINE - *length = found->txt_len; //LCOV_EXCL_LINE + *value = g_strndup(found->txt_record, found->txt_len); + *length = found->txt_len; } else { dnssd_register_data_s *reg = NULL;