summaryrefslogtreecommitdiffstats
path: root/src/kernel/net-txrx.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/net-txrx.h')
-rw-r--r--src/kernel/net-txrx.h116
1 files changed, 116 insertions, 0 deletions
diff --git a/src/kernel/net-txrx.h b/src/kernel/net-txrx.h
new file mode 100644
index 0000000..3636ffe
--- /dev/null
+++ b/src/kernel/net-txrx.h
@@ -0,0 +1,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_ */