batadv-netlink.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright (C) 2009-2016 B.A.T.M.A.N. contributors:
  3. *
  4. * Marek Lindner <mareklindner@neomailbox.ch>, Andrew Lunn <andrew@lunn.ch>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of version 2 of the GNU General Public
  8. * License as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  18. * 02110-1301, USA
  19. *
  20. */
  21. #ifndef _BATADV_NETLINK_H
  22. #define _BATADV_NETLINK_H
  23. #include <netlink/netlink.h>
  24. #include <netlink/genl/genl.h>
  25. #include <netlink/genl/ctrl.h>
  26. #include <stddef.h>
  27. #include <stdbool.h>
  28. #include "batman_adv.h"
  29. struct batadv_nlquery_opts {
  30. int err;
  31. };
  32. #ifndef ARRAY_SIZE
  33. #define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
  34. #endif
  35. #ifndef container_of
  36. #define container_of(ptr, type, member) __extension__ ({ \
  37. const __typeof__(((type *)0)->member) *__pmember = (ptr); \
  38. (type *)((char *)__pmember - offsetof(type, member)); })
  39. #endif
  40. int batadv_nl_query_common(const char *mesh_iface,
  41. enum batadv_nl_commands nl_cmd,
  42. nl_recvmsg_msg_cb_t callback, int flags,
  43. struct batadv_nlquery_opts *query_opts);
  44. static inline bool batadv_nl_missing_attrs(struct nlattr *attrs[],
  45. const enum batadv_nl_attrs mandatory[],
  46. size_t num)
  47. {
  48. size_t i;
  49. for (i = 0; i < num; i++) {
  50. if (!attrs[mandatory[i]])
  51. return true;
  52. }
  53. return false;
  54. }
  55. extern struct nla_policy batadv_netlink_policy[];
  56. #endif /* _BATADV_NETLINK_H */