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)
}
+/**
+ * Function obtain the network type for a session
+ *
+ * @param cls closure ('struct Plugin*')
+ * @param session the session
+ * @return the network type in HBO or GNUNET_SYSERR
+ */
+static enum GNUNET_ATS_Network_Type
+unix_get_network (void *cls,
+ struct Session *session)
+{
+ GNUNET_assert (NULL != session);
+ return GNUNET_ATS_NET_LOOPBACK;
+}
+
+
/**
* Creates a new outbound session the transport service will use to send data to the
* peer
}
addrstr = (char *) &ua[1];
addr_str_len = ntohl (ua->addrlen);
- if (addr_str_len != address->address_length - sizeof (struct UnixAddress *))
+ if (addr_str_len != address->address_length - sizeof (struct UnixAddress))
{
/* This can be a legacy address */
return NULL;
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,
ua_len);
s = lookup_session (plugin, sender, ua, ua_len);
if (NULL == s)
+ {
s = unix_plugin_get_session (plugin, addr);
+ s->inbound = GNUNET_YES;
+ /* Notify transport and ATS about new inbound session */
+ plugin->env->session_start (NULL, sender,
+ 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;
addrstr = (char *) &ua[1];
addr_str_len = ntohl (ua->addrlen);
- if (addr_str_len != addrlen - sizeof (struct UnixAddress *))
+ if (addr_str_len != addrlen - sizeof (struct UnixAddress))
{
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);
api->address_to_string = &unix_address_to_string;
api->check_address = &unix_check_address;
api->string_to_address = &unix_string_to_address;
+ api->get_network = &unix_get_network;
sockets_created = unix_transport_server_start (plugin);
if (0 == sockets_created)
LOG (GNUNET_ERROR_TYPE_WARNING,