diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-01-02 05:03:07 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-01-02 05:03:07 +0000 |
commit | b75373955d92c8ac1e9554182025843c01cbb96c (patch) | |
tree | 701cd50e4282eabc8bbd4ab622ee6e5b1d00447b /src/include/gnunet_dns_service.h | |
parent | a0ba564746ecdff082ac3982d4d911f91deb8ab7 (diff) | |
download | gnunet-b75373955d92c8ac1e9554182025843c01cbb96c.tar.gz gnunet-b75373955d92c8ac1e9554182025843c01cbb96c.zip |
-again moving towards DNS API sanity
Diffstat (limited to 'src/include/gnunet_dns_service.h')
-rw-r--r-- | src/include/gnunet_dns_service.h | 89 |
1 files changed, 64 insertions, 25 deletions
diff --git a/src/include/gnunet_dns_service.h b/src/include/gnunet_dns_service.h index c42f7787f..d697b9c16 100644 --- a/src/include/gnunet_dns_service.h +++ b/src/include/gnunet_dns_service.h | |||
@@ -37,38 +37,44 @@ | |||
37 | #include "gnunet_util_lib.h" | 37 | #include "gnunet_util_lib.h" |
38 | 38 | ||
39 | 39 | ||
40 | /** | ||
41 | * Subtypes of DNS answers. | ||
42 | */ | ||
40 | enum GNUNET_DNS_ANSWER_Subtype | 43 | enum GNUNET_DNS_ANSWER_Subtype |
41 | { | 44 | { |
42 | /** | 45 | /** |
43 | * Answers of this type contain a dns-packet that just has to be transmitted | 46 | * Answers of this type contain a dns-packet that just has to be transmitted |
44 | */ | 47 | */ |
45 | GNUNET_DNS_ANSWER_TYPE_IP, | 48 | GNUNET_DNS_ANSWER_TYPE_IP, |
46 | 49 | ||
47 | /** | 50 | /** |
48 | * Answers of this type contain an incomplete dns-packet. The IP-Address | 51 | * Answers of this type contain an incomplete dns-packet. The IP-Address |
49 | * is all 0s. The addroffset points to it. | 52 | * is all 0s. The addroffset points to it. |
50 | */ | 53 | */ |
51 | GNUNET_DNS_ANSWER_TYPE_SERVICE, | 54 | GNUNET_DNS_ANSWER_TYPE_SERVICE, |
52 | 55 | ||
53 | /** | 56 | /** |
54 | * Answers of this type contain an incomplete dns-packet as answer to a | 57 | * Answers of this type contain an incomplete dns-packet as answer to a |
55 | * PTR-Query. The resolved name is not allocated. The addroffset points to it. | 58 | * PTR-Query. The resolved name is not allocated. The addroffset points to it. |
56 | */ | 59 | */ |
57 | GNUNET_DNS_ANSWER_TYPE_REV, | 60 | GNUNET_DNS_ANSWER_TYPE_REV, |
58 | 61 | ||
59 | /** | 62 | /** |
60 | * Answers of this type contains an IP6-Address but traffic to this IP should | 63 | * Answers of this type contains an IP6-Address but traffic to this IP should |
61 | * be routed through the GNUNet. | 64 | * be routed through the GNUNet. |
62 | */ | 65 | */ |
63 | GNUNET_DNS_ANSWER_TYPE_REMOTE_AAAA, | 66 | GNUNET_DNS_ANSWER_TYPE_REMOTE_AAAA, |
64 | 67 | ||
65 | /** | 68 | /** |
66 | * Answers of this type contains an IP4-Address but traffic to this IP should | 69 | * Answers of this type contains an IP4-Address but traffic to this IP should |
67 | * be routed through the GNUNet. | 70 | * be routed through the GNUNet. |
68 | */ | 71 | */ |
69 | GNUNET_DNS_ANSWER_TYPE_REMOTE_A | 72 | GNUNET_DNS_ANSWER_TYPE_REMOTE_A |
73 | |||
70 | }; | 74 | }; |
71 | 75 | ||
76 | |||
77 | GNUNET_NETWORK_STRUCT_BEGIN | ||
72 | struct GNUNET_vpn_service_descriptor | 78 | struct GNUNET_vpn_service_descriptor |
73 | { | 79 | { |
74 | GNUNET_HashCode peer GNUNET_PACKED; | 80 | GNUNET_HashCode peer GNUNET_PACKED; |
@@ -77,7 +83,7 @@ struct GNUNET_vpn_service_descriptor | |||
77 | uint32_t service_type GNUNET_PACKED; | 83 | uint32_t service_type GNUNET_PACKED; |
78 | }; | 84 | }; |
79 | 85 | ||
80 | GNUNET_NETWORK_STRUCT_BEGIN | 86 | |
81 | struct answer_packet | 87 | struct answer_packet |
82 | { | 88 | { |
83 | /* General data */ | 89 | /* General data */ |
@@ -108,6 +114,8 @@ struct answer_packet | |||
108 | 114 | ||
109 | unsigned char data[1]; | 115 | unsigned char data[1]; |
110 | }; | 116 | }; |
117 | GNUNET_NETWORK_STRUCT_END | ||
118 | |||
111 | 119 | ||
112 | struct answer_packet_list | 120 | struct answer_packet_list |
113 | { | 121 | { |
@@ -116,18 +124,45 @@ struct answer_packet_list | |||
116 | struct GNUNET_SERVER_Client *client; | 124 | struct GNUNET_SERVER_Client *client; |
117 | struct answer_packet pkt; | 125 | struct answer_packet pkt; |
118 | }; | 126 | }; |
119 | GNUNET_NETWORK_STRUCT_END | ||
120 | 127 | ||
128 | |||
129 | /** | ||
130 | * Type of a function to be called by the DNS API whenever | ||
131 | * a DNS reply is obtained. | ||
132 | * | ||
133 | * @param cls closure | ||
134 | * @param pkt reply that we got | ||
135 | */ | ||
136 | typedef void (*GNUNET_DNS_ResponseCallback)(void *cls, | ||
137 | const struct answer_packet *pkt); | ||
138 | |||
139 | |||
140 | /** | ||
141 | * Opaque DNS handle | ||
142 | */ | ||
121 | struct GNUNET_DNS_Handle; | 143 | struct GNUNET_DNS_Handle; |
122 | 144 | ||
145 | |||
123 | /** | 146 | /** |
124 | * Connect to the service-dns | 147 | * Connect to the service-dns |
148 | * | ||
149 | * @param cfg configuration to use | ||
150 | * @param cb function to call with DNS replies | ||
151 | * @param cb_cls closure to pass to cb | ||
152 | * @return DNS handle | ||
125 | */ | 153 | */ |
126 | struct GNUNET_DNS_Handle * | 154 | struct GNUNET_DNS_Handle * |
127 | GNUNET_DNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | 155 | GNUNET_DNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, |
128 | GNUNET_SCHEDULER_Task cb, | 156 | GNUNET_DNS_ResponseCallback cb, |
129 | void *cb_cls); | 157 | void *cb_cls); |
130 | 158 | ||
159 | |||
160 | /** | ||
161 | * Signal the DNS service that it needs to re-initialize the DNS | ||
162 | * hijacking (the network setup has changed significantly). | ||
163 | * | ||
164 | * @param h DNS handle | ||
165 | */ | ||
131 | void | 166 | void |
132 | GNUNET_DNS_restart_hijack (struct GNUNET_DNS_Handle *h); | 167 | GNUNET_DNS_restart_hijack (struct GNUNET_DNS_Handle *h); |
133 | 168 | ||
@@ -170,7 +205,11 @@ GNUNET_DNS_queue_request_v6 (struct GNUNET_DNS_Handle *h, | |||
170 | size_t udp_packet_len, | 205 | size_t udp_packet_len, |
171 | const char *udp_packet); | 206 | const char *udp_packet); |
172 | 207 | ||
173 | 208 | /** | |
209 | * Disconnect from the DNS service. | ||
210 | * | ||
211 | * @param h DNS handle | ||
212 | */ | ||
174 | void | 213 | void |
175 | GNUNET_DNS_disconnect (struct GNUNET_DNS_Handle *h); | 214 | GNUNET_DNS_disconnect (struct GNUNET_DNS_Handle *h); |
176 | 215 | ||