netlinkaccess.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* Copyright (C) 2004-2019 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <http://www.gnu.org/licenses/>. */
  14. #ifndef _NETLINKACCESS_H
  15. #define _NETLINKACCESS_H 1
  16. #include <stdint.h>
  17. #include <sys/types.h>
  18. #include <asm/types.h>
  19. #include <linux/netlink.h>
  20. #include <linux/rtnetlink.h>
  21. struct netlink_res
  22. {
  23. struct netlink_res *next;
  24. struct nlmsghdr *nlh;
  25. size_t size; /* Size of response. */
  26. uint32_t seq; /* sequential number we used. */
  27. };
  28. struct netlink_handle
  29. {
  30. int fd; /* Netlink file descriptor. */
  31. pid_t pid; /* Process ID. */
  32. uint32_t seq; /* The sequence number we use currently. */
  33. struct netlink_res *nlm_list; /* Pointer to list of responses. */
  34. struct netlink_res *end_ptr; /* For faster append of new entries. */
  35. };
  36. extern int __netlink_open (struct netlink_handle *h) attribute_hidden;
  37. extern void __netlink_close (struct netlink_handle *h) attribute_hidden;
  38. extern void __netlink_free_handle (struct netlink_handle *h)
  39. attribute_hidden;
  40. extern int __netlink_request (struct netlink_handle *h, int type)
  41. attribute_hidden;
  42. /* Terminate the process if RESULT is an invalid recvmsg result for
  43. the netlink socket FD. */
  44. void __netlink_assert_response (int fd, ssize_t result);
  45. libc_hidden_proto (__netlink_assert_response)
  46. #endif /* netlinkaccess.h */