[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r33821 - gnunet/src/cadet
From: |
gnunet |
Subject: |
[GNUnet-SVN] r33821 - gnunet/src/cadet |
Date: |
Tue, 24 Jun 2014 05:31:39 +0200 |
Author: bartpolot
Date: 2014-06-24 05:31:39 +0200 (Tue, 24 Jun 2014)
New Revision: 33821
Modified:
gnunet/src/cadet/cadet_api.c
gnunet/src/cadet/gnunet-service-cadet_local.c
Log:
- more info API
Modified: gnunet/src/cadet/cadet_api.c
===================================================================
--- gnunet/src/cadet/cadet_api.c 2014-06-24 03:10:02 UTC (rev 33820)
+++ gnunet/src/cadet/cadet_api.c 2014-06-24 03:31:39 UTC (rev 33821)
@@ -1078,13 +1078,9 @@
struct GNUNET_CADET_LocalInfoTunnel *msg;
size_t esize;
size_t msize;
- unsigned int ch_n;
- unsigned int c_n;
- struct GNUNET_CADET_Hash *conns;
- CADET_ChannelNumber *chns;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Get Tunnel messasge received\n");
- if (NULL == h->info_cb.tunnel_cb)
+ if (NULL == h->info_cb.peer_cb)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " ignored\n");
return;
@@ -1093,38 +1089,28 @@
/* Verify message sanity */
msg = (struct GNUNET_CADET_LocalInfoTunnel *) message;
msize = ntohs (message->size);
- esize = sizeof (struct GNUNET_CADET_LocalInfoTunnel);
+ esize = sizeof (struct GNUNET_CADET_LocalInfoPeer);
if (esize > msize)
{
GNUNET_break_op (0);
- h->info_cb.tunnel_cb (h->info_cls, NULL, 0, 0, NULL, NULL, 0, 0);
+ h->info_cb.peer_cb (h->info_cls, NULL, 0, 0, 0, NULL);
goto clean_cls;
}
- ch_n = ntohl (msg->channels);
- c_n = ntohl (msg->connections);
- esize += ch_n * sizeof (CADET_ChannelNumber);
- esize += c_n * sizeof (struct GNUNET_CADET_Hash);
+// esize += ch_n * sizeof (CADET_ChannelNumber);
+// esize += c_n * sizeof (struct GNUNET_CADET_Hash);
if (msize != esize)
{
GNUNET_break_op (0);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "m:%u, e: %u (%u ch, %u conn)\n",
- msize, esize, ch_n, c_n);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%u (%u ch, %u conn)\n",
- sizeof (struct GNUNET_CADET_LocalInfoTunnel),
- sizeof (CADET_ChannelNumber), sizeof (struct GNUNET_HashCode));
- h->info_cb.tunnel_cb (h->info_cls, NULL, 0, 0, NULL, NULL, 0, 0);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "m:%u, e: %u\n", msize, esize);
+ h->info_cb.peer_cb (h->info_cls, NULL, 0, 0, 0, NULL);
goto clean_cls;
}
/* Call Callback with tunnel info. */
- conns = (struct GNUNET_CADET_Hash *) &msg[1];
- chns = (CADET_ChannelNumber *) &conns[c_n];
- h->info_cb.tunnel_cb (h->info_cls, &msg->destination,
- ch_n, c_n, chns, conns,
- ntohs (msg->estate), ntohs (msg->cstate));
+ h->info_cb.peer_cb (h->info_cls, &msg->destination, 0, 0, 0, NULL);
clean_cls:
- h->info_cb.tunnel_cb = NULL;
+ h->info_cb.peer_cb = NULL;
h->info_cls = NULL;
}
Modified: gnunet/src/cadet/gnunet-service-cadet_local.c
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_local.c 2014-06-24 03:10:02 UTC
(rev 33820)
+++ gnunet/src/cadet/gnunet-service-cadet_local.c 2014-06-24 03:31:39 UTC
(rev 33821)
@@ -680,6 +680,76 @@
/**
+ * Handler for client's SHOW_PEER request.
+ *
+ * @param cls Closure (unused).
+ * @param client Identification of the client.
+ * @param message The actual message.
+ */
+void
+handle_show_peer (void *cls, struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader *message)
+{
+ const struct GNUNET_CADET_LocalInfo *msg;
+ struct GNUNET_CADET_LocalInfoPeer *resp;
+ struct CadetPeer *p;
+ struct CadetClient *c;
+ size_t size;
+
+ /* Sanity check for client registration */
+ if (NULL == (c = GML_client_get (client)))
+ {
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
+
+ msg = (struct GNUNET_CADET_LocalInfo *) message;
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ "Received peer info request from client %u for peer %s\n",
+ c->id, GNUNET_i2s_full (&msg->peer));
+
+ p = GCP_get (&msg->peer);
+ if (NULL == p)
+ {
+ /* We don't know the peer */
+ struct GNUNET_CADET_LocalInfoPeer warn;
+
+ LOG (GNUNET_ERROR_TYPE_INFO, "Peer %s unknown %u\n",
+ GNUNET_i2s_full (&msg->peer), sizeof (warn));
+ warn.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER);
+ warn.header.size = htons (sizeof (warn));
+ warn.destination = msg->peer;
+ warn.paths = htons (0);
+ warn.tunnel = htons (NULL != GCP_get_tunnel (p));
+
+ GNUNET_SERVER_notification_context_unicast (nc, client,
+ &warn.header,
+ GNUNET_NO);
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ return;
+ }
+
+ size = sizeof (struct GNUNET_CADET_LocalInfoPeer);
+// size += c_n * sizeof (struct GNUNET_CADET_Hash);
+
+ resp = GNUNET_malloc (size);
+ resp->header.type = htons (GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER);
+ resp->header.size = htons (size);
+ resp->destination = msg->peer;
+ resp->paths = htons (0);
+ resp->tunnel = htons (0);
+
+ GNUNET_SERVER_notification_context_unicast (nc, c->handle,
+ &resp->header, GNUNET_NO);
+ GNUNET_free (resp);
+
+ LOG (GNUNET_ERROR_TYPE_INFO, "Show peer request from client %u
completed.\n");
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+}
+
+
+/**
* Iterator over all tunnels to send a monitoring client info about each
tunnel.
*
* @param cls Closure ().
@@ -908,6 +978,8 @@
sizeof (struct GNUNET_CADET_LocalAck)},
{&handle_get_peers, NULL, GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEERS,
sizeof (struct GNUNET_MessageHeader)},
+ {&handle_show_peer, NULL, GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_PEER,
+ sizeof (struct GNUNET_CADET_LocalInfo)},
{&handle_get_tunnels, NULL, GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNELS,
sizeof (struct GNUNET_MessageHeader)},
{&handle_show_tunnel, NULL, GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r33821 - gnunet/src/cadet,
gnunet <=