| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
#ifndef _TC_QEVENT_H_ |
| 3 |
#define _TC_QEVENT_H_ |
| 4 |
|
| 5 |
#include <stdbool.h> |
| 6 |
#include <linux/types.h> |
| 7 |
#include <libnetlink.h> |
| 8 |
|
| 9 |
struct qevent_base { |
| 10 |
__u32 block_idx; |
| 11 |
}; |
| 12 |
|
| 13 |
struct qevent_util { |
| 14 |
const char *id; |
| 15 |
int (*parse_qevent)(struct qevent_util *qu, int *argc, char ***argv); |
| 16 |
int (*read_qevent)(struct qevent_util *qu, struct rtattr **tb); |
| 17 |
void (*print_qevent)(struct qevent_util *qu, FILE *f); |
| 18 |
int (*dump_qevent)(struct qevent_util *qu, struct nlmsghdr *n); |
| 19 |
size_t data_size; |
| 20 |
void *data; |
| 21 |
int attr; |
| 22 |
}; |
| 23 |
|
| 24 |
#define QEVENT(_name, _form, _data, _attr) \ |
| 25 |
{ \ |
| 26 |
.id = _name, \ |
| 27 |
.parse_qevent = qevent_parse_##_form, \ |
| 28 |
.read_qevent = qevent_read_##_form, \ |
| 29 |
.print_qevent = qevent_print_##_form, \ |
| 30 |
.dump_qevent = qevent_dump_##_form, \ |
| 31 |
.data_size = sizeof(struct qevent_##_form), \ |
| 32 |
.data = _data, \ |
| 33 |
.attr = _attr, \ |
| 34 |
} |
| 35 |
|
| 36 |
void qevents_init(struct qevent_util *qevents); |
| 37 |
int qevent_parse(struct qevent_util *qevents, int *p_argc, char ***p_argv); |
| 38 |
int qevents_read(struct qevent_util *qevents, struct rtattr **tb); |
| 39 |
int qevents_dump(struct qevent_util *qevents, struct nlmsghdr *n); |
| 40 |
void qevents_print(struct qevent_util *qevents, FILE *f); |
| 41 |
bool qevents_have_block(struct qevent_util *qevents, __u32 block_idx); |
| 42 |
|
| 43 |
struct qevent_plain { |
| 44 |
struct qevent_base base; |
| 45 |
}; |
| 46 |
int qevent_parse_plain(struct qevent_util *qu, int *p_argc, char ***p_argv); |
| 47 |
int qevent_read_plain(struct qevent_util *qu, struct rtattr **tb); |
| 48 |
void qevent_print_plain(struct qevent_util *qu, FILE *f); |
| 49 |
int qevent_dump_plain(struct qevent_util *qu, struct nlmsghdr *n); |
| 50 |
|
| 51 |
#endif |