diff options
author | Bart Polot <bart@net.in.tum.de> | 2012-06-14 17:05:17 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2012-06-14 17:05:17 +0000 |
commit | c44b94ee1f25110f259688c221d8ffcb42cd5aa5 (patch) | |
tree | 8329a4de4b19d58743beb13c783ab8bfa557ade1 /src | |
parent | 78471039156f66f6b2a9f09e44e691c1207d2636 (diff) | |
download | gnunet-c44b94ee1f25110f259688c221d8ffcb42cd5aa5.tar.gz gnunet-c44b94ee1f25110f259688c221d8ffcb42cd5aa5.zip |
- Added basic blacklist support
Diffstat (limited to 'src')
-rw-r--r-- | src/mesh/gnunet-service-mesh_new.c | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/src/mesh/gnunet-service-mesh_new.c b/src/mesh/gnunet-service-mesh_new.c index 3c3cd3d87..f70eb3bbf 100644 --- a/src/mesh/gnunet-service-mesh_new.c +++ b/src/mesh/gnunet-service-mesh_new.c | |||
@@ -371,6 +371,16 @@ struct MeshTunnel | |||
371 | */ | 371 | */ |
372 | unsigned int nignore; | 372 | unsigned int nignore; |
373 | 373 | ||
374 | /** | ||
375 | * Blacklisted peers | ||
376 | */ | ||
377 | GNUNET_PEER_Id *blacklisted; | ||
378 | |||
379 | /** | ||
380 | * Number of elements in blacklisted | ||
381 | */ | ||
382 | unsigned int nblacklisted; | ||
383 | |||
374 | /** | 384 | /** |
375 | * Tunnel paths | 385 | * Tunnel paths |
376 | */ | 386 | */ |
@@ -4223,6 +4233,110 @@ handle_local_connect_del (void *cls, struct GNUNET_SERVER_Client *client, | |||
4223 | return; | 4233 | return; |
4224 | } | 4234 | } |
4225 | 4235 | ||
4236 | /** | ||
4237 | * Handler for blacklist requests of peers in a tunnel | ||
4238 | * | ||
4239 | * @param cls closure | ||
4240 | * @param client identification of the client | ||
4241 | * @param message the actual message (PeerControl) | ||
4242 | */ | ||
4243 | static void | ||
4244 | handle_local_blacklist (void *cls, struct GNUNET_SERVER_Client *client, | ||
4245 | const struct GNUNET_MessageHeader *message) | ||
4246 | { | ||
4247 | struct GNUNET_MESH_PeerControl *peer_msg; | ||
4248 | |||
4249 | struct MeshClient *c; | ||
4250 | struct MeshTunnel *t; | ||
4251 | MESH_TunnelNumber tid; | ||
4252 | |||
4253 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got a PEER BLACKLIST request\n"); | ||
4254 | /* Sanity check for client registration */ | ||
4255 | if (NULL == (c = client_get (client))) | ||
4256 | { | ||
4257 | GNUNET_break (0); | ||
4258 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
4259 | return; | ||
4260 | } | ||
4261 | peer_msg = (struct GNUNET_MESH_PeerControl *) message; | ||
4262 | |||
4263 | /* Sanity check for message size */ | ||
4264 | if (sizeof (struct GNUNET_MESH_PeerControl) != ntohs (peer_msg->header.size)) | ||
4265 | { | ||
4266 | GNUNET_break (0); | ||
4267 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
4268 | return; | ||
4269 | } | ||
4270 | |||
4271 | /* Tunnel exists? */ | ||
4272 | tid = ntohl (peer_msg->tunnel_id); | ||
4273 | t = tunnel_get_by_local_id (c, tid); | ||
4274 | if (NULL == t) | ||
4275 | { | ||
4276 | GNUNET_break (0); | ||
4277 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
4278 | return; | ||
4279 | } | ||
4280 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " on tunnel %X\n", t->id.tid); | ||
4281 | |||
4282 | // GNUNET_array_append(t->blacklisted, t->nblacklisted, GNUNET_PEER_intern(peer)); | ||
4283 | } | ||
4284 | |||
4285 | |||
4286 | /** | ||
4287 | * Handler for unblacklist requests of peers in a tunnel | ||
4288 | * | ||
4289 | * @param cls closure | ||
4290 | * @param client identification of the client | ||
4291 | * @param message the actual message (PeerControl) | ||
4292 | */ | ||
4293 | static void | ||
4294 | handle_local_unblacklist (void *cls, struct GNUNET_SERVER_Client *client, | ||
4295 | const struct GNUNET_MessageHeader *message) | ||
4296 | { | ||
4297 | struct GNUNET_MESH_PeerControl *peer_msg; | ||
4298 | struct MeshClient *c; | ||
4299 | struct MeshTunnel *t; | ||
4300 | MESH_TunnelNumber tid; | ||
4301 | // GNUNET_PEER_Id pid; | ||
4302 | // unsigned int i; | ||
4303 | |||
4304 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got a PEER UNBLACKLIST request\n"); | ||
4305 | /* Sanity check for client registration */ | ||
4306 | if (NULL == (c = client_get (client))) | ||
4307 | { | ||
4308 | GNUNET_break (0); | ||
4309 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
4310 | return; | ||
4311 | } | ||
4312 | peer_msg = (struct GNUNET_MESH_PeerControl *) message; | ||
4313 | |||
4314 | /* Sanity check for message size */ | ||
4315 | if (sizeof (struct GNUNET_MESH_PeerControl) != ntohs (peer_msg->header.size)) | ||
4316 | { | ||
4317 | GNUNET_break (0); | ||
4318 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
4319 | return; | ||
4320 | } | ||
4321 | |||
4322 | /* Tunnel exists? */ | ||
4323 | tid = ntohl (peer_msg->tunnel_id); | ||
4324 | t = tunnel_get_by_local_id (c, tid); | ||
4325 | if (NULL == t) | ||
4326 | { | ||
4327 | GNUNET_break (0); | ||
4328 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
4329 | return; | ||
4330 | } | ||
4331 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " on tunnel %X\n", t->id.tid); | ||
4332 | |||
4333 | // pid = GNUNET_PEER_search (peer); | ||
4334 | // for (i = 0; i < t->nblacklisted; i++) | ||
4335 | // { | ||
4336 | // if (t->blacklisted[i] | ||
4337 | // } | ||
4338 | } | ||
4339 | |||
4226 | 4340 | ||
4227 | /** | 4341 | /** |
4228 | * Handler for connection requests to new peers by type | 4342 | * Handler for connection requests to new peers by type |
@@ -4591,6 +4705,12 @@ static struct GNUNET_SERVER_MessageHandler client_handlers[] = { | |||
4591 | {&handle_local_connect_del, NULL, | 4705 | {&handle_local_connect_del, NULL, |
4592 | GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_DEL, | 4706 | GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_DEL, |
4593 | sizeof (struct GNUNET_MESH_PeerControl)}, | 4707 | sizeof (struct GNUNET_MESH_PeerControl)}, |
4708 | {&handle_local_blacklist, NULL, | ||
4709 | GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_BLACKLIST, | ||
4710 | sizeof (struct GNUNET_MESH_PeerControl)}, | ||
4711 | {&handle_local_unblacklist, NULL, | ||
4712 | GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_UNBLACKLIST, | ||
4713 | sizeof (struct GNUNET_MESH_PeerControl)}, | ||
4594 | {&handle_local_connect_by_type, NULL, | 4714 | {&handle_local_connect_by_type, NULL, |
4595 | GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD_BY_TYPE, | 4715 | GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD_BY_TYPE, |
4596 | sizeof (struct GNUNET_MESH_ConnectPeerByType)}, | 4716 | sizeof (struct GNUNET_MESH_ConnectPeerByType)}, |