dns hijacker code review
[oweals/gnunet.git] / src / vpn / gnunet-helper-vpn-api.h
1 /*
2      This file is part of GNUnet.
3      (C) 2010 Christian Grothoff
4
5      GNUnet is free software; you can redistribute it and/or modify
6      it under the terms of the GNU General Public License as published
7      by the Free Software Foundation; either version 3, or (at your
8      option) any later version.
9
10      GNUnet 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 GNUnet; see the file COPYING.  If not, write to the
17      Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18      Boston, MA 02111-1307, USA.
19 */
20
21 /**
22  * @file vpn/gnunet-helper-vpn-api.h
23  * @brief exposes the API (the convenience-functions) of dealing with the
24  *        helper-vpn
25  * @author Philipp Toelke
26  */
27 #ifndef GNUNET_HELPER_VPN_API_H
28 #define GNUNET_HELPER_VPN_API_H
29
30 /**
31  * The handle to a helper.
32  * sometimes a few entries may be made opaque.
33  */
34 struct GNUNET_VPN_HELPER_Handle
35 {
36 /**
37  * PipeHandle to receive data from the helper
38  */
39   struct GNUNET_DISK_PipeHandle *helper_in;
40
41 /**
42  * PipeHandle to send data to the helper
43  */
44   struct GNUNET_DISK_PipeHandle *helper_out;
45
46 /**
47  * FileHandle to receive data from the helper
48  */
49   const struct GNUNET_DISK_FileHandle *fh_from_helper;
50
51 /**
52  * FileHandle to send data to the helper
53  */
54   const struct GNUNET_DISK_FileHandle *fh_to_helper;
55
56   /**
57    * The process id of the helper
58    */
59   struct GNUNET_OS_Process *helper_proc;
60
61   /**
62    * The Message-Tokenizer that tokenizes the messages comming from the helper
63    */
64   struct GNUNET_SERVER_MessageStreamTokenizer *mst;
65
66   /**
67    * The client-identifier passed to the mst-callback
68    */
69   void *client;
70
71   /**
72    * The name of the interface
73    */
74   char *ifname;
75
76   /**
77    * The task called when the helper dies.
78    * Will be called with the handle as cls
79    */
80   GNUNET_SCHEDULER_Task restart_task;
81 };
82
83 /**
84  * @brief Starts a helper and begins reading from it
85  *
86  * @param ifname The name of the new interface
87  * @param ipv6addr The IPv6 address of the new interface
88  * @param ipv6prefix The IPv6 prefix length of the new IP
89  * @param ipv4addr The IPv4 address of the new interface
90  * @param ipv4mask The associated netmask
91  * @param process_name How the helper should appear in process-listings
92  * @param restart_task The task called when the helper dies. Will be called with the handle as cls
93  * @param cb A callback for messages from the helper
94  * @param cb_cls Closure for the callback
95  *
96  * @return A pointer to the new Handle, NULL on error
97  */
98 struct GNUNET_VPN_HELPER_Handle *
99 start_helper (const char *ifname, const char *ipv6addr, const char *ipv6prefix,
100               const char *ipv4addr, const char *ipv4mask,
101               const char *process_name, GNUNET_SCHEDULER_Task restart_task,
102               GNUNET_SERVER_MessageTokenizerCallback cb, void *cb_cls);
103
104 /**
105  * @brief Kills the helper, closes the pipe and free()s the handle
106  */
107 void
108 cleanup_helper (struct GNUNET_VPN_HELPER_Handle *);
109
110 #endif /* end of include guard: GNUNET_HELPER_VPN_API_H */