aboutsummaryrefslogtreecommitdiff
path: root/src/core/core_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-10-10 11:29:59 +0000
committerChristian Grothoff <christian@grothoff.org>2011-10-10 11:29:59 +0000
commit4e49d814f8c52d784e8aa7bd57a40eda7656d3c0 (patch)
tree86f9971794e0d72f8de9ac2886fd11e85ccde7c1 /src/core/core_api.c
parent0a15f777a19feea3937264b6acf96685b76bbc45 (diff)
downloadgnunet-4e49d814f8c52d784e8aa7bd57a40eda7656d3c0.tar.gz
gnunet-4e49d814f8c52d784e8aa7bd57a40eda7656d3c0.zip
another core API simplification due to ATS introduction
Diffstat (limited to 'src/core/core_api.c')
-rw-r--r--src/core/core_api.c57
1 files changed, 0 insertions, 57 deletions
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
@@ -178,11 +178,6 @@ struct GNUNET_CORE_Handle
178 GNUNET_CORE_DisconnectEventHandler disconnects; 178 GNUNET_CORE_DisconnectEventHandler disconnects;
179 179
180 /** 180 /**
181 * Function to call whenever we're notified about a peer changing status.
182 */
183 GNUNET_CORE_PeerStatusEventHandler status_events;
184
185 /**
186 * Function to call whenever we receive an inbound message. 181 * Function to call whenever we receive an inbound message.
187 */ 182 */
188 GNUNET_CORE_MessageCallback inbound_notify; 183 GNUNET_CORE_MessageCallback inbound_notify;
@@ -785,7 +780,6 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
785 const struct DisconnectNotifyMessage *dnm; 780 const struct DisconnectNotifyMessage *dnm;
786 const struct NotifyTrafficMessage *ntm; 781 const struct NotifyTrafficMessage *ntm;
787 const struct GNUNET_MessageHeader *em; 782 const struct GNUNET_MessageHeader *em;
788 const struct PeerStatusNotifyMessage *psnm;
789 const struct SendMessageReady *smr; 783 const struct SendMessageReady *smr;
790 const struct GNUNET_CORE_MessageHandler *mh; 784 const struct GNUNET_CORE_MessageHandler *mh;
791 GNUNET_CORE_StartupCallback init; 785 GNUNET_CORE_StartupCallback init;
@@ -941,52 +935,6 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
941 if (trigger) 935 if (trigger)
942 trigger_next_request (h, GNUNET_NO); 936 trigger_next_request (h, GNUNET_NO);
943 break; 937 break;
944 case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_STATUS_CHANGE:
945 if (NULL == h->status_events)
946 {
947 GNUNET_break (0);
948 return;
949 }
950 if (msize < sizeof (struct PeerStatusNotifyMessage))
951 {
952 GNUNET_break (0);
953 reconnect_later (h);
954 return;
955 }
956 psnm = (const struct PeerStatusNotifyMessage *) msg;
957 if (0 == memcmp (&h->me, &psnm->peer, sizeof (struct GNUNET_PeerIdentity)))
958 {
959 /* self-change!? */
960 GNUNET_break (0);
961 return;
962 }
963 ats_count = ntohl (psnm->ats_count);
964 if ((msize !=
965 sizeof (struct PeerStatusNotifyMessage) +
966 ats_count * sizeof (struct GNUNET_TRANSPORT_ATS_Information)) ||
967 (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR !=
968 ntohl ((&psnm->ats)[ats_count].type)))
969 {
970 GNUNET_break (0);
971 reconnect_later (h);
972 return;
973 }
974#if DEBUG_CORE > 1
975 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
976 "Received notification about status change by `%s'.\n",
977 GNUNET_i2s (&psnm->peer));
978#endif
979 pr = GNUNET_CONTAINER_multihashmap_get (h->peers, &psnm->peer.hashPubKey);
980 if (pr == NULL)
981 {
982 GNUNET_break (0);
983 reconnect_later (h);
984 return;
985 }
986 h->status_events (h->cls, &psnm->peer, psnm->bandwidth_in,
987 psnm->bandwidth_out,
988 GNUNET_TIME_absolute_ntoh (psnm->timeout), &psnm->ats);
989 break;
990 case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND: 938 case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND:
991 if (msize < sizeof (struct NotifyTrafficMessage)) 939 if (msize < sizeof (struct NotifyTrafficMessage))
992 { 940 {
@@ -1223,8 +1171,6 @@ reconnect (struct GNUNET_CORE_Handle *h)
1223 init->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_INIT); 1171 init->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_INIT);
1224 init->header.size = htons (msize); 1172 init->header.size = htons (msize);
1225 opt = GNUNET_CORE_OPTION_SEND_CONNECT | GNUNET_CORE_OPTION_SEND_DISCONNECT; 1173 opt = GNUNET_CORE_OPTION_SEND_CONNECT | GNUNET_CORE_OPTION_SEND_DISCONNECT;
1226 if (h->status_events != NULL)
1227 opt |= GNUNET_CORE_OPTION_SEND_STATUS_CHANGE;
1228 if (h->inbound_notify != NULL) 1174 if (h->inbound_notify != NULL)
1229 { 1175 {
1230 if (h->inbound_hdr_only) 1176 if (h->inbound_hdr_only)
@@ -1261,7 +1207,6 @@ reconnect (struct GNUNET_CORE_Handle *h)
1261 * connected to the core service; note that timeout is only meaningful if init is not NULL 1207 * connected to the core service; note that timeout is only meaningful if init is not NULL
1262 * @param connects function to call on peer connect, can be NULL 1208 * @param connects function to call on peer connect, can be NULL
1263 * @param disconnects function to call on peer disconnect / timeout, can be NULL 1209 * @param disconnects function to call on peer disconnect / timeout, can be NULL
1264 * @param status_events function to call on changes to peer connection status, can be NULL
1265 * @param inbound_notify function to call for all inbound messages, can be NULL 1210 * @param inbound_notify function to call for all inbound messages, can be NULL
1266 * @param inbound_hdr_only set to GNUNET_YES if inbound_notify will only read the 1211 * @param inbound_hdr_only set to GNUNET_YES if inbound_notify will only read the
1267 * GNUNET_MessageHeader and hence we do not need to give it the full message; 1212 * 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,
1280 GNUNET_CORE_StartupCallback init, 1225 GNUNET_CORE_StartupCallback init,
1281 GNUNET_CORE_ConnectEventHandler connects, 1226 GNUNET_CORE_ConnectEventHandler connects,
1282 GNUNET_CORE_DisconnectEventHandler disconnects, 1227 GNUNET_CORE_DisconnectEventHandler disconnects,
1283 GNUNET_CORE_PeerStatusEventHandler status_events,
1284 GNUNET_CORE_MessageCallback inbound_notify, 1228 GNUNET_CORE_MessageCallback inbound_notify,
1285 int inbound_hdr_only, 1229 int inbound_hdr_only,
1286 GNUNET_CORE_MessageCallback outbound_notify, 1230 GNUNET_CORE_MessageCallback outbound_notify,
@@ -1296,7 +1240,6 @@ GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
1296 h->init = init; 1240 h->init = init;
1297 h->connects = connects; 1241 h->connects = connects;
1298 h->disconnects = disconnects; 1242 h->disconnects = disconnects;
1299 h->status_events = status_events;
1300 h->inbound_notify = inbound_notify; 1243 h->inbound_notify = inbound_notify;
1301 h->outbound_notify = outbound_notify; 1244 h->outbound_notify = outbound_notify;
1302 h->inbound_hdr_only = inbound_hdr_only; 1245 h->inbound_hdr_only = inbound_hdr_only;