connection.h revision 96f89d51e8315f644f46804a9f0fc4f685ac48bf
#ifndef CONNECTION_H
#define CONNECTION_H
#include "network.h"
struct connection;
enum connection_behavior {
};
enum connection_disconnect_reason {
/* not disconnected yet */
/* normal requested disconnection */
/* input buffer full */
/* connection got disconnected */
/* connect() timed out */
/* remote didn't send input */
};
struct connection_vfuncs {
/* implement one of the input*() methods.
They return 0 = ok, -1 = error, disconnect the client */
};
struct connection_settings {
const char *service_name_in;
const char *service_name_out;
unsigned int major_version, minor_version;
unsigned int client_connect_timeout_msecs;
unsigned int input_idle_timeout_secs;
bool client;
bool dont_send_version;
};
struct connection {
struct connection_list *list;
char *name;
/* for IP client: */
unsigned int port;
/* received minor version */
unsigned int minor_version;
unsigned int version_received:1;
};
struct connection_list {
struct connection *connections;
struct connection_settings set;
struct connection_vfuncs v;
};
struct connection *conn,
/* Returns -1 = disconnected, 0 = nothing new, 1 = something new.
If input_full_behavior is ALLOW, may return also -2 = buffer full. */
/* Verify that VERSION input matches what we expect. */
/* Returns human-readable reason for why connection was disconnected. */
struct connection_list *
const struct connection_vfuncs *vfuncs);
#endif