diff --git a/home/nipa/nipa_out/903745/ynl/new-code/binder_genl-user.c b/home/nipa/nipa_out/903745/ynl/new-code/binder_genl-user.c new file mode 100644 index 000000000000..822a6e7b71a4 --- /dev/null +++ b/home/nipa/nipa_out/903745/ynl/new-code/binder_genl-user.c @@ -0,0 +1,131 @@ +// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/binder_genl.yaml */ +/* YNL-GEN user source */ + +#include +#include +#include "binder_genl-user.h" +#include "ynl.h" +#include + +#include + +/* Enums */ +static const char * const binder_genl_op_strmap[] = { + [BINDER_GENL_CMD_SET] = "set", + [BINDER_GENL_CMD_REPLY] = "reply", + [BINDER_GENL_CMD_REPORT] = "report", +}; + +const char *binder_genl_op_str(int op) +{ + if (op < 0 || op >= (int)YNL_ARRAY_SIZE(binder_genl_op_strmap)) + return NULL; + return binder_genl_op_strmap[op]; +} + +static const char * const binder_genl_flag_strmap[] = { + [0] = "failed", + [1] = "delayed", + [2] = "spam", + [3] = "override", +}; + +const char *binder_genl_flag_str(enum binder_genl_flag value) +{ + value = ffs(value) - 1; + if (value < 0 || value >= (int)YNL_ARRAY_SIZE(binder_genl_flag_strmap)) + return NULL; + return binder_genl_flag_strmap[value]; +} + +/* Policies */ +const struct ynl_policy_attr binder_genl_attr_policy[BINDER_GENL_A_ATTR_MAX + 1] = { + [BINDER_GENL_A_ATTR_PID] = { .name = "pid", .type = YNL_PT_U32, }, + [BINDER_GENL_A_ATTR_FLAGS] = { .name = "flags", .type = YNL_PT_U32, }, + [BINDER_GENL_A_ATTR_REPORT] = { .name = "report", .type = YNL_PT_BINARY,}, +}; + +const struct ynl_policy_nest binder_genl_attr_nest = { + .max_attr = BINDER_GENL_A_ATTR_MAX, + .table = binder_genl_attr_policy, +}; + +/* Common nested types */ +/* ============== BINDER_GENL_CMD_SET ============== */ +/* BINDER_GENL_CMD_SET - do */ +void binder_genl_set_req_free(struct binder_genl_set_req *req) +{ + free(req); +} + +void binder_genl_set_rsp_free(struct binder_genl_set_rsp *rsp) +{ + free(rsp); +} + +int binder_genl_set_rsp_parse(const struct nlmsghdr *nlh, + struct ynl_parse_arg *yarg) +{ + struct binder_genl_set_rsp *dst; + const struct nlattr *attr; + + dst = yarg->data; + + ynl_attr_for_each(attr, nlh, yarg->ys->family->hdr_len) { + unsigned int type = ynl_attr_type(attr); + + if (type == BINDER_GENL_A_ATTR_PID) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.pid = 1; + dst->pid = ynl_attr_get_u32(attr); + } else if (type == BINDER_GENL_A_ATTR_FLAGS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.flags = 1; + dst->flags = ynl_attr_get_u32(attr); + } + } + + return YNL_PARSE_CB_OK; +} + +struct binder_genl_set_rsp * +binder_genl_set(struct ynl_sock *ys, struct binder_genl_set_req *req) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct binder_genl_set_rsp *rsp; + struct nlmsghdr *nlh; + int err; + + nlh = ynl_gemsg_start_req(ys, ys->family_id, BINDER_GENL_CMD_SET, 1); + ys->req_policy = &binder_genl_attr_nest; + yrs.yarg.rsp_policy = &binder_genl_attr_nest; + + if (req->_present.pid) + ynl_attr_put_u32(nlh, BINDER_GENL_A_ATTR_PID, req->pid); + if (req->_present.flags) + ynl_attr_put_u32(nlh, BINDER_GENL_A_ATTR_FLAGS, req->flags); + + rsp = calloc(1, sizeof(*rsp)); + yrs.yarg.data = rsp; + yrs.cb = binder_genl_set_rsp_parse; + yrs.rsp_cmd = BINDER_GENL_CMD_SET; + + err = ynl_exec(ys, nlh, &yrs); + if (err < 0) + goto err_free; + + return rsp; + +err_free: + binder_genl_set_rsp_free(rsp); + return NULL; +} + +const struct ynl_family ynl_binder_genl_family = { + .name = "binder_genl", + .hdr_len = sizeof(struct genlmsghdr), +}; diff --git a/home/nipa/nipa_out/903745/ynl/new-code/binder_genl-user.h b/home/nipa/nipa_out/903745/ynl/new-code/binder_genl-user.h new file mode 100644 index 000000000000..fd9583779add --- /dev/null +++ b/home/nipa/nipa_out/903745/ynl/new-code/binder_genl-user.h @@ -0,0 +1,74 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/binder_genl.yaml */ +/* YNL-GEN user header */ + +#ifndef _LINUX_BINDER_GENL_GEN_H +#define _LINUX_BINDER_GENL_GEN_H + +#include +#include +#include +#include + +struct ynl_sock; + +extern const struct ynl_family ynl_binder_genl_family; + +/* Enums */ +const char *binder_genl_op_str(int op); +const char *binder_genl_flag_str(enum binder_genl_flag value); + +/* Common nested types */ +/* ============== BINDER_GENL_CMD_SET ============== */ +/* BINDER_GENL_CMD_SET - do */ +struct binder_genl_set_req { + struct { + __u32 pid:1; + __u32 flags:1; + } _present; + + __u32 pid; + __u32 flags; +}; + +static inline struct binder_genl_set_req *binder_genl_set_req_alloc(void) +{ + return calloc(1, sizeof(struct binder_genl_set_req)); +} +void binder_genl_set_req_free(struct binder_genl_set_req *req); + +static inline void +binder_genl_set_req_set_pid(struct binder_genl_set_req *req, __u32 pid) +{ + req->_present.pid = 1; + req->pid = pid; +} +static inline void +binder_genl_set_req_set_flags(struct binder_genl_set_req *req, __u32 flags) +{ + req->_present.flags = 1; + req->flags = flags; +} + +struct binder_genl_set_rsp { + struct { + __u32 pid:1; + __u32 flags:1; + } _present; + + __u32 pid; + __u32 flags; +}; + +void binder_genl_set_rsp_free(struct binder_genl_set_rsp *rsp); + +/* + * Set flags from user space, requesting what kinds of binder +transactions to report. + + */ +struct binder_genl_set_rsp * +binder_genl_set(struct ynl_sock *ys, struct binder_genl_set_req *req); + +#endif /* _LINUX_BINDER_GENL_GEN_H */