int init_vhost_net(vhost_net **client, const char *vhost_client_path ) { Vhost_Client *run_vhost_client= NULL; VHOST_CLIENT_H_RET_VAL vhost_client_ret_val = E_VHOST_CLIENT_OK; if (!client || !vhost_client_path || !strlen(vhost_client_path)) { fprintf(stderr, "%s(): Error initializing vhost net: no client path\n", __func__); return E_VHOST_NET_ERR_FARG; } vhost_client_ret_val = vhost_client_run_vhost_client(&run_vhost_client, vhost_client_path); if (vhost_client_ret_val != E_VHOST_CLIENT_OK) { return map_ret_val_vhost_client_2_vhost_net(vhost_client_ret_val); } (*client) = calloc(1, sizeof(vhost_net)); if(!(*client)) { fprintf(stderr, "%s(): Error initializing vhost net: %s (%d)\n", __func__, strerror(errno), errno); return E_VHOST_NET_ERR_ALLOC; } (*client)->context = run_vhost_client; (*client)->tx = run_vhost_client->vhost_net_app_handler.tx_func_handler; (*client)->rx = run_vhost_client->vhost_net_app_handler.rx_func_handler; return E_VHOST_NET_OK; }
int init_vhost_net(vhost_net **client, const char *vhost_client_path ) { Vhost_Client *run_vhost_client= NULL; VHOST_CLIENT_H_RET_VAL vhost_client_ret_val = E_VHOST_CLIENT_OK; if (!client || !vhost_client_path || !strlen(vhost_client_path)) { return E_VHOST_NET_ERR_FARG; } vhost_client_ret_val = vhost_client_run_vhost_client(&run_vhost_client, vhost_client_path); if (vhost_client_ret_val != E_VHOST_CLIENT_OK) { return map_ret_val_vhost_client_2_vhost_net(vhost_client_ret_val); } (*client) = calloc(1, sizeof(vhost_net)); if(!(*client)) { return E_VHOST_NET_ERR_ALLOC; } (*client)->context = run_vhost_client; (*client)->tx = run_vhost_client->vhost_net_app_handler.tx_func_handler; (*client)->rx = run_vhost_client->vhost_net_app_handler.rx_func_handler; return E_VHOST_NET_OK; }