aboutgitcodelistschat:MatrixIRC
path: root/gluten.h
blob: 57b53adc3c7aa35edcc704e35a55e1584ddd7cf2 (plain) (blame)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#ifndef GLUTEN_H
#define GLUTEN_H

#include <stdint.h>
#include <stdbool.h>

#define MAX_FD_INJECTED 10

enum ns_spec_type {
	NS_NONE,
	NS_SPEC_TARGET,
	NS_SPEC_PID,
	NS_SPEC_PATH,
};

struct ns_spec {
	enum ns_spec_type type;
	union {
		pid_t pid;
		char *path;
	};
};

/*
 * enum ns_type - Type of namespaces
 */
enum ns_type {
	NS_CGROUP,
	NS_IPC,
	NS_NET,
	NS_MOUNT,
	NS_PID,
	NS_TIME,
	NS_USER,
	NS_UTS,
};

/*
 * struct op_context - Description of the context where the call needs to be executed
 * @ns:	Descrption of the each namespace where the call needs to be executed
 */
struct op_context {
	struct ns_spec ns[sizeof(enum ns_type)];
};

enum op_type {
	OP_CALL,
	OP_BLOCK,
	OP_CONT,
	OP_INJECT,
	OP_INJECT_A,
	OP_RETURN,
	OP_COPY_ARGS,
};

enum value_type {
	IMMEDIATE,
	REFERENCE,
};

struct op_call {
	long nr;
	bool has_ret;
	void *args[6];
	struct op_context context;
	uint16_t ret_off;
};

struct op_block {
	int32_t error;
};

struct op_continue {
	bool cont;
};

struct op_return {
	enum value_type type;
	union {
		int64_t value;
		uint16_t value_off;
	};
};

struct fd_type {
	enum value_type type;
	union {
		uint32_t fd;
		uint16_t fd_off;
	};
};

struct op_inject {
	struct fd_type newfd;
	struct fd_type oldfd;
};

struct copy_arg {
	uint16_t args_off;
	bool need_copied;
	size_t size;
};

struct op_copy_args {
	struct copy_arg args[6];
};

struct op {
	enum op_type type;
	union {
		struct op_call call;
		struct op_block block;
		struct op_continue cont;
		struct op_return ret;
		struct op_inject inj;
		struct op_copy_args copy;
	};
};
#endif /* GLUTEN_H */