summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorLars Müller2008-03-01 19:30:38 +0100
committerLars Müller2008-03-01 19:30:38 +0100
commit868fec1f8eca7c344fc9ac057b7418331299d9ce (patch)
treec07cdf11db710dc495c3c7a513cc0f8fd68d6626 /common
downloaddnbd-868fec1f8eca7c344fc9ac057b7418331299d9ce.tar.gz
dnbd-868fec1f8eca7c344fc9ac057b7418331299d9ce.tar.xz
dnbd-868fec1f8eca7c344fc9ac057b7418331299d9ce.zip
Import dnbd* from the former openslx-contrib repo as of revision 92.
openslx-contrib is currently read only and will get removed in some days. git-svn-id: http://svn.openslx.org/svn/openslx/contrib/dnbd/trunk@1592 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'common')
-rw-r--r--common/dnbd-cliserv.h103
-rw-r--r--common/dnbd.h18
2 files changed, 121 insertions, 0 deletions
diff --git a/common/dnbd-cliserv.h b/common/dnbd-cliserv.h
new file mode 100644
index 0000000..cf96767
--- /dev/null
+++ b/common/dnbd-cliserv.h
@@ -0,0 +1,103 @@
+#ifndef LINUX_DNBD_CLISERV_H
+#define LINUX_DNBD_CLISERV_H 1
+
+#ifndef MODULE
+#include <stdint.h>
+#endif
+
+#ifdef DNBD_USERSPACE
+#include <bits/types.h>
+#include <netinet/in.h>
+#include <endian.h>
+#include <byteswap.h>
+
+/* host byte order <-> network byte order */
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define ntohll(x) (x)
+#else
+#define ntohll(x) bswap_64(x)
+#endif
+
+#else
+#include <linux/in.h>
+#endif
+
+#include <linux/types.h>
+
+/* some constants */
+#define DNBD_VERSION "0.9.0"
+#define DNBD_PORT 5001
+#define DNBD_MAGIC 0x19051979
+#define DNBD_MAJOR 0
+#define DNBD_UIDLEN 20
+
+/* states */
+#define DNBD_STATE_LOADED 1<<0
+#define DNBD_STATE_CONFIGURED 1<<1
+#define DNBD_STATE_RUNNING 1<<2
+
+/* define ioctls */
+#define DNBD_IOCTL_TYPE 0xac
+#define DNBD_SET_SOCK _IO( DNBD_IOCTL_TYPE, 0)
+#define DNBD_SET_GROUPNET _IO( DNBD_IOCTL_TYPE, 1)
+#define DNBD_SET_BLKSIZE _IO( DNBD_IOCTL_TYPE, 2)
+#define DNBD_SET_CAPACITY _IO( DNBD_IOCTL_TYPE, 3)
+#define DNBD_SET_SERVERID _IO( DNBD_IOCTL_TYPE, 4)
+#define DNBD_SET_CACHE _IO( DNBD_IOCTL_TYPE, 5)
+#define DNBD_DO_IT _IO( DNBD_IOCTL_TYPE, 6)
+#define DNBD_DISCONNECT _IO( DNBD_IOCTL_TYPE, 7)
+
+/* define communication between server and client */
+#define DNBD_CMD_MASK 0x07
+#define DNBD_CMD_INIT 0x01
+#define DNBD_CMD_READ 0x02
+#define DNBD_CMD_HB 0x03
+
+#define DNBD_CMD_CLI 0x08
+#define DNBD_CMD_SRV 0x10
+
+#define DNBD_TMR_OUT 0x0a
+
+/* do not allign variables to 32bit etc.*/
+#pragma pack(1)
+struct dnbd_request {
+ uint32_t magic;
+ uint16_t id;
+ uint16_t cmd;
+ uint64_t pos;
+ uint16_t time;
+ uint16_t len;
+};
+#pragma pack()
+
+#pragma pack(1)
+struct dnbd_reply {
+ uint32_t magic;
+ uint16_t id;
+ uint16_t cmd;
+ uint64_t pos;
+ uint16_t time;
+};
+#pragma pack()
+
+#pragma pack(1)
+struct dnbd_reply_init {
+ uint32_t magic;
+ uint16_t id;
+ uint16_t cmd;
+ uint64_t capacity;
+ uint16_t time;
+ uint16_t blksize;
+};
+#pragma pack()
+
+typedef struct dnbd_reply dnbd_reply_t;
+typedef struct dnbd_reply_init dnbd_reply_init_t;
+typedef struct dnbd_request dnbd_request_t;
+
+struct dnbd_file {
+ const char *name;
+ int len;
+};
+
+#endif /* LINUX_DNBD_CLISERV_H */
diff --git a/common/dnbd.h b/common/dnbd.h
new file mode 100644
index 0000000..eb8de33
--- /dev/null
+++ b/common/dnbd.h
@@ -0,0 +1,18 @@
+#define DNBD_MAJOR 43
+#define MAX_DNBD 32
+
+struct dnbd_device {
+ int flags;
+ int harderror; /* Code of hard error */
+ struct socket * sock;
+ struct file * file; /* If == NULL, device is not ready, yet */
+ int magic;
+ spinlock_t queue_lock;
+ struct list_head queue_head;/* Requests are added here... */
+ struct semaphore tx_lock;
+ struct gendisk *disk;
+ int blksize;
+ u64 bytesize;
+};
+
+typedef struct dnbd_device dnbd_device_t;