You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
*/
/**
* @file ats/plugin_ats2_simple.c
struct GNUNET_TIME_Absolute expiration;
struct Hello *hello;
- if (0 != memcmp (&p->pid,
- &record->peer,
- sizeof (struct GNUNET_PeerIdentity)))
+ if (0 != GNUNET_memcmp (&p->pid,
+ &record->peer))
{
GNUNET_break (0);
return;
}
if (0 != strcmp (record->key,
- GNUNET_HELLO_PEERSTORE_KEY))
+ GNUNET_PEERSTORE_TRANSPORT_URLADDRESS_KEY))
{
GNUNET_break (0);
return;
p->wc = GNUNET_PEERSTORE_watch (h->ps,
"transport",
&p->pid,
- GNUNET_HELLO_PEERSTORE_KEY,
+ GNUNET_PEERSTORE_TRANSPORT_URLADDRESS_KEY,
&watch_cb,
p);
GNUNET_assert (GNUNET_YES ==
struct GNUNET_ATS_SessionHandle *best[GNUNET_MQ_PREFERENCE_COUNT];
(void) pid;
+ if (NULL == peer->sh_head)
+ return GNUNET_YES; /* no available session, cannot allocate bandwidth */
memset (best,
0,
sizeof (best));
}
/* for first round, assign target bandwidth simply to sum of
requested bandwidth */
- for (enum GNUNET_MQ_PreferenceKind pk = 0;
+ for (enum GNUNET_MQ_PreferenceKind pk = 1 /* skip GNUNET_MQ_PREFERENCE_NONE */;
pk < GNUNET_MQ_PREFERENCE_COUNT;
pk++)
{
- enum GNUNET_NetworkType nt = best[pk]->data->prop.nt;
+ const struct GNUNET_ATS_SessionData *data = best[pk]->data;
+ enum GNUNET_NetworkType nt;
+ GNUNET_assert (NULL != data);
+ nt = data->prop.nt;
best[pk]->target_out = GNUNET_MIN (peer->bw_by_pk[pk],
MIN_BANDWIDTH_PER_SESSION);
c->bw_out_by_nt[nt] += (uint64_t) (best[pk]->target_out - MIN_BANDWIDTH_PER_SESSION);
struct GNUNET_ATS_SessionHandle *sh;
/* setup session handle */
+ GNUNET_assert (NULL != data);
if (NULL == address)
alen = 0;
else
sh->hello = hello;
}
update (h);
- return NULL;
+ return sh;
}
{
struct SimpleHandle *h = cls;
+ GNUNET_assert (NULL != data);
sh->data = data; /* this statement should not really do anything... */
update (h);
}