/**
* Address
*/
- struct HttpAddress *addr;
-
- /**
- * Address length
- */
- size_t addrlen;
+ struct GNUNET_HELLO_Address *address;
/**
* ATS network type in NBO
struct HTTP_Message *msg;
char *stat_txt;
- GNUNET_assert (plugin != NULL);
- GNUNET_assert (s != NULL);
-
/* lookup if session is really existing */
if (GNUNET_YES != client_exist_session (plugin, s))
{
- GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, plugin->name,
- "Trying to send with invalid session %p \n", s);
+ GNUNET_break (0);
return GNUNET_SYSERR;
}
"Session %p/connection %p: unpausing connection\n",
s, s->client_put);
s->put_paused = GNUNET_NO;
- curl_easy_pause (s->client_put, CURLPAUSE_CONT);
+ if (NULL != s->client_put)
+ curl_easy_pause (s->client_put, CURLPAUSE_CONT);
}
else if (GNUNET_YES == s->put_tmp_disconnected)
{
GNUNET_SERVER_mst_destroy (s->msg_tk);
s->msg_tk = NULL;
}
- GNUNET_free (s->addr);
+ GNUNET_HELLO_address_free (s->address);
GNUNET_free (s->url);
GNUNET_free (s);
}
return GNUNET_SYSERR;
}
- if (s->client_put != NULL)
+ if (NULL != s->client_put)
{
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"Session %p/connection %p: disconnecting PUT connection to peer `%s'\n",
s->recv_wakeup_task = GNUNET_SCHEDULER_NO_TASK;
}
- if (s->client_get != NULL)
+ if (NULL != s->client_get)
{
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Session %p/connection %p: disconnecting GET connection to peer `%s'\n",
- s, s->client_get, GNUNET_i2s (&s->target));
-
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+ "Session %p/connection %p: disconnecting GET connection to peer `%s'\n",
+ s, s->client_get,
+ GNUNET_i2s (&s->target));
/* remove curl handle from multi handle */
mret = curl_multi_remove_handle (plugin->curl_multi_handle, s->client_get);
if (mret != CURLM_OK)
}
msg = s->msg_head;
- while (msg != NULL)
+ while (NULL != msg)
{
t = msg->next;
if (NULL != msg->transmit_cont)
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"Session %p: notifying transport about ending session\n",s);
- plugin->env->session_end (plugin->env->cls, &s->target, s);
+ plugin->env->session_end (plugin->env->cls, s->address, s);
client_delete_session (s);
/* Re-schedule since handles have changed */
struct Session *pos;
for (pos = plugin->head; NULL != pos; pos = pos->next)
+ {
if ((0 == memcmp (&address->peer, &pos->target, sizeof (struct GNUNET_PeerIdentity))) &&
- (address->address_length == pos->addrlen) &&
- (0 == memcmp (address->address, pos->addr, pos->addrlen)))
+ (0 == GNUNET_HELLO_address_cmp(address, pos->address)))
return pos;
+ }
return NULL;
}
s, s->client_put);
s->put_paused = GNUNET_NO;
s->put_tmp_disconnecting = GNUNET_YES;
- curl_easy_pause (s->client_put, CURLPAUSE_CONT);
+ if (NULL != s->client_put)
+ curl_easy_pause (s->client_put, CURLPAUSE_CONT);
client_schedule (s->plugin, GNUNET_YES);
}
"Session %p/connection %p: Waking up GET handle\n",
s,
s->client_get);
- if (s->client_get != NULL)
+ s->put_paused = GNUNET_NO;
+ if (NULL != s->client_get)
curl_easy_pause (s->client_get, CURLPAUSE_CONT);
+
}
atsi.type = htonl (GNUNET_ATS_NETWORK_TYPE);
atsi.value = s->ats_address_network_type;
GNUNET_break (s->ats_address_network_type != ntohl (GNUNET_ATS_NET_UNSPECIFIED));
- delay = s->plugin->env->receive (plugin->env->cls, &s->target, message,
- s, (const char *) s->addr, s->addrlen);
+ delay = s->plugin->env->receive (plugin->env->cls, s->address, s, message);
plugin->env->update_address_metrics (plugin->env->cls,
- &s->target,
- s->addr,
- s->addrlen,
- s,
+ s->address, s,
&atsi, 1);
GNUNET_asprintf (&stat_txt,
"Client: peer `%s' address `%s' next read delayed for %s\n",
GNUNET_i2s (&s->target),
http_common_plugin_address_to_string (NULL,
- s->plugin->protocol,
- s->addr, s->addrlen),
+ s->plugin->protocol, s->address->address,
+ s->address->address_length),
GNUNET_STRINGS_relative_time_to_string (delay,
GNUNET_YES));
}
static int
client_connect_get (struct Session *s)
{
-
CURLMcode mret;
+
/* create get connection */
s->client_get = curl_easy_init ();
s->get.s = s;
#endif
#if BUILD_HTTPS
curl_easy_setopt (s->client_get, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
- if (HTTP_OPTIONS_VERIFY_CERTIFICATE ==
- (ntohl (s->addr->options) & HTTP_OPTIONS_VERIFY_CERTIFICATE))
{
- curl_easy_setopt (s->client_get, CURLOPT_SSL_VERIFYPEER, 1L);
- curl_easy_setopt (s->client_get, CURLOPT_SSL_VERIFYHOST, 2L);
- }
- else
- {
- curl_easy_setopt (s->client_get, CURLOPT_SSL_VERIFYPEER, 0);
- curl_easy_setopt (s->client_get, CURLOPT_SSL_VERIFYHOST, 0);
+ struct HttpAddress *ha;
+ ha = (struct HttpAddress *) s->address->address;
+
+ if (HTTP_OPTIONS_VERIFY_CERTIFICATE ==
+ (ntohl (ha->options) & HTTP_OPTIONS_VERIFY_CERTIFICATE))
+ {
+ curl_easy_setopt (s->client_get, CURLOPT_SSL_VERIFYPEER, 1L);
+ curl_easy_setopt (s->client_get, CURLOPT_SSL_VERIFYHOST, 2L);
+ }
+ else
+ {
+ curl_easy_setopt (s->client_get, CURLOPT_SSL_VERIFYPEER, 0);
+ curl_easy_setopt (s->client_get, CURLOPT_SSL_VERIFYHOST, 0);
+ }
}
curl_easy_setopt (s->client_get, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);
curl_easy_setopt (s->client_get, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS);
curl_easy_setopt (s->client_get, CURLOPT_TIMEOUT, 0);
curl_easy_setopt (s->client_get, CURLOPT_PRIVATE, s);
curl_easy_setopt (s->client_get, CURLOPT_CONNECTTIMEOUT_MS,
- (long) HTTP_CLIENT_NOT_VALIDATED_TIMEOUT.rel_value_us / 1000LL);
+ (long) (HTTP_CLIENT_NOT_VALIDATED_TIMEOUT.rel_value_us / 1000LL));
curl_easy_setopt (s->client_get, CURLOPT_BUFFERSIZE,
2 * GNUNET_SERVER_MAX_MESSAGE_SIZE);
#if CURL_TCP_NODELAY
#endif
#if BUILD_HTTPS
curl_easy_setopt (s->client_put, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
- if (HTTP_OPTIONS_VERIFY_CERTIFICATE ==
- (ntohl (s->addr->options) & HTTP_OPTIONS_VERIFY_CERTIFICATE))
- {
- curl_easy_setopt (s->client_put, CURLOPT_SSL_VERIFYPEER, 1L);
- curl_easy_setopt (s->client_put, CURLOPT_SSL_VERIFYHOST, 2L);
- }
- else
{
- curl_easy_setopt (s->client_put, CURLOPT_SSL_VERIFYPEER, 0);
- curl_easy_setopt (s->client_put, CURLOPT_SSL_VERIFYHOST, 0);
+ struct HttpAddress *ha;
+ ha = (struct HttpAddress *) s->address->address;
+
+ if (HTTP_OPTIONS_VERIFY_CERTIFICATE ==
+ (ntohl (ha->options) & HTTP_OPTIONS_VERIFY_CERTIFICATE))
+ {
+ curl_easy_setopt (s->client_put, CURLOPT_SSL_VERIFYPEER, 1L);
+ curl_easy_setopt (s->client_put, CURLOPT_SSL_VERIFYHOST, 2L);
+ }
+ else
+ {
+ curl_easy_setopt (s->client_put, CURLOPT_SSL_VERIFYPEER, 0);
+ curl_easy_setopt (s->client_put, CURLOPT_SSL_VERIFYHOST, 0);
+ }
}
curl_easy_setopt (s->client_get, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);
curl_easy_setopt (s->client_get, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS);
curl_easy_setopt (s->client_put, CURLOPT_TIMEOUT, 0);
curl_easy_setopt (s->client_put, CURLOPT_PRIVATE, s);
curl_easy_setopt (s->client_put, CURLOPT_CONNECTTIMEOUT_MS,
- (long) HTTP_CLIENT_NOT_VALIDATED_TIMEOUT.rel_value_us / 1000LL);
+ (long) (HTTP_CLIENT_NOT_VALIDATED_TIMEOUT.rel_value_us / 1000LL));
curl_easy_setopt (s->client_put, CURLOPT_BUFFERSIZE,
2 * GNUNET_SERVER_MAX_MESSAGE_SIZE);
#if CURL_TCP_NODELAY
/* create url */
if (NULL == http_common_plugin_address_to_string (NULL,
- plugin->protocol,
- s->addr, s->addrlen))
+ plugin->protocol, s->address->address, s->address->address_length))
{
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
plugin->name,
}
GNUNET_asprintf (&s->url, "%s/%s;%u",
- http_common_plugin_address_to_url (NULL, s->addr, s->addrlen),
+ http_common_plugin_address_to_url (NULL, s->address->address,
+ s->address->address_length),
GNUNET_i2s_full (plugin->env->my_identity),
plugin->last_tag);
if ((GNUNET_SYSERR == client_connect_get (s)) ||
(GNUNET_SYSERR == client_connect_put (s)))
{
- GNUNET_break (0);
+ plugin->env->session_end (plugin->env->cls, s->address, s);
+ client_delete_session (s);
return GNUNET_SYSERR;
}
s = GNUNET_new (struct Session);
s->target = address->peer;
s->plugin = plugin;
- s->addr = GNUNET_malloc (address->address_length);
- memcpy (s->addr, address->address, address->address_length);
- s->addrlen = address->address_length;
+ s->address = GNUNET_HELLO_address_copy (address);
s->ats_address_network_type = ats.value;
s->put_paused = GNUNET_NO;
s->put_tmp_disconnecting = GNUNET_NO;
s);
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"Created new session %p for `%s' address `%s''\n",
- s,
- http_common_plugin_address_to_string (NULL, plugin->protocol, s->addr, s->addrlen),
+ s, http_common_plugin_address_to_string (NULL,
+ plugin->protocol, s->address->address,
+ s->address->address_length),
GNUNET_i2s (&s->target));
/* add new session */
{
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
"Cannot connect to peer `%s' address `%s''\n",
- http_common_plugin_address_to_string (NULL, plugin->protocol, s->addr, s->addrlen),
+ http_common_plugin_address_to_string (NULL,
+ plugin->protocol, s->address->address,
+ s->address->address_length),
GNUNET_i2s (&s->target));
client_delete_session (s);
return NULL;
return http_common_plugin_address_to_string (cls, PLUGIN_NAME, addr, addrlen);
}
+
static void
http_client_plugin_update_session_timeout (void *cls,
const struct GNUNET_PeerIdentity *peer,
/* lookup if session is really existing */
if (GNUNET_YES != client_exist_session (plugin, session))
+ {
+ GNUNET_break (0);
return;
-
+ }
client_reschedule_session_timeout (session);
}