server: Close logfile later on SIGHUP.
[paraslash.git] / client.h
1 /* Copyright (C) 1997 Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */
2
3 /** \file client.h Common client functions and exported symbols from client_common.c. */
4
5 /** The different states of a connection from the view of the client. */
6 enum {
7 /** TCP connection is established. */
8 CL_CONNECTED,
9 /** Server sends the welcome message. */
10 CL_RECEIVED_WELCOME,
11 /** Client sends the authentication request. */
12 CL_SENT_AUTH,
13 /** Server sends encrypted challenge. */
14 CL_RECEIVED_CHALLENGE,
15 /** Client solves the challenge and sends the result. */
16 CL_SENT_CH_RESPONSE,
17 /** Server accepts this authentication. */
18 CL_RECEIVED_PROCEED,
19 /** Command is executing. */
20 CL_EXECUTING,
21 /** Server is expecting data (addblob commands only). */
22 CL_SENDING,
23 };
24
25 /** Data specific to a client task. */
26 struct client_task {
27 /** The state of the connection. */
28 int status;
29 /** The file descriptor and the session keys. */
30 struct stream_cipher_context scc;
31 /** The sideband contexts for receiving/sending. */
32 struct sb_context *sbc[2];
33 /** The buffer tree nodes for receiving/sending. */
34 struct btr_node *btrn[2];
35 /** The hash value of the decrypted challenge. */
36 unsigned char *challenge_hash;
37 /** The parsed command line (including the command). */
38 struct lls_parse_result *lpr;
39 /** The config file for client options. */
40 char *config_file;
41 /** The RSA private key. */
42 char *key_file;
43 /** Paraslash user name. */
44 char *user;
45 /** The client task structure. */
46 struct task *task;
47 /** List of features supported by the server. */
48 char **features;
49 };
50
51 #define CLIENT_CMD_PTR (lls_cmd(0, client_suite))
52 #define CLIENT_OPT_RESULT(_name, _lpr) \
53 (lls_opt_result(LSG_CLIENT_PARA_CLIENT_OPT_ ## _name, _lpr))
54 #define CLIENT_OPT_GIVEN(_name, _lpr) \
55 (lls_opt_given(CLIENT_OPT_RESULT(_name, _lpr)))
56 #define CLIENT_OPT_UINT32_VAL(_name, _lpr) \
57 (lls_uint32_val(0, CLIENT_OPT_RESULT(_name, _lpr)))
58 #define CLIENT_OPT_STRING_VAL(_name, _lpr) \
59 (lls_string_val(0, CLIENT_OPT_RESULT(_name, _lpr)))
60
61 void client_close(struct client_task *ct);
62 int client_parse_config(int argc, char *argv[], struct client_task **ct_ptr,
63 int *loglevel);
64 int client_connect(struct client_task *ct, struct sched *s,
65 struct btr_node *parent, struct btr_node *child);
66 int client_open(int argc, char *argv[], struct client_task **ct_ptr,
67 int *loglevel, struct btr_node *parent, struct btr_node *child,
68 struct sched *sched);