aboutsummaryrefslogtreecommitdiff
path: root/src/ats/ats_api_scheduling.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-02-03 14:11:03 +0000
committerChristian Grothoff <christian@grothoff.org>2015-02-03 14:11:03 +0000
commitb2e99dd91c01b5fcc16b3b1031df897aeec05eef (patch)
tree31caea8a19fd943f8a9f7f7f3c19e52e11d95a77 /src/ats/ats_api_scheduling.c
parent55cecdea8638fa23c68e7ade7a8d5629da658f9e (diff)
downloadgnunet-b2e99dd91c01b5fcc16b3b1031df897aeec05eef.tar.gz
gnunet-b2e99dd91c01b5fcc16b3b1031df897aeec05eef.zip
separate ATS connectivity suggestions from ATS scheduling API
Diffstat (limited to 'src/ats/ats_api_scheduling.c')
-rw-r--r--src/ats/ats_api_scheduling.c148
1 files changed, 0 insertions, 148 deletions
diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c
index 21fb583de..2daa45a73 100644
--- a/src/ats/ats_api_scheduling.c
+++ b/src/ats/ats_api_scheduling.c
@@ -146,18 +146,6 @@ struct ATS_Network
146 146
147 147
148/** 148/**
149 * Handle for ATS address suggestion requests.
150 */
151struct GNUNET_ATS_SuggestHandle
152{
153 /**
154 * ID of the peer for which address suggestion was requested.
155 */
156 struct GNUNET_PeerIdentity id;
157};
158
159
160/**
161 * Handle to the ATS subsystem for bandwidth/transport scheduling information. 149 * Handle to the ATS subsystem for bandwidth/transport scheduling information.
162 */ 150 */
163struct GNUNET_ATS_SchedulingHandle 151struct GNUNET_ATS_SchedulingHandle
@@ -179,13 +167,6 @@ struct GNUNET_ATS_SchedulingHandle
179 void *suggest_cb_cls; 167 void *suggest_cb_cls;
180 168
181 /** 169 /**
182 * Map with the identities of all the peers for which we would
183 * like to have address suggestions. The key is the PID, the
184 * value is currently the `struct GNUNET_ATS_SuggestHandle`
185 */
186 struct GNUNET_CONTAINER_MultiPeerMap *sug_requests;
187
188 /**
189 * Connection to ATS service. 170 * Connection to ATS service.
190 */ 171 */
191 struct GNUNET_CLIENT_Connection *client; 172 struct GNUNET_CLIENT_Connection *client;
@@ -588,34 +569,6 @@ send_add_address_message (struct GNUNET_ATS_SchedulingHandle *sh,
588 569
589 570
590/** 571/**
591 * Transmit request for an address suggestion.
592 *
593 * @param cls the `struct GNUNET_ATS_SchedulingHandle`
594 * @param peer peer to ask for an address suggestion for
595 * @param value the `struct GNUNET_ATS_SuggestHandle`
596 * @return #GNUNET_OK (continue to iterate), #GNUNET_SYSERR on
597 * failure (message queue no longer exists)
598 */
599static int
600transmit_suggestion (void *cls,
601 const struct GNUNET_PeerIdentity *peer,
602 void *value)
603{
604 struct GNUNET_ATS_SchedulingHandle *sh = cls;
605 struct GNUNET_MQ_Envelope *ev;
606 struct RequestAddressMessage *m;
607
608 if (NULL == sh->mq)
609 return GNUNET_SYSERR;
610 ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS);
611 m->reserved = htonl (0);
612 m->peer = *peer;
613 GNUNET_MQ_send (sh->mq, ev);
614 return GNUNET_OK;
615}
616
617
618/**
619 * Generate and transmit the `struct AddressUseMessage` for the given 572 * Generate and transmit the `struct AddressUseMessage` for the given
620 * address record. 573 * address record.
621 * 574 *
@@ -687,9 +640,6 @@ reconnect (struct GNUNET_ATS_SchedulingHandle *sh)
687 if (NULL == sh->mq) 640 if (NULL == sh->mq)
688 return; 641 return;
689 } 642 }
690 GNUNET_CONTAINER_multipeermap_iterate (sh->sug_requests,
691 &transmit_suggestion,
692 sh);
693} 643}
694 644
695 645
@@ -1034,8 +984,6 @@ GNUNET_ATS_scheduling_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
1034 GNUNET_array_grow (sh->session_array, 984 GNUNET_array_grow (sh->session_array,
1035 sh->session_array_size, 985 sh->session_array_size,
1036 4); 986 4);
1037 sh->sug_requests = GNUNET_CONTAINER_multipeermap_create (32,
1038 GNUNET_YES);
1039 GNUNET_OS_network_interfaces_list (&interface_proc, 987 GNUNET_OS_network_interfaces_list (&interface_proc,
1040 sh); 988 sh);
1041 sh->interface_task = GNUNET_SCHEDULER_add_delayed (INTERFACE_PROCESSING_INTERVAL, 989 sh->interface_task = GNUNET_SCHEDULER_add_delayed (INTERFACE_PROCESSING_INTERVAL,
@@ -1047,27 +995,6 @@ GNUNET_ATS_scheduling_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
1047 995
1048 996
1049/** 997/**
1050 * Function called to free all `struct GNUNET_ATS_SuggestHandles`
1051 * in the map.
1052 *
1053 * @param cls NULL
1054 * @param key the key
1055 * @param value the value to free
1056 * @return #GNUNET_OK (continue to iterate)
1057 */
1058static int
1059free_sug_handle (void *cls,
1060 const struct GNUNET_PeerIdentity *key,
1061 void *value)
1062{
1063 struct GNUNET_ATS_SuggestHandle *cur = value;
1064
1065 GNUNET_free (cur);
1066 return GNUNET_OK;
1067}
1068
1069
1070/**
1071 * Client is done with ATS scheduling, release resources. 998 * Client is done with ATS scheduling, release resources.
1072 * 999 *
1073 * @param sh handle to release 1000 * @param sh handle to release
@@ -1090,10 +1017,6 @@ GNUNET_ATS_scheduling_done (struct GNUNET_ATS_SchedulingHandle *sh)
1090 GNUNET_SCHEDULER_cancel (sh->task); 1017 GNUNET_SCHEDULER_cancel (sh->task);
1091 sh->task = NULL; 1018 sh->task = NULL;
1092 } 1019 }
1093 GNUNET_CONTAINER_multipeermap_iterate (sh->sug_requests,
1094 &free_sug_handle,
1095 NULL);
1096 GNUNET_CONTAINER_multipeermap_destroy (sh->sug_requests);
1097 if (NULL != sh->interface_task) 1020 if (NULL != sh->interface_task)
1098 { 1021 {
1099 GNUNET_SCHEDULER_cancel (sh->interface_task); 1022 GNUNET_SCHEDULER_cancel (sh->interface_task);
@@ -1129,77 +1052,6 @@ GNUNET_ATS_reset_backoff (struct GNUNET_ATS_SchedulingHandle *sh,
1129 1052
1130 1053
1131/** 1054/**
1132 * We would like to receive address suggestions for a peer. ATS will
1133 * respond with a call to the continuation immediately containing an address or
1134 * no address if none is available. ATS can suggest more addresses until we call
1135 * #GNUNET_ATS_suggest_address_cancel().
1136 *
1137 * @param sh handle
1138 * @param peer identity of the peer we need an address for
1139 * @return suggest handle, NULL if a request is already pending
1140 */
1141struct GNUNET_ATS_SuggestHandle *
1142GNUNET_ATS_suggest_address (struct GNUNET_ATS_SchedulingHandle *sh,
1143 const struct GNUNET_PeerIdentity *peer)
1144{
1145 struct GNUNET_ATS_SuggestHandle *s;
1146
1147 s = GNUNET_new (struct GNUNET_ATS_SuggestHandle);
1148 s->id = *peer;
1149 if (GNUNET_OK !=
1150 GNUNET_CONTAINER_multipeermap_put (sh->sug_requests,
1151 &s->id,
1152 s,
1153 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
1154 {
1155 GNUNET_break (0);
1156 return NULL;
1157 }
1158 if (NULL == sh->mq)
1159 return s;
1160 (void) transmit_suggestion (sh,
1161 &s->id,
1162 s);
1163 return s;
1164}
1165
1166
1167/**
1168 * We would like to stop receiving address updates for this peer
1169 *
1170 * @param sh handle
1171 * @param peer identity of the peer
1172 */
1173void
1174GNUNET_ATS_suggest_address_cancel (struct GNUNET_ATS_SchedulingHandle *sh,
1175 const struct GNUNET_PeerIdentity *peer)
1176{
1177 struct GNUNET_MQ_Envelope *ev;
1178 struct RequestAddressMessage *m;
1179 struct GNUNET_ATS_SuggestHandle *s;
1180
1181 s = GNUNET_CONTAINER_multipeermap_get (sh->sug_requests,
1182 peer);
1183 if (NULL == s)
1184 {
1185 GNUNET_break (0);
1186 return;
1187 }
1188 GNUNET_assert (GNUNET_OK ==
1189 GNUNET_CONTAINER_multipeermap_remove (sh->sug_requests,
1190 &s->id,
1191 s));
1192 GNUNET_free (s);
1193 if (NULL == sh->mq)
1194 return;
1195 ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL);
1196 m->reserved = htonl (0);
1197 m->peer = *peer;
1198 GNUNET_MQ_send (sh->mq, ev);
1199}
1200
1201
1202/**
1203 * Test if a address and a session is known to ATS 1055 * Test if a address and a session is known to ATS
1204 * 1056 *
1205 * @param sh the scheduling handle 1057 * @param sh the scheduling handle