diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-12-17 08:10:33 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-12-17 08:10:33 +0100 |
commit | c4815dbb193e507dac71ea8f9f926932b54b0fed (patch) | |
tree | 8c47967e4f24d6c06506874424348307da6a6044 /src/nat | |
parent | 88c39e0eb9748da2d96b99342747f8270c52216a (diff) | |
download | gnunet-c4815dbb193e507dac71ea8f9f926932b54b0fed.tar.gz gnunet-c4815dbb193e507dac71ea8f9f926932b54b0fed.zip |
enable sending only differences for autoconfiguration
Diffstat (limited to 'src/nat')
-rw-r--r-- | src/nat/gnunet-service-nat.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/nat/gnunet-service-nat.c b/src/nat/gnunet-service-nat.c index 235ca9389..5ae24c456 100644 --- a/src/nat/gnunet-service-nat.c +++ b/src/nat/gnunet-service-nat.c | |||
@@ -218,6 +218,11 @@ struct AutoconfigContext | |||
218 | struct GNUNET_CONFIGURATION_Handle *c; | 218 | struct GNUNET_CONFIGURATION_Handle *c; |
219 | 219 | ||
220 | /** | 220 | /** |
221 | * Original configuration (for diffing). | ||
222 | */ | ||
223 | struct GNUNET_CONFIGURATION_Handle *orig; | ||
224 | |||
225 | /** | ||
221 | * Timeout task to force termination. | 226 | * Timeout task to force termination. |
222 | */ | 227 | */ |
223 | struct GNUNET_SCHEDULER_Task *timeout_task; | 228 | struct GNUNET_SCHEDULER_Task *timeout_task; |
@@ -1247,13 +1252,17 @@ conclude_autoconfig_request (void *cls) | |||
1247 | struct GNUNET_MQ_Envelope *env; | 1252 | struct GNUNET_MQ_Envelope *env; |
1248 | size_t c_size; | 1253 | size_t c_size; |
1249 | char *buf; | 1254 | char *buf; |
1250 | 1255 | struct GNUNET_CONFIGURATION_Handle *diff; | |
1256 | |||
1251 | ac->timeout_task = NULL; | 1257 | ac->timeout_task = NULL; |
1252 | terminate_ac_activities (ac); | 1258 | terminate_ac_activities (ac); |
1253 | 1259 | ||
1254 | /* Send back response */ | 1260 | /* Send back response */ |
1255 | buf = GNUNET_CONFIGURATION_serialize (ac->c, | 1261 | diff = GNUNET_CONFIGURATION_get_diff (ac->orig, |
1262 | ac->c); | ||
1263 | buf = GNUNET_CONFIGURATION_serialize (diff, | ||
1256 | &c_size); | 1264 | &c_size); |
1265 | GNUNET_CONFIGURATION_destroy (diff); | ||
1257 | env = GNUNET_MQ_msg_extra (arm, | 1266 | env = GNUNET_MQ_msg_extra (arm, |
1258 | c_size, | 1267 | c_size, |
1259 | GNUNET_MESSAGE_TYPE_NAT_AUTO_CFG_RESULT); | 1268 | GNUNET_MESSAGE_TYPE_NAT_AUTO_CFG_RESULT); |
@@ -1268,6 +1277,7 @@ conclude_autoconfig_request (void *cls) | |||
1268 | 1277 | ||
1269 | /* clean up */ | 1278 | /* clean up */ |
1270 | GNUNET_free (ac->system_type); | 1279 | GNUNET_free (ac->system_type); |
1280 | GNUNET_CONFIGURATION_destroy (ac->orig); | ||
1271 | GNUNET_CONFIGURATION_destroy (ac->c); | 1281 | GNUNET_CONFIGURATION_destroy (ac->c); |
1272 | GNUNET_CONTAINER_DLL_remove (ac_head, | 1282 | GNUNET_CONTAINER_DLL_remove (ac_head, |
1273 | ac_tail, | 1283 | ac_tail, |
@@ -1404,6 +1414,8 @@ handle_autoconfig_request (void *cls, | |||
1404 | GNUNET_CONTAINER_DLL_insert (ac_head, | 1414 | GNUNET_CONTAINER_DLL_insert (ac_head, |
1405 | ac_tail, | 1415 | ac_tail, |
1406 | ac); | 1416 | ac); |
1417 | ac->orig | ||
1418 | = GNUNET_CONFIGURATION_dup (ac->c); | ||
1407 | ac->timeout_task | 1419 | ac->timeout_task |
1408 | = GNUNET_SCHEDULER_add_delayed (AUTOCONFIG_TIMEOUT, | 1420 | = GNUNET_SCHEDULER_add_delayed (AUTOCONFIG_TIMEOUT, |
1409 | &conclude_autoconfig_request, | 1421 | &conclude_autoconfig_request, |