udp: refuse to add the same target twice
[paraslash.git] / client.h
1 /*
2  * Copyright (C) 1997-2010 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 /** The different states of a connection from the view of the client. */
12 enum {
13         /** TCP connection is established. */
14         CL_CONNECTED,
15         /** Server sends the welcome message. */
16         CL_RECEIVED_WELCOME,
17         /** Client sends the authentification request. */
18         CL_SENT_AUTH,
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 rc4 keys. */
36         struct rc4_context rc4c;
37         /** The configuration (including the command). */
38         struct client_args_info conf;
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         struct btr_node *btrn;
48 };
49
50 void client_close(struct client_task *ct);
51 int client_open(int argc, char *argv[], struct client_task **ct_ptr,
52                 int *loglevel, struct btr_node *parent, struct btr_node *child);