Add new CAPI for removing SRP service 63/279563/1
authorArkadiusz Bokowy <a.bokowy@partner.samsung.com>
Thu, 11 Aug 2022 13:39:46 +0000 (15:39 +0200)
committerArkadiusz Bokowy <a.bokowy@partner.samsung.com>
Thu, 11 Aug 2022 14:42:43 +0000 (16:42 +0200)
Change-Id: Ib9c7dc90b28f6b92cdea058b4adb59803da50874

include/thread-socket-handler.h
include/thread.h
src/thread-srp.c

index 2714dd4..97ef619 100644 (file)
@@ -40,6 +40,7 @@ extern "C" {
 #define THREAD_SRP_SERVER_STOP_CMD "srp server disable"
 #define THREAD_SRP_SERVER_SERVICE_CMD "srp server service"
 #define THREAD_SRP_CLIENT_REGISTER_SERVICE_CMD "srp client service add"
+#define THREAD_SRP_CLIENT_REMOVE_SERVICE_CMD "srp client service remove"
 #define THREAD_SRP_CLIENT_SET_HOST_ADDRESS_CMD "srp client host address"
 #define THREAD_SRP_CLIENT_SET_HOST_NAME_CMD "srp client host name"
 #define THREAD_SRP_CLIENT_REMOVE_HOST_CMD "srp client host remove"
index 2706457..2f93623 100644 (file)
@@ -1479,6 +1479,25 @@ int thread_srp_client_register_service(thread_instance_h instance,
 
 /**
  * @ingroup CAPI_NETWORK_THREAD_SRP_MODULE
+ * @brief Remove Service from SRP server
+ * @since_tizen 7.0
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #THREAD_ERROR_NONE  Successful
+ * @retval #THREAD_ERROR_NOT_INITIALIZED  Not initialized
+ * @retval #THREAD_ERROR_OPERATION_FAILED  Operation failed
+ * @retval #THREAD_ERROR_NOT_SUPPORTED  Not supported
+ *
+ * @pre thread API must be initialized with thread_initialize().
+ * @see thread_srp_client_start()
+ * @see thread_srp_client_set_host_address()
+ * @see thread_srp_client_register_service()
+ */
+int thread_srp_client_remove_service(thread_instance_h instance,
+       const char *service_name, const char *service_type);
+
+/**
+ * @ingroup CAPI_NETWORK_THREAD_SRP_MODULE
  * @brief Start SRP Server
  * @since_tizen 7.0
  *
index c8da03d..063649a 100644 (file)
@@ -175,6 +175,34 @@ int thread_srp_client_register_service(thread_instance_h instance,
        return ret;
 }
 
+int thread_srp_client_remove_service(thread_instance_h instance,
+       const char *service_name, const char *service_type)
+{
+       FUNC_ENTRY;
+       THREAD_CHECK_SUPPORTED_FEATURE(THREAD_FEATURE_COMMON);
+       THREAD_VALIDATE_INPUT_PARAMETER(service_name);
+       THREAD_CHECK_INIT_STATUS();
+       THREAD_VALIDATE_INPUT_PARAMETER(instance);
+       int ret = THREAD_ERROR_NONE;
+
+       /* Remove SRP service */
+       const char *msg = THREAD_SRP_CLIENT_REMOVE_SERVICE_CMD;
+
+       char buffer[THREAD_MAX_BUFFER_SIZE] = {0};
+       snprintf(buffer, sizeof(buffer), "%s %s %s", msg,
+                               service_name, service_type);
+       ret = _thread_socket_client_execute(_thread_get_socket_fd(),
+                                               buffer, strlen(buffer));
+       if (ret != THREAD_ERROR_NONE && ret != THREAD_ERROR_ALREADY_DONE) {
+               THREAD_DBG("socket srp_client_remove_service execute failed");
+               return ret;
+       }
+       THREAD_DBG("socket srp_client_remove_service execute successful");
+
+       FUNC_EXIT;
+       return ret;
+}
+
 int thread_srp_server_start(thread_instance_h instance)
 {
        FUNC_ENTRY;