X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Freconnect.h;h=e935d0af0afb5e1b6e15c843972b1b3b9cdf102f;hb=e0edde6fee279cdbbf3c179f5f50adaf0c7c7f1e;hp=3442c07ab2a26645d976343e71f186acf0a8be63;hpb=58fda1dab104041fc693032475ec4662c1a52849;p=sliver-openvswitch.git diff --git a/lib/reconnect.h b/lib/reconnect.h index 3442c07ab..e935d0af0 100644 --- a/lib/reconnect.h +++ b/lib/reconnect.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009 Nicira Networks. + * Copyright (c) 2009, 2010 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,17 +35,31 @@ struct reconnect *reconnect_create(long long int now); void reconnect_destroy(struct reconnect *); +void reconnect_set_quiet(struct reconnect *, bool quiet); + const char *reconnect_get_name(const struct reconnect *); void reconnect_set_name(struct reconnect *, const char *name); +/* Defaults, all in msecs. */ +#define RECONNECT_DEFAULT_MIN_BACKOFF 1000 +#define RECONNECT_DEFAULT_MAX_BACKOFF 8000 +#define RECONNECT_DEFAULT_PROBE_INTERVAL 5000 + int reconnect_get_min_backoff(const struct reconnect *); int reconnect_get_max_backoff(const struct reconnect *); int reconnect_get_probe_interval(const struct reconnect *); +void reconnect_set_max_tries(struct reconnect *, unsigned int max_tries); +unsigned int reconnect_get_max_tries(struct reconnect *); + void reconnect_set_backoff(struct reconnect *, int min_backoff, int max_backoff); void reconnect_set_probe_interval(struct reconnect *, int probe_interval); +bool reconnect_is_passive(const struct reconnect *); +void reconnect_set_passive(struct reconnect *, bool passive, + long long int now); + bool reconnect_is_enabled(const struct reconnect *); void reconnect_enable(struct reconnect *, long long int now); void reconnect_disable(struct reconnect *, long long int now); @@ -53,11 +67,15 @@ void reconnect_disable(struct reconnect *, long long int now); void reconnect_force_reconnect(struct reconnect *, long long int now); bool reconnect_is_connected(const struct reconnect *); -unsigned int reconnect_get_connection_duration(const struct reconnect *, - long long int now); +unsigned int reconnect_get_last_connect_elapsed(const struct reconnect *, + long long int now); +unsigned int reconnect_get_last_disconnect_elapsed(const struct reconnect *, + long long int now); void reconnect_disconnected(struct reconnect *, long long int now, int error); void reconnect_connecting(struct reconnect *, long long int now); +void reconnect_listening(struct reconnect *, long long int now); +void reconnect_listen_error(struct reconnect *, long long int now, int error); void reconnect_connected(struct reconnect *, long long int now); void reconnect_connect_failed(struct reconnect *, long long int now, int error); @@ -74,16 +92,18 @@ int reconnect_timeout(struct reconnect *, long long int now); struct reconnect_stats { /* All times and durations in this structure are in milliseconds. */ - long long int creation_time; /* Time reconnect_create() called. */ - long long int last_received; /* Last call to reconnect_received(). */ - long long int last_connected; /* Last call to reconnect_connected(). */ - int backoff; /* Current backoff duration. */ - - unsigned int seqno; /* # of connections + # of disconnections. */ - - bool is_connected; /* Currently connected? */ - unsigned int current_connection_duration; /* Time of current connection. */ - unsigned int total_connected_duration; /* Sum of all connections. */ + long long int creation_time; /* Time reconnect_create() called. */ + long long int last_received; /* Last call to reconnect_received(). */ + long long int last_connected; /* Last call to reconnect_connected(). */ + long long int last_disconnected; /* Last call to reconnect_disconnected(). */ + int backoff; /* Current backoff duration. */ + + unsigned int seqno; /* # of connections + # of disconnections. */ + + bool is_connected; /* Currently connected? */ + unsigned int msec_since_connect; /* Time since last connect. */ + unsigned int msec_since_disconnect; /* Time since last disconnect. */ + unsigned int total_connected_duration; /* Sum of all connections. */ unsigned int n_attempted_connections; unsigned int n_successful_connections;