#define DEBUG_CHAT_SERVICE GNUNET_EXTRA_LOGGING
#define MAX_TRANSMIT_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
#define EXPECTED_NEIGHBOUR_COUNT 16
-#define QUEUE_SIZE 16
#define MAX_ANONYMOUS_MSG_LIST_LENGTH 16
/**
* Hash of the public key (for convenience).
*/
- GNUNET_HashCode id;
+ struct GNUNET_HashCode id;
/**
* Options which the client is willing to receive.
/**
* Hash of the message.
*/
- GNUNET_HashCode hash;
+ struct GNUNET_HashCode hash;
};
/**
* The identity of this host.
*/
-static const struct GNUNET_PeerIdentity *me;
+static struct GNUNET_PeerIdentity me;
/**
* Head of the list of current clients.
remember_anonymous_message (const struct P2PReceiveNotificationMessage
*p2p_rnmsg)
{
- static GNUNET_HashCode hash;
+ static struct GNUNET_HashCode hash;
struct AnonymousMessage *anon_msg;
struct AnonymousMessage *prev;
int anon_list_len;
static int
lookup_anonymous_message (const struct P2PReceiveNotificationMessage *p2p_rnmsg)
{
- static GNUNET_HashCode hash;
+ static struct GNUNET_HashCode hash;
struct AnonymousMessage *anon_msg;
GNUNET_CRYPTO_hash (p2p_rnmsg, ntohs (p2p_rnmsg->header.size), &hash);
anon_msg = anonymous_list_head;
while ((NULL != anon_msg) &&
- (0 != memcmp (&anon_msg->hash, &hash, sizeof (GNUNET_HashCode))))
+ (0 != memcmp (&anon_msg->hash, &hash, sizeof (struct GNUNET_HashCode))))
anon_msg = anon_msg->next;
return (NULL != anon_msg);
}
* Ask to send a message notification to the peer.
*/
static int
-send_message_noficiation (void *cls, const GNUNET_HashCode * key, void *value)
+send_message_noficiation (void *cls, const struct GNUNET_HashCode * key, void *value)
{
struct P2PReceiveNotificationMessage *msg = cls;
struct ConnectedPeer *cp = value;
handle_transmit_request (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
- static GNUNET_HashCode all_zeros;
+ static struct GNUNET_HashCode all_zeros;
const struct TransmitRequestMessage *trmsg;
struct ReceiveNotificationMessage *rnmsg;
struct P2PReceiveNotificationMessage *p2p_rnmsg;
is_anon = (0 != (ntohl (trmsg->msg_options) & GNUNET_CHAT_MSG_ANONYMOUS));
if (is_anon)
{
- memset (&rnmsg->sender, 0, sizeof (GNUNET_HashCode));
+ memset (&rnmsg->sender, 0, sizeof (struct GNUNET_HashCode));
rnmsg->sequence_number = 0;
}
else
"Encrypting the session key using the public key of '%s'\n",
GNUNET_h2s (&trmsg->target));
#endif
- if (0 == memcmp (&all_zeros, &trmsg->target, sizeof (GNUNET_HashCode)))
+ if (0 == memcmp (&all_zeros, &trmsg->target, sizeof (struct GNUNET_HashCode)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Malformed message: private, but no target\n");
target = client_list_head;
while ((NULL != target) &&
(0 !=
- memcmp (&target->id, &trmsg->target, sizeof (GNUNET_HashCode))))
+ memcmp (&target->id, &trmsg->target, sizeof (struct GNUNET_HashCode))))
target = target->next;
if (NULL == target)
{
(pos->client != client))
{
if (((!is_priv) ||
- (0 == memcmp (&trmsg->target, &pos->id, sizeof (GNUNET_HashCode))))
+ (0 == memcmp (&trmsg->target, &pos->id, sizeof (struct GNUNET_HashCode))))
&& (0 == (ntohl (trmsg->msg_options) & (~pos->msg_options))))
{
GNUNET_SERVER_notification_context_unicast (nc, pos->client,
* Ask to send a join notification to the peer.
*/
static int
-send_join_noficiation (void *cls, const GNUNET_HashCode * key, void *value)
+send_join_noficiation (void *cls, const struct GNUNET_HashCode * key, void *value)
{
struct ChatClient *entry = cls;
struct ConnectedPeer *cp = value;
* Ask to send a confirmation receipt to the peer.
*/
static int
-send_confirmation_receipt (void *cls, const GNUNET_HashCode * key, void *value)
+send_confirmation_receipt (void *cls, const struct GNUNET_HashCode * key, void *value)
{
struct P2PConfirmationReceiptMessage *receipt = cls;
struct ConnectedPeer *cp = value;
author = client_list_head;
while ((NULL != author) &&
(0 !=
- memcmp (&receipt->author, &author->id, sizeof (GNUNET_HashCode))))
+ memcmp (&receipt->author, &author->id, sizeof (struct GNUNET_HashCode))))
author = author->next;
if (NULL == author)
{
target = client_list_head;
while ((NULL != target) &&
(0 !=
- memcmp (&receipt->target, &target->id, sizeof (GNUNET_HashCode))))
+ memcmp (&receipt->target, &target->id, sizeof (struct GNUNET_HashCode))))
target = target->next;
if (NULL == target)
{
* Ask to send a leave notification to the peer.
*/
static int
-send_leave_noficiation (void *cls, const GNUNET_HashCode * key, void *value)
+send_leave_noficiation (void *cls, const struct GNUNET_HashCode * key, void *value)
{
struct ChatClient *entry = cls;
struct ConnectedPeer *cp = value;
struct ChatClient *new_entry;
struct ChatClient *entry;
struct JoinNotificationMessage *jnmsg;
- GNUNET_HashCode id;
+ struct GNUNET_HashCode id;
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Got P2P join notification\n");
if (ntohs (message->size) <= sizeof (struct P2PJoinNotificationMessage))
entry = client_list_head;
while (NULL != entry)
{
- if (0 == memcmp (&entry->id, &id, sizeof (GNUNET_HashCode)))
+ if (0 == memcmp (&entry->id, &id, sizeof (struct GNUNET_HashCode)))
{
#if DEBUG_CHAT_SERVICE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
unsigned int atsi_count)
{
const struct P2PLeaveNotificationMessage *p2p_lnmsg;
- GNUNET_HashCode id;
+ struct GNUNET_HashCode id;
struct ChatClient *pos;
struct ChatClient *prev;
struct ChatClient *entry;
prev = NULL;
while (NULL != pos)
{
- if (0 == memcmp (&pos->id, &id, sizeof (GNUNET_HashCode)))
+ if (0 == memcmp (&pos->id, &id, sizeof (struct GNUNET_HashCode)))
break;
prev = pos;
pos = pos->next;
struct ReceiveNotificationMessage *rnmsg;
struct ChatClient *sender;
struct ChatClient *pos;
- static GNUNET_HashCode all_zeros;
+ static struct GNUNET_HashCode all_zeros;
int is_priv;
int is_anon;
uint16_t msg_len;
sender = client_list_head;
while ((NULL != sender) &&
(0 !=
- memcmp (&sender->id, &p2p_rnmsg->sender, sizeof (GNUNET_HashCode))))
+ memcmp (&sender->id, &p2p_rnmsg->sender, sizeof (struct GNUNET_HashCode))))
sender = sender->next;
if (NULL == sender)
{
rnmsg->reserved = htonl (0);
rnmsg->timestamp = p2p_rnmsg->timestamp;
is_priv =
- (0 != memcmp (&all_zeros, &p2p_rnmsg->target, sizeof (GNUNET_HashCode)));
+ (0 != memcmp (&all_zeros, &p2p_rnmsg->target, sizeof (struct GNUNET_HashCode)));
if (is_priv)
memcpy (&rnmsg->encrypted_key, &p2p_rnmsg->encrypted_key,
sizeof (struct GNUNET_CRYPTO_RsaEncryptedData));
{
if (((!is_priv) ||
(0 ==
- memcmp (&p2p_rnmsg->target, &pos->id, sizeof (GNUNET_HashCode)))) &&
+ memcmp (&p2p_rnmsg->target, &pos->id, sizeof (struct GNUNET_HashCode)))) &&
(0 == (ntohl (p2p_rnmsg->msg_options) & (~pos->msg_options))))
{
GNUNET_SERVER_notification_context_unicast (nc, pos->client,
target = client_list_head;
while ((NULL != target) &&
(0 !=
- memcmp (&target->id, &p2p_crmsg->target, sizeof (GNUNET_HashCode))))
+ memcmp (&target->id, &p2p_crmsg->target, sizeof (struct GNUNET_HashCode))))
target = target->next;
if (NULL == target)
{
author = client_list_head;
while ((NULL != author) &&
(0 !=
- memcmp (&author->id, &p2p_crmsg->author, sizeof (GNUNET_HashCode))))
+ memcmp (&author->id, &p2p_crmsg->author, sizeof (struct GNUNET_HashCode))))
author = author->next;
if (NULL == author)
{
struct ConnectedPeer *cp;
struct GNUNET_CORE_TransmitHandle *th;
- if (0 == memcmp (peer, me, sizeof (struct GNUNET_PeerIdentity)))
+ if (0 == memcmp (peer, &me, sizeof (struct GNUNET_PeerIdentity)))
return;
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Peer connected: %s\n",
GNUNET_i2s (peer));
* @return GNUNET_YES (we should continue to iterate)
*/
static int
-clean_peer (void *cls, const GNUNET_HashCode * key, void *value)
+clean_peer (void *cls, const struct GNUNET_HashCode * key, void *value)
{
struct ConnectedPeer *cp;
const struct GNUNET_PeerIdentity *peer =
peer_disconnect_handler (void *cls, const struct GNUNET_PeerIdentity *peer)
{
- if (0 == memcmp (peer, me, sizeof (struct GNUNET_PeerIdentity)))
+ if (0 == memcmp (peer, &me, sizeof (struct GNUNET_PeerIdentity)))
return;
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Peer disconnected: %s\n",
GNUNET_i2s (peer));
- clean_peer (NULL, (const GNUNET_HashCode *) peer, NULL);
+ clean_peer (NULL, (const struct GNUNET_HashCode *) peer, NULL);
}
const struct GNUNET_PeerIdentity *my_identity)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Core initialized\n");
- me = my_identity;
+ me = *my_identity;
}
cfg = c;
nc = GNUNET_SERVER_notification_context_create (server, 16);
connected_peers =
- GNUNET_CONTAINER_multihashmap_create (EXPECTED_NEIGHBOUR_COUNT);
+ GNUNET_CONTAINER_multihashmap_create (EXPECTED_NEIGHBOUR_COUNT, GNUNET_NO);
GNUNET_SERVER_add_handlers (server, handlers);
core =
- GNUNET_CORE_connect (cfg, QUEUE_SIZE, NULL, &core_init,
+ GNUNET_CORE_connect (cfg, NULL, &core_init,
&peer_connect_handler, &peer_disconnect_handler,
NULL, GNUNET_NO, NULL, GNUNET_NO, p2p_handlers);
GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL);