diff options
Diffstat (limited to 'src/transport/transport_api_address_lookup.c')
-rw-r--r-- | src/transport/transport_api_address_lookup.c | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/src/transport/transport_api_address_lookup.c b/src/transport/transport_api_address_lookup.c index 9ae9b4031..a21daab5e 100644 --- a/src/transport/transport_api_address_lookup.c +++ b/src/transport/transport_api_address_lookup.c | |||
@@ -103,9 +103,7 @@ peer_address_response_processor (void *cls, | |||
103 | return; | 103 | return; |
104 | } | 104 | } |
105 | 105 | ||
106 | if ((size < | 106 | if ((size < sizeof (struct AddressIterateResponseMessage)) || |
107 | sizeof (struct GNUNET_MessageHeader) + | ||
108 | sizeof (struct AddressIterateResponseMessage)) || | ||
109 | (ntohs (msg->type) != | 107 | (ntohs (msg->type) != |
110 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE)) | 108 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE)) |
111 | { | 109 | { |
@@ -127,28 +125,35 @@ peer_address_response_processor (void *cls, | |||
127 | return; | 125 | return; |
128 | } | 126 | } |
129 | 127 | ||
130 | addr = (const char *) &air_msg[1]; | 128 | if (alen == 0 && tlen == 0) |
131 | transport_name = &addr[alen]; | ||
132 | |||
133 | if (transport_name[tlen - 1] != '\0') | ||
134 | { | 129 | { |
135 | GNUNET_break_op (0); | 130 | pal_ctx->cb (pal_ctx->cb_cls, &air_msg->peer, NULL); |
136 | pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL); | 131 | } |
137 | GNUNET_TRANSPORT_peer_get_active_addresses_cancel (pal_ctx); | 132 | else |
138 | return; | 133 | { |
134 | addr = (const char *) &air_msg[1]; | ||
135 | transport_name = &addr[alen]; | ||
136 | |||
137 | if (transport_name[tlen - 1] != '\0') | ||
138 | { | ||
139 | GNUNET_break_op (0); | ||
140 | pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL); | ||
141 | GNUNET_TRANSPORT_peer_get_active_addresses_cancel (pal_ctx); | ||
142 | return; | ||
143 | } | ||
144 | |||
145 | /* notify client */ | ||
146 | address = | ||
147 | GNUNET_HELLO_address_allocate (&air_msg->peer, transport_name, addr, | ||
148 | alen); | ||
149 | pal_ctx->cb (pal_ctx->cb_cls, &air_msg->peer, address); | ||
150 | GNUNET_HELLO_address_free (address); | ||
139 | } | 151 | } |
140 | 152 | ||
141 | /* expect more replies */ | 153 | /* expect more replies */ |
142 | GNUNET_CLIENT_receive (pal_ctx->client, &peer_address_response_processor, | 154 | GNUNET_CLIENT_receive (pal_ctx->client, &peer_address_response_processor, |
143 | pal_ctx, | 155 | pal_ctx, |
144 | GNUNET_TIME_absolute_get_remaining (pal_ctx->timeout)); | 156 | GNUNET_TIME_absolute_get_remaining (pal_ctx->timeout)); |
145 | |||
146 | /* notify client */ | ||
147 | address = | ||
148 | GNUNET_HELLO_address_allocate (&air_msg->peer, transport_name, addr, | ||
149 | alen); | ||
150 | pal_ctx->cb (pal_ctx->cb_cls, &air_msg->peer, address); | ||
151 | GNUNET_HELLO_address_free (address); | ||
152 | } | 157 | } |
153 | 158 | ||
154 | 159 | ||
@@ -165,7 +170,7 @@ peer_address_response_processor (void *cls, | |||
165 | * @param peer peer identity to look up the addresses of, CHANGE: allow NULL for all (connected) peers | 170 | * @param peer peer identity to look up the addresses of, CHANGE: allow NULL for all (connected) peers |
166 | * @param one_shot GNUNET_YES to return the current state and then end (with NULL+NULL), | 171 | * @param one_shot GNUNET_YES to return the current state and then end (with NULL+NULL), |
167 | * GNUNET_NO to monitor the set of addresses used (continuously, must be explicitly cancelled) | 172 | * GNUNET_NO to monitor the set of addresses used (continuously, must be explicitly cancelled) |
168 | * @param timeout how long is the lookup allowed to take at most | 173 | * @param timeout how long is the lookup allowed to take at most (irrelevant if one_shot is set to GNUNET_NO) |
169 | * @param peer_address_callback function to call with the results | 174 | * @param peer_address_callback function to call with the results |
170 | * @param peer_address_callback_cls closure for peer_address_callback | 175 | * @param peer_address_callback_cls closure for peer_address_callback |
171 | */ | 176 | */ |
@@ -184,15 +189,11 @@ GNUNET_TRANSPORT_peer_get_active_addresses (const struct | |||
184 | struct GNUNET_CLIENT_Connection *client; | 189 | struct GNUNET_CLIENT_Connection *client; |
185 | struct GNUNET_TIME_Absolute abs_timeout; | 190 | struct GNUNET_TIME_Absolute abs_timeout; |
186 | 191 | ||
187 | if (GNUNET_YES != one_shot) | ||
188 | { | ||
189 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
190 | "Address monitoring not implemented\n"); | ||
191 | return NULL; | ||
192 | } | ||
193 | client = GNUNET_CLIENT_connect ("transport", cfg); | 192 | client = GNUNET_CLIENT_connect ("transport", cfg); |
194 | if (client == NULL) | 193 | if (client == NULL) |
195 | return NULL; | 194 | return NULL; |
195 | if (GNUNET_YES != one_shot) | ||
196 | timeout = GNUNET_TIME_UNIT_FOREVER_REL; | ||
196 | abs_timeout = GNUNET_TIME_relative_to_absolute (timeout); | 197 | abs_timeout = GNUNET_TIME_relative_to_absolute (timeout); |
197 | msg.header.size = htons (sizeof (struct AddressIterateMessage)); | 198 | msg.header.size = htons (sizeof (struct AddressIterateMessage)); |
198 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE); | 199 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE); |