Makefile.in: target "install" depends on target "man"
[paraslash.git] / client.h
1 /*
2 * Copyright (C) 1997-2007 Andre Noll <maan@systemlinux.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
17 */
18
19 /** \file client.h common client functions and exported symbols from client_common.c */
20
21 #include <openssl/rc4.h>
22
23 /**
24 * the different states of a connection from the view of the client
25 */
26 enum {
27 /** tcp connection is established */
28 CL_CONNECTED,
29 /** server sends the welcome message */
30 CL_RECEIVED_WELCOME,
31 /** client sends the authentification request */
32 CL_SENT_AUTH,
33 /** server sends a challenge */
34 CL_RECEIVED_CHALLENGE,
35 /** clientd solves the challenge and sends the result */
36 CL_SENT_CH_RESPONSE,
37 /** server accepts this authentication */
38 CL_RECEIVED_PROCEED,
39 /** client sends the command */
40 CL_SENT_COMMAND,
41 /** server expects data */
42 CL_SENDING,
43 /** client expects data */
44 CL_RECEIVING,
45 };
46
47 /** size of the receiving buffer */
48 #define CLIENT_BUFSIZE 8192
49
50 /**
51 * data specific to a client task
52 */
53 struct private_client_data {
54 /** the state of the connection */
55 int status;
56 /** the file descriptor */
57 int fd;
58 /** the configuration (including the command) */
59 struct client_args_info conf;
60 /** the config file for client options */
61 char *config_file;
62 /** the RSA private key */
63 char *key_file;
64 /** paraslash user name */
65 char *user;
66 /** session key for receiving data */
67 RC4_KEY rc4_recv_key;
68 /** session key for sending data */
69 RC4_KEY rc4_send_key;
70 /** the client task structure */
71 struct task task;
72 /** non-zero if task is unregistered */
73 int eof;
74 /** the buffer used for handshake and receiving */
75 char buf[CLIENT_BUFSIZE];
76 /** number of bytes loaded in \p buf */
77 size_t loaded;
78 /** non-zero if the pre_select hook added \p fd to the read fd set */
79 int check_r;
80 /** non-zero if the pre_select hook added \p fd to the write fd set */
81 int check_w;
82 /** the decrypted challenge */
83 long unsigned challenge_nr;
84 /** pointer to the data to be sent to para_server */
85 char *inbuf;
86 /** number of bytes loaded in \p inbuf */
87 size_t *in_loaded;
88 /** non-zero if input task encountered an eof or an errro condition */
89 int *in_eof;
90 };
91
92 void client_close(struct private_client_data *pcd);
93 int client_open(int argc, char *argv[], struct private_client_data **pcd_ptr);
94 void client_pre_select(struct sched *s, struct task *t);
95 void client_post_select(struct sched *s, struct task *t);