#define TIZEN_ERROR_DNSSD -0x01CA0000
#endif
+/**
+ * @brief Gets the interface name of DNSSD local service
+ * @since_tizen 4.0
+ * @privilevel public
+ * @privilege %http://tizen.org/privilege/internet
+ * @param[in] service The DNSSD service handle
+ * @param[in] interface The interface name
+ * @retval #DNSSD_ERROR_NONE Successful
+ * @retval #DNSSD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DNSSD_ERROR_NOT_SUPPORTED Not Supported
+ * @retval #DNSSD_ERROR_OUT_OF_MEMORY Out of Memory
+ * @retval #DNSSD_ERROR_NOT_INITIALIZED Not Initialized
+ */
int dnssd_service_set_interface(dnssd_service_h local_service, const char *interface);
+/**
+ * @brief Gets the interface name of DNSSD local/remote service.
+ * @since_tizen 6.5
+ * @remarks You must release @a interface using g_free().
+ * @privilevel public
+ * @privilege %http://tizen.org/privilege/internet
+ * @param[in] service The DNSSD service handle
+ * @param[out] interface The interface name
+ * @retval #DNSSD_ERROR_NONE Successful
+ * @retval #DNSSD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DNSSD_ERROR_NOT_SUPPORTED Not Supported
+ * @retval #DNSSD_ERROR_OUT_OF_MEMORY Out of Memory
+ * @retval #DNSSD_ERROR_NOT_INITIALIZED Not Initialized
+ */
+int dnssd_service_get_interface(dnssd_service_h dnssd_service, char **interface);
+
+/**
+ * @brief Starts browsing the DNSSD remote service on a specific network interface.
+ * @details found_cb would be called only if there are any services available of
+ * service_type provided in the argument. Application will keep
+ * browsing for available/unavailable services until it calls
+ * dnssd_stop_browsing_service().
+ * @since_tizen 4.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/internet
+ * @param[in] service_type The DNSSD service type to browse. It is expressed
+ * as type followed by protocol, separated by a dot(e.g. "_ftp._tcp").
+ * It must begin with an underscore, followed by 1-15 characters
+ * which may be letters, digits, or hyphens. The transport protocol
+ * must be "_tcp" or "_udp". New service types should be registered
+ * at http://www.dns-sd.org/ServiceTypes.html
+ * @param[in] interface The interface name
+ * @param[out] dnssd_service The DNSSD browse service handle
+ * @param[in] found_cb The callback function to be called
+ * @param[in] user_data The user data passed to the callback function
+ * @return @c 0 on success,
+ * otherwise negative error value
+ * @retval #DNSSD_ERROR_NONE Successful
+ * @retval #DNSSD_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #DNSSD_ERROR_NOT_SUPPORTED Not Supported
+ * @retval #DNSSD_ERROR_SERVICE_NOT_RUNNING Service Not Running
+ * @retval #DNSSD_ERROR_NOT_INITIALIZED Not Initialized
+ * @retval #DNSSD_ERROR_PERMISSION_DENIED Permission Denied
+ * @pre This API needs dnssd_initialize() before use.
+ */
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);
return DNSSD_ERROR_NONE;
}
+static int __get_valid_handle(dnssd_service_h dnssd_service, dnssd_handle_s **handle)
+{
+ dnssd_handle_s *local_handle;
+
+ 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;
+}
+
static int __get_valid_registered_handle(dnssd_service_h dnssd_service, dnssd_handle_s **handle)
{
dnssd_handle_s *local_handle;
return DNSSD_ERROR_NONE;
}
+EXPORT_API int dnssd_service_get_interface(dnssd_service_h dnssd_service, char **interface)
+{
+ __DNSSD_LOG_FUNC_ENTER__;
+ dnssd_handle_s *local_handle = NULL;
+ int res = DNSSD_ERROR_NONE;
+ unsigned int if_index = 0;
+
+ CHECK_FEATURE_SUPPORTED(NETWORK_SERVICE_DISCOVERY_FEATURE);
+ DNSSD_LOCK;
+
+ CHECK_INITIALIZED();
+
+ res = __get_valid_handle(dnssd_service, &local_handle);
+ if (res != DNSSD_ERROR_NONE) {
+ DNSSD_UNLOCK;
+ return res;
+ }
+
+ if (interface== NULL) {
+ DNSSD_LOGE("Invalid Parameter");
+ DNSSD_UNLOCK;
+ __DNSSD_LOG_FUNC_EXIT__;
+ return DNSSD_ERROR_INVALID_PARAMETER;
+ }
+
+ if (local_handle->op_type == DNSSD_TYPE_FOUND) {
+ dnssd_found_data_s *found = NULL;
+ found = GET_FOUND_DATA_P(local_handle);
+ if_index = found->if_index;
+ } else if (local_handle->op_type == DNSSD_TYPE_REGISTER) {
+ dnssd_register_data_s *reg = NULL;
+ reg = GET_REG_DATA_P(local_handle);
+ if_index = reg->if_index;
+ } else {
+ *interface = NULL;
+ DNSSD_LOGE("Invalid DNS SD service");
+ DNSSD_UNLOCK;
+ __DNSSD_LOG_FUNC_EXIT__;
+ return DNSSD_ERROR_INVALID_PARAMETER;
+ }
+
+ if (if_index > 0) {
+ char iface[IFNAMSIZ + 1];
+ if (if_indextoname(if_index, iface) == NULL) {
+ DNSSD_LOGE("if_indextoname fails. errno: %d", errno);
+ res = DNSSD_ERROR_INVALID_OPERATION;
+ }
+ else {
+ DNSSD_LOGD("Interface Name %s", iface);
+ *interface = g_strdup(iface);
+ }
+ }
+ else {
+ DNSSD_LOGD("No Interface (all interfaces is used)");
+ *interface = NULL;
+ }
+
+ DNSSD_UNLOCK;
+ __DNSSD_LOG_FUNC_EXIT__;
+ return DNSSD_ERROR_NONE;
+}
EXPORT_API int dnssd_service_add_txt_record(dnssd_service_h local_service,
const char *key, unsigned short length, const void *value)
DNSSD_UNLOCK;
}
-static int __get_valid_handle(dnssd_service_h dnssd_service, dnssd_handle_s **handle)
-{
- dnssd_handle_s *local_handle;
-
- 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;
-}
-
static int __dnssd_service_get_all_txt_record(dnssd_service_h dnssd_service,
unsigned short *length, void **value)
{