Bool RpcOut_start(RpcOut *out) // IN { ASSERT(out); ASSERT(out->channel == NULL); out->channel = Message_Open(RPCI_PROTOCOL_NUM); if (out->channel == NULL) { Debug("RpcOut: couldn't open channel with RPCI protocol\n"); return FALSE; } return TRUE; }
static Bool RpcInOpenChannel(RpcIn *in, // IN Bool useBackdoorOnly) // IN { #if defined(VMTOOLS_USE_VSOCKET) static Bool first = TRUE; static Bool initOk = TRUE; AsyncSocket *asock; int res; ASSERT(in->conn == NULL); while (TRUE) { /* one pass loop */ if (useBackdoorOnly) { break; } if (first) { first = FALSE; res = AsyncSocket_Init(); initOk = (res == ASOCKERR_SUCCESS); if (!initOk) { Debug("RpcIn: Error in socket initialization: %s\n", AsyncSocket_Err2String(res)); break; } } if (!initOk) { break; } in->conn = calloc(1, sizeof *(in->conn)); if (in->conn == NULL) { Debug("RpcIn: Error in allocating memory for vsocket connection.\n"); break; } in->conn->in = in; asock = AsyncSocket_ConnectVMCI(VMCI_HYPERVISOR_CONTEXT_ID, GUESTRPC_TCLO_VSOCK_LISTEN_PORT, RpcInConnectDone, in->conn, 0, NULL, &res); if (asock == NULL) { Debug("RpcIn: Error in creating vsocket connection: %s\n", AsyncSocket_Err2String(res)); } else { res = AsyncSocket_SetErrorFn(asock, RpcInConnErrorHandler, in->conn); if (res != ASOCKERR_SUCCESS) { Debug("RpcIn: Error in setting error handler for vsocket %d\n", AsyncSocket_GetFd(asock)); AsyncSocket_Close(asock); } else { Debug("RpcIn: successfully created vsocket connection %d.\n", AsyncSocket_GetFd(asock)); in->conn->asock = asock; return TRUE; } } break; } if (in->conn != NULL) { free(in->conn); in->conn = NULL; } #endif ASSERT(in->channel == NULL); in->channel = Message_Open(0x4f4c4354); if (in->channel == NULL) { Debug("RpcIn: couldn't open channel with TCLO protocol\n"); goto error; } if (!RpcInScheduleRecvEvent(in)) { Debug("RpcIn_start: couldn't start the loop\n"); goto error; } in->mustSend = TRUE; return TRUE; error: RpcInStop(in); return FALSE; }