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.1KB

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