[go: up one dir, main page]

Menu

[r35]: / trunk / osnbd / connection.h  Maximize  Restore  History

Download this file

43 lines (33 with data), 638 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef CONNECTION_H
#define CONNECTION_H
#include <sys/types.h>
#include <inttypes.h>
struct nbd_reply {
uint32_t magic;
uint32_t error;
char handle[8];
};
struct nbd_request {
uint32_t magic;
uint32_t type;
char handle[8];
uint64_t from;
uint32_t len;
} __attribute__ ((packed));
class Disk;
class Connection
{
private:
int m_fd;
Disk *m_pDisk;
bool m_bEnd;
private:
bool sendError(struct nbd_reply *reply, int errcode);
bool pollit(int f, char *buf, size_t len);
public:
Connection(int fd, Disk *pDisk);
inline Disk *getDisk() const { return m_pDisk; }
void close();
void handle();
};
#endif