]> granicus.if.org Git - strace/blob - nlattr.h
xlat: add BPF_F_TEST_STATE_FREQ to bpf_prog_flags
[strace] / nlattr.h
1 /*
2  * Copyright (c) 2016 Fabien Siron <fabien.siron@epita.fr>
3  * Copyright (c) 2017 JingPiao Chen <chenjingpiao@gmail.com>
4  * Copyright (c) 2016-2018 The strace developers.
5  * All rights reserved.
6  *
7  * SPDX-License-Identifier: LGPL-2.1-or-later
8  */
9
10 #ifndef STRACE_NLATTR_H
11 # define STRACE_NLATTR_H
12
13 # include "xlat.h"
14
15 struct decode_nla_xlat_opts {
16         const struct xlat *xlat;
17         const char *dflt;
18         enum xlat_style style;
19         const char *prefix;
20         const char *suffix;
21         uint64_t (*process_fn)(uint64_t val);
22         size_t size;
23 };
24
25 /*
26  * Used for IFLA_LINKINFO decoding.  Since there are no other indicators
27  * regarding the nature of data except for previously provided string
28  * in an IFLA_LINKINFO_KIND attribute, we have to store it in order to pass
29  * between calls as an opaque data.
30  */
31 struct ifla_linkinfo_ctx {
32         char kind[16];
33 };
34
35 typedef bool (*nla_decoder_t)(struct tcb *, kernel_ulong_t addr,
36                               unsigned int len, const void *opaque_data);
37
38 /**
39  * The case of non-NULL decoders and zero size is handled in a special way:
40  * the zeroth decoder is always called with nla_type being passed as opaque
41  * data.
42  */
43 extern void
44 decode_nlattr(struct tcb *,
45               kernel_ulong_t addr,
46               unsigned int len,
47               const struct xlat *,
48               const char *dflt,
49               const nla_decoder_t *decoders,
50               unsigned int size,
51               const void *opaque_data);
52
53 # define DECL_NLA(name)                                 \
54 extern bool                                             \
55 decode_nla_ ## name(struct tcb *, kernel_ulong_t addr,  \
56                     unsigned int len, const void *)     \
57 /* End of DECL_NLA definition. */
58
59 DECL_NLA(x8);
60 DECL_NLA(x16);
61 DECL_NLA(x32);
62 DECL_NLA(x64);
63 DECL_NLA(u8);
64 DECL_NLA(u16);
65 DECL_NLA(u32);
66 DECL_NLA(u64);
67 DECL_NLA(s8);
68 DECL_NLA(s16);
69 DECL_NLA(s32);
70 DECL_NLA(s64);
71 DECL_NLA(be16);
72 DECL_NLA(be64);
73 DECL_NLA(xval);
74 DECL_NLA(flags);
75 DECL_NLA(str);
76 DECL_NLA(strn);
77 DECL_NLA(fd);
78 DECL_NLA(uid);
79 DECL_NLA(gid);
80 DECL_NLA(ifindex);
81 DECL_NLA(ether_proto);
82 DECL_NLA(ip_proto);
83 DECL_NLA(in_addr);
84 DECL_NLA(in6_addr);
85 DECL_NLA(meminfo);
86 DECL_NLA(rt_class);
87 DECL_NLA(rt_proto);
88 DECL_NLA(tc_stats);
89
90 #endif /* !STRACE_NLATTR_H */