📄 trans.h
字号:
/* * * Copyright 1999 Regents of the University of Minnesota * Portions Copyright 1999-2001 Sistina Software, Inc. * Portions Copyright 2001 The OpenGFS Project * * This is free software released under the GNU General Public License. * There is no warranty for this software. See the file COPYING for * details. * * See the file AUTHORS for a list of contributors. * */#ifndef _GNBD_TRANS_H#define _GNBD_TRANS_H/* * The io Header structure and its types. * This gets tacked onto the beginning of every piece of data that is * passed through. */#define tioRequest 0x10#define tioReply 0x20#define tioReadReq (tioRequest|0x02)#define tioReadRpl (tioReply|0x02)#define tioWriteReq (tioRequest|0x03)#define tioWriteRpl (tioReply|0x03)#define tioShutdown 0x0estruct tio_hdr_s { uint64_t key; uint32_t len; uint64_t offset; uint8_t err; uint8_t type;} __attribute__ ((packed));typedef struct tio_hdr_s theader_t;#define theader_len sizeof(theader_t) /* lazy programmer. *//* * ok. * Clients send out Requests and get replies. All client server * interaction is done in this maner. * The meaning of the len and offset fields change depending on the type. * The meaning of all other fields is constant. * So: * type is the type of this header. Types are defined above. * key is for the client to match requests with replies. * err is nonzero if the server had an error processing a request. * For Read Requests: * len is the amount of space the client has waiting for reply * For Read Replies: * len is the amount of data that is following this header. * For Read Requests: * offset is where to find that data we want. * For Write Requests: * offset is where to put the data we're sending. * For other conditions the fields should be ignored. (unless I confused * something here) *//* * This struct holds some various bits of info that we need before the * client can really get going. */struct tio_info_s { uint64_t devsize; uint8_t readonly;} __attribute__ ((packed));typedef struct tio_info_s tio_info_t;/* * The new login structures. We send a lgReq to the server, and get a * lgRpl back. * * For the loginRequest, you need to tell the server which device you * want. This is really only for servers that server multiple block * devices. In most cases this will probably be ignored. */struct lgReq_s { char devname[32];} __attribute__ ((packed));typedef struct lgReq_s lgReq_t;struct lgRpl_s { uint64_t devsize; uint8_t success:1; uint8_t readonly:1;} __attribute__ ((packed));typedef struct lgRpl_s lgRpl_t;#endif /* _GNBD_TRANS_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -