* @author Julius Bünger
*/
#include "platform.h"
+#include "gnunet_applications.h"
#include "gnunet_util_lib.h"
#include "gnunet_cadet_service.h"
#include "gnunet_peerinfo_service.h"
* @param server the initialized server
* @param c configuration to use
*/
- static void
+static void
run (void *cls,
struct GNUNET_SERVER_Handle *server,
const struct GNUNET_CONFIGURATION_Handle *c)
{
+ static const struct GNUNET_CADET_MessageHandler cadet_handlers[] = {
+ {&handle_peer_push , GNUNET_MESSAGE_TYPE_RPS_PP_PUSH ,
+ sizeof (struct GNUNET_MessageHeader)},
+ {&handle_peer_pull_request, GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST,
+ sizeof (struct GNUNET_MessageHeader)},
+ {&handle_peer_pull_reply , GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REPLY , 0},
+ {NULL, 0, 0}
+ };
+
int size;
int out_size;
char* fn_valid_peers;
+ struct GNUNET_HashCode port;
GNUNET_log_setup ("rps", GNUNET_error_type_to_string (GNUNET_ERROR_TYPE_DEBUG), NULL);
cfg = c;
/* Initialise cadet */
- static const struct GNUNET_CADET_MessageHandler cadet_handlers[] = {
- {&handle_peer_push , GNUNET_MESSAGE_TYPE_RPS_PP_PUSH ,
- sizeof (struct GNUNET_MessageHeader)},
- {&handle_peer_pull_request, GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST,
- sizeof (struct GNUNET_MessageHeader)},
- {&handle_peer_pull_reply , GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REPLY , 0},
- {NULL, 0, 0}
- };
cadet_handle = GNUNET_CADET_connect (cfg,
cls,
&cleanup_destroyed_channel,
cadet_handlers);
GNUNET_assert (NULL != cadet_handle);
- GNUNET_CADET_open_port (cadet_handle, GC_u2h (GNUNET_RPS_CADET_PORT),
+ GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_RPS,
+ strlen (GNUNET_APPLICATION_PORT_RPS),
+ &port);
+ GNUNET_CADET_open_port (cadet_handle,
+ &port,
&Peers_handle_inbound_channel, cls);
* @author Julius Bünger
*/
#include "platform.h"
+#include "gnunet_applications.h"
#include "gnunet_util_lib.h"
#include "gnunet_cadet_service.h"
#include <inttypes.h>
return ctx;
}
+
/**
* @brief Create a new #PeerContext and insert it into the peer map
*
return ctx;
}
+
/**
* @brief Create or get a #PeerContext
*
return get_peer_ctx (peer);
}
+
/**
* @brief Check whether we have a connection to this @a peer
*
return GNUNET_YES;
}
+
/**
* @brief The closure to #get_rand_peer_iterator.
*/
const struct GNUNET_PeerIdentity *peer;
};
+
/**
* @brief Iterator function for #get_random_peer_from_peermap.
*
return GNUNET_YES;
}
+
/**
* @brief Get a random peer from @a peer_map
*
return ret;
}
+
/**
* @brief Add a given @a peer to valid peers.
*
return ret;
}
+
/**
* @brief Set the peer flag to living and
* call the pending operations on this peer.
GNUNET_array_grow (peer_ctx->pending_ops, peer_ctx->num_pending_ops, 0);
}
+
/**
* @brief Get the channel of a peer. If not existing, create.
*
get_channel (const struct GNUNET_PeerIdentity *peer)
{
struct PeerContext *peer_ctx;
+ struct GNUNET_HashCode port;
peer_ctx = get_peer_ctx (peer);
if (NULL == peer_ctx->send_channel)
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Trying to establish channel to peer %s\n",
GNUNET_i2s (peer));
+ GNUNET_CRYPTO_hash (GNUNET_APPLICATION_PORT_RPS,
+ strlen (GNUNET_APPLICATION_PORT_RPS),
+ &port);
peer_ctx->send_channel =
GNUNET_CADET_channel_create (cadet_handle,
peer_ctx->send_channel_flags, /* context */
peer,
- GC_u2h (GNUNET_RPS_CADET_PORT),
+ &port,
GNUNET_CADET_OPTION_RELIABLE);
}
GNUNET_assert (NULL != peer_ctx->send_channel);
return peer_ctx->send_channel;
}
+
/**
* Get the message queue (#GNUNET_MQ_Handle) of a specific peer.
*
return pending_msg;
}
+
/**
* @brief Remove a pending message from the respective DLL
*
GNUNET_free (pending_msg);
}
+
/**
* @brief Check whether function of type #PeerOp was already scheduled
*
return GNUNET_NO;
}
+
/**
* Iterator over hash map entries. Deletes all contexts of peers.
*
return GNUNET_YES;
}
+
/**
* @brief This is called once a message is sent.
*
remove_pending_message (pending_msg);
}
+
/**
* @brief Iterator function for #store_valid_peers.
*
return GNUNET_YES;
}
+
/**
* @brief Store the peers currently in #valid_peers to disk.
*/
GNUNET_CONTAINER_multipeermap_size (valid_peers));
}
+
/**
* @brief Convert string representation of peer id to peer id.
*
return peer;
}
+
/**
* @brief Restore the peers on disk to #valid_peers.
*/
num_peers);
}
+
/**
* @brief Initialise storage of peers
*
restore_valid_peers ();
}
+
/**
* @brief Delete storage of peers that was created with #Peers_initialise ()
*/
return ret;
}
+
/**
* @brief Add peer to known peers.
*
return ret;
}
+
/**
* @brief Remove unecessary data
*
return GNUNET_YES;
}
+
/**
* @brief Remove peer
*
return GNUNET_YES;
}
+
/**
* @brief set flags on a given peer.
*
set_peer_flag (peer_ctx, flags);
}
+
/**
* @brief unset flags on a given peer.
*
unset_peer_flag (peer_ctx, flags);
}
+
/**
* @brief Check whether flags on a peer are set.
*
set_channel_flag (channel_flags, flags);
}
+
/**
* @brief unset flags on a given channel.
*
unset_channel_flag (channel_flags, flags);
}
+
/**
* @brief Check whether flags on a channel are set.
*
return check_channel_flag_set (channel_flags, flags);
}
+
/**
* @brief Check whether we have information about the given peer.
*
return GNUNET_CONTAINER_multipeermap_contains (peer_map, peer);
}
+
/**
* @brief Check whether @a peer is actually a peer.
*
return GNUNET_CONTAINER_multipeermap_contains (valid_peers, peer);
}
+
/**
* @brief Indicate that we want to send to the other peer
*
(void) get_channel (peer);
}
+
/**
* @brief Check whether other peer has the intention to send/opened channel
* towars us
return GNUNET_NO;
}
+
/**
* Handle the channel a peer opens to us.
*
return peer_ctx->recv_channel_flags;
}
+
/**
* @brief Check whether a sending channel towards the given peer exists
*
return GNUNET_YES;
}
+
/**
* @brief check whether the given channel is the sending channel of the given
* peer
return GNUNET_NO;
}
+
/**
* @brief Destroy the send channel of a peer e.g. stop indicating a sending
* intention to another peer