diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-11-09 12:34:17 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-11-09 12:34:17 +0000 |
commit | 755b5bb632de94de0e6b0e55212fbcce7b6c719c (patch) | |
tree | 3763a9d1b5ec7ba71f21c145646036580c62ac39 | |
parent | 75493079d34eecaa0984034a2702b768413386e6 (diff) | |
download | gnunet-755b5bb632de94de0e6b0e55212fbcce7b6c719c.tar.gz gnunet-755b5bb632de94de0e6b0e55212fbcce7b6c719c.zip |
adopting to new transport API
-rw-r--r-- | src/testbed/gnunet-service-testbed.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c index c9b7c930a..2f606928a 100644 --- a/src/testbed/gnunet-service-testbed.c +++ b/src/testbed/gnunet-service-testbed.c | |||
@@ -2869,6 +2869,59 @@ overlay_connect_notify (void *cls, const struct GNUNET_PeerIdentity *new_peer, | |||
2869 | * @param tc the TaskContext from scheduler | 2869 | * @param tc the TaskContext from scheduler |
2870 | */ | 2870 | */ |
2871 | static void | 2871 | static void |
2872 | send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
2873 | |||
2874 | |||
2875 | /** | ||
2876 | * Task that is run when hello has been sent | ||
2877 | * | ||
2878 | * @param cls the overlay connect context | ||
2879 | * @param tc the scheduler task context; if tc->reason = | ||
2880 | * GNUNET_SCHEDULER_REASON_TIMEOUT then sending HELLO failed; if | ||
2881 | * GNUNET_SCHEDULER_REASON_READ_READY is succeeded | ||
2882 | */ | ||
2883 | //static FIXME: uncomment when using | ||
2884 | void | ||
2885 | occ_hello_sent_cb (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
2886 | { | ||
2887 | struct OverlayConnectContext *occ = cls; | ||
2888 | int ret; | ||
2889 | |||
2890 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == occ->send_hello_task); | ||
2891 | if (GNUNET_SCHEDULER_REASON_TIMEOUT == tc->reason) | ||
2892 | { | ||
2893 | occ->send_hello_task = | ||
2894 | GNUNET_SCHEDULER_add_delayed | ||
2895 | (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, | ||
2896 | 100 + GNUNET_CRYPTO_random_u32 | ||
2897 | (GNUNET_CRYPTO_QUALITY_WEAK, 500)), | ||
2898 | &send_hello, occ); | ||
2899 | return; | ||
2900 | } | ||
2901 | if (GNUNET_SCHEDULER_REASON_READ_READY != tc->reason) | ||
2902 | return; | ||
2903 | ret = GNUNET_TRANSPORT_try_connect (occ->p2th, &occ->peer_identity); | ||
2904 | if (GNUNET_OK == ret) | ||
2905 | return; | ||
2906 | if (GNUNET_SYSERR == ret) | ||
2907 | GNUNET_break (0); | ||
2908 | occ->send_hello_task = | ||
2909 | GNUNET_SCHEDULER_add_delayed | ||
2910 | (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, | ||
2911 | 100 + GNUNET_CRYPTO_random_u32 | ||
2912 | (GNUNET_CRYPTO_QUALITY_WEAK, 500)), | ||
2913 | &send_hello, occ); | ||
2914 | } | ||
2915 | |||
2916 | |||
2917 | /** | ||
2918 | * Task to offer HELLO of peer 1 to peer 2 and try to make peer 2 to connect to | ||
2919 | * peer 1. | ||
2920 | * | ||
2921 | * @param cls the OverlayConnectContext | ||
2922 | * @param tc the TaskContext from scheduler | ||
2923 | */ | ||
2924 | static void | ||
2872 | send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 2925 | send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
2873 | { | 2926 | { |
2874 | struct OverlayConnectContext *occ = cls; | 2927 | struct OverlayConnectContext *occ = cls; |
@@ -2903,6 +2956,13 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2903 | { | 2956 | { |
2904 | LOG_DEBUG ("Offering HELLO of %s to %s\n", | 2957 | LOG_DEBUG ("Offering HELLO of %s to %s\n", |
2905 | GNUNET_i2s (&occ->peer_identity), other_peer_str); | 2958 | GNUNET_i2s (&occ->peer_identity), other_peer_str); |
2959 | /* FIXME: To be replaced by */ | ||
2960 | /* occ->offer_hello_handle = GNUNET_TRANSPORT_offer_hello (occ->p2th, */ | ||
2961 | /* occ->hello, */ | ||
2962 | /* occ_hello_sent_cb, */ | ||
2963 | /* occ); */ | ||
2964 | |||
2965 | /* FIXME: once offer_hello offers a handle to cancel remove the following lines */ | ||
2906 | GNUNET_TRANSPORT_offer_hello (occ->p2th, occ->hello, NULL, NULL); | 2966 | GNUNET_TRANSPORT_offer_hello (occ->p2th, occ->hello, NULL, NULL); |
2907 | GNUNET_TRANSPORT_try_connect (occ->p2th, &occ->peer_identity); | 2967 | GNUNET_TRANSPORT_try_connect (occ->p2th, &occ->peer_identity); |
2908 | occ->send_hello_task = | 2968 | occ->send_hello_task = |