aboutsummaryrefslogtreecommitdiff
path: root/src/peerinfo/gnunet-service-peerinfo.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-02-16 15:20:29 +0000
committerChristian Grothoff <christian@grothoff.org>2014-02-16 15:20:29 +0000
commit9df90067e4904291d7e1c4acf5237c85a7c9387c (patch)
tree84f5a612229a7f88ce701dc46f91874fb57fabb3 /src/peerinfo/gnunet-service-peerinfo.c
parent24f64b79df59314ba650dbc7279a76d00180b2d6 (diff)
downloadgnunet-9df90067e4904291d7e1c4acf5237c85a7c9387c.tar.gz
gnunet-9df90067e4904291d7e1c4acf5237c85a7c9387c.zip
-doxygen, indentation
Diffstat (limited to 'src/peerinfo/gnunet-service-peerinfo.c')
-rw-r--r--src/peerinfo/gnunet-service-peerinfo.c93
1 files changed, 47 insertions, 46 deletions
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c
index 60ecaeb41..c93072de3 100644
--- a/src/peerinfo/gnunet-service-peerinfo.c
+++ b/src/peerinfo/gnunet-service-peerinfo.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2001, 2002, 2004, 2005, 2007, 2009, 2010, 2012 Christian Grothoff (and other contributing authors) 3 (C) 2001-2014 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -26,9 +26,6 @@
26 * structure of data/hosts/). 26 * structure of data/hosts/).
27 * 27 *
28 * @author Christian Grothoff 28 * @author Christian Grothoff
29 *
30 * TODO:
31 * - notify clients when addresses in HELLO expire (#1933)
32 */ 29 */
33 30
34#include "platform.h" 31#include "platform.h"
@@ -83,11 +80,12 @@ struct TransmitContext
83 struct GNUNET_SERVER_TransmitContext *tc; 80 struct GNUNET_SERVER_TransmitContext *tc;
84 81
85 /** 82 /**
86 * Include friend only HELLOs GNUNET_YES or _NO 83 * Include friend only HELLOs #GNUNET_YES or #GNUNET_NO
87 */ 84 */
88 int friend_only; 85 int friend_only;
89}; 86};
90 87
88
91/** 89/**
92 * Result of reading a file 90 * Result of reading a file
93 */ 91 */
@@ -110,25 +108,25 @@ struct ReadHostFileContext
110 */ 108 */
111struct NotificationContext 109struct NotificationContext
112{ 110{
113 /** 111 /**
114 * Next in DLL 112 * Next in DLL
115 */ 113 */
116 struct NotificationContext *prev; 114 struct NotificationContext *prev;
117 115
118 /** 116 /**
119 * Previous in DLL 117 * Previous in DLL
120 */ 118 */
121 struct NotificationContext *next; 119 struct NotificationContext *next;
122 120
123 /** 121 /**
124 * Server client 122 * Server client
125 */ 123 */
126 struct GNUNET_SERVER_Client *client; 124 struct GNUNET_SERVER_Client *client;
127 125
128 /** 126 /**
129 * Interested in friend only HELLO? 127 * Interested in friend only HELLO?
130 */ 128 */
131 int include_friend_only; 129 int include_friend_only;
132}; 130};
133 131
134 132
@@ -173,7 +171,8 @@ static struct NotificationContext *nc_tail;
173 * @return generated notification message 171 * @return generated notification message
174 */ 172 */
175static struct InfoMessage * 173static struct InfoMessage *
176make_info_message (const struct HostEntry *he, int include_friend_only) 174make_info_message (const struct HostEntry *he,
175 int include_friend_only)
177{ 176{
178 struct InfoMessage *im; 177 struct InfoMessage *im;
179 struct GNUNET_HELLO_Message *src; 178 struct GNUNET_HELLO_Message *src;
@@ -201,10 +200,11 @@ make_info_message (const struct HostEntry *he, int include_friend_only)
201 * @param cls pointer to the current time 200 * @param cls pointer to the current time
202 * @param address the address 201 * @param address the address
203 * @param expiration expiration time for the address 202 * @param expiration expiration time for the address
204 * @return GNUNET_NO if expiration smaller than the current time 203 * @return #GNUNET_NO if expiration smaller than the current time
205 */ 204 */
206static int 205static int
207discard_expired (void *cls, const struct GNUNET_HELLO_Address *address, 206discard_expired (void *cls,
207 const struct GNUNET_HELLO_Address *address,
208 struct GNUNET_TIME_Absolute expiration) 208 struct GNUNET_TIME_Absolute expiration)
209{ 209{
210 const struct GNUNET_TIME_Absolute *now = cls; 210 const struct GNUNET_TIME_Absolute *now = cls;
@@ -226,10 +226,11 @@ discard_expired (void *cls, const struct GNUNET_HELLO_Address *address,
226 * @param cls pointer to the counter 226 * @param cls pointer to the counter
227 * @param address the address 227 * @param address the address
228 * @param expiration expiration time for the address 228 * @param expiration expiration time for the address
229 * @return GNUNET_OK (always) 229 * @return #GNUNET_OK (always)
230 */ 230 */
231static int 231static int
232count_addresses (void *cls, const struct GNUNET_HELLO_Address *address, 232count_addresses (void *cls,
233 const struct GNUNET_HELLO_Address *address,
233 struct GNUNET_TIME_Absolute expiration) 234 struct GNUNET_TIME_Absolute expiration)
234{ 235{
235 unsigned int *cnt = cls; 236 unsigned int *cnt = cls;
@@ -312,12 +313,10 @@ update_hello (const struct GNUNET_PeerIdentity *peer,
312 313
313/** 314/**
314 * Try to read the HELLOs in the given filename and discard expired 315 * Try to read the HELLOs in the given filename and discard expired
315 * addresses. Removes the file if one the HELLO is mal-formed. If all 316 * addresses. Removes the file if one the HELLO is malformed. If all
316 * addresses are expired, the HELLO is also removed (but the HELLO 317 * addresses are expired, the HELLO is also removed (but the HELLO
317 * with the public key is still returned if it was found and valid). 318 * with the public key is still returned if it was found and valid).
318 * 319 * The file can contain multiple HELLO messages.
319 * The file can contain multiple HELLO messages, but onlu a public and a friend only
320 * HELLO should be included
321 * 320 *
322 * @param fn name of the file 321 * @param fn name of the file
323 * @param unlink_garbage if #GNUNET_YES, try to remove useless files 322 * @param unlink_garbage if #GNUNET_YES, try to remove useless files
@@ -332,7 +331,6 @@ read_host_file (const char *fn,
332 unsigned int size_total; 331 unsigned int size_total;
333 struct GNUNET_TIME_Absolute now; 332 struct GNUNET_TIME_Absolute now;
334 unsigned int left; 333 unsigned int left;
335
336 const struct GNUNET_HELLO_Message *hello; 334 const struct GNUNET_HELLO_Message *hello;
337 struct GNUNET_HELLO_Message *hello_clean; 335 struct GNUNET_HELLO_Message *hello_clean;
338 unsigned read_pos; 336 unsigned read_pos;
@@ -443,7 +441,7 @@ read_host_file (const char *fn,
443 } 441 }
444 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 442 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
445 "Found `%s' and `%s' HELLO message in file\n", 443 "Found `%s' and `%s' HELLO message in file\n",
446 (NULL != r->hello) ? "public" : "NO public", 444 (NULL != r->hello) ? "public" : "NON-public",
447 (NULL != r->friend_only_hello) ? "friend only" : "NO friend only"); 445 (NULL != r->friend_only_hello) ? "friend only" : "NO friend only");
448} 446}
449 447
@@ -516,8 +514,8 @@ remove_garbage (const char *fullname)
516struct DirScanContext 514struct DirScanContext
517{ 515{
518 /** 516 /**
519 * GNUNET_YES if we should remove files that are broken, 517 * #GNUNET_YES if we should remove files that are broken,
520 * GNUNET_NO if the directory we are iterating over should 518 * #GNUNET_NO if the directory we are iterating over should
521 * be treated as read-only by us. 519 * be treated as read-only by us.
522 */ 520 */
523 int remove_files; 521 int remove_files;
@@ -845,7 +843,7 @@ update_hello (const struct GNUNET_PeerIdentity *peer,
845 * @param cls NULL to hit all hosts, otherwise specifies a particular target 843 * @param cls NULL to hit all hosts, otherwise specifies a particular target
846 * @param key hostID 844 * @param key hostID
847 * @param value information to transmit 845 * @param value information to transmit
848 * @return GNUNET_YES (continue to iterate) 846 * @return #GNUNET_YES (continue to iterate)
849 */ 847 */
850static int 848static int
851add_to_tc (void *cls, const struct GNUNET_PeerIdentity *key, void *value) 849add_to_tc (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
@@ -902,7 +900,7 @@ add_to_tc (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
902 * 900 *
903 * @param cls pointer to current time (struct GNUNET_TIME_Absolute) 901 * @param cls pointer to current time (struct GNUNET_TIME_Absolute)
904 * @param fn filename to test to see if the HELLO expired 902 * @param fn filename to test to see if the HELLO expired
905 * @return GNUNET_OK (continue iteration) 903 * @return #GNUNET_OK (continue iteration)
906 */ 904 */
907static int 905static int
908discard_hosts_helper (void *cls, const char *fn) 906discard_hosts_helper (void *cls, const char *fn)
@@ -1086,10 +1084,10 @@ handle_get_all (void *cls, struct GNUNET_SERVER_Client *client,
1086 * Pass the given client the information we have in the respective 1084 * Pass the given client the information we have in the respective
1087 * host entry; the client is already in the notification context. 1085 * host entry; the client is already in the notification context.
1088 * 1086 *
1089 * @param cls the 'struct GNUNET_SERVER_Client' to notify 1087 * @param cls the `struct GNUNET_SERVER_Client` to notify
1090 * @param key key for the value (unused) 1088 * @param key key for the value (unused)
1091 * @param value the 'struct HostEntry' to notify the client about 1089 * @param value the `struct HostEntry` to notify the client about
1092 * @return GNUNET_YES (always, continue to iterate) 1090 * @return #GNUNET_YES (always, continue to iterate)
1093 */ 1091 */
1094static int 1092static int
1095do_notify_entry (void *cls, const struct GNUNET_PeerIdentity *key, void *value) 1093do_notify_entry (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
@@ -1176,11 +1174,13 @@ disconnect_cb (void *cls,struct GNUNET_SERVER_Client *client)
1176 * 1174 *
1177 * @param cls NULL 1175 * @param cls NULL
1178 * @param key key of the host entry 1176 * @param key key of the host entry
1179 * @param value the 'struct HostEntry' to free 1177 * @param value the `struct HostEntry` to free
1180 * @return GNUNET_YES (continue to iterate) 1178 * @return #GNUNET_YES (continue to iterate)
1181 */ 1179 */
1182static int 1180static int
1183free_host_entry (void *cls, const struct GNUNET_PeerIdentity *key, void *value) 1181free_host_entry (void *cls,
1182 const struct GNUNET_PeerIdentity *key,
1183 void *value)
1184{ 1184{
1185 struct HostEntry *he = value; 1185 struct HostEntry *he = value;
1186 1186
@@ -1198,7 +1198,8 @@ free_host_entry (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
1198 * @param tc scheduler task context, unused 1198 * @param tc scheduler task context, unused
1199 */ 1199 */
1200static void 1200static void
1201shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1201shutdown_task (void *cls,
1202 const struct GNUNET_SCHEDULER_TaskContext *tc)
1202{ 1203{
1203 struct NotificationContext *cur; 1204 struct NotificationContext *cur;
1204 struct NotificationContext *next; 1205 struct NotificationContext *next;