Rename vine-data-path functions for consistency 76/258176/1
authorSeonah Moon <seonah1.moon@samsung.com>
Wed, 12 May 2021 01:50:26 +0000 (10:50 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Wed, 12 May 2021 01:50:32 +0000 (10:50 +0900)
Change-Id: I300799e4393f32a09efe5cb1b5545ff717fd8f49

src/include/vine-data-path.h
src/vine-data-path-state.cpp
src/vine-data-path.cpp
src/vine-dp.cpp

index 72cde1ea76fd3661f66cee9cd7b4b095d5a34005..a38687af268a80d619604c7d0521f4fd3e6080cb 100755 (executable)
@@ -37,21 +37,10 @@ typedef void (*vine_data_path_accepted_cb)(vine_data_path_h datapath, void *user
 typedef void (*vine_data_path_connected_cb)(vine_data_path_h datapath, int result, void *user_data);
 typedef void (*vine_data_path_terminated_cb)(vine_data_path_h datapath, void *user_data);
 
-int _vine_data_path_read(vine_data_path_h datapath,
-               unsigned char *buf, size_t buf_len, size_t *read_len);
-int _vine_data_path_write(vine_data_path_h datapath, unsigned char *buf, size_t len);
-int _vine_data_path_set_received_cb(vine_data_path_h datapath,
-               vine_data_path_received_cb callback, void *user_data);
-int _vine_data_path_unset_received_cb(vine_data_path_h datapath);
-int _vine_data_path_close(vine_data_path_h datapath);
-int _vine_data_path_destroy(vine_data_path_h datapath);
-
-const char *_vine_data_path_get_ip(vine_data_path_h datapath);
-vine_address_family_e _vine_data_path_get_addr_family(vine_data_path_h datapath);
-int _vine_data_path_get_port(vine_data_path_h datapath);
 
 int vine_data_path_init(void);
 int vine_data_path_deinit(void);
+
 int vine_data_path_open(vine_address_family_e addr_family, int port,
                const char *iface_name, int max_conn, vine_security_h security,
                vine_data_path_opened_cb opened_cb, void *opened_cb_data,
@@ -64,11 +53,24 @@ int vine_data_path_connect(vine_address_family_e addr_family,
                vine_data_path_connected_cb callback, void *user_data,
                vine_data_path_h *connected_datapath,
                vine_event_queue_h event_fd);
+
+const char *vine_data_path_get_ip(vine_data_path_h datapath);
+vine_address_family_e vine_data_path_get_addr_family(vine_data_path_h datapath);
+int vine_data_path_get_port(vine_data_path_h datapath);
+vine_security_h vine_data_path_get_security(vine_data_path_h datapath);
+
+int vine_data_path_set_received_cb(vine_data_path_h datapath,
+               vine_data_path_received_cb callback, void *user_data);
+int vine_data_path_unset_received_cb(vine_data_path_h datapath);
+int vine_data_path_read(vine_data_path_h datapath,
+               unsigned char *buf, size_t buf_len, size_t *read_len);
+int vine_data_path_write(vine_data_path_h datapath, unsigned char *buf, size_t len);
+
 int vine_data_path_set_terminated_cb(vine_data_path_h datapath,
                vine_data_path_terminated_cb callback, void *user_data);
 int vine_data_path_get_token(vine_data_path_h datapath, char **token);
-
-vine_security_h _vine_dp_get_security(vine_data_path_h datapath);
+int vine_data_path_close(vine_data_path_h datapath);
+int vine_data_path_destroy(vine_data_path_h datapath);
 
 void notify_connected(vine_data_path_h datapath, int result);
 void notify_accepted(vine_data_path_h datapath, int result);
index eb64421137aa19985a97ed6da51345a132ea45be..2c62af2b8ce34ff49e4da7318248a73417d16eea 100644 (file)
@@ -91,7 +91,7 @@ void VineAcceptedState::enter()
 {
        VINE_LOGD("+");
 
-       vine_security_h security = _vine_dp_get_security(__dp);
+       vine_security_h security = vine_data_path_get_security(__dp);
        vine_security_type_e security_type;
        if (security == NULL) {
                security_type = VINE_SECURITY_TYPE_NONE;
@@ -311,7 +311,7 @@ void VineConnectedState::recv_auth_request(unsigned char ver,
                return;
        }
 
-       vine_security_h security = _vine_dp_get_security(__dp);
+       vine_security_h security = vine_data_path_get_security(__dp);
        if (security == NULL) {
                handle_failure("security is NULL (OPEN)");
                return;
@@ -352,7 +352,7 @@ void VineConnectedState::send_auth_response()
 {
        VINE_LOGI("Send AUTH_RESPONSE dp[%p]", __dp);
 
-       vine_security_h security = _vine_dp_get_security(__dp);
+       vine_security_h security = vine_data_path_get_security(__dp);
        char *psk;
        if (_vine_security_get_psk(security, &psk) != VINE_ERROR_NONE) {
                handle_failure("Fail to get PSK");
@@ -485,7 +485,7 @@ void VineAuthRequestedState::recv_auth_response(unsigned char ver,
                return;
        }
 
-       vine_security_h security = _vine_dp_get_security(__dp);
+       vine_security_h security = vine_data_path_get_security(__dp);
        if (security == NULL) {
                handle_failure("security is NULL (OPEN)");
                return;
index 3872a240fa7fb0038905630429c7549ea67e2168..64d628412ffab7c990fd97d101658eb40692ab16 100755 (executable)
@@ -210,7 +210,7 @@ void notify_accepted(vine_data_path_h datapath, int result)
        if (result < 0) {
                // TODO: Handle auth failure
                VINE_LOGE("Failure dp[%p]", datapath);
-               _vine_data_path_destroy(datapath);
+               vine_data_path_destroy(datapath);
                return;
        }
 
@@ -412,7 +412,7 @@ static int _load_data_path_plugins(void)
        return VINE_ERROR_NONE;
 }
 
-int _vine_data_path_set_received_cb(
+int vine_data_path_set_received_cb(
                vine_data_path_h datapath, vine_data_path_received_cb callback, void *user_data)
 {
        RET_VAL_IF(datapath == NULL, VINE_ERROR_INVALID_PARAMETER, "datapath is NULL");
@@ -425,7 +425,7 @@ int _vine_data_path_set_received_cb(
        return VINE_ERROR_NONE;
 }
 
-int _vine_data_path_unset_received_cb(vine_data_path_h datapath)
+int vine_data_path_unset_received_cb(vine_data_path_h datapath)
 {
        RET_VAL_IF(datapath == NULL, VINE_ERROR_INVALID_PARAMETER, "datapath is NULL");
 
@@ -436,7 +436,7 @@ int _vine_data_path_unset_received_cb(vine_data_path_h datapath)
        return VINE_ERROR_NONE;
 }
 
-int _vine_data_path_write(vine_data_path_h datapath, unsigned char *buf, size_t len)
+int vine_data_path_write(vine_data_path_h datapath, unsigned char *buf, size_t len)
 {
        RET_VAL_IF(datapath == NULL, VINE_ERROR_INVALID_PARAMETER, "datapath is NULL");
        RET_VAL_IF(buf == NULL, VINE_ERROR_INVALID_PARAMETER, "buf is NULL");
@@ -446,7 +446,7 @@ int _vine_data_path_write(vine_data_path_h datapath, unsigned char *buf, size_t
        return dp->state->write(buf, len);
 }
 
-int _vine_data_path_read(vine_data_path_h datapath,
+int vine_data_path_read(vine_data_path_h datapath,
                unsigned char *buf, size_t buf_len, size_t *read_len)
 {
        RET_VAL_IF(datapath == NULL, VINE_ERROR_INVALID_PARAMETER, "datapath is NULL");
@@ -458,7 +458,7 @@ int _vine_data_path_read(vine_data_path_h datapath,
        return dp->state->read(buf, buf_len, read_len);
 }
 
-int _vine_data_path_close(vine_data_path_h datapath)
+int vine_data_path_close(vine_data_path_h datapath)
 {
        RET_VAL_IF(datapath == NULL, VINE_ERROR_INVALID_PARAMETER, "datapath is NULL");
 
@@ -518,7 +518,7 @@ static vine_data_path_s *_vine_data_path_create(vine_data_path_type_e type,
        return dp;
 }
 
-int _vine_data_path_destroy(vine_data_path_h datapath)
+int vine_data_path_destroy(vine_data_path_h datapath)
 {
        RET_VAL_IF(datapath == NULL, VINE_ERROR_INVALID_PARAMETER, "datapath is NULL");
        vine_data_path_s *dp = (vine_data_path_s *)datapath;
@@ -533,21 +533,21 @@ int _vine_data_path_destroy(vine_data_path_h datapath)
        return VINE_ERROR_NONE;
 }
 
-const char *_vine_data_path_get_ip(vine_data_path_h datapath)
+const char *vine_data_path_get_ip(vine_data_path_h datapath)
 {
        RET_VAL_IF(datapath == NULL, NULL, "datapath is NULL");
        vine_data_path_s *dp = (vine_data_path_s *)datapath;
        return (const char *)dp->addr;
 }
 
-vine_address_family_e _vine_data_path_get_addr_family(vine_data_path_h datapath)
+vine_address_family_e vine_data_path_get_addr_family(vine_data_path_h datapath)
 {
        RET_VAL_IF(datapath == NULL, VINE_ADDRESS_FAMILY_DEFAULT, "datapath is NULL");
        vine_data_path_s *dp = (vine_data_path_s *)datapath;
        return dp->addr_family;
 }
 
-int _vine_data_path_get_port(vine_data_path_h datapath)
+int vine_data_path_get_port(vine_data_path_h datapath)
 {
        RET_VAL_IF(datapath == NULL, VINE_ERROR_INVALID_PARAMETER, "datapath is NULL");
        vine_data_path_s *dp = (vine_data_path_s *)datapath;
@@ -697,13 +697,13 @@ int vine_data_path_open(vine_address_family_e addr_family, int port, const char
        _destroy_security_info(&ssl);
 
        if (ret != VINE_DATA_PATH_ERROR_NONE) {
-               _vine_data_path_destroy(dp);
+               vine_data_path_destroy(dp);
                return __convert_data_path_error_to_vine_error((vine_data_path_error)ret);
        }
 
        if (*opened_datapath) {
                VINE_LOGI("Destroy a stale datapath.");
-               _vine_data_path_destroy(*opened_datapath);
+               vine_data_path_destroy(*opened_datapath);
        }
        *opened_datapath = dp;
 
@@ -731,7 +731,7 @@ int vine_data_path_connect(vine_address_family_e addr_family,
        if (token) {
                ret = g_dp_plugin_fn.set_token(dp->plugin_handle, token);
                if (ret != VINE_DATA_PATH_ERROR_NONE) {
-                       _vine_data_path_destroy(dp);
+                       vine_data_path_destroy(dp);
                        _destroy_security_info(&ssl);
                        return __convert_data_path_error_to_vine_error((vine_data_path_error)ret);
                }
@@ -744,7 +744,7 @@ int vine_data_path_connect(vine_address_family_e addr_family,
 
        if (*connected_datapath) {
                VINE_LOGI("Destroy a stale datapath.");
-               _vine_data_path_destroy(*connected_datapath);
+               vine_data_path_destroy(*connected_datapath);
        }
 
        *connected_datapath = dp;
@@ -775,7 +775,7 @@ int vine_data_path_get_token(vine_data_path_h datapath, char **token)
        return __convert_data_path_error_to_vine_error((vine_data_path_error)ret);
 }
 
-vine_security_h _vine_dp_get_security(vine_data_path_h datapath)
+vine_security_h vine_data_path_get_security(vine_data_path_h datapath)
 {
        RET_VAL_IF(datapath == NULL, NULL, "datapath is NULL");
 
index c9f7088c230da79b74a2c93481653cebf2824e48..52c94dbc52b0a7d03ee7f6f6d71233c3c2647e22 100644 (file)
@@ -105,7 +105,7 @@ static void _accepted_cb(vine_data_path_h datapath, void *user_data)
        // datapath is created newly. DP class should be needed for it.
        // event_fd is the same as corresponding DPServer.
        DPClient *connected_client_dp = new DPClient(event_fd, datapath);
-       _vine_data_path_set_received_cb(datapath,
+       vine_data_path_set_received_cb(datapath,
                        _received_cb, static_cast<void *>(connected_client_dp));
        vine_data_path_set_terminated_cb(datapath,
                        _terminated_cb, static_cast<void *>(connected_client_dp));
@@ -114,7 +114,7 @@ static void _accepted_cb(vine_data_path_h datapath, void *user_data)
 
 static void _connected_cb(vine_data_path_h datapath, int result, void *user_data)
 {
-       _vine_data_path_set_received_cb(datapath, _received_cb, user_data);
+       vine_data_path_set_received_cb(datapath, _received_cb, user_data);
        vine_data_path_set_terminated_cb(datapath, _terminated_cb, user_data);
        static_cast<DataPath *>(user_data)->invoke_opened_cb(result);
 }
@@ -139,10 +139,10 @@ static void _pubsub_terminated_cb(vine_data_path_h datapath, void *user_data)
        DPPubSub *dp =  static_cast<DPPubSub *>(user_data);
        dp->del_joined_peer(datapath);
 
-       const char *ip = _vine_data_path_get_ip(datapath);
-       int port = _vine_data_path_get_port(datapath);
+       const char *ip = vine_data_path_get_ip(datapath);
+       int port = vine_data_path_get_port(datapath);
        dp->invoke_peer_left_cb(ip, port);
-       _vine_data_path_destroy(datapath);
+       vine_data_path_destroy(datapath);
 }
 
 static void _pubsub_opened_cb(vine_data_path_h datapath, int result, int port, void *userdata)
@@ -178,26 +178,26 @@ static void _pubsub_accepted_cb(vine_data_path_h datapath, void *user_data)
        DPPubSub *dp = static_cast<DPPubSub *>(user_data);
        if (dp->get_max_conns() <= dp->get_joined_peer()) {
                VINE_LOGE("The max connection limit is reached. Ignore [%p].", datapath);
-               _vine_data_path_close(datapath);
+               vine_data_path_close(datapath);
                return;
        }
 
        char *token = NULL;
        if (vine_data_path_get_token(datapath, &token) != VINE_ERROR_NONE) {
                VINE_LOGE("Cannot find peer's service name. Ignore[%p]", datapath);
-               _vine_data_path_close(datapath);
-               _vine_data_path_destroy(datapath);
+               vine_data_path_close(datapath);
+               vine_data_path_destroy(datapath);
                return;
        }
 
        dp->add_joined_peer(token, datapath);
        free(token);
 
-       _vine_data_path_set_received_cb(datapath, _pubsub_received_cb, user_data);
+       vine_data_path_set_received_cb(datapath, _pubsub_received_cb, user_data);
        vine_data_path_set_terminated_cb(datapath, _pubsub_terminated_cb, user_data);
 
-       const char *ip = _vine_data_path_get_ip(datapath);
-       int port = _vine_data_path_get_port(datapath);
+       const char *ip = vine_data_path_get_ip(datapath);
+       int port = vine_data_path_get_port(datapath);
        dp->invoke_peer_joined_cb(ip, port);
 }
 
@@ -216,19 +216,19 @@ static void _pubsub_connected_cb(vine_data_path_h datapath, int result, void *us
        struct pubsub_connect_data *conn_data = (struct pubsub_connect_data *)user_data;
        if (!conn_data->service_name) {
                VINE_LOGE("service_name is NULL.");
-               _vine_data_path_close(datapath);
-               _vine_data_path_destroy(datapath);
+               vine_data_path_close(datapath);
+               vine_data_path_destroy(datapath);
                return;
        }
 
        DPPubSub *dp = static_cast<DPPubSub *>(conn_data->dp);
        dp->add_joined_peer(conn_data->service_name, datapath);
 
-       _vine_data_path_set_received_cb(datapath, _pubsub_received_cb, conn_data->dp);
+       vine_data_path_set_received_cb(datapath, _pubsub_received_cb, conn_data->dp);
        vine_data_path_set_terminated_cb(datapath, _pubsub_terminated_cb, conn_data->dp);
 
-       const char *ip = _vine_data_path_get_ip(datapath);
-       int port = _vine_data_path_get_port(datapath);
+       const char *ip = vine_data_path_get_ip(datapath);
+       int port = vine_data_path_get_port(datapath);
        dp->invoke_peer_joined_cb(ip, port);
 
        conn_data->dp = NULL;
@@ -466,7 +466,7 @@ DPServer::~DPServer()
 {
        VINE_LOGD("DPServer[%p] is deleted.", this);
        _vine_security_destroy(mSecurity);
-       _vine_data_path_destroy(mDataPath);
+       vine_data_path_destroy(mDataPath);
 }
 
 int DPServer::set_addr_family(vine_address_family_e addr_family)
@@ -572,17 +572,17 @@ int DPServer::open(vine_dp_opened_cb callback, void *user_data)
 void DPServer::close()
 {
        mOpenState = VINE_DP_OPEN_STATE_NONE;
-       _vine_data_path_close(mDataPath);
+       vine_data_path_close(mDataPath);
 }
 
 int DPServer::send(unsigned char *buf, size_t len)
 {
-       return _vine_data_path_write(mDataPath, buf, len);
+       return vine_data_path_write(mDataPath, buf, len);
 }
 
 int DPServer::recv(unsigned char *buf, size_t buf_len, size_t *read_len)
 {
-       return _vine_data_path_read(mDataPath, buf, buf_len, read_len);
+       return vine_data_path_read(mDataPath, buf, buf_len, read_len);
 }
 
 DPClient::DPClient(void *event_fd)
@@ -612,9 +612,9 @@ DPClient::DPClient(void *event_fd, void *datapath)
        mSecurity = NULL;
        mOpenState = VINE_DP_OPEN_STATE_NONE;
        mDataPath = datapath;
-       mAddrFamily = _vine_data_path_get_addr_family(mDataPath);
-       mPeerIp = _vine_data_path_get_ip(mDataPath);
-       mPeerPort = _vine_data_path_get_port(mDataPath);
+       mAddrFamily = vine_data_path_get_addr_family(mDataPath);
+       mPeerIp = vine_data_path_get_ip(mDataPath);
+       mPeerPort = vine_data_path_get_port(mDataPath);
        mReceivedCb = NULL;
        mReceivedCbData = NULL;
        mOpenedCb = NULL;
@@ -629,7 +629,7 @@ DPClient::~DPClient()
 {
        VINE_LOGD("DPClient[%p] is deleted.", this);
        _vine_security_destroy(mSecurity);
-       _vine_data_path_destroy(mDataPath);
+       vine_data_path_destroy(mDataPath);
 }
 
 int DPClient::set_addr_family(vine_address_family_e addr_family)
@@ -723,17 +723,17 @@ int DPClient::open(vine_dp_opened_cb callback, void *user_data)
 void DPClient::close()
 {
        mOpenState = VINE_DP_OPEN_STATE_NONE;
-       _vine_data_path_close(mDataPath);
+       vine_data_path_close(mDataPath);
 }
 
 int DPClient::send(unsigned char *buf, size_t len)
 {
-       return _vine_data_path_write(mDataPath, buf, len);
+       return vine_data_path_write(mDataPath, buf, len);
 }
 
 int DPClient::recv(unsigned char *buf, size_t buf_len, size_t *read_len)
 {
-       return _vine_data_path_read(mDataPath, buf, buf_len, read_len);
+       return vine_data_path_read(mDataPath, buf, buf_len, read_len);
 }
 
 DPPubSub::DPPubSub(void *event_fd)
@@ -889,7 +889,7 @@ int DPPubSub::connect(const char *service_name, const char *ip, int port)
 
 int DPPubSub::close_server_dp()
 {
-       int ret = _vine_data_path_close(mServerDataPath);
+       int ret = vine_data_path_close(mServerDataPath);
        mServerDataPath = NULL;
        return ret;
 }
@@ -1001,8 +1001,8 @@ void DPPubSub::close()
        mSdPub = NULL;
 
        clear_joined_peer();
-       _vine_data_path_close(mServerDataPath);
-       _vine_data_path_destroy(mServerDataPath);
+       vine_data_path_close(mServerDataPath);
+       vine_data_path_destroy(mServerDataPath);
        mServerDataPath = NULL;
 
        mOpenState = VINE_DP_OPEN_STATE_NONE;
@@ -1015,7 +1015,7 @@ int DPPubSub::send(unsigned char *buf, size_t len)
        for (auto &peer : mDataPathList) {
                if (!peer.second)
                        continue;
-               ret = _vine_data_path_write(peer.second, buf, len);
+               ret = vine_data_path_write(peer.second, buf, len);
                if (ret != VINE_ERROR_NONE) {
                        VINE_LOGE("fail to write to a peer[%p] ", peer.second);
                        break;
@@ -1029,7 +1029,7 @@ int DPPubSub::recv(unsigned char *buf, size_t buf_len, size_t *read_len)
 {
        auto &dp_info = mRecvDataPathList.front();
        size_t bytes = 0;
-       int ret = _vine_data_path_read(dp_info.first, buf, buf_len, &bytes);
+       int ret = vine_data_path_read(dp_info.first, buf, buf_len, &bytes);
        if (ret != VINE_ERROR_NONE)
                return ret;
 
@@ -1095,8 +1095,8 @@ void DPPubSub::clear_joined_peer()
        for (auto &peer : mDataPathList) {
                if (!peer.second)
                        continue;
-               _vine_data_path_close(peer.second);
-               _vine_data_path_destroy(peer.second);
+               vine_data_path_close(peer.second);
+               vine_data_path_destroy(peer.second);
        }
 
        mDataPathList.clear();