summaryrefslogtreecommitdiffstats
path: root/src/trans.h
blob: e7c38bcd4fd22176750fa661ad75278bac083e1f (plain)
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

#ifndef TRANS_H
#define TRANS_H

#include <sys/ioctl.h>

struct trans_handle;
struct trans_msg;

typedef int(*trans_cb_t)(struct trans_handle *h, struct trans_msg *msg);

struct trans_msg {
	/* netlink command */
	int cmd;

	/* common attributes */
	int type;
	int idx;

	/* flags indicating error/ack message */
	int err;
	int ack;

	/* attributes based on cmd field */
	union {
		/* data message */
		struct {
			void *ptr;
			int   len;
			uint  flags;
			struct timespec time;
			struct winsize ws;
		} data;
		/* notify message */
		int action;
		/* error message */
		int error;
		/* group message */
		int group;
	};
};

int trans_init(struct trans_handle *h, trans_cb_t cb);
int trans_close(struct trans_handle *h);
int trans_process(struct trans_handle *h);
int trans_send(struct trans_handle *h, struct trans_msg *msg);
int trans_group(struct trans_handle *h, int group);
int trans_fd(struct trans_handle *h);

/* TODO make CONFIG option and ifdef this place */
#include "trans-libnl.h"

#endif /* !TRANS_H */