Implement client-server feature negotiation.
[paraslash.git] / client.h
1 /*
2 * Copyright (C) 1997-2012 Andre Noll <maan@systemlinux.org>
3 *
4 * Licensed under the GPL v2. For licencing details see COPYING.
5 */
6
7 /** \file client.h Common client functions and exported symbols from client_common.c. */
8
9 /** The different states of a connection from the view of the client. */
10 enum {
11 /** TCP connection is established. */
12 CL_CONNECTED,
13 /** Server sends the welcome message. */
14 CL_RECEIVED_WELCOME,
15 /** Client sends the authentification request. */
16 CL_SENT_AUTH,
17 /** Client solves the challenge and sends the result. */
18 CL_SENT_CH_RESPONSE,
19 /** Server accepts this authentication. */
20 CL_RECEIVED_PROCEED,
21 /** Client sends the command. */
22 CL_SENT_COMMAND,
23 /** Server expects data. */
24 CL_SENDING,
25 /** Client expects data. */
26 CL_RECEIVING,
27 };
28
29 /** Data specific to a client task. */
30 struct client_task {
31 /** The state of the connection. */
32 int status;
33 /** The file descriptor and the session keys. */
34 struct stream_cipher_context scc;
35 /** True if this connections uses the sideband API. */
36 bool use_sideband;
37 /** The sideband context, ignored if \a use_sideband is false. */
38 struct sb_context *sbc;
39 /** The configuration (including the command). */
40 struct client_args_info conf;
41 /** The config file for client options. */
42 char *config_file;
43 /** The RSA private key. */
44 char *key_file;
45 /** Paraslash user name. */
46 char *user;
47 /** The client task structure. */
48 struct task task;
49 /** The buffer tree node of the client task. */
50 struct btr_node *btrn;
51 /** List of features supported by the server. */
52 char **features;
53 };
54
55 void client_disconnect(struct client_task *ct);
56 void client_close(struct client_task *ct);
57 int client_parse_config(int argc, char *argv[], struct client_task **ct_ptr,
58 int *loglevel);
59 int client_connect(struct client_task *ct, struct sched *s,
60 struct btr_node *parent, struct btr_node *child);
61 int client_open(int argc, char *argv[], struct client_task **ct_ptr,
62 int *loglevel, struct btr_node *parent, struct btr_node *child,
63 struct sched *sched);