1/*
2 * Network Block Device protocol
3 * Copyright 2006-2007, Fran��ois Revol. All rights reserved.
4 * Distributed under the terms of the MIT License.
5 *
6 * references:
7 * include/linux/nbd.h
8 */
9
10enum {
11	NBD_CMD_READ = 0,
12	NBD_CMD_WRITE,
13	NBD_CMD_DISC
14};
15
16#define NBD_REQUEST_MAGIC 0x25609513
17#define NBD_REPLY_MAGIC 0x67446698
18
19/* in network byte order */
20struct nbd_request {
21	uint32 magic; /* REQUEST_MAGIC */
22	uint32 type;
23	uint64 handle; //char handle[8];
24	uint64 from;
25	uint32 len;
26} _PACKED;
27
28/* in network byte order */
29struct nbd_reply {
30	uint32 magic; /* REPLY_MAGIC */
31	uint32 error;
32	uint64 handle; //char handle[8];
33} _PACKED;
34
35/* initialization protocol (ENBD ? or at least Linux specific ?) */
36
37#define NBD_INIT_PASSWD "NBDMAGIC"
38#define NBD_INIT_MAGIC 0x0000420281861253LL
39
40/* in network byte order */
41struct nbd_init_packet {
42	uint8 passwd[8]; /* "NBDMAGIC" */
43	uint64 magic; /* INIT_MAGIC */
44	uint64 device_size; /* size in bytes */
45	uint8 dummy[128]; /* reserved for future use */
46} _PACKED;