aboutsummaryrefslogtreecommitdiff
path: root/src/core/core_api_iterate_peers.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-08-21 15:17:23 +0000
committerChristian Grothoff <christian@grothoff.org>2013-08-21 15:17:23 +0000
commit4440df3d5ddffe5038b0354075e85c18fee57f3a (patch)
tree62a40f8b837c732624cbe2808d4145a32242b012 /src/core/core_api_iterate_peers.c
parent5a38c8f0d1826ea964e3e3452e1a3a2a24d7d35b (diff)
downloadgnunet-4440df3d5ddffe5038b0354075e85c18fee57f3a.tar.gz
gnunet-4440df3d5ddffe5038b0354075e85c18fee57f3a.zip
removing deprecated, dead test-connected API
Diffstat (limited to 'src/core/core_api_iterate_peers.c')
-rw-r--r--src/core/core_api_iterate_peers.c27
1 files changed, 7 insertions, 20 deletions
diff --git a/src/core/core_api_iterate_peers.c b/src/core/core_api_iterate_peers.c
index cc3db6476..4889e638a 100644
--- a/src/core/core_api_iterate_peers.c
+++ b/src/core/core_api_iterate_peers.c
@@ -37,6 +37,7 @@ struct GNUNET_CORE_RequestContext
37 struct GNUNET_CLIENT_Connection *client; 37 struct GNUNET_CLIENT_Connection *client;
38 38
39 /** 39 /**
40
40 * Handle for transmitting a request. 41 * Handle for transmitting a request.
41 */ 42 */
42 struct GNUNET_CLIENT_TransmitHandle *th; 43 struct GNUNET_CLIENT_TransmitHandle *th;
@@ -120,7 +121,7 @@ receive_info (void *cls, const struct GNUNET_MessageHeader *msg)
120 * NULL and "size" zero if the socket was closed for 121 * NULL and "size" zero if the socket was closed for
121 * writing in the meantime. 122 * writing in the meantime.
122 * 123 *
123 * @param cls closure 124 * @param cls closure, always NULL
124 * @param size number of bytes available in buf 125 * @param size number of bytes available in buf
125 * @param buf where the callee should write the message 126 * @param buf where the callee should write the message
126 * @return number of bytes written to buf 127 * @return number of bytes written to buf
@@ -129,32 +130,19 @@ static size_t
129transmit_request (void *cls, size_t size, void *buf) 130transmit_request (void *cls, size_t size, void *buf)
130{ 131{
131 struct GNUNET_MessageHeader *msg; 132 struct GNUNET_MessageHeader *msg;
132 struct GNUNET_PeerIdentity *peer = cls;
133 int msize; 133 int msize;
134 134
135 if (peer == NULL) 135 msize = sizeof (struct GNUNET_MessageHeader);
136 msize = sizeof (struct GNUNET_MessageHeader);
137 else
138 msize =
139 sizeof (struct GNUNET_MessageHeader) +
140 sizeof (struct GNUNET_PeerIdentity);
141 if ((size < msize) || (buf == NULL)) 136 if ((size < msize) || (buf == NULL))
142 return 0; 137 return 0;
143 msg = (struct GNUNET_MessageHeader *) buf; 138 msg = (struct GNUNET_MessageHeader *) buf;
144 msg->size = htons (msize); 139 msg->size = htons (msize);
145 if (peer != NULL) 140 msg->type = htons (GNUNET_MESSAGE_TYPE_CORE_ITERATE_PEERS);
146 {
147 msg->type = htons (GNUNET_MESSAGE_TYPE_CORE_PEER_CONNECTED);
148 memcpy (&msg[1], peer, sizeof (struct GNUNET_PeerIdentity));
149 }
150 else
151 msg->type = htons (GNUNET_MESSAGE_TYPE_CORE_ITERATE_PEERS);
152 141
153 return msize; 142 return msize;
154} 143}
155 144
156 145
157
158/** 146/**
159 * Iterate over all currently connected peers. 147 * Iterate over all currently connected peers.
160 * Calls peer_cb with each connected peer, and then 148 * Calls peer_cb with each connected peer, and then
@@ -163,9 +151,8 @@ transmit_request (void *cls, size_t size, void *buf)
163 * 151 *
164 * @param cfg configuration to use 152 * @param cfg configuration to use
165 * @param peer_cb function to call with the peer information 153 * @param peer_cb function to call with the peer information
166 * @param cb_cls closure for peer_cb 154 * @param cb_cls closure for @a peer_cb
167 * 155 * @return #GNUNET_OK if iterating, #GNUNET_SYSERR on error
168 * @return GNUNET_OK if iterating, GNUNET_SYSERR on error
169 */ 156 */
170int 157int
171GNUNET_CORE_iterate_peers (const struct GNUNET_CONFIGURATION_Handle *cfg, 158GNUNET_CORE_iterate_peers (const struct GNUNET_CONFIGURATION_Handle *cfg,
@@ -178,7 +165,7 @@ GNUNET_CORE_iterate_peers (const struct GNUNET_CONFIGURATION_Handle *cfg,
178 client = GNUNET_CLIENT_connect ("core", cfg); 165 client = GNUNET_CLIENT_connect ("core", cfg);
179 if (client == NULL) 166 if (client == NULL)
180 return GNUNET_SYSERR; 167 return GNUNET_SYSERR;
181 request_context = GNUNET_malloc (sizeof (struct GNUNET_CORE_RequestContext)); 168 request_context = GNUNET_new (struct GNUNET_CORE_RequestContext);
182 request_context->client = client; 169 request_context->client = client;
183 request_context->peer_cb = peer_cb; 170 request_context->peer_cb = peer_cb;
184 request_context->cb_cls = cb_cls; 171 request_context->cb_cls = cb_cls;