netlink.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * netlink/netlink.h Netlink Interface
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation version 2.1
  7. * of the License.
  8. *
  9. * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
  10. */
  11. #ifndef NETLINK_NETLINK_H_
  12. #define NETLINK_NETLINK_H_
  13. #include <stdio.h>
  14. #include <stdint.h>
  15. #include <string.h>
  16. #include <stdlib.h>
  17. #include <poll.h>
  18. #include <sys/socket.h>
  19. #include <sys/types.h>
  20. #include <sys/time.h>
  21. #include <netdb.h>
  22. #include <netlink/netlink-compat.h>
  23. #include <linux/netlink.h>
  24. #include <linux/genetlink.h>
  25. #include <netlink/version.h>
  26. #include <netlink/errno.h>
  27. #include <netlink/types.h>
  28. #include <netlink/handlers.h>
  29. #include <netlink/socket.h>
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. extern int nl_debug;
  34. extern struct nl_dump_params nl_debug_dp;
  35. /* Connection Management */
  36. extern int nl_connect(struct nl_sock *, int);
  37. extern void nl_close(struct nl_sock *);
  38. /* Send */
  39. extern int nl_sendto(struct nl_sock *, void *, size_t);
  40. extern int nl_sendmsg(struct nl_sock *, struct nl_msg *,
  41. struct msghdr *);
  42. extern int nl_send(struct nl_sock *, struct nl_msg *);
  43. extern int nl_send_auto_complete(struct nl_sock *,
  44. struct nl_msg *);
  45. extern int nl_send_simple(struct nl_sock *, int, int,
  46. void *, size_t);
  47. /* Receive */
  48. extern int nl_recv(struct nl_sock *,
  49. struct sockaddr_nl *, unsigned char **,
  50. struct ucred **);
  51. extern int nl_recvmsgs(struct nl_sock *sk, struct nl_cb *cb);
  52. extern int nl_wait_for_ack(struct nl_sock *);
  53. /* Netlink Family Translations */
  54. extern char * nl_nlfamily2str(int, char *, size_t);
  55. extern int nl_str2nlfamily(const char *);
  56. /**
  57. * Receive a set of message from a netlink socket using handlers in nl_sock.
  58. * @arg sk Netlink socket.
  59. *
  60. * Calls nl_recvmsgs() with the handlers configured in the netlink socket.
  61. */
  62. static inline int nl_recvmsgs_default(struct nl_sock *sk)
  63. {
  64. return nl_recvmsgs(sk, sk->s_cb);
  65. }
  66. #ifdef __cplusplus
  67. }
  68. #endif
  69. #endif