Mirror of strace – the linux syscall tracer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

nlattr.h 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. #ifndef STRACE_NLATTR_H
  10. # define STRACE_NLATTR_H
  11. # include "xlat.h"
  12. struct decode_nla_xlat_opts {
  13. const struct xlat *xlat;
  14. const char *dflt;
  15. enum xlat_style style;
  16. const char *prefix;
  17. const char *suffix;
  18. uint64_t (*process_fn)(uint64_t val);
  19. size_t size;
  20. };
  21. /*
  22. * Used for IFLA_LINKINFO decoding. Since there are no other indicators
  23. * regarding the nature of data except for previously provided string
  24. * in an IFLA_LINKINFO_KIND attribute, we have to store it in order to pass
  25. * between calls as an opaque data.
  26. */
  27. struct ifla_linkinfo_ctx {
  28. char kind[16];
  29. };
  30. typedef bool (*nla_decoder_t)(struct tcb *, kernel_ulong_t addr,
  31. unsigned int len, const void *opaque_data);
  32. /**
  33. * The case of non-NULL decoders and zero size is handled in a special way:
  34. * the zeroth decoder is always called with nla_type being passed as opaque
  35. * data.
  36. */
  37. extern void
  38. decode_nlattr(struct tcb *,
  39. kernel_ulong_t addr,
  40. unsigned int len,
  41. const struct xlat *,
  42. const char *dflt,
  43. const nla_decoder_t *decoders,
  44. unsigned int size,
  45. const void *opaque_data);
  46. # define DECL_NLA(name) \
  47. extern bool \
  48. decode_nla_ ## name(struct tcb *, kernel_ulong_t addr, \
  49. unsigned int len, const void *) \
  50. /* End of DECL_NLA definition. */
  51. DECL_NLA(x8);
  52. DECL_NLA(x16);
  53. DECL_NLA(x32);
  54. DECL_NLA(x64);
  55. DECL_NLA(u8);
  56. DECL_NLA(u16);
  57. DECL_NLA(u32);
  58. DECL_NLA(u64);
  59. DECL_NLA(s8);
  60. DECL_NLA(s16);
  61. DECL_NLA(s32);
  62. DECL_NLA(s64);
  63. DECL_NLA(be16);
  64. DECL_NLA(be64);
  65. DECL_NLA(xval);
  66. DECL_NLA(flags);
  67. DECL_NLA(str);
  68. DECL_NLA(strn);
  69. DECL_NLA(fd);
  70. DECL_NLA(uid);
  71. DECL_NLA(gid);
  72. DECL_NLA(ifindex);
  73. DECL_NLA(ether_proto);
  74. DECL_NLA(ip_proto);
  75. DECL_NLA(in_addr);
  76. DECL_NLA(in6_addr);
  77. DECL_NLA(meminfo);
  78. DECL_NLA(rt_class);
  79. DECL_NLA(rt_proto);
  80. DECL_NLA(tc_stats);
  81. #endif /* !STRACE_NLATTR_H */