static int send_auth_result(server_generic_client_t *client, int result) { int ret; uint64_t nident; prelude_client_profile_t *cp; if ( ! client->msg ) { ret = prelude_msg_new(&client->msg, 1, sizeof(uint64_t), PRELUDE_MSG_AUTH, 0); if ( ret < 0 ) return -1; cp = prelude_client_get_profile(manager_client); nident = prelude_hton64(prelude_client_profile_get_analyzerid(cp)); prelude_msg_set(client->msg, result, sizeof(nident), &nident); } ret = prelude_msg_write(client->msg, client->fd); if ( ret < 0 ) { if ( prelude_error_get_code(ret) == PRELUDE_ERROR_EAGAIN ) { server_generic_notify_write_enable(client); return 0; } prelude_msg_destroy(client->msg); return -1; } prelude_msg_destroy(client->msg); client->msg = NULL; return (client->state & SERVER_GENERIC_CLIENT_STATE_AUTHENTICATED) ? 1 : -1; }
int prelude_option_new_request(prelude_msgbuf_t *msgbuf, uint32_t request_id, uint64_t *target_id, size_t size) { size_t i; uint32_t hop, instance_id = 0; prelude_msg_set_tag(prelude_msgbuf_get_msg(msgbuf), PRELUDE_MSG_OPTION_REQUEST); /* * the caller is supposed to provide a full path, * from him to the destination, to the original hop is 1. */ hop = htonl(1); for ( i = 0; i < size; i++ ) target_id[i] = prelude_hton64(target_id[i]); request_id = htonl(request_id); prelude_msgbuf_set(msgbuf, PRELUDE_MSG_OPTION_REQUEST_ID, sizeof(request_id), &request_id); prelude_msgbuf_set(msgbuf, PRELUDE_MSG_OPTION_TARGET_ID, i * sizeof(*target_id), target_id); prelude_msgbuf_set(msgbuf, PRELUDE_MSG_OPTION_TARGET_INSTANCE_ID, sizeof(instance_id), &instance_id); prelude_msgbuf_set(msgbuf, PRELUDE_MSG_OPTION_HOP, sizeof(hop), &hop); return 0; }