This repository has been archived by the owner on Sep 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
nlusctl.h
84 lines (64 loc) · 2.32 KB
/
nlusctl.h
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
/* Netlink-based userspace service control protocol.
Essentially simplified request-reply GENL with hairy stuff like
notifications and multipart replies removed.
This is kept separated from proper netlink code for now, in part
because this is only expected to be used in half-duplex mode
with a single rx/tx buffer. */
#include <stdint.h>
#include <sys/types.h>
struct ucbuf {
char* brk;
char* ptr;
char* end;
int over;
};
struct urbuf {
char* buf;
char* mptr;
char* rptr;
char* end;
struct ucmsg* msg;
};
struct ucmsg {
uint32_t len;
int32_t cmd;
char payload[];
} __attribute__((packed));
struct ucattr {
uint16_t len;
uint16_t key;
char payload[];
} __attribute__((packed));
void uc_buf_set(struct ucbuf* uc, char* buf, size_t len);
void uc_put_hdr(struct ucbuf* uc, int cmd);
void uc_put_end(struct ucbuf* uc);
struct ucattr* uc_put_attr(struct ucbuf* uc, int key, size_t len);
void uc_put_bin(struct ucbuf* uc, int key, void* buf, size_t len);
void uc_put_int(struct ucbuf* uc, int key, int v);
void uc_put_str(struct ucbuf* uc, int key, char* str);
void uc_put_flag(struct ucbuf* uc, int key);
struct ucattr* uc_put_nest(struct ucbuf* uc, int key);
void uc_end_nest(struct ucbuf* uc, struct ucattr* nest);
int uc_msglen(char* buf, size_t len);
struct ucmsg* uc_msg(char* buf, size_t len);
struct ucattr* uc_get_0(struct ucmsg* msg);
struct ucattr* uc_get_n(struct ucmsg* msg, struct ucattr* at);
struct ucattr* uc_sub_0(struct ucattr* ab);
struct ucattr* uc_sub_n(struct ucattr* ab, struct ucattr* at);
struct ucattr* uc_get(struct ucmsg* msg, int key);
void* uc_get_bin(struct ucmsg* msg, int key, int len);
int* uc_get_int(struct ucmsg* msg, int key);
char* uc_get_str(struct ucmsg* msg, int key);
struct ucattr* uc_sub(struct ucattr* at, int key);
void* uc_sub_bin(struct ucattr* at, int key, int len);
int* uc_sub_int(struct ucattr* at, int key);
char* uc_sub_str(struct ucattr* at, int key);
void* uc_is_bin(struct ucattr* at, int key, int len);
int* uc_is_int(struct ucattr* at, int key);
char* uc_is_str(struct ucattr* at, int key);
struct ucattr* uc_is_nest(struct ucattr* at, int key);
void* uc_payload(struct ucattr* at);
int uc_paylen(struct ucattr* at);
void uc_dump(struct ucmsg* msg);
int uc_recv(int fd, struct urbuf* ur, int block);
int uc_recvmsg(int fd, struct urbuf* ur, struct ucbuf* uc, int block);