- {
- /* last reply */
- address = NULL;
- }
- else
- {
- address = (const char *) &msg[1];
- if (address[size - sizeof (struct GNUNET_MessageHeader) - 1] != '\0')
- {
- /* invalid reply */
- GNUNET_break_op (0);
- alucb->cb (alucb->cls, NULL);
- GNUNET_CLIENT_disconnect (alucb->client);
- GNUNET_free (alucb);
- return;
- }
- else
- {
- /* expect more replies */
- GNUNET_CLIENT_receive (alucb->client, &address_response_processor,
- alucb,
- GNUNET_TIME_absolute_get_remaining
- (alucb->timeout));
- }
- }
- alucb->cb (alucb->cls, address);
- if (address == NULL)
- {
- /* done! */
- GNUNET_CLIENT_disconnect (alucb->client);
- GNUNET_free (alucb);
- }
+ {
+ /* done! */
+ pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL);
+ GNUNET_TRANSPORT_peer_get_active_addresses_cancel (pal_ctx);
+ return;
+ }
+
+ if ((size <
+ sizeof (struct GNUNET_MessageHeader) +
+ sizeof (struct AddressIterateResponseMessage)) ||
+ (ntohs (msg->type) !=
+ GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE))
+ {
+ GNUNET_break (0);
+ pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL);
+ GNUNET_TRANSPORT_peer_get_active_addresses_cancel (pal_ctx);
+ return;
+ }
+
+ air_msg = (struct AddressIterateResponseMessage *) msg;
+ tlen = ntohl (air_msg->pluginlen);
+ alen = ntohl (air_msg->addrlen);
+
+ if (size != sizeof (struct AddressIterateResponseMessage) + tlen + alen)
+ {
+ GNUNET_break (0);
+ pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL);
+ GNUNET_TRANSPORT_peer_get_active_addresses_cancel (pal_ctx);
+ return;
+ }
+
+ addr = (const char *) &air_msg[1];
+ transport_name = &addr[alen];
+
+ if (transport_name[tlen - 1] != '\0')
+ {
+ GNUNET_break_op (0);
+ pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL);
+ GNUNET_TRANSPORT_peer_get_active_addresses_cancel (pal_ctx);
+ return;
+ }
+
+ /* expect more replies */
+ GNUNET_CLIENT_receive (pal_ctx->client, &peer_address_response_processor,
+ pal_ctx,
+ GNUNET_TIME_absolute_get_remaining (pal_ctx->timeout));
+
+ /* notify client */
+ address =
+ GNUNET_HELLO_address_allocate (&air_msg->peer, transport_name, addr,
+ alen);
+ pal_ctx->cb (pal_ctx->cb_cls, &air_msg->peer, address);
+ GNUNET_HELLO_address_free (address);