(root)/
strace-6.5/
src/
netlink.h
       1  /*
       2   * Copyright (c) 2017 JingPiao Chen <chenjingpiao@gmail.com>
       3   * Copyright (c) 2017-2021 The strace developers.
       4   * All rights reserved.
       5   *
       6   * SPDX-License-Identifier: LGPL-2.1-or-later
       7   */
       8  
       9  #ifndef STRACE_NETLINK_H
      10  # define STRACE_NETLINK_H
      11  
      12  # include <stdbool.h>
      13  # include <sys/socket.h>
      14  # include <linux/netlink.h>
      15  
      16  # undef NLMSG_HDRLEN
      17  # define NLMSG_HDRLEN ((unsigned int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
      18  
      19  # undef NLA_HDRLEN
      20  # define NLA_HDRLEN ((unsigned int) NLA_ALIGN(sizeof(struct nlattr)))
      21  
      22  static inline bool
      23  is_nlmsg_ok(const struct nlmsghdr *const nlh, const ssize_t len)
      24  {
      25  	return len >= (ssize_t) sizeof(*nlh)
      26  	       && nlh->nlmsg_len >= sizeof(*nlh)
      27  	       && (size_t) len >= nlh->nlmsg_len;
      28  }
      29  
      30  #endif /* !STRACE_NETLINK_H */