NCDInterfaceMonitor.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * @file NCDInterfaceMonitor.h
  3. * @author Ambroz Bizjak <ambrop7@gmail.com>
  4. *
  5. * @section LICENSE
  6. *
  7. * This file is part of BadVPN.
  8. *
  9. * BadVPN is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2
  11. * as published by the Free Software Foundation.
  12. *
  13. * BadVPN is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, write to the Free Software Foundation, Inc.,
  20. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  21. */
  22. #ifndef BADVPN_NCD_NCDINTERFACEMONITOR_H
  23. #define BADVPN_NCD_NCDINTERFACEMONITOR_H
  24. #include <sys/socket.h>
  25. #include <linux/netlink.h>
  26. #include <misc/debug.h>
  27. #include <system/DebugObject.h>
  28. #include <system/BReactor.h>
  29. #include <system/BPending.h>
  30. #include <ncd/NCDIfConfig.h>
  31. typedef void (*NCDInterfaceMonitor_handler) (void *user, const char *ifname, int if_flags);
  32. typedef struct {
  33. BReactor *reactor;
  34. NCDInterfaceMonitor_handler handler;
  35. void *user;
  36. int netlink_fd;
  37. BFileDescriptor bfd;
  38. uint8_t buf[4096];
  39. struct nlmsghdr *buf_nh;
  40. int buf_left;
  41. BPending more_job;
  42. DebugObject d_obj;
  43. } NCDInterfaceMonitor;
  44. int NCDInterfaceMonitor_Init (NCDInterfaceMonitor *o, BReactor *reactor, NCDInterfaceMonitor_handler handler, void *user) WARN_UNUSED;
  45. void NCDInterfaceMonitor_Free (NCDInterfaceMonitor *o);
  46. #endif