|
| 1 | +// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) |
| 2 | +/* Do not edit directly, auto-generated from: */ |
| 3 | +/* Documentation/netlink/specs/binder.yaml */ |
| 4 | +/* YNL-GEN user source */ |
| 5 | + |
| 6 | +#include <stdlib.h> |
| 7 | +#include <string.h> |
| 8 | +#include "binder-user.h" |
| 9 | +#include "ynl.h" |
| 10 | +#include <linux/android/binder_netlink.h> |
| 11 | + |
| 12 | +#include <linux/genetlink.h> |
| 13 | + |
| 14 | +/* Enums */ |
| 15 | +static const char * const binder_op_strmap[] = { |
| 16 | + [BINDER_CMD_REPORT] = "report", |
| 17 | +}; |
| 18 | + |
| 19 | +const char *binder_op_str(int op) |
| 20 | +{ |
| 21 | + if (op < 0 || op >= (int)YNL_ARRAY_SIZE(binder_op_strmap)) |
| 22 | + return NULL; |
| 23 | + return binder_op_strmap[op]; |
| 24 | +} |
| 25 | + |
| 26 | +/* Policies */ |
| 27 | +const struct ynl_policy_attr binder_report_policy[BINDER_A_REPORT_MAX + 1] = { |
| 28 | + [BINDER_A_REPORT_ERROR] = { .name = "error", .type = YNL_PT_U32, }, |
| 29 | + [BINDER_A_REPORT_CONTEXT] = { .name = "context", .type = YNL_PT_NUL_STR, }, |
| 30 | + [BINDER_A_REPORT_FROM_PID] = { .name = "from-pid", .type = YNL_PT_U32, }, |
| 31 | + [BINDER_A_REPORT_FROM_TID] = { .name = "from-tid", .type = YNL_PT_U32, }, |
| 32 | + [BINDER_A_REPORT_TO_PID] = { .name = "to-pid", .type = YNL_PT_U32, }, |
| 33 | + [BINDER_A_REPORT_TO_TID] = { .name = "to-tid", .type = YNL_PT_U32, }, |
| 34 | + [BINDER_A_REPORT_IS_REPLY] = { .name = "is-reply", .type = YNL_PT_FLAG, }, |
| 35 | + [BINDER_A_REPORT_FLAGS] = { .name = "flags", .type = YNL_PT_U32, }, |
| 36 | + [BINDER_A_REPORT_CODE] = { .name = "code", .type = YNL_PT_U32, }, |
| 37 | + [BINDER_A_REPORT_DATA_SIZE] = { .name = "data-size", .type = YNL_PT_U32, }, |
| 38 | +}; |
| 39 | + |
| 40 | +const struct ynl_policy_nest binder_report_nest = { |
| 41 | + .max_attr = BINDER_A_REPORT_MAX, |
| 42 | + .table = binder_report_policy, |
| 43 | +}; |
| 44 | + |
| 45 | +/* Common nested types */ |
| 46 | +/* BINDER_CMD_REPORT - event */ |
| 47 | +int binder_report_rsp_parse(const struct nlmsghdr *nlh, |
| 48 | + struct ynl_parse_arg *yarg) |
| 49 | +{ |
| 50 | + struct binder_report_rsp *dst; |
| 51 | + const struct nlattr *attr; |
| 52 | + unsigned int len; |
| 53 | + |
| 54 | + dst = yarg->data; |
| 55 | + |
| 56 | + ynl_attr_for_each(attr, nlh, yarg->ys->family->hdr_len) { |
| 57 | + unsigned int type = ynl_attr_type(attr); |
| 58 | + |
| 59 | + if (type == BINDER_A_REPORT_ERROR) { |
| 60 | + if (ynl_attr_validate(yarg, attr)) |
| 61 | + return YNL_PARSE_CB_ERROR; |
| 62 | + dst->_present.error = 1; |
| 63 | + dst->error = ynl_attr_get_u32(attr); |
| 64 | + } else if (type == BINDER_A_REPORT_CONTEXT) { |
| 65 | + if (ynl_attr_validate(yarg, attr)) |
| 66 | + return YNL_PARSE_CB_ERROR; |
| 67 | + |
| 68 | + len = strnlen(ynl_attr_get_str(attr), ynl_attr_data_len(attr)); |
| 69 | + dst->_len.context = len; |
| 70 | + dst->context = malloc(len + 1); |
| 71 | + memcpy(dst->context, ynl_attr_get_str(attr), len); |
| 72 | + dst->context[len] = 0; |
| 73 | + } else if (type == BINDER_A_REPORT_FROM_PID) { |
| 74 | + if (ynl_attr_validate(yarg, attr)) |
| 75 | + return YNL_PARSE_CB_ERROR; |
| 76 | + dst->_present.from_pid = 1; |
| 77 | + dst->from_pid = ynl_attr_get_u32(attr); |
| 78 | + } else if (type == BINDER_A_REPORT_FROM_TID) { |
| 79 | + if (ynl_attr_validate(yarg, attr)) |
| 80 | + return YNL_PARSE_CB_ERROR; |
| 81 | + dst->_present.from_tid = 1; |
| 82 | + dst->from_tid = ynl_attr_get_u32(attr); |
| 83 | + } else if (type == BINDER_A_REPORT_TO_PID) { |
| 84 | + if (ynl_attr_validate(yarg, attr)) |
| 85 | + return YNL_PARSE_CB_ERROR; |
| 86 | + dst->_present.to_pid = 1; |
| 87 | + dst->to_pid = ynl_attr_get_u32(attr); |
| 88 | + } else if (type == BINDER_A_REPORT_TO_TID) { |
| 89 | + if (ynl_attr_validate(yarg, attr)) |
| 90 | + return YNL_PARSE_CB_ERROR; |
| 91 | + dst->_present.to_tid = 1; |
| 92 | + dst->to_tid = ynl_attr_get_u32(attr); |
| 93 | + } else if (type == BINDER_A_REPORT_IS_REPLY) { |
| 94 | + if (ynl_attr_validate(yarg, attr)) |
| 95 | + return YNL_PARSE_CB_ERROR; |
| 96 | + dst->_present.is_reply = 1; |
| 97 | + } else if (type == BINDER_A_REPORT_FLAGS) { |
| 98 | + if (ynl_attr_validate(yarg, attr)) |
| 99 | + return YNL_PARSE_CB_ERROR; |
| 100 | + dst->_present.flags = 1; |
| 101 | + dst->flags = ynl_attr_get_u32(attr); |
| 102 | + } else if (type == BINDER_A_REPORT_CODE) { |
| 103 | + if (ynl_attr_validate(yarg, attr)) |
| 104 | + return YNL_PARSE_CB_ERROR; |
| 105 | + dst->_present.code = 1; |
| 106 | + dst->code = ynl_attr_get_u32(attr); |
| 107 | + } else if (type == BINDER_A_REPORT_DATA_SIZE) { |
| 108 | + if (ynl_attr_validate(yarg, attr)) |
| 109 | + return YNL_PARSE_CB_ERROR; |
| 110 | + dst->_present.data_size = 1; |
| 111 | + dst->data_size = ynl_attr_get_u32(attr); |
| 112 | + } |
| 113 | + } |
| 114 | + |
| 115 | + return YNL_PARSE_CB_OK; |
| 116 | +} |
| 117 | + |
| 118 | +void binder_report_free(struct binder_report *rsp) |
| 119 | +{ |
| 120 | + free(rsp->obj.context); |
| 121 | + free(rsp); |
| 122 | +} |
| 123 | + |
| 124 | +static const struct ynl_ntf_info binder_ntf_info[] = { |
| 125 | + [BINDER_CMD_REPORT] = { |
| 126 | + .alloc_sz = sizeof(struct binder_report), |
| 127 | + .cb = binder_report_rsp_parse, |
| 128 | + .policy = &binder_report_nest, |
| 129 | + .free = (void *)binder_report_free, |
| 130 | + }, |
| 131 | +}; |
| 132 | + |
| 133 | +const struct ynl_family ynl_binder_family = { |
| 134 | + .name = "binder", |
| 135 | + .hdr_len = sizeof(struct genlmsghdr), |
| 136 | + .ntf_info = binder_ntf_info, |
| 137 | + .ntf_info_size = YNL_ARRAY_SIZE(binder_ntf_info), |
| 138 | +}; |
0 commit comments