From f63be84d800e501c70e57b4f844dbc0898663097 Mon Sep 17 00:00:00 2001 From: nick Date: Fri, 8 Feb 2013 17:05:22 +0000 Subject: [PATCH] flexnbd: Add some more information to nbdtypes.h --- src/nbdtypes.c | 1 + src/nbdtypes.h | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/nbdtypes.c b/src/nbdtypes.c index 51b57f9..8403e73 100644 --- a/src/nbdtypes.c +++ b/src/nbdtypes.c @@ -55,3 +55,4 @@ void nbd_h2r_reply( struct nbd_reply * from, struct nbd_reply_raw * to ) to->error = be32toh( from->error ); memcpy( to->handle, from->handle, 8 ); } + diff --git a/src/nbdtypes.h b/src/nbdtypes.h index 36d94b8..ea82699 100644 --- a/src/nbdtypes.h +++ b/src/nbdtypes.h @@ -3,13 +3,19 @@ /* http://linux.derkeiler.com/Mailing-Lists/Kernel/2003-09/2332.html */ -#define INIT_PASSWD "NBDMAGIC" -#define INIT_MAGIC 0x0000420281861253 -#define REQUEST_MAGIC 0x25609513 -#define REPLY_MAGIC 0x67446698 -#define REQUEST_READ 0 -#define REQUEST_WRITE 1 -#define REQUEST_DISCONNECT 2 +#define INIT_PASSWD "NBDMAGIC" +#define INIT_MAGIC 0x0000420281861253 +#define REQUEST_MAGIC 0x25609513 +#define REPLY_MAGIC 0x67446698 +#define REQUEST_READ 0 +#define REQUEST_WRITE 1 +#define REQUEST_DISCONNECT 2 + +/* 1MiB is the de-facto standard for maximum size of header + data */ +#define NBD_MAX_SIZE ( 1024 * 1024 ) + +#define NBD_REQUEST_SIZE ( sizeof( struct nbd_request_raw ) ) +#define NBD_REPLY_SIZE ( sizeof( struct nbd_reply_raw ) ) #include #include @@ -51,7 +57,7 @@ struct nbd_init { struct nbd_request { uint32_t magic; - uint32_t type; /* == READ || == WRITE */ + uint32_t type; /* == READ || == WRITE || == DISCONNECT */ char handle[8]; uint64_t from; uint32_t len; @@ -63,7 +69,6 @@ struct nbd_reply { char handle[8]; /* handle you got from request */ }; - void nbd_r2h_init( struct nbd_init_raw * from, struct nbd_init * to ); void nbd_r2h_request( struct nbd_request_raw *from, struct nbd_request * to ); void nbd_r2h_reply( struct nbd_reply_raw * from, struct nbd_reply * to );