diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:46:35 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:46:35 +0000 |
commit | 502af2167f7c218366666ca4944bd7cc54b5b19a (patch) | |
tree | a91fec5cc9769d260640bd91c6633cb9cf395524 /src/transport/transport_api_blacklist.c | |
parent | 03af5a603b7cc53432249d5854cd412aa90dde0d (diff) | |
download | gnunet-502af2167f7c218366666ca4944bd7cc54b5b19a.tar.gz gnunet-502af2167f7c218366666ca4944bd7cc54b5b19a.zip |
indentation
Diffstat (limited to 'src/transport/transport_api_blacklist.c')
-rw-r--r-- | src/transport/transport_api_blacklist.c | 97 |
1 files changed, 44 insertions, 53 deletions
diff --git a/src/transport/transport_api_blacklist.c b/src/transport/transport_api_blacklist.c index 2315b515f..f8f430995 100644 --- a/src/transport/transport_api_blacklist.c +++ b/src/transport/transport_api_blacklist.c | |||
@@ -42,7 +42,7 @@ struct GNUNET_TRANSPORT_Blacklist | |||
42 | /** | 42 | /** |
43 | * Connection to transport service. | 43 | * Connection to transport service. |
44 | */ | 44 | */ |
45 | struct GNUNET_CLIENT_Connection * client; | 45 | struct GNUNET_CLIENT_Connection *client; |
46 | 46 | ||
47 | /** | 47 | /** |
48 | * Configuration to use. | 48 | * Configuration to use. |
@@ -78,8 +78,7 @@ struct GNUNET_TRANSPORT_Blacklist | |||
78 | * | 78 | * |
79 | * @param br overall handle | 79 | * @param br overall handle |
80 | */ | 80 | */ |
81 | static void | 81 | static void reconnect (struct GNUNET_TRANSPORT_Blacklist *br); |
82 | reconnect (struct GNUNET_TRANSPORT_Blacklist *br); | ||
83 | 82 | ||
84 | 83 | ||
85 | /** | 84 | /** |
@@ -87,8 +86,7 @@ reconnect (struct GNUNET_TRANSPORT_Blacklist *br); | |||
87 | * | 86 | * |
88 | * @param br our overall context | 87 | * @param br our overall context |
89 | */ | 88 | */ |
90 | static void | 89 | static void reply (struct GNUNET_TRANSPORT_Blacklist *br); |
91 | reply (struct GNUNET_TRANSPORT_Blacklist *br); | ||
92 | 90 | ||
93 | 91 | ||
94 | /** | 92 | /** |
@@ -98,19 +96,18 @@ reply (struct GNUNET_TRANSPORT_Blacklist *br); | |||
98 | * @param msg query | 96 | * @param msg query |
99 | */ | 97 | */ |
100 | static void | 98 | static void |
101 | query_handler (void *cls, | 99 | query_handler (void *cls, const struct GNUNET_MessageHeader *msg) |
102 | const struct GNUNET_MessageHeader *msg) | ||
103 | { | 100 | { |
104 | struct GNUNET_TRANSPORT_Blacklist *br = cls; | 101 | struct GNUNET_TRANSPORT_Blacklist *br = cls; |
105 | const struct BlacklistMessage *bm; | 102 | const struct BlacklistMessage *bm; |
106 | 103 | ||
107 | if ( (ntohs(msg->size) != sizeof (struct BlacklistMessage)) || | 104 | if ((ntohs (msg->size) != sizeof (struct BlacklistMessage)) || |
108 | (ntohs(msg->type) != GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY) ) | 105 | (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY)) |
109 | { | 106 | { |
110 | reconnect (br); | 107 | reconnect (br); |
111 | return; | 108 | return; |
112 | } | 109 | } |
113 | bm = (const struct BlacklistMessage *)msg; | 110 | bm = (const struct BlacklistMessage *) msg; |
114 | GNUNET_break (0 == ntohl (bm->is_allowed)); | 111 | GNUNET_break (0 == ntohl (bm->is_allowed)); |
115 | br->peer = bm->peer; | 112 | br->peer = bm->peer; |
116 | reply (br); | 113 | reply (br); |
@@ -126,9 +123,7 @@ static void | |||
126 | receive (struct GNUNET_TRANSPORT_Blacklist *br) | 123 | receive (struct GNUNET_TRANSPORT_Blacklist *br) |
127 | { | 124 | { |
128 | GNUNET_CLIENT_receive (br->client, | 125 | GNUNET_CLIENT_receive (br->client, |
129 | &query_handler, | 126 | &query_handler, br, GNUNET_TIME_UNIT_FOREVER_REL); |
130 | br, | ||
131 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
132 | } | 127 | } |
133 | 128 | ||
134 | 129 | ||
@@ -141,17 +136,16 @@ receive (struct GNUNET_TRANSPORT_Blacklist *br) | |||
141 | * @return number of bytes written to buf | 136 | * @return number of bytes written to buf |
142 | */ | 137 | */ |
143 | static size_t | 138 | static size_t |
144 | transmit_blacklist_init (void *cls, | 139 | transmit_blacklist_init (void *cls, size_t size, void *buf) |
145 | size_t size, void *buf) | ||
146 | { | 140 | { |
147 | struct GNUNET_TRANSPORT_Blacklist *br = cls; | 141 | struct GNUNET_TRANSPORT_Blacklist *br = cls; |
148 | struct GNUNET_MessageHeader req; | 142 | struct GNUNET_MessageHeader req; |
149 | 143 | ||
150 | if (buf == NULL) | 144 | if (buf == NULL) |
151 | { | 145 | { |
152 | reconnect (br); | 146 | reconnect (br); |
153 | return 0; | 147 | return 0; |
154 | } | 148 | } |
155 | req.size = htons (sizeof (struct GNUNET_MessageHeader)); | 149 | req.size = htons (sizeof (struct GNUNET_MessageHeader)); |
156 | req.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_INIT); | 150 | req.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_INIT); |
157 | memcpy (buf, &req, sizeof (req)); | 151 | memcpy (buf, &req, sizeof (req)); |
@@ -170,15 +164,14 @@ reconnect (struct GNUNET_TRANSPORT_Blacklist *br) | |||
170 | { | 164 | { |
171 | if (br->client != NULL) | 165 | if (br->client != NULL) |
172 | GNUNET_CLIENT_disconnect (br->client, GNUNET_NO); | 166 | GNUNET_CLIENT_disconnect (br->client, GNUNET_NO); |
173 | br->client = GNUNET_CLIENT_connect ("transport", | 167 | br->client = GNUNET_CLIENT_connect ("transport", br->cfg); |
174 | br->cfg); | ||
175 | GNUNET_assert (br->client != NULL); | 168 | GNUNET_assert (br->client != NULL); |
176 | br->th = GNUNET_CLIENT_notify_transmit_ready (br->client, | 169 | br->th = GNUNET_CLIENT_notify_transmit_ready (br->client, |
177 | sizeof (struct GNUNET_MessageHeader), | 170 | sizeof (struct |
178 | GNUNET_TIME_UNIT_FOREVER_REL, | 171 | GNUNET_MessageHeader), |
179 | GNUNET_YES, | 172 | GNUNET_TIME_UNIT_FOREVER_REL, |
180 | &transmit_blacklist_init, | 173 | GNUNET_YES, |
181 | br); | 174 | &transmit_blacklist_init, br); |
182 | } | 175 | } |
183 | 176 | ||
184 | 177 | ||
@@ -191,17 +184,16 @@ reconnect (struct GNUNET_TRANSPORT_Blacklist *br) | |||
191 | * @return number of bytes written to buf | 184 | * @return number of bytes written to buf |
192 | */ | 185 | */ |
193 | static size_t | 186 | static size_t |
194 | transmit_blacklist_reply (void *cls, | 187 | transmit_blacklist_reply (void *cls, size_t size, void *buf) |
195 | size_t size, void *buf) | ||
196 | { | 188 | { |
197 | struct GNUNET_TRANSPORT_Blacklist *br = cls; | 189 | struct GNUNET_TRANSPORT_Blacklist *br = cls; |
198 | struct BlacklistMessage req; | 190 | struct BlacklistMessage req; |
199 | 191 | ||
200 | if (buf == NULL) | 192 | if (buf == NULL) |
201 | { | 193 | { |
202 | reconnect (br); | 194 | reconnect (br); |
203 | return 0; | 195 | return 0; |
204 | } | 196 | } |
205 | req.header.size = htons (sizeof (req)); | 197 | req.header.size = htons (sizeof (req)); |
206 | req.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY); | 198 | req.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY); |
207 | req.is_allowed = htonl (br->cb (br->cb_cls, &br->peer)); | 199 | req.is_allowed = htonl (br->cb (br->cb_cls, &br->peer)); |
@@ -221,16 +213,16 @@ static void | |||
221 | reply (struct GNUNET_TRANSPORT_Blacklist *br) | 213 | reply (struct GNUNET_TRANSPORT_Blacklist *br) |
222 | { | 214 | { |
223 | br->th = GNUNET_CLIENT_notify_transmit_ready (br->client, | 215 | br->th = GNUNET_CLIENT_notify_transmit_ready (br->client, |
224 | sizeof (struct BlacklistMessage), | 216 | sizeof (struct |
225 | GNUNET_TIME_UNIT_FOREVER_REL, | 217 | BlacklistMessage), |
226 | GNUNET_NO, | 218 | GNUNET_TIME_UNIT_FOREVER_REL, |
227 | &transmit_blacklist_reply, | 219 | GNUNET_NO, |
228 | br); | 220 | &transmit_blacklist_reply, br); |
229 | if (br->th == NULL) | 221 | if (br->th == NULL) |
230 | { | 222 | { |
231 | reconnect (br); | 223 | reconnect (br); |
232 | return; | 224 | return; |
233 | } | 225 | } |
234 | } | 226 | } |
235 | 227 | ||
236 | 228 | ||
@@ -250,10 +242,9 @@ reply (struct GNUNET_TRANSPORT_Blacklist *br) | |||
250 | */ | 242 | */ |
251 | struct GNUNET_TRANSPORT_Blacklist * | 243 | struct GNUNET_TRANSPORT_Blacklist * |
252 | GNUNET_TRANSPORT_blacklist (const struct GNUNET_CONFIGURATION_Handle *cfg, | 244 | GNUNET_TRANSPORT_blacklist (const struct GNUNET_CONFIGURATION_Handle *cfg, |
253 | GNUNET_TRANSPORT_BlacklistCallback cb, | 245 | GNUNET_TRANSPORT_BlacklistCallback cb, void *cb_cls) |
254 | void *cb_cls) | ||
255 | { | 246 | { |
256 | struct GNUNET_CLIENT_Connection * client; | 247 | struct GNUNET_CLIENT_Connection *client; |
257 | struct GNUNET_TRANSPORT_Blacklist *ret; | 248 | struct GNUNET_TRANSPORT_Blacklist *ret; |
258 | 249 | ||
259 | client = GNUNET_CLIENT_connect ("transport", cfg); | 250 | client = GNUNET_CLIENT_connect ("transport", cfg); |
@@ -263,11 +254,11 @@ GNUNET_TRANSPORT_blacklist (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
263 | ret->client = client; | 254 | ret->client = client; |
264 | ret->cfg = cfg; | 255 | ret->cfg = cfg; |
265 | ret->th = GNUNET_CLIENT_notify_transmit_ready (client, | 256 | ret->th = GNUNET_CLIENT_notify_transmit_ready (client, |
266 | sizeof (struct GNUNET_MessageHeader), | 257 | sizeof (struct |
267 | GNUNET_TIME_UNIT_FOREVER_REL, | 258 | GNUNET_MessageHeader), |
268 | GNUNET_YES, | 259 | GNUNET_TIME_UNIT_FOREVER_REL, |
269 | &transmit_blacklist_init, | 260 | GNUNET_YES, |
270 | ret); | 261 | &transmit_blacklist_init, ret); |
271 | return ret; | 262 | return ret; |
272 | } | 263 | } |
273 | 264 | ||