diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-04-18 20:23:40 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-04-18 20:23:40 +0000 |
commit | 541caf3dec54aaee621fed935e667f9ee423ef31 (patch) | |
tree | 6f80958e68541ce071bc557bbfc168644963c473 /src/core | |
parent | e8bc962b2ed43e194ba124537573da236786e82c (diff) | |
download | gnunet-541caf3dec54aaee621fed935e667f9ee423ef31.tar.gz gnunet-541caf3dec54aaee621fed935e667f9ee423ef31.zip |
towards fixing blacklisting APIs and implementation
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/core.h | 13 | ||||
-rw-r--r-- | src/core/core_api.c | 28 | ||||
-rw-r--r-- | src/core/gnunet-service-core.c | 14 | ||||
-rw-r--r-- | src/core/test_core_api.c | 6 | ||||
-rw-r--r-- | src/core/test_core_api_start_only.c | 6 |
5 files changed, 10 insertions, 57 deletions
diff --git a/src/core/core.h b/src/core/core.h index 45d138140..f91995734 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
@@ -43,13 +43,12 @@ | |||
43 | * transmitted to the client. | 43 | * transmitted to the client. |
44 | */ | 44 | */ |
45 | #define GNUNET_CORE_OPTION_NOTHING 0 | 45 | #define GNUNET_CORE_OPTION_NOTHING 0 |
46 | #define GNUNET_CORE_OPTION_SEND_PRE_CONNECT 1 | 46 | #define GNUNET_CORE_OPTION_SEND_CONNECT 1 |
47 | #define GNUNET_CORE_OPTION_SEND_CONNECT 2 | 47 | #define GNUNET_CORE_OPTION_SEND_DISCONNECT 2 |
48 | #define GNUNET_CORE_OPTION_SEND_DISCONNECT 4 | 48 | #define GNUNET_CORE_OPTION_SEND_FULL_INBOUND 4 |
49 | #define GNUNET_CORE_OPTION_SEND_FULL_INBOUND 8 | 49 | #define GNUNET_CORE_OPTION_SEND_HDR_INBOUND 8 |
50 | #define GNUNET_CORE_OPTION_SEND_HDR_INBOUND 16 | 50 | #define GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND 16 |
51 | #define GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND 32 | 51 | #define GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND 32 |
52 | #define GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND 64 | ||
53 | 52 | ||
54 | 53 | ||
55 | /** | 54 | /** |
diff --git a/src/core/core_api.c b/src/core/core_api.c index 4672c7843..42e8f1c06 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c | |||
@@ -56,12 +56,6 @@ struct GNUNET_CORE_Handle | |||
56 | GNUNET_CORE_StartupCallback init; | 56 | GNUNET_CORE_StartupCallback init; |
57 | 57 | ||
58 | /** | 58 | /** |
59 | * Function to call whenever we're notified about a peer connecting | ||
60 | * (pre-connects, no session key exchange yet). | ||
61 | */ | ||
62 | GNUNET_CORE_ConnectEventHandler pre_connects; | ||
63 | |||
64 | /** | ||
65 | * Function to call whenever we're notified about a peer connecting. | 59 | * Function to call whenever we're notified about a peer connecting. |
66 | */ | 60 | */ |
67 | GNUNET_CORE_ConnectEventHandler connects; | 61 | GNUNET_CORE_ConnectEventHandler connects; |
@@ -406,23 +400,6 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
406 | #endif | 400 | #endif |
407 | switch (ntohs (msg->type)) | 401 | switch (ntohs (msg->type)) |
408 | { | 402 | { |
409 | case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_PRE_CONNECT: | ||
410 | if (NULL == h->pre_connects) | ||
411 | { | ||
412 | GNUNET_break (0); | ||
413 | break; | ||
414 | } | ||
415 | if (msize != sizeof (struct ConnectNotifyMessage)) | ||
416 | { | ||
417 | GNUNET_break (0); | ||
418 | break; | ||
419 | } | ||
420 | cnm = (const struct ConnectNotifyMessage *) msg; | ||
421 | h->pre_connects (h->cls, | ||
422 | &cnm->peer, | ||
423 | GNUNET_TIME_relative_ntoh (cnm->latency), | ||
424 | ntohl (cnm->distance)); | ||
425 | break; | ||
426 | case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT: | 403 | case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT: |
427 | if (NULL == h->connects) | 404 | if (NULL == h->connects) |
428 | { | 405 | { |
@@ -662,8 +639,6 @@ transmit_start (void *cls, size_t size, void *buf) | |||
662 | init->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_INIT); | 639 | init->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_INIT); |
663 | init->header.size = htons (msize); | 640 | init->header.size = htons (msize); |
664 | opt = GNUNET_CORE_OPTION_NOTHING; | 641 | opt = GNUNET_CORE_OPTION_NOTHING; |
665 | if (h->pre_connects != NULL) | ||
666 | opt |= GNUNET_CORE_OPTION_SEND_PRE_CONNECT; | ||
667 | if (h->connects != NULL) | 642 | if (h->connects != NULL) |
668 | opt |= GNUNET_CORE_OPTION_SEND_CONNECT; | 643 | opt |= GNUNET_CORE_OPTION_SEND_CONNECT; |
669 | if (h->disconnects != NULL) | 644 | if (h->disconnects != NULL) |
@@ -705,7 +680,6 @@ transmit_start (void *cls, size_t size, void *buf) | |||
705 | * @param cls closure for the various callbacks that follow (including handlers in the handlers array) | 680 | * @param cls closure for the various callbacks that follow (including handlers in the handlers array) |
706 | * @param init callback to call on timeout or once we have successfully | 681 | * @param init callback to call on timeout or once we have successfully |
707 | * connected to the core service; note that timeout is only meaningful if init is not NULL | 682 | * connected to the core service; note that timeout is only meaningful if init is not NULL |
708 | * @param pre_connects function to call on peer pre-connect (no session key yet), can be NULL | ||
709 | * @param connects function to call on peer connect, can be NULL | 683 | * @param connects function to call on peer connect, can be NULL |
710 | * @param disconnects function to call on peer disconnect / timeout, can be NULL | 684 | * @param disconnects function to call on peer disconnect / timeout, can be NULL |
711 | * @param inbound_notify function to call for all inbound messages, can be NULL | 685 | * @param inbound_notify function to call for all inbound messages, can be NULL |
@@ -726,7 +700,6 @@ GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched, | |||
726 | struct GNUNET_TIME_Relative timeout, | 700 | struct GNUNET_TIME_Relative timeout, |
727 | void *cls, | 701 | void *cls, |
728 | GNUNET_CORE_StartupCallback init, | 702 | GNUNET_CORE_StartupCallback init, |
729 | GNUNET_CORE_ConnectEventHandler pre_connects, | ||
730 | GNUNET_CORE_ConnectEventHandler connects, | 703 | GNUNET_CORE_ConnectEventHandler connects, |
731 | GNUNET_CORE_DisconnectEventHandler disconnects, | 704 | GNUNET_CORE_DisconnectEventHandler disconnects, |
732 | GNUNET_CORE_MessageCallback inbound_notify, | 705 | GNUNET_CORE_MessageCallback inbound_notify, |
@@ -742,7 +715,6 @@ GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched, | |||
742 | h->cfg = cfg; | 715 | h->cfg = cfg; |
743 | h->cls = cls; | 716 | h->cls = cls; |
744 | h->init = init; | 717 | h->init = init; |
745 | h->pre_connects = pre_connects; | ||
746 | h->connects = connects; | 718 | h->connects = connects; |
747 | h->disconnects = disconnects; | 719 | h->disconnects = disconnects; |
748 | h->inbound_notify = inbound_notify; | 720 | h->inbound_notify = inbound_notify; |
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index 044b7496e..bad6f05d3 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c | |||
@@ -3450,13 +3450,6 @@ handle_transport_receive (void *cls, | |||
3450 | (n->status != PEER_STATE_KEY_CONFIRMED)) | 3450 | (n->status != PEER_STATE_KEY_CONFIRMED)) |
3451 | { | 3451 | { |
3452 | GNUNET_break_op (0); | 3452 | GNUNET_break_op (0); |
3453 | /* blacklist briefly (?); might help recover (?) */ | ||
3454 | GNUNET_TRANSPORT_blacklist (sched, cfg, | ||
3455 | &n->peer, | ||
3456 | GNUNET_TIME_UNIT_SECONDS, | ||
3457 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, | ||
3458 | 5), | ||
3459 | NULL, NULL); | ||
3460 | return; | 3453 | return; |
3461 | } | 3454 | } |
3462 | handle_encrypted_message (n, (const struct EncryptedMessage *) message); | 3455 | handle_encrypted_message (n, (const struct EncryptedMessage *) message); |
@@ -3626,7 +3619,6 @@ handle_transport_notify_connect (void *cls, | |||
3626 | unsigned int distance) | 3619 | unsigned int distance) |
3627 | { | 3620 | { |
3628 | struct Neighbour *n; | 3621 | struct Neighbour *n; |
3629 | struct ConnectNotifyMessage cnm; | ||
3630 | 3622 | ||
3631 | if (0 == memcmp (peer, &my_identity, sizeof (struct GNUNET_PeerIdentity))) | 3623 | if (0 == memcmp (peer, &my_identity, sizeof (struct GNUNET_PeerIdentity))) |
3632 | { | 3624 | { |
@@ -3665,12 +3657,6 @@ handle_transport_notify_connect (void *cls, | |||
3665 | "Received connection from `%4s'.\n", | 3657 | "Received connection from `%4s'.\n", |
3666 | GNUNET_i2s (&n->peer)); | 3658 | GNUNET_i2s (&n->peer)); |
3667 | #endif | 3659 | #endif |
3668 | cnm.header.size = htons (sizeof (struct ConnectNotifyMessage)); | ||
3669 | cnm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_PRE_CONNECT); | ||
3670 | cnm.distance = htonl (n->last_distance); | ||
3671 | cnm.latency = GNUNET_TIME_relative_hton (n->last_latency); | ||
3672 | cnm.peer = *peer; | ||
3673 | send_to_all_clients (&cnm.header, GNUNET_YES, GNUNET_CORE_OPTION_SEND_PRE_CONNECT); | ||
3674 | GNUNET_TRANSPORT_set_quota (transport, | 3660 | GNUNET_TRANSPORT_set_quota (transport, |
3675 | &n->peer, | 3661 | &n->peer, |
3676 | n->bw_in, | 3662 | n->bw_in, |
diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c index 78d6b7fe1..6b8387461 100644 --- a/src/core/test_core_api.c +++ b/src/core/test_core_api.c | |||
@@ -229,8 +229,7 @@ init_notify (void *cls, | |||
229 | p2.cfg, | 229 | p2.cfg, |
230 | TIMEOUT, | 230 | TIMEOUT, |
231 | &p2, | 231 | &p2, |
232 | &init_notify, | 232 | &init_notify, |
233 | NULL, | ||
234 | &connect_notify, | 233 | &connect_notify, |
235 | &disconnect_notify, | 234 | &disconnect_notify, |
236 | &inbound_notify, | 235 | &inbound_notify, |
@@ -325,8 +324,7 @@ run (void *cls, | |||
325 | TIMEOUT, | 324 | TIMEOUT, |
326 | &p1, | 325 | &p1, |
327 | &init_notify, | 326 | &init_notify, |
328 | NULL, | 327 | &connect_notify, |
329 | &connect_notify, | ||
330 | &disconnect_notify, | 328 | &disconnect_notify, |
331 | &inbound_notify, | 329 | &inbound_notify, |
332 | GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); | 330 | GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); |
diff --git a/src/core/test_core_api_start_only.c b/src/core/test_core_api_start_only.c index e8bfdd4e5..86eff056c 100644 --- a/src/core/test_core_api_start_only.c +++ b/src/core/test_core_api_start_only.c | |||
@@ -130,8 +130,7 @@ init_notify (void *cls, | |||
130 | p2.cfg, | 130 | p2.cfg, |
131 | TIMEOUT, | 131 | TIMEOUT, |
132 | &p2, | 132 | &p2, |
133 | &init_notify, | 133 | &init_notify, |
134 | NULL, | ||
135 | &connect_notify, | 134 | &connect_notify, |
136 | &disconnect_notify, | 135 | &disconnect_notify, |
137 | &inbound_notify, | 136 | &inbound_notify, |
@@ -185,8 +184,7 @@ run (void *cls, | |||
185 | TIMEOUT, | 184 | TIMEOUT, |
186 | &p1, | 185 | &p1, |
187 | &init_notify, | 186 | &init_notify, |
188 | NULL, | 187 | &connect_notify, |
189 | &connect_notify, | ||
190 | &disconnect_notify, | 188 | &disconnect_notify, |
191 | &inbound_notify, | 189 | &inbound_notify, |
192 | GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); | 190 | GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); |