Move MAX_HOSTLEN from server.h to net.h.
[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 RSA private key. */
40         char *key_file;
41         /** Paraslash user name. */
42         char *user;
43         /** The client task structure. */
44         struct task *task;
45         /** List of features supported by the server. */
46         char **features;
47 };
48
49 #define CLIENT_CMD_PTR (lls_cmd(0, client_suite))
50 #define CLIENT_OPT_RESULT(_name, _lpr) \
51         (lls_opt_result(LSG_CLIENT_PARA_CLIENT_OPT_ ## _name, _lpr))
52 #define CLIENT_OPT_GIVEN(_name, _lpr) \
53         (lls_opt_given(CLIENT_OPT_RESULT(_name, _lpr)))
54 #define CLIENT_OPT_UINT32_VAL(_name, _lpr) \
55         (lls_uint32_val(0, CLIENT_OPT_RESULT(_name, _lpr)))
56 #define CLIENT_OPT_STRING_VAL(_name, _lpr) \
57         (lls_string_val(0, CLIENT_OPT_RESULT(_name, _lpr)))
58
59 void client_close(struct client_task *ct);
60 int client_parse_config(int argc, char *argv[], struct client_task **ct_ptr,
61                 int *loglevel);
62 int client_connect(struct client_task *ct, struct sched *s,
63                 struct btr_node *parent, struct btr_node *child);
64 int client_open(int argc, char *argv[], struct client_task **ct_ptr,
65                 int *loglevel, struct btr_node *parent, struct btr_node *child,
66                 struct sched *sched);