size_t addrlen;
+ int inbound;
+
/**
* Session timeout task
*/
struct Session *t = value;
if (t->addrlen != lctx->ua_len)
+ {
+ GNUNET_break (0);
return GNUNET_YES;
+ }
- if (0 == memcmp (&t->addr, lctx->ua, lctx->ua_len))
+ if (0 == memcmp (t->addr, lctx->ua, lctx->ua_len))
{
lctx->s = t;
return GNUNET_NO;
}
+ GNUNET_break (0);
return GNUNET_YES;
}
resend:
/* Send the data */
- sent = 0;
sent = GNUNET_NETWORK_socket_sendto (send_handle, msgbuf, msgbuf_size, sb, sbs);
if (GNUNET_SYSERR == sent)
struct GetSessionIteratorContext *gsi = cls;
struct Session *s = value;
- if ( (gsi->addrlen == s->addrlen) &&
+ if ((GNUNET_NO == s->inbound) && (gsi->addrlen == s->addrlen) &&
(0 == memcmp (gsi->address, s->addr, s->addrlen)) )
{
gsi->res = s;
disconnect_session (s);
}
+
/**
* Function obtain the network type for a session
*
* @return the network type in HBO or GNUNET_SYSERR
*/
static enum GNUNET_ATS_Network_Type
-unix_get_network (void *cls, void *session)
+unix_get_network (void *cls,
+ struct Session *session)
{
- GNUNET_assert (NULL != session);
- return GNUNET_ATS_NET_LOOPBACK;
+ GNUNET_assert (NULL != session);
+ return GNUNET_ATS_NET_LOOPBACK;
}
s->addr = (struct UnixAddress *) &s[1];
s->addrlen = address->address_length;
s->plugin = plugin;
+ s->inbound = GNUNET_NO;
memcpy (s->addr, address->address, address->address_length);
memcpy (&s->target, &address->peer, sizeof (struct GNUNET_PeerIdentity));
GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == s->timeout_task);
GNUNET_assert (ua_len >= sizeof (struct UnixAddress));
- LOG (GNUNET_ERROR_TYPE_DEBUG,
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
"Received message from %s\n",
unix_address_to_string(NULL, ua, ua_len));
GNUNET_STATISTICS_update (plugin->env->stats,
if (NULL == s)
{
s = unix_plugin_get_session (plugin, addr);
- /* Notify transport and ATS about new session */
+ s->inbound = GNUNET_YES;
+ /* Notify transport and ATS about new inbound session */
plugin->env->session_start (NULL, sender,
- PLUGIN_NAME, ua, ua_len, s, &plugin->ats_network, 1);
+ PLUGIN_NAME, NULL, 0, s, &plugin->ats_network, 1);
}
reschedule_session_timeout (s);
- plugin->env->receive (plugin->env->cls, sender, currhdr,
- s, (const char *) ua, ua_len);
+ plugin->env->receive (plugin->env->cls, sender, currhdr, s,
+ (GNUNET_YES == s->inbound) ? NULL : (const char *) ua,
+ (GNUNET_YES == s->inbound) ? 0 : ua_len);
- plugin->env->update_address_metrics (plugin->env->cls,
- sender,
- (const char *) ua, ua_len,
- s,
- &plugin->ats_network, 1);
+ plugin->env->update_address_metrics (plugin->env->cls, sender,
+ (GNUNET_YES == s->inbound) ? NULL : (const char *) ua,
+ (GNUNET_YES == s->inbound) ? 0 : ua_len,
+ s, &plugin->ats_network, 1);
GNUNET_free (addr);
}
if ((csize < sizeof (struct UNIXMessage)) || (csize > ret))
{
GNUNET_break_op (0);
+ GNUNET_free (ua);
return;
}
msgbuf = (char *) &msg[1];
while (NULL != (msgw = plugin->msg_tail))
{
- if (GNUNET_TIME_absolute_get_remaining (msgw->timeout).rel_value > 0)
+ if (GNUNET_TIME_absolute_get_remaining (msgw->timeout).rel_value_us > 0)
break; /* Message is ready for sending */
/* Message has a timeout */
LOG (GNUNET_ERROR_TYPE_DEBUG,
static char rbuf[1024];
struct UnixAddress *ua = (struct UnixAddress *) addr;
char *addrstr;
- char *tmp;
size_t addr_str_len;
- if ((NULL == addr) || (0 == addrlen) || (sizeof (struct UnixAddress) > addrlen))
+ if (0 == addrlen)
+ {
+ GNUNET_snprintf(rbuf, sizeof (rbuf), "%s", TRANSPORT_SESSION_INBOUND_STRING);
+ }
+ if ((NULL == addr) || (sizeof (struct UnixAddress) > addrlen))
{
GNUNET_break (0);
return NULL;
return NULL;
}
- GNUNET_asprintf(&tmp, "%s.%u.%s", PLUGIN_NAME, ntohl (ua->options), addrstr);
- memcpy (rbuf, tmp, strlen (tmp) + 1);
- GNUNET_free (tmp);
+ GNUNET_snprintf(rbuf, sizeof (rbuf), "%s.%u.%s", PLUGIN_NAME, ntohl (ua->options), addrstr);
return rbuf;
}
{
asc (asc_cls, unix_address_to_string (NULL, addr, addrlen));
}
+ else if (0 == addrlen)
+ {
+ asc (asc_cls, TRANSPORT_SESSION_INBOUND_STRING);
+ }
else
{
GNUNET_break (0);
address = NULL;
plugin = NULL;
optionstr = NULL;
- options = 0;
+
if ((NULL == addr) || (addrlen == 0))
{
GNUNET_break (0);