interactive: Honor SIGTERM.
[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         /** Server sends encrypted challenge. */
18         CL_RECEIVED_CHALLENGE,
19         /** Client solves the challenge and sends the result. */
20         CL_SENT_CH_RESPONSE,
21         /** Server accepts this authentication. */
22         CL_RECEIVED_PROCEED,
23         /** Client sends the command. */
24         CL_SENT_COMMAND,
25         /** Server expects data. */
26         CL_SENDING,
27         /** Client expects data. */
28         CL_RECEIVING,
29 };
30
31 /** Data specific to a client task. */
32 struct client_task {
33         /** The state of the connection. */
34         int status;
35         /** The file descriptor and the session keys. */
36         struct stream_cipher_context scc;
37         /** True if this connections uses the sideband API. */
38         bool use_sideband;
39         /** The sideband context, ignored if \a use_sideband is false. */
40         struct sb_context *sbc;
41         /** The hash value of the decrypted challenge. */
42         unsigned char *challenge_hash;
43         /** The configuration (including the command). */
44         struct client_args_info conf;
45         /** The config file for client options. */
46         char *config_file;
47         /** The RSA private key. */
48         char *key_file;
49         /** Paraslash user name. */
50         char *user;
51         /** The client task structure. */
52         struct task task;
53         /** The buffer tree node of the client task. */
54         struct btr_node *btrn;
55         /** List of features supported by the server. */
56         char **features;
57 };
58
59 void client_disconnect(struct client_task *ct);
60 void client_close(struct client_task *ct);
61 int client_parse_config(int argc, char *argv[], struct client_task **ct_ptr,
62                 int *loglevel);
63 int client_connect(struct client_task *ct, struct sched *s,
64                 struct btr_node *parent, struct btr_node *child);
65 int client_open(int argc, char *argv[], struct client_task **ct_ptr,
66                 int *loglevel, struct btr_node *parent, struct btr_node *child,
67                 struct sched *sched);