find_session (struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id,
const struct GNUNET_PeerIdentity *peer)
{
-#if DEBUG_ATS
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Find session %u from peer %s in %p\n",
+
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-scheduling-api",
+ "Find session %u from peer %s in %p\n",
(unsigned int) session_id, GNUNET_i2s (peer), sh);
-#endif
+
if (session_id >= sh->session_array_size)
{
GNUNET_break (0);
unsigned int i;
unsigned int f;
-#if DEBUG_ATS
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-scheduling-api",
"Get session ID for session %p from peer %s in %p\n", session,
GNUNET_i2s (peer), sh);
-#endif
+
if (NULL == session)
return 0;
f = 0;
sh->session_array[f].session = session;
sh->session_array[f].peer = *peer;
sh->session_array[f].slot_used = GNUNET_YES;
-#if DEBUG_ATS
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-scheduling-api",
"Assigning session ID %u for session %p of peer %s in %p\n", f,
session, GNUNET_i2s (peer), sh);
-#endif
+
return f;
}
remove_session (struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id,
const struct GNUNET_PeerIdentity *peer)
{
-#if DEBUG_ATS
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Remove sessionID %u from peer %s in %p\n",
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-scheduling-api",
+ "Remove sessionID %u from peer %s in %p\n", "ats-scheduling-api",
(unsigned int) session_id, GNUNET_i2s (peer), sh);
-#endif
if (0 == session_id)
return;
GNUNET_assert (session_id < sh->session_array_size);
release_session (struct GNUNET_ATS_SchedulingHandle *sh, uint32_t session_id,
const struct GNUNET_PeerIdentity *peer)
{
-#if DEBUG_ATS
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-scheduling-api",
"Release sessionID %u from peer %s in %p\n",
(unsigned int) session_id, GNUNET_i2s (peer), sh);
-#endif
+
if (session_id >= sh->session_array_size)
{
GNUNET_break (0);
s = find_session (sh, session_id, &m->peer);
if (s == NULL)
{
-#if DEBUG_ATS
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-scheduling-api",
"ATS tries to use outdated session `%s'\n",
GNUNET_i2s (&m->peer));
-#endif
GNUNET_CLIENT_receive (sh->client, &process_ats_message, sh,
GNUNET_TIME_UNIT_FOREVER_REL);
return;
net->netmask = (struct sockaddr *) &tmp[1];
net->length = addrlen;
+ memset (&network4, 0, sizeof (network4));
network4.sin_family = AF_INET;
- network4.sin_port = htons (0);
#if HAVE_SOCKADDR_IN_SIN_LEN
network4.sin_len = sizeof (network4);
#endif
net->netmask = (struct sockaddr *) &tmp[1];
net->length = addrlen;
+ memset (&network6, 0, sizeof (network6));
network6.sin6_family = AF_INET6;
- network6.sin6_port = htons (0);
#if HAVE_SOCKADDR_IN_SIN_LEN
network6.sin6_len = sizeof (network6);
#endif
if (net != NULL)
{
#if VERBOSE_ATS
- char * netmask = strdup (GNUNET_a2s((struct sockaddr *) net->netmask, addrlen));
+ char * netmask = GNUNET_strdup (GNUNET_a2s((struct sockaddr *) net->netmask, addrlen));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding network `%s', netmask `%s'\n",
GNUNET_a2s((struct sockaddr *) net->network, addrlen),
netmask);
/**
* Returns where the address is located: LAN or WAN or ...
+ * @param sh the scheduling handle
* @param addr address
* @param addrlen address length
* @return location as GNUNET_ATS_Information
*/
-struct GNUNET_ATS_Information
+const struct GNUNET_ATS_Information
GNUNET_ATS_address_get_type (struct GNUNET_ATS_SchedulingHandle * sh, const struct sockaddr * addr, socklen_t addrlen)
{
GNUNET_assert (sh != NULL);
if (((a4->sin_addr.s_addr & mask4->sin_addr.s_addr)) == net4->sin_addr.s_addr)
{
- char * net = strdup (GNUNET_a2s ((const struct sockaddr *) net4, addrlen));
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' is in network `%s'\n",
+ char * net = GNUNET_strdup (GNUNET_a2s ((const struct sockaddr *) net4, addrlen));
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-scheduling-api",
+ "`%s' is in network `%s'\n",
GNUNET_a2s ((const struct sockaddr *)a4, addrlen),
net);
GNUNET_free (net);
if (res == GNUNET_YES)
{
- char * net = strdup (GNUNET_a2s ((const struct sockaddr *) net6, addrlen));
+ char * net = GNUNET_strdup (GNUNET_a2s ((const struct sockaddr *) net6, addrlen));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' is in network `%s'\n",
GNUNET_a2s ((const struct sockaddr *) a6, addrlen),
net);
break;
}
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "`%s' is in network `%s'\n",
- GNUNET_a2s ((const struct sockaddr *) addr, addrlen),
- range);
#endif
ats.type = htonl (GNUNET_ATS_NETWORK_TYPE);
ats.value = htonl (type);
- return ats;
+ return (const struct GNUNET_ATS_Information) ats;
}
/**
size_t namelen;
size_t msize;
+ if (address == NULL)
+ {
+ GNUNET_break (0);
+ return;
+ }
if ((address == NULL) && (session == NULL))
{
GNUNET_break (0);