command_template.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * @file command_template.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. * @section DESCRIPTION
  23. *
  24. * Template for a module which executes a command to start and stop.
  25. * The command is executed asynchronously.
  26. */
  27. #ifndef BADVPN_NCD_MODULES_COMMAND_TEMPLATE_H
  28. #define BADVPN_NCD_MODULES_COMMAND_TEMPLATE_H
  29. #include <misc/cmdline.h>
  30. #include <ncd/BEventLock.h>
  31. #include <ncd/NCDModule.h>
  32. #include <generated/blog_channel_ncd_net_iptables.h>
  33. typedef int (*command_template_build_cmdline) (NCDModuleInst *i, int remove, char **exec, CmdLine *cl);
  34. typedef void (*command_template_free_func) (void *user, int is_error);
  35. typedef struct {
  36. NCDModuleInst *i;
  37. command_template_build_cmdline build_cmdline;
  38. command_template_free_func free_func;
  39. void *user;
  40. int blog_channel;
  41. char *do_exec;
  42. CmdLine do_cmdline;
  43. char *undo_exec;
  44. CmdLine undo_cmdline;
  45. BEventLockJob elock_job;
  46. int state;
  47. int have_process;
  48. BProcess process;
  49. } command_template_instance;
  50. void command_template_new (command_template_instance *o, NCDModuleInst *i, command_template_build_cmdline build_cmdline, command_template_free_func free_func, void *user, int blog_channel, BEventLock *elock);
  51. void command_template_die (command_template_instance *o);
  52. #endif