diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-12-13 17:30:08 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-12-13 17:30:16 +0100 |
commit | bdb3420bc937f0ab9187695a56f0e63d7c227f00 (patch) | |
tree | 14e1995fbb0d12c2049afd04515ed3337261627a /src/include | |
parent | fe4f3105b7b0f6bc3160b1396fe7af07bde0bd8d (diff) | |
download | gnunet-bdb3420bc937f0ab9187695a56f0e63d7c227f00.tar.gz gnunet-bdb3420bc937f0ab9187695a56f0e63d7c227f00.zip |
add function to obtain monotonic time
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gnunet_time_lib.h | 31 | ||||
-rw-r--r-- | src/include/gnunet_transport_communication_service.h | 39 |
2 files changed, 68 insertions, 2 deletions
diff --git a/src/include/gnunet_time_lib.h b/src/include/gnunet_time_lib.h index c7a06ba23..674a95534 100644 --- a/src/include/gnunet_time_lib.h +++ b/src/include/gnunet_time_lib.h | |||
@@ -365,7 +365,8 @@ GNUNET_TIME_absolute_get_remaining (struct GNUNET_TIME_Absolute future); | |||
365 | * assuming it continues at the same speed | 365 | * assuming it continues at the same speed |
366 | */ | 366 | */ |
367 | struct GNUNET_TIME_Relative | 367 | struct GNUNET_TIME_Relative |
368 | GNUNET_TIME_calculate_eta (struct GNUNET_TIME_Absolute start, uint64_t finished, | 368 | GNUNET_TIME_calculate_eta (struct GNUNET_TIME_Absolute start, |
369 | uint64_t finished, | ||
369 | uint64_t total); | 370 | uint64_t total); |
370 | 371 | ||
371 | 372 | ||
@@ -565,6 +566,34 @@ unsigned int | |||
565 | GNUNET_TIME_time_to_year (struct GNUNET_TIME_Absolute at); | 566 | GNUNET_TIME_time_to_year (struct GNUNET_TIME_Absolute at); |
566 | 567 | ||
567 | 568 | ||
569 | /** | ||
570 | * A configuration object. | ||
571 | */ | ||
572 | struct GNUNET_CONFIGURATION_Handle; | ||
573 | |||
574 | |||
575 | /** | ||
576 | * Obtain the current time and make sure it is monotonically | ||
577 | * increasing. Guards against systems without an RTC or | ||
578 | * clocks running backwards and other nasty surprises. Does | ||
579 | * not guarantee that the returned time is near the current | ||
580 | * time returned by #GNUNET_TIME_absolute_get(). Two | ||
581 | * subsequent calls (within a short time period) may return the | ||
582 | * same value. Persists the last returned time on disk to | ||
583 | * ensure that time never goes backwards. As a result, the | ||
584 | * resulting value can be used to check if a message is the | ||
585 | * "most recent" value and replays of older messages (from | ||
586 | * the same origin) would be discarded. | ||
587 | * | ||
588 | * @param cfg configuration, used to determine where to | ||
589 | * store the time; user can also insist RTC is working | ||
590 | * nicely and disable the feature | ||
591 | * @return monotonically increasing time | ||
592 | */ | ||
593 | struct GNUNET_TIME_Absolute | ||
594 | GNUNET_TIME_absolute_get_monotonic (const struct GNUNET_CONFIGURATION_Handle *cfg); | ||
595 | |||
596 | |||
568 | #if 0 /* keep Emacsens' auto-indent happy */ | 597 | #if 0 /* keep Emacsens' auto-indent happy */ |
569 | { | 598 | { |
570 | #endif | 599 | #endif |
diff --git a/src/include/gnunet_transport_communication_service.h b/src/include/gnunet_transport_communication_service.h index f81ee6d9a..8cf275660 100644 --- a/src/include/gnunet_transport_communication_service.h +++ b/src/include/gnunet_transport_communication_service.h | |||
@@ -103,6 +103,19 @@ enum GNUNET_TRANSPORT_CommunicatorCharacteristics { | |||
103 | 103 | ||
104 | 104 | ||
105 | /** | 105 | /** |
106 | * Function called when the transport service has received an | ||
107 | * acknowledgement for this communicator (!) via a different return | ||
108 | * path. | ||
109 | */ | ||
110 | typedef void | ||
111 | (*GNUNET_TRANSPORT_CommunicatorNotify) (void *cls, | ||
112 | const struct GNUNET_PeerIdentity *sender, | ||
113 | struct GNUNET_TIME_Absolute monotonic_time, | ||
114 | struct GNUNET_TIME_Relative validity, | ||
115 | const struct GNUNET_HashCode *token | ||
116 | ); | ||
117 | |||
118 | /** | ||
106 | * Connect to the transport service. | 119 | * Connect to the transport service. |
107 | * | 120 | * |
108 | * @param cfg configuration to use | 121 | * @param cfg configuration to use |
@@ -122,7 +135,9 @@ GNUNET_TRANSPORT_communicator_connect (const struct GNUNET_CONFIGURATION_Handle | |||
122 | const char *addr_prefix, | 135 | const char *addr_prefix, |
123 | enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc, | 136 | enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc, |
124 | GNUNET_TRANSPORT_CommunicatorMqInit mq_init, | 137 | GNUNET_TRANSPORT_CommunicatorMqInit mq_init, |
125 | void *mq_init_cls); | 138 | void *mq_init_cls, |
139 | GNUNET_TRANSPORT_CommunicatorNotify notify_cb, | ||
140 | void *notify_cb_cls); | ||
126 | 141 | ||
127 | 142 | ||
128 | /** | 143 | /** |
@@ -275,6 +290,28 @@ void | |||
275 | GNUNET_TRANSPORT_communicator_address_remove (struct GNUNET_TRANSPORT_AddressIdentifier *ai); | 290 | GNUNET_TRANSPORT_communicator_address_remove (struct GNUNET_TRANSPORT_AddressIdentifier *ai); |
276 | 291 | ||
277 | 292 | ||
293 | /** | ||
294 | * The communicator asks the transport service to route a message via | ||
295 | * a different path to another communicator service at another peer. | ||
296 | * This must only be done for special control traffic (as there is no | ||
297 | * flow control for this API), such as acknowledgements, and generally | ||
298 | * only be done if the communicator is uni-directional (i.e. cannot | ||
299 | * send the message back itself). | ||
300 | * | ||
301 | * @param ch handle of this communicator | ||
302 | * @param target_pid peer to send the message to | ||
303 | * @param target_comm name of the communicator to send the message to | ||
304 | */ | ||
305 | void | ||
306 | GNUNET_TRANSPORT_communicator_notify (struct GNUNET_TRANSPORT_CommunicatorHandle *ch, | ||
307 | const struct GNUNET_PeerIdentity *pid, | ||
308 | const char *comm, | ||
309 | struct GNUNET_TIME_Absolute monotonic_time, | ||
310 | struct GNUNET_TIME_Relative validity, | ||
311 | const struct GNUNET_HashCode *token | ||
312 | ); | ||
313 | |||
314 | |||
278 | #if 0 /* keep Emacsens' auto-indent happy */ | 315 | #if 0 /* keep Emacsens' auto-indent happy */ |
279 | { | 316 | { |
280 | #endif | 317 | #endif |