diff options
author | Philipp Tölke <toelke@in.tum.de> | 2011-02-02 23:02:52 +0000 |
---|---|---|
committer | Philipp Tölke <toelke@in.tum.de> | 2011-02-02 23:02:52 +0000 |
commit | ac0d240e011c27b1d660b6db05d067bf8766db73 (patch) | |
tree | a8e3192455ab15ab08b2c38f1d075751795529ff /src/vpn/gnunet-helper-vpn-api.h | |
parent | b13a84b528dc581a6c1a042317f8e9cc3874642e (diff) | |
download | gnunet-ac0d240e011c27b1d660b6db05d067bf8766db73.tar.gz gnunet-ac0d240e011c27b1d660b6db05d067bf8766db73.zip |
refactor the interface to the helper a bit to make it easier to use from -exit
Diffstat (limited to 'src/vpn/gnunet-helper-vpn-api.h')
-rw-r--r-- | src/vpn/gnunet-helper-vpn-api.h | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/src/vpn/gnunet-helper-vpn-api.h b/src/vpn/gnunet-helper-vpn-api.h new file mode 100644 index 000000000..00eb7db62 --- /dev/null +++ b/src/vpn/gnunet-helper-vpn-api.h | |||
@@ -0,0 +1,116 @@ | |||
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 | * @param client client_name for the callback | ||
96 | * | ||
97 | * @return A pointer to the new Handle, NULL on error | ||
98 | */ | ||
99 | struct GNUNET_VPN_HELPER_Handle *start_helper (const char *ifname, | ||
100 | const char *ipv6addr, | ||
101 | const char *ipv6prefix, | ||
102 | const char *ipv4addr, | ||
103 | const char *ipv4mask, | ||
104 | const char *process_name, | ||
105 | GNUNET_SCHEDULER_Task | ||
106 | restart_task, | ||
107 | GNUNET_SERVER_MessageTokenizerCallback | ||
108 | cb, void *cb_cls, | ||
109 | void *client); | ||
110 | |||
111 | /** | ||
112 | * @brief Kills the helper, closes the pipe and free()s the handle | ||
113 | */ | ||
114 | void cleanup_helper (struct GNUNET_VPN_HELPER_Handle *); | ||
115 | |||
116 | #endif /* end of include guard: GNUNET_HELPER_VPN_API_H */ | ||