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,
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);
if (result < 0) {
// TODO: Handle auth failure
VINE_LOGE("Failure dp[%p]", datapath);
- _vine_data_path_destroy(datapath);
+ vine_data_path_destroy(datapath);
return;
}
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");
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");
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");
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");
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");
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;
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;
_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;
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);
}
if (*connected_datapath) {
VINE_LOGI("Destroy a stale datapath.");
- _vine_data_path_destroy(*connected_datapath);
+ vine_data_path_destroy(*connected_datapath);
}
*connected_datapath = dp;
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");
// 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));
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);
}
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)
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);
}
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;
{
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)
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)
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;
{
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)
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)
int DPPubSub::close_server_dp()
{
- int ret = _vine_data_path_close(mServerDataPath);
+ int ret = vine_data_path_close(mServerDataPath);
mServerDataPath = NULL;
return ret;
}
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;
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;
{
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;
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();