summaryrefslogtreecommitdiff
path: root/client.h
blob: e7b5fa5bc01b1697e31459c6e09476f3df737451 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* SPDX-License-Identifier: GPL-2.0 */

/** \file client.h Common client functions and exported symbols from client_common.c. */

/** The different states of a connection from the view of the client. */
enum {
	/** TCP connection is established. */
	CL_CONNECTED,
	/** Server sends the welcome message. */
	CL_RECEIVED_WELCOME,
	/** Client sends the authentication request. */
	CL_SENT_AUTH,
	/** Server sends encrypted challenge. */
	CL_RECEIVED_CHALLENGE,
	/** Client solves the challenge and sends the result. */
	CL_SENT_CH_RESPONSE,
	/** Server accepts this authentication. */
	CL_RECEIVED_PROCEED,
	/** Command is executing. */
	CL_EXECUTING,
	/** Server is expecting data (addblob commands only). */
	CL_SENDING,
};

/** Data specific to a client task. */
struct client_task {
	/** The state of the connection. */
	int status;
	/** The file descriptor and the session keys. */
	struct stream_cipher_context scc;
	/** The sideband contexts for receiving/sending. */
	struct sb_context *sbc[2];
	/** The buffer tree nodes for receiving/sending. */
	struct btr_node *btrn[2];
	/** The hash value of the decrypted challenge. */
	unsigned char *challenge_hash;
	/** The parsed command line (including the command). */
	struct lls_parse_result *lpr;
	/** The RSA private key. */
	char *key_file;
	/** Paraslash user name. */
	char *user;
	/** The client task structure. */
	struct task *task;
	/** List of features supported by the server. */
	char **features;
};

#define CLIENT_CMD_PTR (lls_cmd(0, client_suite))
#define CLIENT_OPT_RESULT(_name, _lpr) \
	(lls_opt_result(LSG_CLIENT_PARA_CLIENT_OPT_ ## _name, _lpr))
#define CLIENT_OPT_GIVEN(_name, _lpr) \
	(lls_opt_given(CLIENT_OPT_RESULT(_name, _lpr)))
#define CLIENT_OPT_UINT32_VAL(_name, _lpr) \
	(lls_uint32_val(0, CLIENT_OPT_RESULT(_name, _lpr)))
#define CLIENT_OPT_STRING_VAL(_name, _lpr) \
	(lls_string_val(0, CLIENT_OPT_RESULT(_name, _lpr)))

void client_close(struct client_task *ct);
int client_parse_config(int argc, char *argv[], struct client_task **ct_ptr);
int client_connect(struct client_task *ct, struct sched *s,
		struct btr_node *parent, struct btr_node *child);
int client_open(int argc, char *argv[], struct client_task **ct_ptr,
		struct btr_node *parent, struct btr_node *child,
		struct sched *sched);