diff options
Diffstat (limited to 'src/common/util.h')
-rw-r--r-- | src/common/util.h | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/src/common/util.h b/src/common/util.h index 833fd904c7..633c613d43 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -248,14 +248,22 @@ void update_approx_time(time_t now); #endif /* Fuzzy time. */ -void ftime_set_maximum_sloppiness(int seconds); -void ftime_set_estimated_skew(int seconds); -/* typedef struct ftime_t { time_t earliest; time_t latest; } ftime_t; */ -/* void ftime_get_window(time_t now, ftime_t *ft_out); */ -int ftime_maybe_after(time_t now, time_t when); -int ftime_maybe_before(time_t now, time_t when); -int ftime_definitely_after(time_t now, time_t when); -int ftime_definitely_before(time_t now, time_t when); + +/** Return true iff <a>a</b> is definitely after <b>b</b>, even if there + * could be up to <b>allow_seconds</b> of skew in one of them. */ +static INLINE int +time_definitely_after(time_t a, time_t b, int allow_skew) +{ + return a-allow_skew > b; +} + +/** Return true iff <a>a</b> is definitely before <b>b</b>, even if there + * could be up to <b>allow_seconds</b> of skew in one of them. */ +static INLINE int +time_definitely_before(time_t a, time_t b, int allow_skew) +{ + return a+allow_skew < b; +} /* Rate-limiter */ @@ -340,10 +348,27 @@ void start_daemon(void); void finish_daemon(const char *desired_cwd); void write_pidfile(char *filename); +/* Port forwarding */ +void tor_check_port_forwarding(const char *filename, + int dir_port, int or_port, time_t now); + #ifdef MS_WINDOWS HANDLE load_windows_system_library(const TCHAR *library_name); #endif +#ifdef UTIL_PRIVATE +/* Prototypes for private functions only used by util.c (and unit tests) */ +int tor_spawn_background(const char *const filename, int *stdout_read, + int *stderr_read, const char **argv); +void format_helper_exit_status(unsigned char child_state, + int saved_errno, char *hex_errno); + +/* Space for hex values of child state, a slash, saved_errno (with + leading minus) and newline (no null) */ +#define HEX_ERRNO_SIZE (sizeof(char) * 2 + 1 + \ + 1 + sizeof(int) * 2 + 1) +#endif + const char *libor_get_digests(void); #endif |