NCDInterfaceMonitor.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 <linux/netlink.h>
  25. #include <ncd/NCDIfConfig.h>
  26. #include <system/DebugObject.h>
  27. #include <system/BReactor.h>
  28. #include <system/BPending.h>
  29. typedef void (*NCDInterfaceMonitor_handler) (void *user, const char *ifname, int if_flags);
  30. typedef struct {
  31. BReactor *reactor;
  32. NCDInterfaceMonitor_handler handler;
  33. void *user;
  34. int netlink_fd;
  35. BFileDescriptor bfd;
  36. uint8_t buf[4096];
  37. struct nlmsghdr *buf_nh;
  38. int buf_left;
  39. BPending more_job;
  40. DebugObject d_obj;
  41. } NCDInterfaceMonitor;
  42. int NCDInterfaceMonitor_Init (NCDInterfaceMonitor *o, BReactor *reactor, NCDInterfaceMonitor_handler handler, void *user);
  43. void NCDInterfaceMonitor_Free (NCDInterfaceMonitor *o);
  44. #endif