diff options
Diffstat (limited to 'src/transport/transport_api_address_lookup.c')
-rw-r--r-- | src/transport/transport_api_address_lookup.c | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/src/transport/transport_api_address_lookup.c b/src/transport/transport_api_address_lookup.c index 7cd61e896..9ae9b4031 100644 --- a/src/transport/transport_api_address_lookup.c +++ b/src/transport/transport_api_address_lookup.c | |||
@@ -93,7 +93,8 @@ peer_address_response_processor (void *cls, | |||
93 | return; | 93 | return; |
94 | } | 94 | } |
95 | size = ntohs (msg->size); | 95 | size = ntohs (msg->size); |
96 | GNUNET_break (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE); | 96 | GNUNET_break (ntohs (msg->type) == |
97 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE); | ||
97 | if (size == sizeof (struct GNUNET_MessageHeader)) | 98 | if (size == sizeof (struct GNUNET_MessageHeader)) |
98 | { | 99 | { |
99 | /* done! */ | 100 | /* done! */ |
@@ -102,8 +103,11 @@ peer_address_response_processor (void *cls, | |||
102 | return; | 103 | return; |
103 | } | 104 | } |
104 | 105 | ||
105 | if ( (size < sizeof (struct GNUNET_MessageHeader) + sizeof (struct AddressIterateResponseMessage)) || | 106 | if ((size < |
106 | (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE) ) | 107 | sizeof (struct GNUNET_MessageHeader) + |
108 | sizeof (struct AddressIterateResponseMessage)) || | ||
109 | (ntohs (msg->type) != | ||
110 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE)) | ||
107 | { | 111 | { |
108 | GNUNET_break (0); | 112 | GNUNET_break (0); |
109 | pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL); | 113 | pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL); |
@@ -112,8 +116,8 @@ peer_address_response_processor (void *cls, | |||
112 | } | 116 | } |
113 | 117 | ||
114 | air_msg = (struct AddressIterateResponseMessage *) msg; | 118 | air_msg = (struct AddressIterateResponseMessage *) msg; |
115 | tlen = ntohl(air_msg->pluginlen); | 119 | tlen = ntohl (air_msg->pluginlen); |
116 | alen = ntohl(air_msg->addrlen); | 120 | alen = ntohl (air_msg->addrlen); |
117 | 121 | ||
118 | if (size != sizeof (struct AddressIterateResponseMessage) + tlen + alen) | 122 | if (size != sizeof (struct AddressIterateResponseMessage) + tlen + alen) |
119 | { | 123 | { |
@@ -126,7 +130,7 @@ peer_address_response_processor (void *cls, | |||
126 | addr = (const char *) &air_msg[1]; | 130 | addr = (const char *) &air_msg[1]; |
127 | transport_name = &addr[alen]; | 131 | transport_name = &addr[alen]; |
128 | 132 | ||
129 | if (transport_name[tlen-1] != '\0') | 133 | if (transport_name[tlen - 1] != '\0') |
130 | { | 134 | { |
131 | GNUNET_break_op (0); | 135 | GNUNET_break_op (0); |
132 | pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL); | 136 | pal_ctx->cb (pal_ctx->cb_cls, NULL, NULL); |
@@ -135,13 +139,14 @@ peer_address_response_processor (void *cls, | |||
135 | } | 139 | } |
136 | 140 | ||
137 | /* expect more replies */ | 141 | /* expect more replies */ |
138 | GNUNET_CLIENT_receive (pal_ctx->client, | 142 | GNUNET_CLIENT_receive (pal_ctx->client, &peer_address_response_processor, |
139 | &peer_address_response_processor, pal_ctx, | 143 | pal_ctx, |
140 | GNUNET_TIME_absolute_get_remaining (pal_ctx->timeout)); | 144 | GNUNET_TIME_absolute_get_remaining (pal_ctx->timeout)); |
141 | 145 | ||
142 | /* notify client */ | 146 | /* notify client */ |
143 | address = GNUNET_HELLO_address_allocate (&air_msg->peer, | 147 | address = |
144 | transport_name, addr, alen); | 148 | GNUNET_HELLO_address_allocate (&air_msg->peer, transport_name, addr, |
149 | alen); | ||
145 | pal_ctx->cb (pal_ctx->cb_cls, &air_msg->peer, address); | 150 | pal_ctx->cb (pal_ctx->cb_cls, &air_msg->peer, address); |
146 | GNUNET_HELLO_address_free (address); | 151 | GNUNET_HELLO_address_free (address); |
147 | } | 152 | } |
@@ -165,11 +170,13 @@ peer_address_response_processor (void *cls, | |||
165 | * @param peer_address_callback_cls closure for peer_address_callback | 170 | * @param peer_address_callback_cls closure for peer_address_callback |
166 | */ | 171 | */ |
167 | struct GNUNET_TRANSPORT_PeerIterateContext * | 172 | struct GNUNET_TRANSPORT_PeerIterateContext * |
168 | GNUNET_TRANSPORT_peer_get_active_addresses (const struct GNUNET_CONFIGURATION_Handle *cfg, | 173 | GNUNET_TRANSPORT_peer_get_active_addresses (const struct |
169 | const struct GNUNET_PeerIdentity *peer, | 174 | GNUNET_CONFIGURATION_Handle *cfg, |
170 | int one_shot, | 175 | const struct GNUNET_PeerIdentity |
176 | *peer, int one_shot, | ||
171 | struct GNUNET_TIME_Relative timeout, | 177 | struct GNUNET_TIME_Relative timeout, |
172 | GNUNET_TRANSPORT_PeerIterateCallback peer_address_callback, | 178 | GNUNET_TRANSPORT_PeerIterateCallback |
179 | peer_address_callback, | ||
173 | void *peer_address_callback_cls) | 180 | void *peer_address_callback_cls) |
174 | { | 181 | { |
175 | struct GNUNET_TRANSPORT_PeerIterateContext *pal_ctx; | 182 | struct GNUNET_TRANSPORT_PeerIterateContext *pal_ctx; |
@@ -180,7 +187,7 @@ GNUNET_TRANSPORT_peer_get_active_addresses (const struct GNUNET_CONFIGURATION_Ha | |||
180 | if (GNUNET_YES != one_shot) | 187 | if (GNUNET_YES != one_shot) |
181 | { | 188 | { |
182 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 189 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
183 | "Address monitoring not implemented\n"); | 190 | "Address monitoring not implemented\n"); |
184 | return NULL; | 191 | return NULL; |
185 | } | 192 | } |
186 | client = GNUNET_CLIENT_connect ("transport", cfg); | 193 | client = GNUNET_CLIENT_connect ("transport", cfg); |
@@ -192,7 +199,7 @@ GNUNET_TRANSPORT_peer_get_active_addresses (const struct GNUNET_CONFIGURATION_Ha | |||
192 | msg.one_shot = htonl (one_shot); | 199 | msg.one_shot = htonl (one_shot); |
193 | msg.timeout = GNUNET_TIME_absolute_hton (abs_timeout); | 200 | msg.timeout = GNUNET_TIME_absolute_hton (abs_timeout); |
194 | if (peer == NULL) | 201 | if (peer == NULL) |
195 | memset (&msg.peer, 0 , sizeof (struct GNUNET_PeerIdentity)); | 202 | memset (&msg.peer, 0, sizeof (struct GNUNET_PeerIdentity)); |
196 | else | 203 | else |
197 | msg.peer = *peer; | 204 | msg.peer = *peer; |
198 | pal_ctx = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PeerIterateContext)); | 205 | pal_ctx = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PeerIterateContext)); |
@@ -216,8 +223,8 @@ GNUNET_TRANSPORT_peer_get_active_addresses (const struct GNUNET_CONFIGURATION_Ha | |||
216 | */ | 223 | */ |
217 | void | 224 | void |
218 | GNUNET_TRANSPORT_peer_get_active_addresses_cancel (struct | 225 | GNUNET_TRANSPORT_peer_get_active_addresses_cancel (struct |
219 | GNUNET_TRANSPORT_PeerIterateContext | 226 | GNUNET_TRANSPORT_PeerIterateContext |
220 | *alc) | 227 | *alc) |
221 | { | 228 | { |
222 | GNUNET_CLIENT_disconnect (alc->client, GNUNET_NO); | 229 | GNUNET_CLIENT_disconnect (alc->client, GNUNET_NO); |
223 | GNUNET_free (alc); | 230 | GNUNET_free (alc); |