forked from virtualopensystems/vapp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.h
More file actions
60 lines (43 loc) · 1.54 KB
/
common.h
File metadata and controls
60 lines (43 loc) · 1.54 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* common.h
*/
#ifndef COMMON_H_
#define COMMON_H_
#include <inttypes.h>
#include <stddef.h>
#include <stdint.h>
#define INSTANCE_CREATED 1
#define INSTANCE_INITIALIZED 2
#define INSTANCE_END 3
#define ONEMEG (1024*1024)
#define ETH_PACKET_SIZE (1518)
#define BUFFER_SIZE (sizeof(struct virtio_net_hdr) + ETH_PACKET_SIZE)
#define BUFFER_ALIGNMENT (8) // alignment in bytes
#define VHOST_SOCK_NAME "vhost.sock"
// align a value on a boundary
#define ALIGN(v,b) (((long int)v + (long int)b - 1)&(-(long int)b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
#define DUMP_PACKETS
struct ServerMsg;
typedef int (*InMsgHandler)(void* context, struct ServerMsg* msg);
typedef int (*PollHandler)(void* context);
struct AppHandlers {
void* context;
InMsgHandler in_handler;
PollHandler poll_handler;
};
typedef struct AppHandlers AppHandlers;
struct VhostUserMsg;
const char* cmd_from_vhostmsg(const struct VhostUserMsg* msg);
void dump_vhostmsg(const struct VhostUserMsg* msg);
struct vring_desc;
struct vring_avail;
struct vring_used;
struct vhost_vring;
void dump_buffer(uint8_t* p, size_t len);
void dump_vring(struct vring_desc* desc, struct vring_avail* avail,struct vring_used* used);
void dump_vhost_vring(struct vhost_vring* vring);
int vhost_user_send_fds(int fd, const struct VhostUserMsg *msg, int *fds, size_t fd_num);
int vhost_user_recv_fds(int fd, const struct VhostUserMsg *msg, int *fds, size_t *fd_num);
#endif /* COMMON_H_ */