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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/*
* This file is part of the Distributed Network Block Device 3
*
* Copyright(c) 2019 Frederic Robra <frederic@robra.org>
* Parts copyright 2011-2012 Johann Latocha <johann@latocha.de>
*
* This file may be licensed under the terms of of the
* GNU General Public License Version 2 (the ``GPL'').
*
* Software distributed under the License is distributed
* on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the GPL for the specific language
* governing rights and limitations.
*
* You should have received a copy of the GPL along with this
* program. If not, go to http://www.gnu.org/licenses/gpl.html
* or write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef NET_TXRX_H_
#define NET_TXRX_H_
#include "dnbd3.h"
#define dnbd3_is_sock_alive(s) ((s).sock && (s).server)
int dnbd3_send_request(struct dnbd3_sock *sock, struct request *req, struct dnbd3_cmd *cmd);
/**
* dnbd3_send_request_cmd - send a dndb3 cmd
* @sock: the socket where the request is send
* @dnbd3_cmd: the dnbd3 cmd to send
*/
int dnbd3_send_request_cmd(struct dnbd3_sock *sock, uint16_t dnbd3_cmd);
/**
* dnbd3_receive_cmd - receive a command
* @sock: the socket where the request is received
* @reply: an unused reply will be filled with the reply of the server
*
* this method should be called directly after the dnbd3_send_request_ method
*/
int dnbd3_receive_cmd(struct dnbd3_sock *sock, dnbd3_reply_t *reply);
/**
* dnbd3_receive_cmd_get_block_mq - receive a block for mq
* @sock: the socket where the request is received
* @reply: the reply initialized by dnbd3_receive_cmd
*
* this method should be called directly after the dnbd3_receive_cmd method
*
* this method copies the data to user space according to the request which is
* encoded in the handle by the send request method and decoded here.
*/
int dnbd3_receive_cmd_get_block_mq(struct dnbd3_sock *sock,
dnbd3_reply_t *reply);
/**
* dnbd3_receive_cmd_get_block_test - receive a test block
* @sock: the socket where the request is received
* @reply: the reply initialized by dnbd3_receive_cmd
*
* this method should be called directly after the dnbd3_receive_cmd method
*
* the received data is just thrown away
*/
int dnbd3_receive_cmd_get_block_test(struct dnbd3_sock *sock,
dnbd3_reply_t *reply);
/**
* dnbd3_receive_cmd_get_servers - receive new servers
* @sock: the socket where the request is received
* @reply: the reply initialized by dnbd3_receive_cmd
*
* this method should be called directly after the dnbd3_receive_cmd method
*
* the new servers are copied to dnbd3_device.new_servers and
* dnbd3_device.new_server_num is set accordingly
*/
int dnbd3_receive_cmd_get_servers(struct dnbd3_sock *sock, dnbd3_reply_t *reply);
/**
* dnbd3_receive_cmd_latest_rid - receive latest rid
* @sock: the socket where the request is received
* @reply: the reply initialized by dnbd3_receive_cmd
*
* this method should be called directly after the dnbd3_receive_cmd method
*
* dnbd3_device.update_available is set if a new RID is received
*/
int dnbd3_receive_cmd_latest_rid(struct dnbd3_sock *sock, dnbd3_reply_t *reply);
/**
* dnbd3_receive_cmd_latest_rid - select the image
* @sock: the socket where the request is received
* @reply: the reply initialized by dnbd3_receive_cmd
*
* this method should be called directly after the dnbd3_receive_cmd method
*
* if this is the first connection the image name, file size and rid will be set
* if this is a further connection image name, file size and rid will be checked
*/
int dnbd3_receive_cmd_select_image(struct dnbd3_sock *sock,
dnbd3_reply_t *reply);
#endif /* KERNEL_NET_TXRX_H_ */
|