From: Christian Grothoff Date: Mon, 10 Oct 2011 11:29:59 +0000 (+0000) Subject: another core API simplification due to ATS introduction X-Git-Tag: initial-import-from-subversion-38251~16679 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=4e49d814f8c52d784e8aa7bd57a40eda7656d3c0;p=oweals%2Fgnunet.git another core API simplification due to ATS introduction --- diff --git a/src/core/core_api.c b/src/core/core_api.c index 16668e9fc..78f606322 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c @@ -177,11 +177,6 @@ struct GNUNET_CORE_Handle */ GNUNET_CORE_DisconnectEventHandler disconnects; - /** - * Function to call whenever we're notified about a peer changing status. - */ - GNUNET_CORE_PeerStatusEventHandler status_events; - /** * Function to call whenever we receive an inbound message. */ @@ -785,7 +780,6 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) const struct DisconnectNotifyMessage *dnm; const struct NotifyTrafficMessage *ntm; const struct GNUNET_MessageHeader *em; - const struct PeerStatusNotifyMessage *psnm; const struct SendMessageReady *smr; const struct GNUNET_CORE_MessageHandler *mh; GNUNET_CORE_StartupCallback init; @@ -941,52 +935,6 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) if (trigger) trigger_next_request (h, GNUNET_NO); break; - case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_STATUS_CHANGE: - if (NULL == h->status_events) - { - GNUNET_break (0); - return; - } - if (msize < sizeof (struct PeerStatusNotifyMessage)) - { - GNUNET_break (0); - reconnect_later (h); - return; - } - psnm = (const struct PeerStatusNotifyMessage *) msg; - if (0 == memcmp (&h->me, &psnm->peer, sizeof (struct GNUNET_PeerIdentity))) - { - /* self-change!? */ - GNUNET_break (0); - return; - } - ats_count = ntohl (psnm->ats_count); - if ((msize != - sizeof (struct PeerStatusNotifyMessage) + - ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information)) || - (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR != - ntohl ((&psnm->ats)[ats_count].type))) - { - GNUNET_break (0); - reconnect_later (h); - return; - } -#if DEBUG_CORE > 1 - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received notification about status change by `%s'.\n", - GNUNET_i2s (&psnm->peer)); -#endif - pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &psnm->peer.hashPubKey); - if (pr == NULL) - { - GNUNET_break (0); - reconnect_later (h); - return; - } - h->status_events (h->cls, &psnm->peer, psnm->bandwidth_in, - psnm->bandwidth_out, - GNUNET_TIME_absolute_ntoh (psnm->timeout), &psnm->ats); - break; case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND: if (msize < sizeof (struct NotifyTrafficMessage)) { @@ -1223,8 +1171,6 @@ reconnect (struct GNUNET_CORE_Handle *h) init->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_INIT); init->header.size = htons (msize); opt = GNUNET_CORE_OPTION_SEND_CONNECT | GNUNET_CORE_OPTION_SEND_DISCONNECT; - if (h->status_events != NULL) - opt |= GNUNET_CORE_OPTION_SEND_STATUS_CHANGE; if (h->inbound_notify != NULL) { if (h->inbound_hdr_only) @@ -1261,7 +1207,6 @@ reconnect (struct GNUNET_CORE_Handle *h) * connected to the core service; note that timeout is only meaningful if init is not NULL * @param connects function to call on peer connect, can be NULL * @param disconnects function to call on peer disconnect / timeout, can be NULL - * @param status_events function to call on changes to peer connection status, can be NULL * @param inbound_notify function to call for all inbound messages, can be NULL * @param inbound_hdr_only set to GNUNET_YES if inbound_notify will only read the * GNUNET_MessageHeader and hence we do not need to give it the full message; @@ -1280,7 +1225,6 @@ GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CORE_StartupCallback init, GNUNET_CORE_ConnectEventHandler connects, GNUNET_CORE_DisconnectEventHandler disconnects, - GNUNET_CORE_PeerStatusEventHandler status_events, GNUNET_CORE_MessageCallback inbound_notify, int inbound_hdr_only, GNUNET_CORE_MessageCallback outbound_notify, @@ -1296,7 +1240,6 @@ GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, h->init = init; h->connects = connects; h->disconnects = disconnects; - h->status_events = status_events; h->inbound_notify = inbound_notify; h->outbound_notify = outbound_notify; h->inbound_hdr_only = inbound_hdr_only; diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c index 7695f9e86..db3bb4ce5 100644 --- a/src/core/test_core_api.c +++ b/src/core/test_core_api.c @@ -299,7 +299,7 @@ init_notify (void *cls, struct GNUNET_CORE_Handle *server, /* connect p2 */ p2.ch = GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify, - &disconnect_notify, NULL, &inbound_notify, + &disconnect_notify, &inbound_notify, GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); } @@ -347,7 +347,7 @@ run (void *cls, char *const *args, const char *cfgfile, &terminate_task_error, NULL); p1.ch = GNUNET_CORE_connect (p1.cfg, 1, &p1, &init_notify, &connect_notify, - &disconnect_notify, NULL, &inbound_notify, + &disconnect_notify, &inbound_notify, GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); } diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c index a696c7cbd..895b72449 100644 --- a/src/core/test_core_api_reliability.c +++ b/src/core/test_core_api_reliability.c @@ -381,7 +381,7 @@ init_notify (void *cls, struct GNUNET_CORE_Handle *server, OKPP; /* connect p2 */ GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify, - &disconnect_notify, NULL, &inbound_notify, GNUNET_YES, + &disconnect_notify, &inbound_notify, GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); } else @@ -451,7 +451,7 @@ run (void *cls, char *const *args, const char *cfgfile, err_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL); GNUNET_CORE_connect (p1.cfg, 1, &p1, &init_notify, &connect_notify, - &disconnect_notify, NULL, &inbound_notify, GNUNET_YES, + &disconnect_notify, &inbound_notify, GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); } diff --git a/src/core/test_core_api_send_to_self.c b/src/core/test_core_api_send_to_self.c index 25651beb5..b7e2b449b 100644 --- a/src/core/test_core_api_send_to_self.c +++ b/src/core/test_core_api_send_to_self.c @@ -182,7 +182,7 @@ run (void *cls, char *const *args, const char *cfgfile, "test_core_api_peer1.conf")); core = - GNUNET_CORE_connect (core_cfg, 42, NULL, &init, &connect_cb, NULL, NULL, + GNUNET_CORE_connect (core_cfg, 42, NULL, &init, &connect_cb, NULL, NULL, 0, NULL, 0, handlers); die_task = diff --git a/src/core/test_core_api_start_only.c b/src/core/test_core_api_start_only.c index 6b1f3da1c..744758191 100644 --- a/src/core/test_core_api_start_only.c +++ b/src/core/test_core_api_start_only.c @@ -127,7 +127,7 @@ init_notify (void *cls, struct GNUNET_CORE_Handle *server, /* connect p2 */ p2.ch = GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify, - &disconnect_notify, NULL, &inbound_notify, + &disconnect_notify, &inbound_notify, GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); } @@ -190,7 +190,7 @@ run (void *cls, char *const *args, const char *cfgfile, &timeout_task, NULL); p1.ch = GNUNET_CORE_connect (p1.cfg, 1, &p1, &init_notify, &connect_notify, - &disconnect_notify, NULL, &inbound_notify, + &disconnect_notify, &inbound_notify, GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); } diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c index 5fce06b31..e3b760624 100644 --- a/src/core/test_core_quota_compliance.c +++ b/src/core/test_core_quota_compliance.c @@ -520,7 +520,7 @@ init_notify (void *cls, struct GNUNET_CORE_Handle *server, OKPP; /* connect p2 */ p2.ch = GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify, - &disconnect_notify, NULL, &inbound_notify, GNUNET_YES, + &disconnect_notify, &inbound_notify, GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); } else @@ -630,7 +630,7 @@ run (void *cls, char *const *args, const char *cfgfile, ¤t_quota_p2_out)); p1.ch = GNUNET_CORE_connect (p1.cfg, 1, &p1, &init_notify, &connect_notify, - &disconnect_notify, NULL, &inbound_notify, GNUNET_YES, + &disconnect_notify, &inbound_notify, GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); } diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c index e1421e0f6..f4717711f 100644 --- a/src/dht/gnunet-service-dht_neighbours.c +++ b/src/dht/gnunet-service-dht_neighbours.c @@ -2053,7 +2053,6 @@ GDS_NEIGHBOURS_init () &core_init, &handle_core_connect, &handle_core_disconnect, - NULL, /* Do we care about "status" updates? */ NULL, GNUNET_NO, NULL, GNUNET_NO, core_handlers); diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index f2770df3e..d4728760d 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c @@ -508,7 +508,7 @@ main_init (struct GNUNET_SERVER_Handle *server, NULL, &peer_init_handler, &peer_connect_handler, &GSF_peer_disconnect_handler_, - &GSF_peer_status_handler_, NULL, GNUNET_NO, + NULL, GNUNET_NO, NULL, GNUNET_NO, p2p_handlers); if (NULL == GSF_core) { diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c index 05e5bedef..0fed7b855 100644 --- a/src/fs/gnunet-service-fs_cp.c +++ b/src/fs/gnunet-service-fs_cp.c @@ -1502,32 +1502,6 @@ GSF_peer_update_responder_peer_ (struct GSF_ConnectedPeer *cp, } -/** - * Method called whenever a given peer has a status change. - * - * @param cls closure - * @param peer peer identity this notification is about - * @param bandwidth_in available amount of inbound bandwidth - * @param bandwidth_out available amount of outbound bandwidth - * @param timeout absolute time when this peer will time out - * unless we see some further activity from it - * @param atsi status information - */ -void -GSF_peer_status_handler_ (void *cls, const struct GNUNET_PeerIdentity *peer, - struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, - struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, - struct GNUNET_TIME_Absolute timeout, - const struct GNUNET_TRANSPORT_ATS_Information *atsi) -{ - struct GSF_ConnectedPeer *cp; - - cp = GNUNET_CONTAINER_multihashmap_get (cp_map, &peer->hashPubKey); - GNUNET_assert (NULL != cp); - update_atsi (cp, atsi); -} - - /** * A peer disconnected from us. Tear down the connected peer * record. diff --git a/src/fs/gnunet-service-fs_cp.h b/src/fs/gnunet-service-fs_cp.h index 0f22b0280..4a238dce8 100644 --- a/src/fs/gnunet-service-fs_cp.h +++ b/src/fs/gnunet-service-fs_cp.h @@ -252,25 +252,6 @@ GSF_peer_update_responder_peer_ (struct GSF_ConnectedPeer *cp, *initiator_peer); -/** - * Method called whenever a given peer has a status change. - * - * @param cls closure - * @param peer peer identity this notification is about - * @param bandwidth_in available amount of inbound bandwidth - * @param bandwidth_out available amount of outbound bandwidth - * @param timeout absolute time when this peer will time out - * unless we see some further activity from it - * @param atsi status information - */ -void -GSF_peer_status_handler_ (void *cls, const struct GNUNET_PeerIdentity *peer, - struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, - struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, - struct GNUNET_TIME_Absolute timeout, - const struct GNUNET_TRANSPORT_ATS_Information *atsi); - - /** * Handle P2P "MIGRATION_STOP" message. * diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c index 859f8498c..30f736002 100644 --- a/src/hostlist/gnunet-daemon-hostlist.c +++ b/src/hostlist/gnunet-daemon-hostlist.c @@ -259,7 +259,7 @@ run (void *cls, char *const *args, const char *cfgfile, core = GNUNET_CORE_connect (cfg, 1, NULL, &core_init, &connect_handler, - &disconnect_handler, NULL, NULL, GNUNET_NO, NULL, + &disconnect_handler, NULL, GNUNET_NO, NULL, GNUNET_NO, learning ? learn_handlers : no_learn_handlers); diff --git a/src/include/gnunet_ats_service.h b/src/include/gnunet_ats_service.h index eb785afdd..33539bdaf 100644 --- a/src/include/gnunet_ats_service.h +++ b/src/include/gnunet_ats_service.h @@ -282,7 +282,8 @@ struct GNUNET_ATS_InformationRequestContext; * @param preference increase incoming traffic share preference by this amount; * in the absence of "amount" reservations, we use this * preference value to assign proportional bandwidth shares - * to all connected peers + * to all connected peers; in the future, this should be + * replaced with more specific QoS expressions... * @param info function to call with the resulting configuration information * @param info_cls closure for info * @return NULL on error diff --git a/src/include/gnunet_core_service.h b/src/include/gnunet_core_service.h index 366986b4b..24083f1a1 100644 --- a/src/include/gnunet_core_service.h +++ b/src/include/gnunet_core_service.h @@ -66,33 +66,6 @@ typedef void (*GNUNET_CORE_ConnectEventHandler) (void *cls, * atsi); -/** - * Method called whenever a given peer has a status change. - * - * @param cls closure - * @param peer peer identity this notification is about - * @param timeout absolute time when this peer will time out - * unless we see some further activity from it - * @param bandwidth_in available amount of inbound bandwidth - * @param bandwidth_out available amount of outbound bandwidth - * @param atsi performance data for the connection - */ -typedef void (*GNUNET_CORE_PeerStatusEventHandler) (void *cls, - const struct - GNUNET_PeerIdentity * peer, - struct - GNUNET_BANDWIDTH_Value32NBO - bandwidth_in, - struct - GNUNET_BANDWIDTH_Value32NBO - bandwidth_out, - struct GNUNET_TIME_Absolute - timeout, - const struct - GNUNET_TRANSPORT_ATS_Information - * atsi); - - /** * Method called whenever a peer disconnects. * @@ -186,7 +159,6 @@ typedef void (*GNUNET_CORE_StartupCallback) (void *cls, * connected to the core service; note that timeout is only meaningful if init is not NULL * @param connects function to call on peer connect, can be NULL * @param disconnects function to call on peer disconnect / timeout, can be NULL - * @param status_events function to call on peer status changes, can be NULL * @param inbound_notify function to call for all inbound messages, can be NULL * note that the core is allowed to drop notifications about inbound * messages if the client does not process them fast enough (for this @@ -220,7 +192,6 @@ GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CORE_StartupCallback init, GNUNET_CORE_ConnectEventHandler connects, GNUNET_CORE_DisconnectEventHandler disconnects, - GNUNET_CORE_PeerStatusEventHandler status_events, GNUNET_CORE_MessageCallback inbound_notify, int inbound_hdr_only, GNUNET_CORE_MessageCallback outbound_notify, diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 1b95d847b..31f6e0b4c 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h @@ -401,12 +401,6 @@ extern "C" */ #define GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND 71 -/** - * Response from server about (possibly updated) P2P - * connection configuration. - */ -#define GNUNET_MESSAGE_TYPE_CORE_CONFIGURATION_INFO 73 - /** * Request from client to transmit message. */ diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index 8d6780493..e76d440cf 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c @@ -3370,7 +3370,6 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, &core_init, /* Call core_init once connected */ &core_connect, /* Handle connects */ &core_disconnect, /* remove peers on disconnects */ - NULL, /* Do we care about "status" updates? */ NULL, /* Don't notify about all incoming messages */ GNUNET_NO, /* For header only in notification */ NULL, /* Don't notify about all outbound messages */ diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c index 4e510e596..9c2af545b 100644 --- a/src/mesh/mesh_api.c +++ b/src/mesh/mesh_api.c @@ -872,7 +872,7 @@ GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, ret->core = GNUNET_CORE_connect (cfg, 42, ret, &core_startup, &core_connect, - &core_disconnect, NULL, NULL, GNUNET_NO, NULL, + &core_disconnect, NULL, GNUNET_NO, NULL, GNUNET_NO, core_handlers); ret->transport = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL, NULL, NULL); diff --git a/src/nse/gnunet-service-nse.c b/src/nse/gnunet-service-nse.c index 47014fd60..7000ec602 100644 --- a/src/nse/gnunet-service-nse.c +++ b/src/nse/gnunet-service-nse.c @@ -1360,7 +1360,6 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, &core_init, /* Call core_init once connected */ &handle_core_connect, /* Handle connects */ &handle_core_disconnect, /* Handle disconnects */ - NULL, /* Do we care about "status" updates? */ NULL, /* Don't want notified about all incoming messages */ GNUNET_NO, /* For header only inbound notification */ NULL, /* Don't want notified about all outbound messages */ diff --git a/src/testing/testing.c b/src/testing/testing.c index ca7ed6376..df2a67668 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c @@ -1994,7 +1994,7 @@ reattempt_daemons_connect (void *cls, ctx->d1core_ready = GNUNET_NO; ctx->d1core = GNUNET_CORE_connect (ctx->d1->cfg, 1, ctx, &core_init_notify, - &connect_notify, NULL, NULL, NULL, GNUNET_NO, NULL, + &connect_notify, NULL, NULL, GNUNET_NO, NULL, GNUNET_NO, no_handlers); if (ctx->d1core == NULL) { @@ -2115,7 +2115,7 @@ core_initial_iteration (void *cls, const struct GNUNET_PeerIdentity *peer, #endif ctx->d1core = GNUNET_CORE_connect (ctx->d1->cfg, 1, ctx, &core_init_notify, - &connect_notify, NULL, NULL, NULL, GNUNET_NO, NULL, + &connect_notify, NULL, NULL, GNUNET_NO, NULL, GNUNET_NO, no_handlers); } diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index e8704552b..1616ab613 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c @@ -1278,7 +1278,7 @@ run (void *cls, char *const *args, const char *cfgfile, transport = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL, NULL, NULL); handle = GNUNET_CORE_connect (cfg, 1, NULL, &core_init, &connect_notify, - &disconnect_notify, NULL, NULL, GNUNET_NO, NULL, + &disconnect_notify, NULL, GNUNET_NO, NULL, GNUNET_NO, handlers); GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleaning_task, NULL);