static int pscom_extoll_accept(pscom_con_t *con, int con_fd) { int arch = PSCOM_ARCH_EXTOLL; psex_con_info_t *ci = psex_con_create(); psex_info_msg_t msg; if (!ci) goto err_no_ci; if (psex_init()) goto out_noextoll; if (psex_con_init(ci, NULL, con)) goto dont_use; /* Initialize connection */ /* step 1: Yes, we talk extoll. */ pscom_writeall(con_fd, &arch, sizeof(arch)); /* step 2: Send Connection id's */ psex_con_get_info_msg(ci, &msg); pscom_writeall(con_fd, &msg, sizeof(msg)); /* step 3 : recv connection id's */ if ((pscom_readall(con_fd, &msg, sizeof(msg)) != sizeof(msg))) goto err_remote; /* Connect */ if (psex_con_connect(ci, &msg)) { /* ToDo: bad! How to inform the peer about the error? */ DPRINT(0, "Extoll psex_con_connect() failed!"); goto err_local; } pscom_extoll_con_init(con, con_fd, ci); return 1; /* --- */ err_local: err_remote: if (ci) psex_con_cleanup(ci); if (ci) psex_con_free(ci); return 0; /* --- */ dont_use: out_noextoll: psex_con_free(ci); err_no_ci: arch = PSCOM_ARCH_ERROR; pscom_writeall(con_fd, &arch, sizeof(arch)); return 0; /* Dont use extoll */ /* --- */ }
static int pscom_extoll_con_init(pscom_con_t *con) { return psex_init(); }