diff options
Diffstat (limited to 'src/nat/upnp-discover.c')
-rw-r--r-- | src/nat/upnp-discover.c | 40 |
1 files changed, 9 insertions, 31 deletions
diff --git a/src/nat/upnp-discover.c b/src/nat/upnp-discover.c index ba9594462..d915fb622 100644 --- a/src/nat/upnp-discover.c +++ b/src/nat/upnp-discover.c | |||
@@ -86,11 +86,6 @@ typedef void (*download_cb) (char *data, void *cls); | |||
86 | struct download_cls | 86 | struct download_cls |
87 | { | 87 | { |
88 | /** | 88 | /** |
89 | * Scheduler used for the download task. | ||
90 | */ | ||
91 | struct GNUNET_SCHEDULER_Handle *sched; | ||
92 | |||
93 | /** | ||
94 | * curl_easy handle. | 89 | * curl_easy handle. |
95 | */ | 90 | */ |
96 | CURL *curl; | 91 | CURL *curl; |
@@ -243,8 +238,7 @@ download_prepare (struct download_cls *cls) | |||
243 | GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1); | 238 | GNUNET_NETWORK_fdset_copy_native (grs, &rs, max + 1); |
244 | GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1); | 239 | GNUNET_NETWORK_fdset_copy_native (gws, &ws, max + 1); |
245 | 240 | ||
246 | GNUNET_SCHEDULER_add_select (cls->sched, | 241 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
247 | GNUNET_SCHEDULER_PRIORITY_DEFAULT, | ||
248 | GNUNET_SCHEDULER_NO_TASK, | 242 | GNUNET_SCHEDULER_NO_TASK, |
249 | rtime, | 243 | rtime, |
250 | grs, | 244 | grs, |
@@ -352,14 +346,12 @@ task_download (struct download_cls *cls, | |||
352 | /** | 346 | /** |
353 | * Download description from devices. | 347 | * Download description from devices. |
354 | * | 348 | * |
355 | * @param sched the scheduler to use for the download task | ||
356 | * @param url URL of the file to download | 349 | * @param url URL of the file to download |
357 | * @param caller_cb user function to call when done | 350 | * @param caller_cb user function to call when done |
358 | * @caller_cls closure to pass to caller_cb | 351 | * @caller_cls closure to pass to caller_cb |
359 | */ | 352 | */ |
360 | void | 353 | void |
361 | download_device_description (struct GNUNET_SCHEDULER_Handle *sched, | 354 | download_device_description (char *url, download_cb caller_cb, |
362 | char *url, download_cb caller_cb, | ||
363 | void *caller_cls) | 355 | void *caller_cls) |
364 | { | 356 | { |
365 | CURL *curl; | 357 | CURL *curl; |
@@ -425,7 +417,6 @@ download_device_description (struct GNUNET_SCHEDULER_Handle *sched, | |||
425 | url); | 417 | url); |
426 | #endif | 418 | #endif |
427 | 419 | ||
428 | cls->sched = sched; | ||
429 | cls->curl = curl; | 420 | cls->curl = curl; |
430 | cls->multi = multi; | 421 | cls->multi = multi; |
431 | cls->url = url; | 422 | cls->url = url; |
@@ -588,11 +579,6 @@ struct UPNP_Dev_ | |||
588 | struct UPNP_discover_cls | 579 | struct UPNP_discover_cls |
589 | { | 580 | { |
590 | /** | 581 | /** |
591 | * Scheduler to use for networking tasks. | ||
592 | */ | ||
593 | struct GNUNET_SCHEDULER_Handle *sched; | ||
594 | |||
595 | /** | ||
596 | * Remote address used for multicast emission and reception. | 582 | * Remote address used for multicast emission and reception. |
597 | */ | 583 | */ |
598 | struct sockaddr *multicast_addr; | 584 | struct sockaddr *multicast_addr; |
@@ -818,8 +804,7 @@ get_valid_igd_receive (char *desc, void *data) | |||
818 | 804 | ||
819 | /* Check whether device is connected */ | 805 | /* Check whether device is connected */ |
820 | buffer = GNUNET_malloc (UPNP_COMMAND_BUFSIZE); | 806 | buffer = GNUNET_malloc (UPNP_COMMAND_BUFSIZE); |
821 | UPNP_command_ (cls->sched, | 807 | UPNP_command_ (cls->current_dev->control_url, |
822 | cls->current_dev->control_url, | ||
823 | cls->current_dev->data->service_type, | 808 | cls->current_dev->data->service_type, |
824 | "GetStatusInfo", NULL, buffer, UPNP_COMMAND_BUFSIZE, | 809 | "GetStatusInfo", NULL, buffer, UPNP_COMMAND_BUFSIZE, |
825 | get_valid_igd_connected_cb, cls); | 810 | get_valid_igd_connected_cb, cls); |
@@ -900,7 +885,7 @@ get_valid_igd (struct UPNP_discover_cls *cls) | |||
900 | } | 885 | } |
901 | 886 | ||
902 | /* There are still devices to ask, go on */ | 887 | /* There are still devices to ask, go on */ |
903 | download_device_description (cls->sched, cls->current_dev->desc_url, | 888 | download_device_description (cls->current_dev->desc_url, |
904 | get_valid_igd_receive, cls); | 889 | get_valid_igd_receive, cls); |
905 | } | 890 | } |
906 | 891 | ||
@@ -999,16 +984,14 @@ discover_recv (void *data, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
999 | GNUNET_NETWORK_fdset_zero (cls->fdset); | 984 | GNUNET_NETWORK_fdset_zero (cls->fdset); |
1000 | GNUNET_NETWORK_fdset_set (cls->fdset, cls->sudp); | 985 | GNUNET_NETWORK_fdset_set (cls->fdset, cls->sudp); |
1001 | 986 | ||
1002 | task_w = GNUNET_SCHEDULER_add_select (cls->sched, | 987 | task_w = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
1003 | GNUNET_SCHEDULER_PRIORITY_DEFAULT, | ||
1004 | GNUNET_SCHEDULER_NO_TASK, | 988 | GNUNET_SCHEDULER_NO_TASK, |
1005 | GNUNET_TIME_relative_multiply | 989 | GNUNET_TIME_relative_multiply |
1006 | (GNUNET_TIME_UNIT_SECONDS, 15), | 990 | (GNUNET_TIME_UNIT_SECONDS, 15), |
1007 | NULL, cls->fdset, &discover_send, | 991 | NULL, cls->fdset, &discover_send, |
1008 | cls); | 992 | cls); |
1009 | 993 | ||
1010 | GNUNET_SCHEDULER_add_select (cls->sched, | 994 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
1011 | GNUNET_SCHEDULER_PRIORITY_DEFAULT, | ||
1012 | task_w, | 995 | task_w, |
1013 | GNUNET_TIME_relative_multiply | 996 | GNUNET_TIME_relative_multiply |
1014 | (GNUNET_TIME_UNIT_SECONDS, 5), cls->fdset, | 997 | (GNUNET_TIME_UNIT_SECONDS, 5), cls->fdset, |
@@ -1079,15 +1062,13 @@ discover_send (void *data, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1079 | * If several devices are found, a device that is connected to the WAN | 1062 | * If several devices are found, a device that is connected to the WAN |
1080 | * is returned first (if any). | 1063 | * is returned first (if any). |
1081 | * | 1064 | * |
1082 | * @param sched scheduler to use for network tasks | ||
1083 | * @param multicastif network interface to send discovery messages, or NULL | 1065 | * @param multicastif network interface to send discovery messages, or NULL |
1084 | * @param addr address used to send messages on multicastif, or NULL | 1066 | * @param addr address used to send messages on multicastif, or NULL |
1085 | * @param caller_cb user function to call when done | 1067 | * @param caller_cb user function to call when done |
1086 | * @param caller_cls closure to pass to caller_cb | 1068 | * @param caller_cls closure to pass to caller_cb |
1087 | */ | 1069 | */ |
1088 | void | 1070 | void |
1089 | UPNP_discover_ (struct GNUNET_SCHEDULER_Handle *sched, | 1071 | UPNP_discover_ (const char *multicastif, |
1090 | const char *multicastif, | ||
1091 | const struct sockaddr *addr, | 1072 | const struct sockaddr *addr, |
1092 | UPNP_discover_cb_ caller_cb, void *caller_cls) | 1073 | UPNP_discover_cb_ caller_cb, void *caller_cls) |
1093 | { | 1074 | { |
@@ -1129,7 +1110,6 @@ UPNP_discover_ (struct GNUNET_SCHEDULER_Handle *sched, | |||
1129 | 1110 | ||
1130 | 1111 | ||
1131 | cls = GNUNET_malloc (sizeof (struct UPNP_discover_cls)); | 1112 | cls = GNUNET_malloc (sizeof (struct UPNP_discover_cls)); |
1132 | cls->sched = sched; | ||
1133 | cls->sudp = sudp; | 1113 | cls->sudp = sudp; |
1134 | cls->type_index = 0; | 1114 | cls->type_index = 0; |
1135 | cls->dev_list = NULL; | 1115 | cls->dev_list = NULL; |
@@ -1270,15 +1250,13 @@ UPNP_discover_ (struct GNUNET_SCHEDULER_Handle *sched, | |||
1270 | GNUNET_NETWORK_fdset_zero (cls->fdset); | 1250 | GNUNET_NETWORK_fdset_zero (cls->fdset); |
1271 | GNUNET_NETWORK_fdset_set (cls->fdset, sudp); | 1251 | GNUNET_NETWORK_fdset_set (cls->fdset, sudp); |
1272 | 1252 | ||
1273 | task_w = GNUNET_SCHEDULER_add_select (sched, | 1253 | task_w = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
1274 | GNUNET_SCHEDULER_PRIORITY_DEFAULT, | ||
1275 | GNUNET_SCHEDULER_NO_TASK, | 1254 | GNUNET_SCHEDULER_NO_TASK, |
1276 | GNUNET_TIME_relative_multiply | 1255 | GNUNET_TIME_relative_multiply |
1277 | (GNUNET_TIME_UNIT_SECONDS, 15), NULL, | 1256 | (GNUNET_TIME_UNIT_SECONDS, 15), NULL, |
1278 | cls->fdset, &discover_send, cls); | 1257 | cls->fdset, &discover_send, cls); |
1279 | 1258 | ||
1280 | GNUNET_SCHEDULER_add_select (sched, | 1259 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
1281 | GNUNET_SCHEDULER_PRIORITY_DEFAULT, | ||
1282 | task_w, | 1260 | task_w, |
1283 | GNUNET_TIME_relative_multiply | 1261 | GNUNET_TIME_relative_multiply |
1284 | (GNUNET_TIME_UNIT_SECONDS, 15), cls->fdset, | 1262 | (GNUNET_TIME_UNIT_SECONDS, 15), cls->fdset, |