diff options
Diffstat (limited to 'src/transport/transport_api_address_iterate.c')
-rw-r--r-- | src/transport/transport_api_address_iterate.c | 75 |
1 files changed, 38 insertions, 37 deletions
diff --git a/src/transport/transport_api_address_iterate.c b/src/transport/transport_api_address_iterate.c index 7bbeb499d..4f442fda0 100644 --- a/src/transport/transport_api_address_iterate.c +++ b/src/transport/transport_api_address_iterate.c | |||
@@ -82,37 +82,37 @@ peer_address_response_processor (void *cls, | |||
82 | uint16_t size; | 82 | uint16_t size; |
83 | 83 | ||
84 | if (msg == NULL) | 84 | if (msg == NULL) |
85 | { | 85 | { |
86 | alucb->cb (alucb->cb_cls, NULL); | 86 | alucb->cb (alucb->cb_cls, NULL); |
87 | GNUNET_CLIENT_disconnect (alucb->client, GNUNET_NO); | 87 | GNUNET_CLIENT_disconnect (alucb->client, GNUNET_NO); |
88 | GNUNET_free (alucb); | 88 | GNUNET_free (alucb); |
89 | return; | 89 | return; |
90 | } | 90 | } |
91 | GNUNET_break (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); | 91 | GNUNET_break (ntohs (msg->type) == |
92 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_REPLY); | ||
92 | size = ntohs (msg->size); | 93 | size = ntohs (msg->size); |
93 | if (size == sizeof (struct GNUNET_MessageHeader)) | 94 | if (size == sizeof (struct GNUNET_MessageHeader)) |
94 | { | 95 | { |
95 | /* done! */ | 96 | /* done! */ |
96 | alucb->cb (alucb->cb_cls, NULL); | 97 | alucb->cb (alucb->cb_cls, NULL); |
97 | GNUNET_CLIENT_disconnect (alucb->client, GNUNET_NO); | 98 | GNUNET_CLIENT_disconnect (alucb->client, GNUNET_NO); |
98 | GNUNET_free (alucb); | 99 | GNUNET_free (alucb); |
99 | return; | 100 | return; |
100 | } | 101 | } |
101 | address = (const char *) &msg[1]; | 102 | address = (const char *) &msg[1]; |
102 | if (address[size - sizeof (struct GNUNET_MessageHeader) - 1] != '\0') | 103 | if (address[size - sizeof (struct GNUNET_MessageHeader) - 1] != '\0') |
103 | { | 104 | { |
104 | /* invalid reply */ | 105 | /* invalid reply */ |
105 | GNUNET_break (0); | 106 | GNUNET_break (0); |
106 | alucb->cb (alucb->cb_cls, NULL); | 107 | alucb->cb (alucb->cb_cls, NULL); |
107 | GNUNET_CLIENT_disconnect (alucb->client, GNUNET_NO); | 108 | GNUNET_CLIENT_disconnect (alucb->client, GNUNET_NO); |
108 | GNUNET_free (alucb); | 109 | GNUNET_free (alucb); |
109 | return; | 110 | return; |
110 | } | 111 | } |
111 | /* expect more replies */ | 112 | /* expect more replies */ |
112 | GNUNET_CLIENT_receive (alucb->client, | 113 | GNUNET_CLIENT_receive (alucb->client, |
113 | &peer_address_response_processor, alucb, | 114 | &peer_address_response_processor, alucb, |
114 | GNUNET_TIME_absolute_get_remaining | 115 | GNUNET_TIME_absolute_get_remaining (alucb->timeout)); |
115 | (alucb->timeout)); | ||
116 | alucb->cb (alucb->cb_cls, address); | 116 | alucb->cb (alucb->cb_cls, address); |
117 | } | 117 | } |
118 | 118 | ||
@@ -128,7 +128,8 @@ peer_address_response_processor (void *cls, | |||
128 | void | 128 | void |
129 | GNUNET_TRANSPORT_address_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg, | 129 | GNUNET_TRANSPORT_address_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg, |
130 | struct GNUNET_TIME_Relative timeout, | 130 | struct GNUNET_TIME_Relative timeout, |
131 | GNUNET_TRANSPORT_AddressLookUpCallback peer_address_callback, | 131 | GNUNET_TRANSPORT_AddressLookUpCallback |
132 | peer_address_callback, | ||
132 | void *peer_address_callback_cls) | 133 | void *peer_address_callback_cls) |
133 | { | 134 | { |
134 | struct AddressIterateMessage msg; | 135 | struct AddressIterateMessage msg; |
@@ -138,13 +139,13 @@ GNUNET_TRANSPORT_address_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
138 | 139 | ||
139 | client = GNUNET_CLIENT_connect ("transport", cfg); | 140 | client = GNUNET_CLIENT_connect ("transport", cfg); |
140 | if (client == NULL) | 141 | if (client == NULL) |
141 | { | 142 | { |
142 | peer_address_callback (peer_address_callback_cls, NULL); | 143 | peer_address_callback (peer_address_callback_cls, NULL); |
143 | return; | 144 | return; |
144 | } | 145 | } |
145 | abs_timeout = GNUNET_TIME_relative_to_absolute (timeout); | 146 | abs_timeout = GNUNET_TIME_relative_to_absolute (timeout); |
146 | 147 | ||
147 | msg.header.size = htons (sizeof(struct AddressLookupMessage)); | 148 | msg.header.size = htons (sizeof (struct AddressLookupMessage)); |
148 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE); | 149 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE); |
149 | msg.timeout = GNUNET_TIME_absolute_hton (abs_timeout); | 150 | msg.timeout = GNUNET_TIME_absolute_hton (abs_timeout); |
150 | peer_address_lookup_cb = GNUNET_malloc (sizeof (struct AddressLookupCtx)); | 151 | peer_address_lookup_cb = GNUNET_malloc (sizeof (struct AddressLookupCtx)); |
@@ -153,12 +154,12 @@ GNUNET_TRANSPORT_address_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
153 | peer_address_lookup_cb->timeout = abs_timeout; | 154 | peer_address_lookup_cb->timeout = abs_timeout; |
154 | peer_address_lookup_cb->client = client; | 155 | peer_address_lookup_cb->client = client; |
155 | GNUNET_assert (GNUNET_OK == | 156 | GNUNET_assert (GNUNET_OK == |
156 | GNUNET_CLIENT_transmit_and_get_response (client, | 157 | GNUNET_CLIENT_transmit_and_get_response (client, |
157 | &msg.header, | 158 | &msg.header, |
158 | timeout, | 159 | timeout, |
159 | GNUNET_YES, | 160 | GNUNET_YES, |
160 | &peer_address_response_processor, | 161 | &peer_address_response_processor, |
161 | peer_address_lookup_cb)); | 162 | peer_address_lookup_cb)); |
162 | } | 163 | } |
163 | 164 | ||
164 | /* end of transport_api_address_iterate.c */ | 165 | /* end of transport_api_address_iterate.c */ |