- set_state_and_timeout (n, GNUNET_TRANSPORT_PS_SYN_RECV_ATS,
- GNUNET_TIME_relative_to_absolute (ATS_RESPONSE_TIMEOUT));
- return;
- }
-
-}
-
-struct QuotaNotificationRequest
-{
- struct GNUNET_PeerIdentity peer;
- struct Session *session;
- char *plugin;
-};
-
-struct QNR_LookContext
-{
- struct GNUNET_PeerIdentity peer;
- struct Session *session;
- const char *plugin;
-
- struct QuotaNotificationRequest *res;
-};
-
-static int
-find_notification_request (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
-{
- struct QNR_LookContext *qnr_ctx = cls;
- struct QuotaNotificationRequest *qnr = value;
-
- if ((qnr->session == qnr_ctx->session) &&
- (0 == memcmp (&qnr->peer,
- &qnr_ctx->peer,
- sizeof (struct GNUNET_PeerIdentity))) &&
- (0 == strcmp(qnr_ctx->plugin, qnr->plugin)))
- {
- qnr_ctx->res = value;
- return GNUNET_NO;
- }
- return GNUNET_YES;
-}
-
-
-void
-GST_neighbours_register_quota_notification (void *cls,
- const struct GNUNET_PeerIdentity *peer,
- const char *plugin,
- struct Session *session)
-{
- struct QuotaNotificationRequest *qnr;
- struct QNR_LookContext qnr_ctx;
-
- if (NULL == registered_quota_notifications)
- {
- return; /* init or shutdown */
- }
-
- qnr_ctx.peer = (*peer);
- qnr_ctx.plugin = plugin;
- qnr_ctx.session = session;
- qnr_ctx.res = NULL;
-
- GNUNET_CONTAINER_multipeermap_get_multiple (registered_quota_notifications,
- peer, &find_notification_request, &qnr_ctx);
- if (NULL != qnr_ctx.res)
- {
- GNUNET_break(0);
- return;
- }
-
- qnr = GNUNET_new (struct QuotaNotificationRequest);
- qnr->peer = (*peer);
- qnr->plugin = GNUNET_strdup (plugin);
- qnr->session = session;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Adding notification for peer `%s' plugin `%s' session %p \n",
- GNUNET_i2s (peer), plugin, session);
-
- GNUNET_CONTAINER_multipeermap_put (registered_quota_notifications, peer,
- qnr, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
-}
-
-
-void
-GST_neighbours_unregister_quota_notification(void *cls,
- const struct GNUNET_PeerIdentity *peer,
- const char *plugin,
- struct Session *session)
-{
- struct QNR_LookContext qnr_ctx;
-
- if (NULL == registered_quota_notifications)
- {
- return; /* init or shutdown */
- }
-
- qnr_ctx.peer = (*peer);
- qnr_ctx.plugin = plugin;
- qnr_ctx.session = session;
- qnr_ctx.res = NULL;
-
- GNUNET_CONTAINER_multipeermap_iterate (registered_quota_notifications,
- &find_notification_request, &qnr_ctx);
- if (NULL == qnr_ctx.res)
- {
- GNUNET_break(0);