/usr/include/dovecot/connection.h is in dovecot-dev 1:2.2.9-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | #ifndef CONNECTION_H
#define CONNECTION_H
#include "net.h"
struct connection;
enum connection_behavior {
CONNECTION_BEHAVIOR_DESTROY = 0,
CONNECTION_BEHAVIOR_ALLOW
};
enum connection_disconnect_reason {
/* not disconnected yet */
CONNECTION_DISCONNECT_NOT = 0,
/* normal requested disconnection */
CONNECTION_DISCONNECT_DEINIT,
/* input buffer full */
CONNECTION_DISCONNECT_BUFFER_FULL,
/* connection got disconnected */
CONNECTION_DISCONNECT_CONN_CLOSED,
/* connect() timed out */
CONNECTION_DISCONNECT_CONNECT_TIMEOUT,
/* remote didn't send input */
CONNECTION_DISCONNECT_IDLE_TIMEOUT
};
struct connection_vfuncs {
void (*destroy)(struct connection *conn);
/* For UNIX socket clients this gets called immediately with
success=TRUE, for IP connections it gets called later:
If connect() fails, sets success=FALSE and errno. Streams aren't
initialized in that situation either. destroy() is called after
the callback. */
void (*client_connected)(struct connection *conn, bool success);
/* implement one of the input*() methods.
They return 1 = ok, continue. 0 = ok, but stop processing more
lines, -1 = error, disconnect the client. */
void (*input)(struct connection *conn);
int (*input_line)(struct connection *conn, const char *line);
int (*input_args)(struct connection *conn, const char *const *args);
};
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;
size_t input_max_size;
size_t output_max_size;
enum connection_behavior input_full_behavior;
bool client;
bool dont_send_version;
};
struct connection {
struct connection *prev, *next;
struct connection_list *list;
char *name;
int fd_in, fd_out;
struct io *io;
struct istream *input;
struct ostream *output;
struct timeout *to;
time_t last_input;
/* for IP client: */
struct ip_addr ip;
unsigned int port;
/* received minor version */
unsigned int minor_version;
enum connection_disconnect_reason disconnect_reason;
unsigned int version_received:1;
};
struct connection_list {
struct connection *connections;
unsigned int connections_count;
struct connection_settings set;
struct connection_vfuncs v;
};
void connection_init_server(struct connection_list *list,
struct connection *conn, const char *name,
int fd_in, int fd_out);
void connection_init_client_ip(struct connection_list *list,
struct connection *conn,
const struct ip_addr *ip, unsigned int port);
void connection_init_client_unix(struct connection_list *list,
struct connection *conn, const char *path);
int connection_client_connect(struct connection *conn);
void connection_disconnect(struct connection *conn);
void connection_deinit(struct connection *conn);
/* Returns -1 = disconnected, 0 = nothing new, 1 = something new.
If input_full_behavior is ALLOW, may return also -2 = buffer full. */
int connection_input_read(struct connection *conn);
/* Verify that VERSION input matches what we expect. */
int connection_verify_version(struct connection *conn, const char *const *args);
/* Returns human-readable reason for why connection was disconnected. */
const char *connection_disconnect_reason(struct connection *conn);
void connection_switch_ioloop(struct connection *conn);
struct connection_list *
connection_list_init(const struct connection_settings *set,
const struct connection_vfuncs *vfuncs);
void connection_list_deinit(struct connection_list **list);
void connection_input_default(struct connection *conn);
int connection_input_line_default(struct connection *conn, const char *line);
#endif
|