diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-04-04 12:02:43 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-04-04 12:02:43 +0000 |
commit | 425e9cdea733ca7be9a901abff7a070c460fa84d (patch) | |
tree | c4e2919e2f4183a324801c061fb2d57a3b232ddc /src/peerinfo/peerinfo_api_notify.c | |
parent | 6713f0ce7d70cdb5cb0172157e647b8dfb6852ff (diff) | |
download | gnunet-425e9cdea733ca7be9a901abff7a070c460fa84d.tar.gz gnunet-425e9cdea733ca7be9a901abff7a070c460fa84d.zip |
peerinfo API change + changes in code using api
Diffstat (limited to 'src/peerinfo/peerinfo_api_notify.c')
-rw-r--r-- | src/peerinfo/peerinfo_api_notify.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/peerinfo/peerinfo_api_notify.c b/src/peerinfo/peerinfo_api_notify.c index b9e83c9e7..4520decfd 100644 --- a/src/peerinfo/peerinfo_api_notify.c +++ b/src/peerinfo/peerinfo_api_notify.c | |||
@@ -69,6 +69,11 @@ struct GNUNET_PEERINFO_NotifyContext | |||
69 | */ | 69 | */ |
70 | GNUNET_SCHEDULER_TaskIdentifier task; | 70 | GNUNET_SCHEDULER_TaskIdentifier task; |
71 | 71 | ||
72 | /** | ||
73 | * Include friend only HELLOs in callbacks | ||
74 | */ | ||
75 | |||
76 | int include_friend_only; | ||
72 | }; | 77 | }; |
73 | 78 | ||
74 | 79 | ||
@@ -195,7 +200,7 @@ static size_t | |||
195 | transmit_notify_request (void *cls, size_t size, void *buf) | 200 | transmit_notify_request (void *cls, size_t size, void *buf) |
196 | { | 201 | { |
197 | struct GNUNET_PEERINFO_NotifyContext *nc = cls; | 202 | struct GNUNET_PEERINFO_NotifyContext *nc = cls; |
198 | struct GNUNET_MessageHeader hdr; | 203 | struct NotifyMessage nm; |
199 | 204 | ||
200 | nc->init = NULL; | 205 | nc->init = NULL; |
201 | if (buf == NULL) | 206 | if (buf == NULL) |
@@ -205,10 +210,11 @@ transmit_notify_request (void *cls, size_t size, void *buf) | |||
205 | request_notifications (nc); | 210 | request_notifications (nc); |
206 | return 0; | 211 | return 0; |
207 | } | 212 | } |
208 | GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader)); | 213 | GNUNET_assert (size >= sizeof (struct NotifyMessage)); |
209 | hdr.size = htons (sizeof (struct GNUNET_MessageHeader)); | 214 | nm.header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_NOTIFY); |
210 | hdr.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_NOTIFY); | 215 | nm.header.size = htons (sizeof (struct NotifyMessage)); |
211 | memcpy (buf, &hdr, sizeof (struct GNUNET_MessageHeader)); | 216 | nm.include_friend_only = htonl (nc->include_friend_only); |
217 | memcpy (buf, &nm, sizeof (struct NotifyMessage)); | ||
212 | receive_notifications (nc); | 218 | receive_notifications (nc); |
213 | return sizeof (struct GNUNET_MessageHeader); | 219 | return sizeof (struct GNUNET_MessageHeader); |
214 | } | 220 | } |
@@ -226,7 +232,7 @@ request_notifications (struct GNUNET_PEERINFO_NotifyContext *nc) | |||
226 | GNUNET_assert (NULL == nc->init); | 232 | GNUNET_assert (NULL == nc->init); |
227 | nc->init = | 233 | nc->init = |
228 | GNUNET_CLIENT_notify_transmit_ready (nc->client, | 234 | GNUNET_CLIENT_notify_transmit_ready (nc->client, |
229 | sizeof (struct GNUNET_MessageHeader), | 235 | sizeof (struct NotifyMessage), |
230 | GNUNET_TIME_UNIT_FOREVER_REL, | 236 | GNUNET_TIME_UNIT_FOREVER_REL, |
231 | GNUNET_YES, &transmit_notify_request, | 237 | GNUNET_YES, &transmit_notify_request, |
232 | nc); | 238 | nc); |
@@ -238,13 +244,19 @@ request_notifications (struct GNUNET_PEERINFO_NotifyContext *nc) | |||
238 | * changes. Initially calls the given function for all known | 244 | * changes. Initially calls the given function for all known |
239 | * peers and then only signals changes. | 245 | * peers and then only signals changes. |
240 | * | 246 | * |
247 | * If include_friend_only is set to GNUNET_YES peerinfo will include HELLO | ||
248 | * messages which are intended for friend to friend mode and which do not | ||
249 | * have to be gossiped. Otherwise these messages are skipped. | ||
250 | * | ||
241 | * @param cfg configuration to use | 251 | * @param cfg configuration to use |
252 | * @param include_friend_only include HELLO messages for friends only | ||
242 | * @param callback the method to call for each peer | 253 | * @param callback the method to call for each peer |
243 | * @param callback_cls closure for callback | 254 | * @param callback_cls closure for callback |
244 | * @return NULL on error | 255 | * @return NULL on error |
245 | */ | 256 | */ |
246 | struct GNUNET_PEERINFO_NotifyContext * | 257 | struct GNUNET_PEERINFO_NotifyContext * |
247 | GNUNET_PEERINFO_notify (const struct GNUNET_CONFIGURATION_Handle *cfg, | 258 | GNUNET_PEERINFO_notify (const struct GNUNET_CONFIGURATION_Handle *cfg, |
259 | int include_friend_only, | ||
248 | GNUNET_PEERINFO_Processor callback, void *callback_cls) | 260 | GNUNET_PEERINFO_Processor callback, void *callback_cls) |
249 | { | 261 | { |
250 | struct GNUNET_PEERINFO_NotifyContext *nc; | 262 | struct GNUNET_PEERINFO_NotifyContext *nc; |
@@ -262,6 +274,7 @@ GNUNET_PEERINFO_notify (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
262 | nc->client = client; | 274 | nc->client = client; |
263 | nc->callback = callback; | 275 | nc->callback = callback; |
264 | nc->callback_cls = callback_cls; | 276 | nc->callback_cls = callback_cls; |
277 | nc->include_friend_only = include_friend_only; | ||
265 | request_notifications (nc); | 278 | request_notifications (nc); |
266 | return nc; | 279 | return nc; |
267 | } | 280 | } |