X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fcore%2Fgnunet-service-core_kx.h;h=28293e6072143de5e920c797e7f2c72ca2a95a1e;hb=81ea73fcf38405a714d949189ed0ec6bc5b6bea6;hp=f4f1daaeb9ed692447fe9ecad914b2ffd1997101;hpb=0f29195adbd56ae10dea70c2951333c13e765f88;p=oweals%2Fgnunet.git diff --git a/src/core/gnunet-service-core_kx.h b/src/core/gnunet-service-core_kx.h index f4f1daaeb..28293e607 100644 --- a/src/core/gnunet-service-core_kx.h +++ b/src/core/gnunet-service-core_kx.h @@ -1,77 +1,102 @@ -struct GSC_KeyExchangeInfo -{ - - /** - * SetKeyMessage to transmit, NULL if we are not currently trying - * to send one. - */ - struct SetKeyMessage *skm; - - /** - * Non-NULL if we are currently looking up HELLOs for this peer. - * for this peer. - */ - struct GNUNET_PEERINFO_IteratorContext *pitr; - - /** - * Public key of the neighbour, NULL if we don't have it yet. - */ - struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key; - - /** - * We received a PING message before we got the "public_key" - * (or the SET_KEY). We keep it here until we have a key - * to decrypt it. NULL if no PING is pending. - */ - struct PingMessage *pending_ping; - - /** - * We received a PONG message before we got the "public_key" - * (or the SET_KEY). We keep it here until we have a key - * to decrypt it. NULL if no PONG is pending. - */ - struct PongMessage *pending_pong; - - /** - * Key we use to encrypt our messages for the other peer - * (initialized by us when we do the handshake). - */ - struct GNUNET_CRYPTO_AesSessionKey encrypt_key; - - /** - * Key we use to decrypt messages from the other peer - * (given to us by the other peer during the handshake). - */ - struct GNUNET_CRYPTO_AesSessionKey decrypt_key; - - /** - * At what time did we generate our encryption key? - */ - struct GNUNET_TIME_Absolute encrypt_key_created; - - /** - * At what time did the other peer generate the decryption key? - */ - struct GNUNET_TIME_Absolute decrypt_key_created; - - /** - * At what frequency are we currently re-trying SET_KEY messages? - */ - struct GNUNET_TIME_Relative set_key_retry_frequency; - - /** - * ID of task used for re-trying SET_KEY and PING message. - */ - GNUNET_SCHEDULER_TaskIdentifier retry_set_key_task; - - /** - * What was our PING challenge number (for this peer)? - */ - uint32_t ping_challenge; - - /** - * What is our connection status? - */ - enum PeerStateMachine status; - -}; +/* + This file is part of GNUnet. + Copyright (C) 2009, 2010, 2011 GNUnet e.V. + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +/** + * @file core/gnunet-service-core_kx.h + * @brief code for managing the key exchange (SET_KEY, PING, PONG) with other peers + * @author Christian Grothoff + */ +#ifndef GNUNET_SERVICE_CORE_KX_H +#define GNUNET_SERVICE_CORE_KX_H + +#include "gnunet_util_lib.h" +#include "gnunet_transport_service.h" + + +/** + * Information about the status of a key exchange with another peer. + */ +struct GSC_KeyExchangeInfo; + + +/** + * Encrypt and transmit a message with the given payload. + * + * @param kx key exchange context + * @param payload payload of the message + * @param payload_size number of bytes in 'payload' + */ +void +GSC_KX_encrypt_and_transmit (struct GSC_KeyExchangeInfo *kx, + const void *payload, + size_t payload_size); + + +/** + * Initialize KX subsystem. + * + * @param pk private key to use for the peer + * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure + */ +int +GSC_KX_init (struct GNUNET_CRYPTO_EddsaPrivateKey *pk); + + +/** + * Shutdown KX subsystem. + */ +void +GSC_KX_done (void); + + +/** + * Check if the given neighbour has excess bandwidth available. + * + * @param target neighbour to check + * @return #GNUNET_YES if excess bandwidth is available, #GNUNET_NO if not + */ +int +GSC_NEIGHBOURS_check_excess_bandwidth (const struct GSC_KeyExchangeInfo *target); + + +/** + * Check how many messages are queued for the given neighbour. + * + * @param target neighbour to check + * @return number of items in the message queue + */ +unsigned int +GSC_NEIGHBOURS_get_queue_length (const struct GSC_KeyExchangeInfo *target); + + +/** + * Handle #GNUNET_MESSAGE_TYPE_CORE_MONITOR_PEERS request. For this + * request type, the client does not have to have transmitted an INIT + * request. All current peers are returned, regardless of which + * message types they accept. + * + * @param mq message queue to add for monitoring + */ +void +GSC_KX_handle_client_monitor_peers (struct GNUNET_MQ_Handle *mq); + + +#endif +/* end of gnunet-service-core_kx.h */