NCDInterfaceModule.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /**
  2. * @file NCDInterfaceModule.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_NCDINTERFACEMODULE_H
  23. #define BADVPN_NCD_NCDINTERFACEMODULE_H
  24. #include <stdarg.h>
  25. #include <system/BReactor.h>
  26. #include <system/BLog.h>
  27. #include <system/BProcess.h>
  28. #include <system/BPending.h>
  29. #include <ncdconfig/NCDConfig.h>
  30. #include <generated/blog_channel_ncd.h>
  31. #define NCDINTERFACEMODULE_EVENT_UP 1
  32. #define NCDINTERFACEMODULE_EVENT_DOWN 2
  33. typedef void (*NCDInterfaceModule_handler_event) (void *user, int event);
  34. typedef void (*NCDInterfaceModule_handler_error) (void *user);
  35. struct NCDInterfaceModule;
  36. typedef struct {
  37. const struct NCDInterfaceModule *m;
  38. BReactor *reactor;
  39. BProcessManager *manager;
  40. struct NCDConfig_interfaces *conf;
  41. NCDInterfaceModule_handler_event handler_event;
  42. NCDInterfaceModule_handler_error handler_error;
  43. void *user;
  44. BPending event_job;
  45. BPending finish_job;
  46. int up;
  47. int finishing;
  48. void *inst_user;
  49. DebugObject d_obj;
  50. #ifndef NDEBUG
  51. dead_t d_dead;
  52. #endif
  53. } NCDInterfaceModuleInst;
  54. int NCDInterfaceModuleInst_Init (
  55. NCDInterfaceModuleInst *n, const struct NCDInterfaceModule *m, BReactor *reactor, BProcessManager *manager,
  56. struct NCDConfig_interfaces *conf, NCDInterfaceModule_handler_event handler_event,
  57. NCDInterfaceModule_handler_error handler_error,
  58. void *user
  59. );
  60. void NCDInterfaceModuleInst_Free (NCDInterfaceModuleInst *n);
  61. void NCDInterfaceModuleInst_Finish (NCDInterfaceModuleInst *n);
  62. void NCDInterfaceModuleInst_Backend_Event (NCDInterfaceModuleInst *n, int event);
  63. void NCDInterfaceModuleInst_Backend_Error (NCDInterfaceModuleInst *n);
  64. void NCDInterfaceModuleInst_Backend_Log (NCDInterfaceModuleInst *n, int level, const char *fmt, ...);
  65. typedef void * (*NCDInterfaceModule_func_new) (NCDInterfaceModuleInst *params);
  66. typedef void (*NCDInterfaceModule_func_free) (void *o);
  67. typedef void (*NCDInterfaceModule_func_finish) (void *o);
  68. struct NCDInterfaceModule {
  69. const char *type;
  70. NCDInterfaceModule_func_new func_new;
  71. NCDInterfaceModule_func_free func_free;
  72. NCDInterfaceModule_func_finish func_finish;
  73. };
  74. #endif