stat.c: Comment out noisy debug messages.
[paraslash.git] / client.h
1 /*
2  * Copyright (C) 1997-2008 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 #include <openssl/rc4.h>
10
11 /**
12  * the different states of a connection from the view of the client
13  */
14 enum {
15         /** tcp connection is established */
16         CL_CONNECTED,
17         /** server sends the welcome message */
18         CL_RECEIVED_WELCOME,
19         /** client sends the authentification request */
20         CL_SENT_AUTH,
21         /** server sends a challenge */
22         CL_RECEIVED_CHALLENGE,
23         /** clientd solves the challenge and sends the result */
24         CL_SENT_CH_RESPONSE,
25         /** server accepts this authentication */
26         CL_RECEIVED_PROCEED,
27         /** client sends the command */
28         CL_SENT_COMMAND,
29         /** server expects data */
30         CL_SENDING,
31         /** client expects data */
32         CL_RECEIVING,
33 };
34
35 /** size of the receiving buffer */
36 #define CLIENT_BUFSIZE 8192
37
38 /**
39  * data specific to a client task
40  */
41 struct client_task {
42         /** the state of the connection */
43         int status;
44         /** the file descriptor */
45         int fd;
46         /** the configuration (including the command) */
47         struct client_args_info conf;
48         /** the config file for client options */
49         char *config_file;
50         /** the RSA private key */
51         char *key_file;
52         /** paraslash user name */
53         char *user;
54         /** session key for receiving data */
55         RC4_KEY rc4_recv_key;
56         /** session key for sending data */
57         RC4_KEY rc4_send_key;
58         /** the client task structure */
59         struct task task;
60         /** the buffer used for handshake and receiving */
61         char buf[CLIENT_BUFSIZE];
62         /** number of bytes loaded in \p buf */
63         size_t loaded;
64         /** non-zero if the pre_select hook added \p fd to the read fd set */
65         int check_r;
66         /** non-zero if the pre_select hook added \p fd to the write fd set */
67         int check_w;
68         /** the decrypted challenge */
69         long unsigned challenge_nr;
70         /** pointer to the data to be sent to para_server */
71         char *inbuf;
72         /** number of bytes loaded in \p inbuf */
73         size_t *in_loaded;
74         /** Non-zero if input task encountered an eof or an error condition. */
75         int *in_error;
76 };
77
78 void client_close(struct client_task *ct);
79 int client_open(int argc, char *argv[], struct client_task **ct);