2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#ifndef DIRECTOR_CONNECTION_H
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#define DIRECTOR_CONNECTION_H
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
56139ffc94e481ca1940ffd8d8f7166879150665Timo Sirainenstruct director_connection_status {
56139ffc94e481ca1940ffd8d8f7166879150665Timo Sirainen uoff_t bytes_read, bytes_sent;
56139ffc94e481ca1940ffd8d8f7166879150665Timo Sirainen size_t bytes_buffered, peak_bytes_buffered;
56139ffc94e481ca1940ffd8d8f7166879150665Timo Sirainen struct timeval last_input, last_output;
f1551f4a50a471f0adecd92dd1f94702beeed72dTimo Sirainen unsigned int last_ping_msecs;
5cdaaf2ecfed02503572935266f55123923ba00aTimo Sirainen
5cdaaf2ecfed02503572935266f55123923ba00aTimo Sirainen unsigned int handshake_users_received;
5cdaaf2ecfed02503572935266f55123923ba00aTimo Sirainen unsigned int handshake_users_sent;
56139ffc94e481ca1940ffd8d8f7166879150665Timo Sirainen};
56139ffc94e481ca1940ffd8d8f7166879150665Timo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenstruct director_host;
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenstruct director;
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenstruct director_connection *
0a53eb0283d7ec28c6105f61e118b96fce8ecb95Timo Sirainendirector_connection_init_in(struct director *dir, int fd,
0a53eb0283d7ec28c6105f61e118b96fce8ecb95Timo Sirainen const struct ip_addr *ip);
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenstruct director_connection *
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainendirector_connection_init_out(struct director *dir, int fd,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen struct director_host *host);
dff32d11a411a24f3b76003c1ae22c5a960f180eTimo Sirainenvoid director_connection_deinit(struct director_connection **conn,
dff32d11a411a24f3b76003c1ae22c5a960f180eTimo Sirainen const char *remote_reason);
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenvoid director_connection_send(struct director_connection *conn,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen const char *data);
f64b5bc9e73bedc63ba3c072c286542c29c69e43Timo Sirainenvoid director_connection_set_synced(struct director_connection *conn,
f64b5bc9e73bedc63ba3c072c286542c29c69e43Timo Sirainen bool synced);
5f5713d6468dca1acf3d350dd8a33057331f78c5Timo Sirainenvoid director_connection_ping(struct director_connection *conn);
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen
242abe3ad2423776e9cf05e1304eb8fda4831b23Timo Sirainenconst char *director_connection_get_name(struct director_connection *conn);
0a53eb0283d7ec28c6105f61e118b96fce8ecb95Timo Sirainenstruct director_host *
0a53eb0283d7ec28c6105f61e118b96fce8ecb95Timo Sirainendirector_connection_get_host(struct director_connection *conn);
377dd19a90436b8f96902af741a3ea130bc3fe75Timo Sirainenbool director_connection_is_handshaked(struct director_connection *conn);
ad404d294fedf792619aed432ed8de5174e9ce7cTimo Sirainenbool director_connection_is_synced(struct director_connection *conn);
caae18c876f81e261350e4957471efa453c0ea9fTimo Sirainenbool director_connection_is_incoming(struct director_connection *conn);
ee3362f3b78827a2c9a7e9ddee83f5a429c06213Timo Sirainenunsigned int
ee3362f3b78827a2c9a7e9ddee83f5a429c06213Timo Sirainendirector_connection_get_minor_version(struct director_connection *conn);
0a53eb0283d7ec28c6105f61e118b96fce8ecb95Timo Sirainen
0a53eb0283d7ec28c6105f61e118b96fce8ecb95Timo Sirainenvoid director_connection_cork(struct director_connection *conn);
0a53eb0283d7ec28c6105f61e118b96fce8ecb95Timo Sirainenvoid director_connection_uncork(struct director_connection *conn);
242abe3ad2423776e9cf05e1304eb8fda4831b23Timo Sirainen
56139ffc94e481ca1940ffd8d8f7166879150665Timo Sirainenvoid director_connection_get_status(struct director_connection *conn,
56139ffc94e481ca1940ffd8d8f7166879150665Timo Sirainen struct director_connection_status *status_r);
56139ffc94e481ca1940ffd8d8f7166879150665Timo Sirainen
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen#endif