Fix type in socks5.trunnel
[tor.git] / src / trunnel / socks5.h
blobd8f13c2abb5f16945621aa8fb0c7b756e2828e4d
1 /* socks5.h -- generated by Trunnel v1.5.2.
2 * https://gitweb.torproject.org/trunnel.git
3 * You probably shouldn't edit this file.
4 */
5 #ifndef TRUNNEL_SOCKS5_H
6 #define TRUNNEL_SOCKS5_H
8 #include <stdint.h>
9 #include "trunnel.h"
11 #define CMD_CONNECT 1
12 #define CMD_BIND 2
13 #define CMD_UDP_ASSOCIATE 3
14 #define CMD_RESOLVE 240
15 #define CMD_RESOLVE_PTR 241
16 #define ATYPE_IPV4 1
17 #define ATYPE_IPV6 4
18 #define ATYPE_DOMAINNAME 3
19 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_DOMAINNAME)
20 struct domainname_st {
21 uint8_t len;
22 trunnel_string_t name;
23 uint8_t trunnel_error_code_;
25 #endif
26 typedef struct domainname_st domainname_t;
27 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_SOCKS4_CLIENT_REQUEST)
28 struct socks4_client_request_st {
29 uint8_t version;
30 uint8_t command;
31 uint16_t port;
32 uint32_t addr;
33 char *username;
34 char *socks4a_addr_hostname;
35 uint8_t trunnel_error_code_;
37 #endif
38 typedef struct socks4_client_request_st socks4_client_request_t;
39 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_SOCKS4_SERVER_REPLY)
40 struct socks4_server_reply_st {
41 uint8_t version;
42 uint8_t status;
43 uint16_t port;
44 uint32_t addr;
45 uint8_t trunnel_error_code_;
47 #endif
48 typedef struct socks4_server_reply_st socks4_server_reply_t;
49 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_SOCKS5_CLIENT_USERPASS_AUTH)
50 struct socks5_client_userpass_auth_st {
51 uint8_t version;
52 uint8_t username_len;
53 trunnel_string_t username;
54 uint8_t passwd_len;
55 trunnel_string_t passwd;
56 uint8_t trunnel_error_code_;
58 #endif
59 typedef struct socks5_client_userpass_auth_st socks5_client_userpass_auth_t;
60 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_SOCKS5_CLIENT_VERSION)
61 struct socks5_client_version_st {
62 uint8_t version;
63 uint8_t n_methods;
64 TRUNNEL_DYNARRAY_HEAD(, uint8_t) methods;
65 uint8_t trunnel_error_code_;
67 #endif
68 typedef struct socks5_client_version_st socks5_client_version_t;
69 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_SOCKS5_SERVER_METHOD)
70 struct socks5_server_method_st {
71 uint8_t version;
72 uint8_t method;
73 uint8_t trunnel_error_code_;
75 #endif
76 typedef struct socks5_server_method_st socks5_server_method_t;
77 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_SOCKS5_SERVER_USERPASS_AUTH)
78 struct socks5_server_userpass_auth_st {
79 uint8_t version;
80 uint8_t status;
81 uint8_t trunnel_error_code_;
83 #endif
84 typedef struct socks5_server_userpass_auth_st socks5_server_userpass_auth_t;
85 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_TOR_SOCKSAUTH_KEYVAL)
86 struct tor_socksauth_keyval_st {
87 uint16_t keylen;
88 trunnel_string_t key;
89 uint16_t vallen;
90 trunnel_string_t val;
91 uint8_t trunnel_error_code_;
93 #endif
94 typedef struct tor_socksauth_keyval_st tor_socksauth_keyval_t;
95 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_SOCKS5_CLIENT_REQUEST)
96 struct socks5_client_request_st {
97 uint8_t version;
98 uint8_t command;
99 uint8_t reserved;
100 uint8_t atype;
101 uint32_t dest_addr_ipv4;
102 uint8_t dest_addr_ipv6[16];
103 struct domainname_st *dest_addr_domainname;
104 uint16_t dest_port;
105 uint8_t trunnel_error_code_;
107 #endif
108 typedef struct socks5_client_request_st socks5_client_request_t;
109 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_SOCKS5_SERVER_REPLY)
110 struct socks5_server_reply_st {
111 uint8_t version;
112 uint8_t reply;
113 uint8_t reserved;
114 uint8_t atype;
115 uint32_t bind_addr_ipv4;
116 uint8_t bind_addr_ipv6[16];
117 struct domainname_st *bind_addr_domainname;
118 uint16_t bind_port;
119 uint8_t trunnel_error_code_;
121 #endif
122 typedef struct socks5_server_reply_st socks5_server_reply_t;
123 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_TOR_EXTENDED_SOCKS_AUTH_REQUEST)
124 struct tor_extended_socks_auth_request_st {
125 uint8_t version;
126 uint16_t npairs;
127 TRUNNEL_DYNARRAY_HEAD(, struct tor_socksauth_keyval_st *) pairs;
128 uint8_t trunnel_error_code_;
130 #endif
131 typedef struct tor_extended_socks_auth_request_st tor_extended_socks_auth_request_t;
132 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_TOR_EXTENDED_SOCKS_AUTH_RESPONSE)
133 struct tor_extended_socks_auth_response_st {
134 uint8_t version;
135 uint8_t status;
136 uint16_t npairs;
137 TRUNNEL_DYNARRAY_HEAD(, struct tor_socksauth_keyval_st *) pairs;
138 uint8_t trunnel_error_code_;
140 #endif
141 typedef struct tor_extended_socks_auth_response_st tor_extended_socks_auth_response_t;
142 /** Return a newly allocated domainname with all elements set to zero.
144 domainname_t *domainname_new(void);
145 /** Release all storage held by the domainname in 'victim'. (Do
146 * nothing if 'victim' is NULL.)
148 void domainname_free(domainname_t *victim);
149 /** Try to parse a domainname from the buffer in 'input', using up to
150 * 'len_in' bytes from the input buffer. On success, return the number
151 * of bytes consumed and set *output to the newly allocated
152 * domainname_t. On failure, return -2 if the input appears truncated,
153 * and -1 if the input is otherwise invalid.
155 ssize_t domainname_parse(domainname_t **output, const uint8_t *input, const size_t len_in);
156 /** Return the number of bytes we expect to need to encode the
157 * domainname in 'obj'. On failure, return a negative value. Note that
158 * this value may be an overestimate, and can even be an underestimate
159 * for certain unencodeable objects.
161 ssize_t domainname_encoded_len(const domainname_t *obj);
162 /** Try to encode the domainname from 'input' into the buffer at
163 * 'output', using up to 'avail' bytes of the output buffer. On
164 * success, return the number of bytes used. On failure, return -2 if
165 * the buffer was not long enough, and -1 if the input was invalid.
167 ssize_t domainname_encode(uint8_t *output, size_t avail, const domainname_t *input);
168 /** Check whether the internal state of the domainname in 'obj' is
169 * consistent. Return NULL if it is, and a short message if it is not.
171 const char *domainname_check(const domainname_t *obj);
172 /** Clear any errors that were set on the object 'obj' by its setter
173 * functions. Return true iff errors were cleared.
175 int domainname_clear_errors(domainname_t *obj);
176 /** Return the value of the len field of the domainname_t in 'inp'
178 uint8_t domainname_get_len(const domainname_t *inp);
179 /** Set the value of the len field of the domainname_t in 'inp' to
180 * 'val'. Return 0 on success; return -1 and set the error code on
181 * 'inp' on failure.
183 int domainname_set_len(domainname_t *inp, uint8_t val);
184 /** Return the length of the dynamic array holding the name field of
185 * the domainname_t in 'inp'.
187 size_t domainname_getlen_name(const domainname_t *inp);
188 /** Return the element at position 'idx' of the dynamic array field
189 * name of the domainname_t in 'inp'.
191 char domainname_get_name(domainname_t *inp, size_t idx);
192 /** As domainname_get_name, but take and return a const pointer
194 char domainname_getconst_name(const domainname_t *inp, size_t idx);
195 /** Change the element at position 'idx' of the dynamic array field
196 * name of the domainname_t in 'inp', so that it will hold the value
197 * 'elt'.
199 int domainname_set_name(domainname_t *inp, size_t idx, char elt);
200 /** Append a new element 'elt' to the dynamic array field name of the
201 * domainname_t in 'inp'.
203 int domainname_add_name(domainname_t *inp, char elt);
204 /** Return a pointer to the variable-length array field name of 'inp'.
206 char * domainname_getarray_name(domainname_t *inp);
207 /** As domainname_get_name, but take and return a const pointer
209 const char * domainname_getconstarray_name(const domainname_t *inp);
210 /** Change the length of the variable-length array field name of 'inp'
211 * to 'newlen'.Fill extra elements with 0. Return 0 on success; return
212 * -1 and set the error code on 'inp' on failure.
214 int domainname_setlen_name(domainname_t *inp, size_t newlen);
215 /** Return the value of the name field of a domainname_t as a NUL-
216 * terminated string.
218 const char * domainname_getstr_name(domainname_t *inp);
219 /** Set the value of the name field of a domainname_t to a given
220 * string of length 'len'. Return 0 on success; return -1 and set the
221 * error code on 'inp' on failure.
223 int domainname_setstr0_name(domainname_t *inp, const char *val, size_t len);
224 /** Set the value of the name field of a domainname_t to a given NUL-
225 * terminated string. Return 0 on success; return -1 and set the error
226 * code on 'inp' on failure.
228 int domainname_setstr_name(domainname_t *inp, const char *val);
229 /** Return a newly allocated socks4_client_request with all elements
230 * set to zero.
232 socks4_client_request_t *socks4_client_request_new(void);
233 /** Release all storage held by the socks4_client_request in 'victim'.
234 * (Do nothing if 'victim' is NULL.)
236 void socks4_client_request_free(socks4_client_request_t *victim);
237 /** Try to parse a socks4_client_request from the buffer in 'input',
238 * using up to 'len_in' bytes from the input buffer. On success,
239 * return the number of bytes consumed and set *output to the newly
240 * allocated socks4_client_request_t. On failure, return -2 if the
241 * input appears truncated, and -1 if the input is otherwise invalid.
243 ssize_t socks4_client_request_parse(socks4_client_request_t **output, const uint8_t *input, const size_t len_in);
244 /** Return the number of bytes we expect to need to encode the
245 * socks4_client_request in 'obj'. On failure, return a negative
246 * value. Note that this value may be an overestimate, and can even be
247 * an underestimate for certain unencodeable objects.
249 ssize_t socks4_client_request_encoded_len(const socks4_client_request_t *obj);
250 /** Try to encode the socks4_client_request from 'input' into the
251 * buffer at 'output', using up to 'avail' bytes of the output buffer.
252 * On success, return the number of bytes used. On failure, return -2
253 * if the buffer was not long enough, and -1 if the input was invalid.
255 ssize_t socks4_client_request_encode(uint8_t *output, size_t avail, const socks4_client_request_t *input);
256 /** Check whether the internal state of the socks4_client_request in
257 * 'obj' is consistent. Return NULL if it is, and a short message if
258 * it is not.
260 const char *socks4_client_request_check(const socks4_client_request_t *obj);
261 /** Clear any errors that were set on the object 'obj' by its setter
262 * functions. Return true iff errors were cleared.
264 int socks4_client_request_clear_errors(socks4_client_request_t *obj);
265 /** Return the value of the version field of the
266 * socks4_client_request_t in 'inp'
268 uint8_t socks4_client_request_get_version(const socks4_client_request_t *inp);
269 /** Set the value of the version field of the socks4_client_request_t
270 * in 'inp' to 'val'. Return 0 on success; return -1 and set the error
271 * code on 'inp' on failure.
273 int socks4_client_request_set_version(socks4_client_request_t *inp, uint8_t val);
274 /** Return the value of the command field of the
275 * socks4_client_request_t in 'inp'
277 uint8_t socks4_client_request_get_command(const socks4_client_request_t *inp);
278 /** Set the value of the command field of the socks4_client_request_t
279 * in 'inp' to 'val'. Return 0 on success; return -1 and set the error
280 * code on 'inp' on failure.
282 int socks4_client_request_set_command(socks4_client_request_t *inp, uint8_t val);
283 /** Return the value of the port field of the socks4_client_request_t
284 * in 'inp'
286 uint16_t socks4_client_request_get_port(const socks4_client_request_t *inp);
287 /** Set the value of the port field of the socks4_client_request_t in
288 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
289 * code on 'inp' on failure.
291 int socks4_client_request_set_port(socks4_client_request_t *inp, uint16_t val);
292 /** Return the value of the addr field of the socks4_client_request_t
293 * in 'inp'
295 uint32_t socks4_client_request_get_addr(const socks4_client_request_t *inp);
296 /** Set the value of the addr field of the socks4_client_request_t in
297 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
298 * code on 'inp' on failure.
300 int socks4_client_request_set_addr(socks4_client_request_t *inp, uint32_t val);
301 /** Return the value of the username field of the
302 * socks4_client_request_t in 'inp'
304 const char * socks4_client_request_get_username(const socks4_client_request_t *inp);
305 /** Set the value of the username field of the socks4_client_request_t
306 * in 'inp' to 'val'. Free the old value if any. Does not steal the
307 * reference to 'val'.Return 0 on success; return -1 and set the error
308 * code on 'inp' on failure.
310 int socks4_client_request_set_username(socks4_client_request_t *inp, const char *val);
311 /** Return the value of the socks4a_addr_hostname field of the
312 * socks4_client_request_t in 'inp'
314 const char * socks4_client_request_get_socks4a_addr_hostname(const socks4_client_request_t *inp);
315 /** Set the value of the socks4a_addr_hostname field of the
316 * socks4_client_request_t in 'inp' to 'val'. Free the old value if
317 * any. Does not steal the reference to 'val'.Return 0 on success;
318 * return -1 and set the error code on 'inp' on failure.
320 int socks4_client_request_set_socks4a_addr_hostname(socks4_client_request_t *inp, const char *val);
321 /** Return a newly allocated socks4_server_reply with all elements set
322 * to zero.
324 socks4_server_reply_t *socks4_server_reply_new(void);
325 /** Release all storage held by the socks4_server_reply in 'victim'.
326 * (Do nothing if 'victim' is NULL.)
328 void socks4_server_reply_free(socks4_server_reply_t *victim);
329 /** Try to parse a socks4_server_reply from the buffer in 'input',
330 * using up to 'len_in' bytes from the input buffer. On success,
331 * return the number of bytes consumed and set *output to the newly
332 * allocated socks4_server_reply_t. On failure, return -2 if the input
333 * appears truncated, and -1 if the input is otherwise invalid.
335 ssize_t socks4_server_reply_parse(socks4_server_reply_t **output, const uint8_t *input, const size_t len_in);
336 /** Return the number of bytes we expect to need to encode the
337 * socks4_server_reply in 'obj'. On failure, return a negative value.
338 * Note that this value may be an overestimate, and can even be an
339 * underestimate for certain unencodeable objects.
341 ssize_t socks4_server_reply_encoded_len(const socks4_server_reply_t *obj);
342 /** Try to encode the socks4_server_reply from 'input' into the buffer
343 * at 'output', using up to 'avail' bytes of the output buffer. On
344 * success, return the number of bytes used. On failure, return -2 if
345 * the buffer was not long enough, and -1 if the input was invalid.
347 ssize_t socks4_server_reply_encode(uint8_t *output, size_t avail, const socks4_server_reply_t *input);
348 /** Check whether the internal state of the socks4_server_reply in
349 * 'obj' is consistent. Return NULL if it is, and a short message if
350 * it is not.
352 const char *socks4_server_reply_check(const socks4_server_reply_t *obj);
353 /** Clear any errors that were set on the object 'obj' by its setter
354 * functions. Return true iff errors were cleared.
356 int socks4_server_reply_clear_errors(socks4_server_reply_t *obj);
357 /** Return the value of the version field of the socks4_server_reply_t
358 * in 'inp'
360 uint8_t socks4_server_reply_get_version(const socks4_server_reply_t *inp);
361 /** Set the value of the version field of the socks4_server_reply_t in
362 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
363 * code on 'inp' on failure.
365 int socks4_server_reply_set_version(socks4_server_reply_t *inp, uint8_t val);
366 /** Return the value of the status field of the socks4_server_reply_t
367 * in 'inp'
369 uint8_t socks4_server_reply_get_status(const socks4_server_reply_t *inp);
370 /** Set the value of the status field of the socks4_server_reply_t in
371 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
372 * code on 'inp' on failure.
374 int socks4_server_reply_set_status(socks4_server_reply_t *inp, uint8_t val);
375 /** Return the value of the port field of the socks4_server_reply_t in
376 * 'inp'
378 uint16_t socks4_server_reply_get_port(const socks4_server_reply_t *inp);
379 /** Set the value of the port field of the socks4_server_reply_t in
380 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
381 * code on 'inp' on failure.
383 int socks4_server_reply_set_port(socks4_server_reply_t *inp, uint16_t val);
384 /** Return the value of the addr field of the socks4_server_reply_t in
385 * 'inp'
387 uint32_t socks4_server_reply_get_addr(const socks4_server_reply_t *inp);
388 /** Set the value of the addr field of the socks4_server_reply_t in
389 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
390 * code on 'inp' on failure.
392 int socks4_server_reply_set_addr(socks4_server_reply_t *inp, uint32_t val);
393 /** Return a newly allocated socks5_client_userpass_auth with all
394 * elements set to zero.
396 socks5_client_userpass_auth_t *socks5_client_userpass_auth_new(void);
397 /** Release all storage held by the socks5_client_userpass_auth in
398 * 'victim'. (Do nothing if 'victim' is NULL.)
400 void socks5_client_userpass_auth_free(socks5_client_userpass_auth_t *victim);
401 /** Try to parse a socks5_client_userpass_auth from the buffer in
402 * 'input', using up to 'len_in' bytes from the input buffer. On
403 * success, return the number of bytes consumed and set *output to the
404 * newly allocated socks5_client_userpass_auth_t. On failure, return
405 * -2 if the input appears truncated, and -1 if the input is otherwise
406 * invalid.
408 ssize_t socks5_client_userpass_auth_parse(socks5_client_userpass_auth_t **output, const uint8_t *input, const size_t len_in);
409 /** Return the number of bytes we expect to need to encode the
410 * socks5_client_userpass_auth in 'obj'. On failure, return a negative
411 * value. Note that this value may be an overestimate, and can even be
412 * an underestimate for certain unencodeable objects.
414 ssize_t socks5_client_userpass_auth_encoded_len(const socks5_client_userpass_auth_t *obj);
415 /** Try to encode the socks5_client_userpass_auth from 'input' into
416 * the buffer at 'output', using up to 'avail' bytes of the output
417 * buffer. On success, return the number of bytes used. On failure,
418 * return -2 if the buffer was not long enough, and -1 if the input
419 * was invalid.
421 ssize_t socks5_client_userpass_auth_encode(uint8_t *output, size_t avail, const socks5_client_userpass_auth_t *input);
422 /** Check whether the internal state of the
423 * socks5_client_userpass_auth in 'obj' is consistent. Return NULL if
424 * it is, and a short message if it is not.
426 const char *socks5_client_userpass_auth_check(const socks5_client_userpass_auth_t *obj);
427 /** Clear any errors that were set on the object 'obj' by its setter
428 * functions. Return true iff errors were cleared.
430 int socks5_client_userpass_auth_clear_errors(socks5_client_userpass_auth_t *obj);
431 /** Return the value of the version field of the
432 * socks5_client_userpass_auth_t in 'inp'
434 uint8_t socks5_client_userpass_auth_get_version(const socks5_client_userpass_auth_t *inp);
435 /** Set the value of the version field of the
436 * socks5_client_userpass_auth_t in 'inp' to 'val'. Return 0 on
437 * success; return -1 and set the error code on 'inp' on failure.
439 int socks5_client_userpass_auth_set_version(socks5_client_userpass_auth_t *inp, uint8_t val);
440 /** Return the value of the username_len field of the
441 * socks5_client_userpass_auth_t in 'inp'
443 uint8_t socks5_client_userpass_auth_get_username_len(const socks5_client_userpass_auth_t *inp);
444 /** Set the value of the username_len field of the
445 * socks5_client_userpass_auth_t in 'inp' to 'val'. Return 0 on
446 * success; return -1 and set the error code on 'inp' on failure.
448 int socks5_client_userpass_auth_set_username_len(socks5_client_userpass_auth_t *inp, uint8_t val);
449 /** Return the length of the dynamic array holding the username field
450 * of the socks5_client_userpass_auth_t in 'inp'.
452 size_t socks5_client_userpass_auth_getlen_username(const socks5_client_userpass_auth_t *inp);
453 /** Return the element at position 'idx' of the dynamic array field
454 * username of the socks5_client_userpass_auth_t in 'inp'.
456 char socks5_client_userpass_auth_get_username(socks5_client_userpass_auth_t *inp, size_t idx);
457 /** As socks5_client_userpass_auth_get_username, but take and return a
458 * const pointer
460 char socks5_client_userpass_auth_getconst_username(const socks5_client_userpass_auth_t *inp, size_t idx);
461 /** Change the element at position 'idx' of the dynamic array field
462 * username of the socks5_client_userpass_auth_t in 'inp', so that it
463 * will hold the value 'elt'.
465 int socks5_client_userpass_auth_set_username(socks5_client_userpass_auth_t *inp, size_t idx, char elt);
466 /** Append a new element 'elt' to the dynamic array field username of
467 * the socks5_client_userpass_auth_t in 'inp'.
469 int socks5_client_userpass_auth_add_username(socks5_client_userpass_auth_t *inp, char elt);
470 /** Return a pointer to the variable-length array field username of
471 * 'inp'.
473 char * socks5_client_userpass_auth_getarray_username(socks5_client_userpass_auth_t *inp);
474 /** As socks5_client_userpass_auth_get_username, but take and return a
475 * const pointer
477 const char * socks5_client_userpass_auth_getconstarray_username(const socks5_client_userpass_auth_t *inp);
478 /** Change the length of the variable-length array field username of
479 * 'inp' to 'newlen'.Fill extra elements with 0. Return 0 on success;
480 * return -1 and set the error code on 'inp' on failure.
482 int socks5_client_userpass_auth_setlen_username(socks5_client_userpass_auth_t *inp, size_t newlen);
483 /** Return the value of the username field of a
484 * socks5_client_userpass_auth_t as a NUL-terminated string.
486 const char * socks5_client_userpass_auth_getstr_username(socks5_client_userpass_auth_t *inp);
487 /** Set the value of the username field of a
488 * socks5_client_userpass_auth_t to a given string of length 'len'.
489 * Return 0 on success; return -1 and set the error code on 'inp' on
490 * failure.
492 int socks5_client_userpass_auth_setstr0_username(socks5_client_userpass_auth_t *inp, const char *val, size_t len);
493 /** Set the value of the username field of a
494 * socks5_client_userpass_auth_t to a given NUL-terminated string.
495 * Return 0 on success; return -1 and set the error code on 'inp' on
496 * failure.
498 int socks5_client_userpass_auth_setstr_username(socks5_client_userpass_auth_t *inp, const char *val);
499 /** Return the value of the passwd_len field of the
500 * socks5_client_userpass_auth_t in 'inp'
502 uint8_t socks5_client_userpass_auth_get_passwd_len(const socks5_client_userpass_auth_t *inp);
503 /** Set the value of the passwd_len field of the
504 * socks5_client_userpass_auth_t in 'inp' to 'val'. Return 0 on
505 * success; return -1 and set the error code on 'inp' on failure.
507 int socks5_client_userpass_auth_set_passwd_len(socks5_client_userpass_auth_t *inp, uint8_t val);
508 /** Return the length of the dynamic array holding the passwd field of
509 * the socks5_client_userpass_auth_t in 'inp'.
511 size_t socks5_client_userpass_auth_getlen_passwd(const socks5_client_userpass_auth_t *inp);
512 /** Return the element at position 'idx' of the dynamic array field
513 * passwd of the socks5_client_userpass_auth_t in 'inp'.
515 char socks5_client_userpass_auth_get_passwd(socks5_client_userpass_auth_t *inp, size_t idx);
516 /** As socks5_client_userpass_auth_get_passwd, but take and return a
517 * const pointer
519 char socks5_client_userpass_auth_getconst_passwd(const socks5_client_userpass_auth_t *inp, size_t idx);
520 /** Change the element at position 'idx' of the dynamic array field
521 * passwd of the socks5_client_userpass_auth_t in 'inp', so that it
522 * will hold the value 'elt'.
524 int socks5_client_userpass_auth_set_passwd(socks5_client_userpass_auth_t *inp, size_t idx, char elt);
525 /** Append a new element 'elt' to the dynamic array field passwd of
526 * the socks5_client_userpass_auth_t in 'inp'.
528 int socks5_client_userpass_auth_add_passwd(socks5_client_userpass_auth_t *inp, char elt);
529 /** Return a pointer to the variable-length array field passwd of
530 * 'inp'.
532 char * socks5_client_userpass_auth_getarray_passwd(socks5_client_userpass_auth_t *inp);
533 /** As socks5_client_userpass_auth_get_passwd, but take and return a
534 * const pointer
536 const char * socks5_client_userpass_auth_getconstarray_passwd(const socks5_client_userpass_auth_t *inp);
537 /** Change the length of the variable-length array field passwd of
538 * 'inp' to 'newlen'.Fill extra elements with 0. Return 0 on success;
539 * return -1 and set the error code on 'inp' on failure.
541 int socks5_client_userpass_auth_setlen_passwd(socks5_client_userpass_auth_t *inp, size_t newlen);
542 /** Return the value of the passwd field of a
543 * socks5_client_userpass_auth_t as a NUL-terminated string.
545 const char * socks5_client_userpass_auth_getstr_passwd(socks5_client_userpass_auth_t *inp);
546 /** Set the value of the passwd field of a
547 * socks5_client_userpass_auth_t to a given string of length 'len'.
548 * Return 0 on success; return -1 and set the error code on 'inp' on
549 * failure.
551 int socks5_client_userpass_auth_setstr0_passwd(socks5_client_userpass_auth_t *inp, const char *val, size_t len);
552 /** Set the value of the passwd field of a
553 * socks5_client_userpass_auth_t to a given NUL-terminated string.
554 * Return 0 on success; return -1 and set the error code on 'inp' on
555 * failure.
557 int socks5_client_userpass_auth_setstr_passwd(socks5_client_userpass_auth_t *inp, const char *val);
558 /** Return a newly allocated socks5_client_version with all elements
559 * set to zero.
561 socks5_client_version_t *socks5_client_version_new(void);
562 /** Release all storage held by the socks5_client_version in 'victim'.
563 * (Do nothing if 'victim' is NULL.)
565 void socks5_client_version_free(socks5_client_version_t *victim);
566 /** Try to parse a socks5_client_version from the buffer in 'input',
567 * using up to 'len_in' bytes from the input buffer. On success,
568 * return the number of bytes consumed and set *output to the newly
569 * allocated socks5_client_version_t. On failure, return -2 if the
570 * input appears truncated, and -1 if the input is otherwise invalid.
572 ssize_t socks5_client_version_parse(socks5_client_version_t **output, const uint8_t *input, const size_t len_in);
573 /** Return the number of bytes we expect to need to encode the
574 * socks5_client_version in 'obj'. On failure, return a negative
575 * value. Note that this value may be an overestimate, and can even be
576 * an underestimate for certain unencodeable objects.
578 ssize_t socks5_client_version_encoded_len(const socks5_client_version_t *obj);
579 /** Try to encode the socks5_client_version from 'input' into the
580 * buffer at 'output', using up to 'avail' bytes of the output buffer.
581 * On success, return the number of bytes used. On failure, return -2
582 * if the buffer was not long enough, and -1 if the input was invalid.
584 ssize_t socks5_client_version_encode(uint8_t *output, size_t avail, const socks5_client_version_t *input);
585 /** Check whether the internal state of the socks5_client_version in
586 * 'obj' is consistent. Return NULL if it is, and a short message if
587 * it is not.
589 const char *socks5_client_version_check(const socks5_client_version_t *obj);
590 /** Clear any errors that were set on the object 'obj' by its setter
591 * functions. Return true iff errors were cleared.
593 int socks5_client_version_clear_errors(socks5_client_version_t *obj);
594 /** Return the value of the version field of the
595 * socks5_client_version_t in 'inp'
597 uint8_t socks5_client_version_get_version(const socks5_client_version_t *inp);
598 /** Set the value of the version field of the socks5_client_version_t
599 * in 'inp' to 'val'. Return 0 on success; return -1 and set the error
600 * code on 'inp' on failure.
602 int socks5_client_version_set_version(socks5_client_version_t *inp, uint8_t val);
603 /** Return the value of the n_methods field of the
604 * socks5_client_version_t in 'inp'
606 uint8_t socks5_client_version_get_n_methods(const socks5_client_version_t *inp);
607 /** Set the value of the n_methods field of the
608 * socks5_client_version_t in 'inp' to 'val'. Return 0 on success;
609 * return -1 and set the error code on 'inp' on failure.
611 int socks5_client_version_set_n_methods(socks5_client_version_t *inp, uint8_t val);
612 /** Return the length of the dynamic array holding the methods field
613 * of the socks5_client_version_t in 'inp'.
615 size_t socks5_client_version_getlen_methods(const socks5_client_version_t *inp);
616 /** Return the element at position 'idx' of the dynamic array field
617 * methods of the socks5_client_version_t in 'inp'.
619 uint8_t socks5_client_version_get_methods(socks5_client_version_t *inp, size_t idx);
620 /** As socks5_client_version_get_methods, but take and return a const
621 * pointer
623 uint8_t socks5_client_version_getconst_methods(const socks5_client_version_t *inp, size_t idx);
624 /** Change the element at position 'idx' of the dynamic array field
625 * methods of the socks5_client_version_t in 'inp', so that it will
626 * hold the value 'elt'.
628 int socks5_client_version_set_methods(socks5_client_version_t *inp, size_t idx, uint8_t elt);
629 /** Append a new element 'elt' to the dynamic array field methods of
630 * the socks5_client_version_t in 'inp'.
632 int socks5_client_version_add_methods(socks5_client_version_t *inp, uint8_t elt);
633 /** Return a pointer to the variable-length array field methods of
634 * 'inp'.
636 uint8_t * socks5_client_version_getarray_methods(socks5_client_version_t *inp);
637 /** As socks5_client_version_get_methods, but take and return a const
638 * pointer
640 const uint8_t * socks5_client_version_getconstarray_methods(const socks5_client_version_t *inp);
641 /** Change the length of the variable-length array field methods of
642 * 'inp' to 'newlen'.Fill extra elements with 0. Return 0 on success;
643 * return -1 and set the error code on 'inp' on failure.
645 int socks5_client_version_setlen_methods(socks5_client_version_t *inp, size_t newlen);
646 /** Return a newly allocated socks5_server_method with all elements
647 * set to zero.
649 socks5_server_method_t *socks5_server_method_new(void);
650 /** Release all storage held by the socks5_server_method in 'victim'.
651 * (Do nothing if 'victim' is NULL.)
653 void socks5_server_method_free(socks5_server_method_t *victim);
654 /** Try to parse a socks5_server_method from the buffer in 'input',
655 * using up to 'len_in' bytes from the input buffer. On success,
656 * return the number of bytes consumed and set *output to the newly
657 * allocated socks5_server_method_t. On failure, return -2 if the
658 * input appears truncated, and -1 if the input is otherwise invalid.
660 ssize_t socks5_server_method_parse(socks5_server_method_t **output, const uint8_t *input, const size_t len_in);
661 /** Return the number of bytes we expect to need to encode the
662 * socks5_server_method in 'obj'. On failure, return a negative value.
663 * Note that this value may be an overestimate, and can even be an
664 * underestimate for certain unencodeable objects.
666 ssize_t socks5_server_method_encoded_len(const socks5_server_method_t *obj);
667 /** Try to encode the socks5_server_method from 'input' into the
668 * buffer at 'output', using up to 'avail' bytes of the output buffer.
669 * On success, return the number of bytes used. On failure, return -2
670 * if the buffer was not long enough, and -1 if the input was invalid.
672 ssize_t socks5_server_method_encode(uint8_t *output, size_t avail, const socks5_server_method_t *input);
673 /** Check whether the internal state of the socks5_server_method in
674 * 'obj' is consistent. Return NULL if it is, and a short message if
675 * it is not.
677 const char *socks5_server_method_check(const socks5_server_method_t *obj);
678 /** Clear any errors that were set on the object 'obj' by its setter
679 * functions. Return true iff errors were cleared.
681 int socks5_server_method_clear_errors(socks5_server_method_t *obj);
682 /** Return the value of the version field of the
683 * socks5_server_method_t in 'inp'
685 uint8_t socks5_server_method_get_version(const socks5_server_method_t *inp);
686 /** Set the value of the version field of the socks5_server_method_t
687 * in 'inp' to 'val'. Return 0 on success; return -1 and set the error
688 * code on 'inp' on failure.
690 int socks5_server_method_set_version(socks5_server_method_t *inp, uint8_t val);
691 /** Return the value of the method field of the socks5_server_method_t
692 * in 'inp'
694 uint8_t socks5_server_method_get_method(const socks5_server_method_t *inp);
695 /** Set the value of the method field of the socks5_server_method_t in
696 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
697 * code on 'inp' on failure.
699 int socks5_server_method_set_method(socks5_server_method_t *inp, uint8_t val);
700 /** Return a newly allocated socks5_server_userpass_auth with all
701 * elements set to zero.
703 socks5_server_userpass_auth_t *socks5_server_userpass_auth_new(void);
704 /** Release all storage held by the socks5_server_userpass_auth in
705 * 'victim'. (Do nothing if 'victim' is NULL.)
707 void socks5_server_userpass_auth_free(socks5_server_userpass_auth_t *victim);
708 /** Try to parse a socks5_server_userpass_auth from the buffer in
709 * 'input', using up to 'len_in' bytes from the input buffer. On
710 * success, return the number of bytes consumed and set *output to the
711 * newly allocated socks5_server_userpass_auth_t. On failure, return
712 * -2 if the input appears truncated, and -1 if the input is otherwise
713 * invalid.
715 ssize_t socks5_server_userpass_auth_parse(socks5_server_userpass_auth_t **output, const uint8_t *input, const size_t len_in);
716 /** Return the number of bytes we expect to need to encode the
717 * socks5_server_userpass_auth in 'obj'. On failure, return a negative
718 * value. Note that this value may be an overestimate, and can even be
719 * an underestimate for certain unencodeable objects.
721 ssize_t socks5_server_userpass_auth_encoded_len(const socks5_server_userpass_auth_t *obj);
722 /** Try to encode the socks5_server_userpass_auth from 'input' into
723 * the buffer at 'output', using up to 'avail' bytes of the output
724 * buffer. On success, return the number of bytes used. On failure,
725 * return -2 if the buffer was not long enough, and -1 if the input
726 * was invalid.
728 ssize_t socks5_server_userpass_auth_encode(uint8_t *output, size_t avail, const socks5_server_userpass_auth_t *input);
729 /** Check whether the internal state of the
730 * socks5_server_userpass_auth in 'obj' is consistent. Return NULL if
731 * it is, and a short message if it is not.
733 const char *socks5_server_userpass_auth_check(const socks5_server_userpass_auth_t *obj);
734 /** Clear any errors that were set on the object 'obj' by its setter
735 * functions. Return true iff errors were cleared.
737 int socks5_server_userpass_auth_clear_errors(socks5_server_userpass_auth_t *obj);
738 /** Return the value of the version field of the
739 * socks5_server_userpass_auth_t in 'inp'
741 uint8_t socks5_server_userpass_auth_get_version(const socks5_server_userpass_auth_t *inp);
742 /** Set the value of the version field of the
743 * socks5_server_userpass_auth_t in 'inp' to 'val'. Return 0 on
744 * success; return -1 and set the error code on 'inp' on failure.
746 int socks5_server_userpass_auth_set_version(socks5_server_userpass_auth_t *inp, uint8_t val);
747 /** Return the value of the status field of the
748 * socks5_server_userpass_auth_t in 'inp'
750 uint8_t socks5_server_userpass_auth_get_status(const socks5_server_userpass_auth_t *inp);
751 /** Set the value of the status field of the
752 * socks5_server_userpass_auth_t in 'inp' to 'val'. Return 0 on
753 * success; return -1 and set the error code on 'inp' on failure.
755 int socks5_server_userpass_auth_set_status(socks5_server_userpass_auth_t *inp, uint8_t val);
756 /** Return a newly allocated tor_socksauth_keyval with all elements
757 * set to zero.
759 tor_socksauth_keyval_t *tor_socksauth_keyval_new(void);
760 /** Release all storage held by the tor_socksauth_keyval in 'victim'.
761 * (Do nothing if 'victim' is NULL.)
763 void tor_socksauth_keyval_free(tor_socksauth_keyval_t *victim);
764 /** Try to parse a tor_socksauth_keyval from the buffer in 'input',
765 * using up to 'len_in' bytes from the input buffer. On success,
766 * return the number of bytes consumed and set *output to the newly
767 * allocated tor_socksauth_keyval_t. On failure, return -2 if the
768 * input appears truncated, and -1 if the input is otherwise invalid.
770 ssize_t tor_socksauth_keyval_parse(tor_socksauth_keyval_t **output, const uint8_t *input, const size_t len_in);
771 /** Return the number of bytes we expect to need to encode the
772 * tor_socksauth_keyval in 'obj'. On failure, return a negative value.
773 * Note that this value may be an overestimate, and can even be an
774 * underestimate for certain unencodeable objects.
776 ssize_t tor_socksauth_keyval_encoded_len(const tor_socksauth_keyval_t *obj);
777 /** Try to encode the tor_socksauth_keyval from 'input' into the
778 * buffer at 'output', using up to 'avail' bytes of the output buffer.
779 * On success, return the number of bytes used. On failure, return -2
780 * if the buffer was not long enough, and -1 if the input was invalid.
782 ssize_t tor_socksauth_keyval_encode(uint8_t *output, size_t avail, const tor_socksauth_keyval_t *input);
783 /** Check whether the internal state of the tor_socksauth_keyval in
784 * 'obj' is consistent. Return NULL if it is, and a short message if
785 * it is not.
787 const char *tor_socksauth_keyval_check(const tor_socksauth_keyval_t *obj);
788 /** Clear any errors that were set on the object 'obj' by its setter
789 * functions. Return true iff errors were cleared.
791 int tor_socksauth_keyval_clear_errors(tor_socksauth_keyval_t *obj);
792 /** Return the value of the keylen field of the tor_socksauth_keyval_t
793 * in 'inp'
795 uint16_t tor_socksauth_keyval_get_keylen(const tor_socksauth_keyval_t *inp);
796 /** Set the value of the keylen field of the tor_socksauth_keyval_t in
797 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
798 * code on 'inp' on failure.
800 int tor_socksauth_keyval_set_keylen(tor_socksauth_keyval_t *inp, uint16_t val);
801 /** Return the length of the dynamic array holding the key field of
802 * the tor_socksauth_keyval_t in 'inp'.
804 size_t tor_socksauth_keyval_getlen_key(const tor_socksauth_keyval_t *inp);
805 /** Return the element at position 'idx' of the dynamic array field
806 * key of the tor_socksauth_keyval_t in 'inp'.
808 char tor_socksauth_keyval_get_key(tor_socksauth_keyval_t *inp, size_t idx);
809 /** As tor_socksauth_keyval_get_key, but take and return a const
810 * pointer
812 char tor_socksauth_keyval_getconst_key(const tor_socksauth_keyval_t *inp, size_t idx);
813 /** Change the element at position 'idx' of the dynamic array field
814 * key of the tor_socksauth_keyval_t in 'inp', so that it will hold
815 * the value 'elt'.
817 int tor_socksauth_keyval_set_key(tor_socksauth_keyval_t *inp, size_t idx, char elt);
818 /** Append a new element 'elt' to the dynamic array field key of the
819 * tor_socksauth_keyval_t in 'inp'.
821 int tor_socksauth_keyval_add_key(tor_socksauth_keyval_t *inp, char elt);
822 /** Return a pointer to the variable-length array field key of 'inp'.
824 char * tor_socksauth_keyval_getarray_key(tor_socksauth_keyval_t *inp);
825 /** As tor_socksauth_keyval_get_key, but take and return a const
826 * pointer
828 const char * tor_socksauth_keyval_getconstarray_key(const tor_socksauth_keyval_t *inp);
829 /** Change the length of the variable-length array field key of 'inp'
830 * to 'newlen'.Fill extra elements with 0. Return 0 on success; return
831 * -1 and set the error code on 'inp' on failure.
833 int tor_socksauth_keyval_setlen_key(tor_socksauth_keyval_t *inp, size_t newlen);
834 /** Return the value of the key field of a tor_socksauth_keyval_t as a
835 * NUL-terminated string.
837 const char * tor_socksauth_keyval_getstr_key(tor_socksauth_keyval_t *inp);
838 /** Set the value of the key field of a tor_socksauth_keyval_t to a
839 * given string of length 'len'. Return 0 on success; return -1 and
840 * set the error code on 'inp' on failure.
842 int tor_socksauth_keyval_setstr0_key(tor_socksauth_keyval_t *inp, const char *val, size_t len);
843 /** Set the value of the key field of a tor_socksauth_keyval_t to a
844 * given NUL-terminated string. Return 0 on success; return -1 and set
845 * the error code on 'inp' on failure.
847 int tor_socksauth_keyval_setstr_key(tor_socksauth_keyval_t *inp, const char *val);
848 /** Return the value of the vallen field of the tor_socksauth_keyval_t
849 * in 'inp'
851 uint16_t tor_socksauth_keyval_get_vallen(const tor_socksauth_keyval_t *inp);
852 /** Set the value of the vallen field of the tor_socksauth_keyval_t in
853 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
854 * code on 'inp' on failure.
856 int tor_socksauth_keyval_set_vallen(tor_socksauth_keyval_t *inp, uint16_t val);
857 /** Return the length of the dynamic array holding the val field of
858 * the tor_socksauth_keyval_t in 'inp'.
860 size_t tor_socksauth_keyval_getlen_val(const tor_socksauth_keyval_t *inp);
861 /** Return the element at position 'idx' of the dynamic array field
862 * val of the tor_socksauth_keyval_t in 'inp'.
864 char tor_socksauth_keyval_get_val(tor_socksauth_keyval_t *inp, size_t idx);
865 /** As tor_socksauth_keyval_get_val, but take and return a const
866 * pointer
868 char tor_socksauth_keyval_getconst_val(const tor_socksauth_keyval_t *inp, size_t idx);
869 /** Change the element at position 'idx' of the dynamic array field
870 * val of the tor_socksauth_keyval_t in 'inp', so that it will hold
871 * the value 'elt'.
873 int tor_socksauth_keyval_set_val(tor_socksauth_keyval_t *inp, size_t idx, char elt);
874 /** Append a new element 'elt' to the dynamic array field val of the
875 * tor_socksauth_keyval_t in 'inp'.
877 int tor_socksauth_keyval_add_val(tor_socksauth_keyval_t *inp, char elt);
878 /** Return a pointer to the variable-length array field val of 'inp'.
880 char * tor_socksauth_keyval_getarray_val(tor_socksauth_keyval_t *inp);
881 /** As tor_socksauth_keyval_get_val, but take and return a const
882 * pointer
884 const char * tor_socksauth_keyval_getconstarray_val(const tor_socksauth_keyval_t *inp);
885 /** Change the length of the variable-length array field val of 'inp'
886 * to 'newlen'.Fill extra elements with 0. Return 0 on success; return
887 * -1 and set the error code on 'inp' on failure.
889 int tor_socksauth_keyval_setlen_val(tor_socksauth_keyval_t *inp, size_t newlen);
890 /** Return the value of the val field of a tor_socksauth_keyval_t as a
891 * NUL-terminated string.
893 const char * tor_socksauth_keyval_getstr_val(tor_socksauth_keyval_t *inp);
894 /** Set the value of the val field of a tor_socksauth_keyval_t to a
895 * given string of length 'len'. Return 0 on success; return -1 and
896 * set the error code on 'inp' on failure.
898 int tor_socksauth_keyval_setstr0_val(tor_socksauth_keyval_t *inp, const char *val, size_t len);
899 /** Set the value of the val field of a tor_socksauth_keyval_t to a
900 * given NUL-terminated string. Return 0 on success; return -1 and set
901 * the error code on 'inp' on failure.
903 int tor_socksauth_keyval_setstr_val(tor_socksauth_keyval_t *inp, const char *val);
904 /** Return a newly allocated socks5_client_request with all elements
905 * set to zero.
907 socks5_client_request_t *socks5_client_request_new(void);
908 /** Release all storage held by the socks5_client_request in 'victim'.
909 * (Do nothing if 'victim' is NULL.)
911 void socks5_client_request_free(socks5_client_request_t *victim);
912 /** Try to parse a socks5_client_request from the buffer in 'input',
913 * using up to 'len_in' bytes from the input buffer. On success,
914 * return the number of bytes consumed and set *output to the newly
915 * allocated socks5_client_request_t. On failure, return -2 if the
916 * input appears truncated, and -1 if the input is otherwise invalid.
918 ssize_t socks5_client_request_parse(socks5_client_request_t **output, const uint8_t *input, const size_t len_in);
919 /** Return the number of bytes we expect to need to encode the
920 * socks5_client_request in 'obj'. On failure, return a negative
921 * value. Note that this value may be an overestimate, and can even be
922 * an underestimate for certain unencodeable objects.
924 ssize_t socks5_client_request_encoded_len(const socks5_client_request_t *obj);
925 /** Try to encode the socks5_client_request from 'input' into the
926 * buffer at 'output', using up to 'avail' bytes of the output buffer.
927 * On success, return the number of bytes used. On failure, return -2
928 * if the buffer was not long enough, and -1 if the input was invalid.
930 ssize_t socks5_client_request_encode(uint8_t *output, size_t avail, const socks5_client_request_t *input);
931 /** Check whether the internal state of the socks5_client_request in
932 * 'obj' is consistent. Return NULL if it is, and a short message if
933 * it is not.
935 const char *socks5_client_request_check(const socks5_client_request_t *obj);
936 /** Clear any errors that were set on the object 'obj' by its setter
937 * functions. Return true iff errors were cleared.
939 int socks5_client_request_clear_errors(socks5_client_request_t *obj);
940 /** Return the value of the version field of the
941 * socks5_client_request_t in 'inp'
943 uint8_t socks5_client_request_get_version(const socks5_client_request_t *inp);
944 /** Set the value of the version field of the socks5_client_request_t
945 * in 'inp' to 'val'. Return 0 on success; return -1 and set the error
946 * code on 'inp' on failure.
948 int socks5_client_request_set_version(socks5_client_request_t *inp, uint8_t val);
949 /** Return the value of the command field of the
950 * socks5_client_request_t in 'inp'
952 uint8_t socks5_client_request_get_command(const socks5_client_request_t *inp);
953 /** Set the value of the command field of the socks5_client_request_t
954 * in 'inp' to 'val'. Return 0 on success; return -1 and set the error
955 * code on 'inp' on failure.
957 int socks5_client_request_set_command(socks5_client_request_t *inp, uint8_t val);
958 /** Return the value of the reserved field of the
959 * socks5_client_request_t in 'inp'
961 uint8_t socks5_client_request_get_reserved(const socks5_client_request_t *inp);
962 /** Set the value of the reserved field of the socks5_client_request_t
963 * in 'inp' to 'val'. Return 0 on success; return -1 and set the error
964 * code on 'inp' on failure.
966 int socks5_client_request_set_reserved(socks5_client_request_t *inp, uint8_t val);
967 /** Return the value of the atype field of the socks5_client_request_t
968 * in 'inp'
970 uint8_t socks5_client_request_get_atype(const socks5_client_request_t *inp);
971 /** Set the value of the atype field of the socks5_client_request_t in
972 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
973 * code on 'inp' on failure.
975 int socks5_client_request_set_atype(socks5_client_request_t *inp, uint8_t val);
976 /** Return the value of the dest_addr_ipv4 field of the
977 * socks5_client_request_t in 'inp'
979 uint32_t socks5_client_request_get_dest_addr_ipv4(const socks5_client_request_t *inp);
980 /** Set the value of the dest_addr_ipv4 field of the
981 * socks5_client_request_t in 'inp' to 'val'. Return 0 on success;
982 * return -1 and set the error code on 'inp' on failure.
984 int socks5_client_request_set_dest_addr_ipv4(socks5_client_request_t *inp, uint32_t val);
985 /** Return the (constant) length of the array holding the
986 * dest_addr_ipv6 field of the socks5_client_request_t in 'inp'.
988 size_t socks5_client_request_getlen_dest_addr_ipv6(const socks5_client_request_t *inp);
989 /** Return the element at position 'idx' of the fixed array field
990 * dest_addr_ipv6 of the socks5_client_request_t in 'inp'.
992 uint8_t socks5_client_request_get_dest_addr_ipv6(socks5_client_request_t *inp, size_t idx);
993 /** As socks5_client_request_get_dest_addr_ipv6, but take and return a
994 * const pointer
996 uint8_t socks5_client_request_getconst_dest_addr_ipv6(const socks5_client_request_t *inp, size_t idx);
997 /** Change the element at position 'idx' of the fixed array field
998 * dest_addr_ipv6 of the socks5_client_request_t in 'inp', so that it
999 * will hold the value 'elt'.
1001 int socks5_client_request_set_dest_addr_ipv6(socks5_client_request_t *inp, size_t idx, uint8_t elt);
1002 /** Return a pointer to the 16-element array field dest_addr_ipv6 of
1003 * 'inp'.
1005 uint8_t * socks5_client_request_getarray_dest_addr_ipv6(socks5_client_request_t *inp);
1006 /** As socks5_client_request_get_dest_addr_ipv6, but take and return a
1007 * const pointer
1009 const uint8_t * socks5_client_request_getconstarray_dest_addr_ipv6(const socks5_client_request_t *inp);
1010 /** Return the value of the dest_addr_domainname field of the
1011 * socks5_client_request_t in 'inp'
1013 struct domainname_st * socks5_client_request_get_dest_addr_domainname(socks5_client_request_t *inp);
1014 /** As socks5_client_request_get_dest_addr_domainname, but take and
1015 * return a const pointer
1017 const struct domainname_st * socks5_client_request_getconst_dest_addr_domainname(const socks5_client_request_t *inp);
1018 /** Set the value of the dest_addr_domainname field of the
1019 * socks5_client_request_t in 'inp' to 'val'. Free the old value if
1020 * any. Steals the referenceto 'val'.Return 0 on success; return -1
1021 * and set the error code on 'inp' on failure.
1023 int socks5_client_request_set_dest_addr_domainname(socks5_client_request_t *inp, struct domainname_st *val);
1024 /** As socks5_client_request_set_dest_addr_domainname, but does not
1025 * free the previous value.
1027 int socks5_client_request_set0_dest_addr_domainname(socks5_client_request_t *inp, struct domainname_st *val);
1028 /** Return the value of the dest_port field of the
1029 * socks5_client_request_t in 'inp'
1031 uint16_t socks5_client_request_get_dest_port(const socks5_client_request_t *inp);
1032 /** Set the value of the dest_port field of the
1033 * socks5_client_request_t in 'inp' to 'val'. Return 0 on success;
1034 * return -1 and set the error code on 'inp' on failure.
1036 int socks5_client_request_set_dest_port(socks5_client_request_t *inp, uint16_t val);
1037 /** Return a newly allocated socks5_server_reply with all elements set
1038 * to zero.
1040 socks5_server_reply_t *socks5_server_reply_new(void);
1041 /** Release all storage held by the socks5_server_reply in 'victim'.
1042 * (Do nothing if 'victim' is NULL.)
1044 void socks5_server_reply_free(socks5_server_reply_t *victim);
1045 /** Try to parse a socks5_server_reply from the buffer in 'input',
1046 * using up to 'len_in' bytes from the input buffer. On success,
1047 * return the number of bytes consumed and set *output to the newly
1048 * allocated socks5_server_reply_t. On failure, return -2 if the input
1049 * appears truncated, and -1 if the input is otherwise invalid.
1051 ssize_t socks5_server_reply_parse(socks5_server_reply_t **output, const uint8_t *input, const size_t len_in);
1052 /** Return the number of bytes we expect to need to encode the
1053 * socks5_server_reply in 'obj'. On failure, return a negative value.
1054 * Note that this value may be an overestimate, and can even be an
1055 * underestimate for certain unencodeable objects.
1057 ssize_t socks5_server_reply_encoded_len(const socks5_server_reply_t *obj);
1058 /** Try to encode the socks5_server_reply from 'input' into the buffer
1059 * at 'output', using up to 'avail' bytes of the output buffer. On
1060 * success, return the number of bytes used. On failure, return -2 if
1061 * the buffer was not long enough, and -1 if the input was invalid.
1063 ssize_t socks5_server_reply_encode(uint8_t *output, size_t avail, const socks5_server_reply_t *input);
1064 /** Check whether the internal state of the socks5_server_reply in
1065 * 'obj' is consistent. Return NULL if it is, and a short message if
1066 * it is not.
1068 const char *socks5_server_reply_check(const socks5_server_reply_t *obj);
1069 /** Clear any errors that were set on the object 'obj' by its setter
1070 * functions. Return true iff errors were cleared.
1072 int socks5_server_reply_clear_errors(socks5_server_reply_t *obj);
1073 /** Return the value of the version field of the socks5_server_reply_t
1074 * in 'inp'
1076 uint8_t socks5_server_reply_get_version(const socks5_server_reply_t *inp);
1077 /** Set the value of the version field of the socks5_server_reply_t in
1078 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
1079 * code on 'inp' on failure.
1081 int socks5_server_reply_set_version(socks5_server_reply_t *inp, uint8_t val);
1082 /** Return the value of the reply field of the socks5_server_reply_t
1083 * in 'inp'
1085 uint8_t socks5_server_reply_get_reply(const socks5_server_reply_t *inp);
1086 /** Set the value of the reply field of the socks5_server_reply_t in
1087 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
1088 * code on 'inp' on failure.
1090 int socks5_server_reply_set_reply(socks5_server_reply_t *inp, uint8_t val);
1091 /** Return the value of the reserved field of the
1092 * socks5_server_reply_t in 'inp'
1094 uint8_t socks5_server_reply_get_reserved(const socks5_server_reply_t *inp);
1095 /** Set the value of the reserved field of the socks5_server_reply_t
1096 * in 'inp' to 'val'. Return 0 on success; return -1 and set the error
1097 * code on 'inp' on failure.
1099 int socks5_server_reply_set_reserved(socks5_server_reply_t *inp, uint8_t val);
1100 /** Return the value of the atype field of the socks5_server_reply_t
1101 * in 'inp'
1103 uint8_t socks5_server_reply_get_atype(const socks5_server_reply_t *inp);
1104 /** Set the value of the atype field of the socks5_server_reply_t in
1105 * 'inp' to 'val'. Return 0 on success; return -1 and set the error
1106 * code on 'inp' on failure.
1108 int socks5_server_reply_set_atype(socks5_server_reply_t *inp, uint8_t val);
1109 /** Return the value of the bind_addr_ipv4 field of the
1110 * socks5_server_reply_t in 'inp'
1112 uint32_t socks5_server_reply_get_bind_addr_ipv4(const socks5_server_reply_t *inp);
1113 /** Set the value of the bind_addr_ipv4 field of the
1114 * socks5_server_reply_t in 'inp' to 'val'. Return 0 on success;
1115 * return -1 and set the error code on 'inp' on failure.
1117 int socks5_server_reply_set_bind_addr_ipv4(socks5_server_reply_t *inp, uint32_t val);
1118 /** Return the (constant) length of the array holding the
1119 * bind_addr_ipv6 field of the socks5_server_reply_t in 'inp'.
1121 size_t socks5_server_reply_getlen_bind_addr_ipv6(const socks5_server_reply_t *inp);
1122 /** Return the element at position 'idx' of the fixed array field
1123 * bind_addr_ipv6 of the socks5_server_reply_t in 'inp'.
1125 uint8_t socks5_server_reply_get_bind_addr_ipv6(socks5_server_reply_t *inp, size_t idx);
1126 /** As socks5_server_reply_get_bind_addr_ipv6, but take and return a
1127 * const pointer
1129 uint8_t socks5_server_reply_getconst_bind_addr_ipv6(const socks5_server_reply_t *inp, size_t idx);
1130 /** Change the element at position 'idx' of the fixed array field
1131 * bind_addr_ipv6 of the socks5_server_reply_t in 'inp', so that it
1132 * will hold the value 'elt'.
1134 int socks5_server_reply_set_bind_addr_ipv6(socks5_server_reply_t *inp, size_t idx, uint8_t elt);
1135 /** Return a pointer to the 16-element array field bind_addr_ipv6 of
1136 * 'inp'.
1138 uint8_t * socks5_server_reply_getarray_bind_addr_ipv6(socks5_server_reply_t *inp);
1139 /** As socks5_server_reply_get_bind_addr_ipv6, but take and return a
1140 * const pointer
1142 const uint8_t * socks5_server_reply_getconstarray_bind_addr_ipv6(const socks5_server_reply_t *inp);
1143 /** Return the value of the bind_addr_domainname field of the
1144 * socks5_server_reply_t in 'inp'
1146 struct domainname_st * socks5_server_reply_get_bind_addr_domainname(socks5_server_reply_t *inp);
1147 /** As socks5_server_reply_get_bind_addr_domainname, but take and
1148 * return a const pointer
1150 const struct domainname_st * socks5_server_reply_getconst_bind_addr_domainname(const socks5_server_reply_t *inp);
1151 /** Set the value of the bind_addr_domainname field of the
1152 * socks5_server_reply_t in 'inp' to 'val'. Free the old value if any.
1153 * Steals the referenceto 'val'.Return 0 on success; return -1 and set
1154 * the error code on 'inp' on failure.
1156 int socks5_server_reply_set_bind_addr_domainname(socks5_server_reply_t *inp, struct domainname_st *val);
1157 /** As socks5_server_reply_set_bind_addr_domainname, but does not free
1158 * the previous value.
1160 int socks5_server_reply_set0_bind_addr_domainname(socks5_server_reply_t *inp, struct domainname_st *val);
1161 /** Return the value of the bind_port field of the
1162 * socks5_server_reply_t in 'inp'
1164 uint16_t socks5_server_reply_get_bind_port(const socks5_server_reply_t *inp);
1165 /** Set the value of the bind_port field of the socks5_server_reply_t
1166 * in 'inp' to 'val'. Return 0 on success; return -1 and set the error
1167 * code on 'inp' on failure.
1169 int socks5_server_reply_set_bind_port(socks5_server_reply_t *inp, uint16_t val);
1170 /** Return a newly allocated tor_extended_socks_auth_request with all
1171 * elements set to zero.
1173 tor_extended_socks_auth_request_t *tor_extended_socks_auth_request_new(void);
1174 /** Release all storage held by the tor_extended_socks_auth_request in
1175 * 'victim'. (Do nothing if 'victim' is NULL.)
1177 void tor_extended_socks_auth_request_free(tor_extended_socks_auth_request_t *victim);
1178 /** Try to parse a tor_extended_socks_auth_request from the buffer in
1179 * 'input', using up to 'len_in' bytes from the input buffer. On
1180 * success, return the number of bytes consumed and set *output to the
1181 * newly allocated tor_extended_socks_auth_request_t. On failure,
1182 * return -2 if the input appears truncated, and -1 if the input is
1183 * otherwise invalid.
1185 ssize_t tor_extended_socks_auth_request_parse(tor_extended_socks_auth_request_t **output, const uint8_t *input, const size_t len_in);
1186 /** Return the number of bytes we expect to need to encode the
1187 * tor_extended_socks_auth_request in 'obj'. On failure, return a
1188 * negative value. Note that this value may be an overestimate, and
1189 * can even be an underestimate for certain unencodeable objects.
1191 ssize_t tor_extended_socks_auth_request_encoded_len(const tor_extended_socks_auth_request_t *obj);
1192 /** Try to encode the tor_extended_socks_auth_request from 'input'
1193 * into the buffer at 'output', using up to 'avail' bytes of the
1194 * output buffer. On success, return the number of bytes used. On
1195 * failure, return -2 if the buffer was not long enough, and -1 if the
1196 * input was invalid.
1198 ssize_t tor_extended_socks_auth_request_encode(uint8_t *output, size_t avail, const tor_extended_socks_auth_request_t *input);
1199 /** Check whether the internal state of the
1200 * tor_extended_socks_auth_request in 'obj' is consistent. Return NULL
1201 * if it is, and a short message if it is not.
1203 const char *tor_extended_socks_auth_request_check(const tor_extended_socks_auth_request_t *obj);
1204 /** Clear any errors that were set on the object 'obj' by its setter
1205 * functions. Return true iff errors were cleared.
1207 int tor_extended_socks_auth_request_clear_errors(tor_extended_socks_auth_request_t *obj);
1208 /** Return the value of the version field of the
1209 * tor_extended_socks_auth_request_t in 'inp'
1211 uint8_t tor_extended_socks_auth_request_get_version(const tor_extended_socks_auth_request_t *inp);
1212 /** Set the value of the version field of the
1213 * tor_extended_socks_auth_request_t in 'inp' to 'val'. Return 0 on
1214 * success; return -1 and set the error code on 'inp' on failure.
1216 int tor_extended_socks_auth_request_set_version(tor_extended_socks_auth_request_t *inp, uint8_t val);
1217 /** Return the value of the npairs field of the
1218 * tor_extended_socks_auth_request_t in 'inp'
1220 uint16_t tor_extended_socks_auth_request_get_npairs(const tor_extended_socks_auth_request_t *inp);
1221 /** Set the value of the npairs field of the
1222 * tor_extended_socks_auth_request_t in 'inp' to 'val'. Return 0 on
1223 * success; return -1 and set the error code on 'inp' on failure.
1225 int tor_extended_socks_auth_request_set_npairs(tor_extended_socks_auth_request_t *inp, uint16_t val);
1226 /** Return the length of the dynamic array holding the pairs field of
1227 * the tor_extended_socks_auth_request_t in 'inp'.
1229 size_t tor_extended_socks_auth_request_getlen_pairs(const tor_extended_socks_auth_request_t *inp);
1230 /** Return the element at position 'idx' of the dynamic array field
1231 * pairs of the tor_extended_socks_auth_request_t in 'inp'.
1233 struct tor_socksauth_keyval_st * tor_extended_socks_auth_request_get_pairs(tor_extended_socks_auth_request_t *inp, size_t idx);
1234 /** As tor_extended_socks_auth_request_get_pairs, but take and return
1235 * a const pointer
1237 const struct tor_socksauth_keyval_st * tor_extended_socks_auth_request_getconst_pairs(const tor_extended_socks_auth_request_t *inp, size_t idx);
1238 /** Change the element at position 'idx' of the dynamic array field
1239 * pairs of the tor_extended_socks_auth_request_t in 'inp', so that it
1240 * will hold the value 'elt'. Free the previous value, if any.
1242 int tor_extended_socks_auth_request_set_pairs(tor_extended_socks_auth_request_t *inp, size_t idx, struct tor_socksauth_keyval_st * elt);
1243 /** As tor_extended_socks_auth_request_set_pairs, but does not free
1244 * the previous value.
1246 int tor_extended_socks_auth_request_set0_pairs(tor_extended_socks_auth_request_t *inp, size_t idx, struct tor_socksauth_keyval_st * elt);
1247 /** Append a new element 'elt' to the dynamic array field pairs of the
1248 * tor_extended_socks_auth_request_t in 'inp'.
1250 int tor_extended_socks_auth_request_add_pairs(tor_extended_socks_auth_request_t *inp, struct tor_socksauth_keyval_st * elt);
1251 /** Return a pointer to the variable-length array field pairs of
1252 * 'inp'.
1254 struct tor_socksauth_keyval_st * * tor_extended_socks_auth_request_getarray_pairs(tor_extended_socks_auth_request_t *inp);
1255 /** As tor_extended_socks_auth_request_get_pairs, but take and return
1256 * a const pointer
1258 const struct tor_socksauth_keyval_st * const * tor_extended_socks_auth_request_getconstarray_pairs(const tor_extended_socks_auth_request_t *inp);
1259 /** Change the length of the variable-length array field pairs of
1260 * 'inp' to 'newlen'.Fill extra elements with NULL; free removed
1261 * elements. Return 0 on success; return -1 and set the error code on
1262 * 'inp' on failure.
1264 int tor_extended_socks_auth_request_setlen_pairs(tor_extended_socks_auth_request_t *inp, size_t newlen);
1265 /** Return a newly allocated tor_extended_socks_auth_response with all
1266 * elements set to zero.
1268 tor_extended_socks_auth_response_t *tor_extended_socks_auth_response_new(void);
1269 /** Release all storage held by the tor_extended_socks_auth_response
1270 * in 'victim'. (Do nothing if 'victim' is NULL.)
1272 void tor_extended_socks_auth_response_free(tor_extended_socks_auth_response_t *victim);
1273 /** Try to parse a tor_extended_socks_auth_response from the buffer in
1274 * 'input', using up to 'len_in' bytes from the input buffer. On
1275 * success, return the number of bytes consumed and set *output to the
1276 * newly allocated tor_extended_socks_auth_response_t. On failure,
1277 * return -2 if the input appears truncated, and -1 if the input is
1278 * otherwise invalid.
1280 ssize_t tor_extended_socks_auth_response_parse(tor_extended_socks_auth_response_t **output, const uint8_t *input, const size_t len_in);
1281 /** Return the number of bytes we expect to need to encode the
1282 * tor_extended_socks_auth_response in 'obj'. On failure, return a
1283 * negative value. Note that this value may be an overestimate, and
1284 * can even be an underestimate for certain unencodeable objects.
1286 ssize_t tor_extended_socks_auth_response_encoded_len(const tor_extended_socks_auth_response_t *obj);
1287 /** Try to encode the tor_extended_socks_auth_response from 'input'
1288 * into the buffer at 'output', using up to 'avail' bytes of the
1289 * output buffer. On success, return the number of bytes used. On
1290 * failure, return -2 if the buffer was not long enough, and -1 if the
1291 * input was invalid.
1293 ssize_t tor_extended_socks_auth_response_encode(uint8_t *output, size_t avail, const tor_extended_socks_auth_response_t *input);
1294 /** Check whether the internal state of the
1295 * tor_extended_socks_auth_response in 'obj' is consistent. Return
1296 * NULL if it is, and a short message if it is not.
1298 const char *tor_extended_socks_auth_response_check(const tor_extended_socks_auth_response_t *obj);
1299 /** Clear any errors that were set on the object 'obj' by its setter
1300 * functions. Return true iff errors were cleared.
1302 int tor_extended_socks_auth_response_clear_errors(tor_extended_socks_auth_response_t *obj);
1303 /** Return the value of the version field of the
1304 * tor_extended_socks_auth_response_t in 'inp'
1306 uint8_t tor_extended_socks_auth_response_get_version(const tor_extended_socks_auth_response_t *inp);
1307 /** Set the value of the version field of the
1308 * tor_extended_socks_auth_response_t in 'inp' to 'val'. Return 0 on
1309 * success; return -1 and set the error code on 'inp' on failure.
1311 int tor_extended_socks_auth_response_set_version(tor_extended_socks_auth_response_t *inp, uint8_t val);
1312 /** Return the value of the status field of the
1313 * tor_extended_socks_auth_response_t in 'inp'
1315 uint8_t tor_extended_socks_auth_response_get_status(const tor_extended_socks_auth_response_t *inp);
1316 /** Set the value of the status field of the
1317 * tor_extended_socks_auth_response_t in 'inp' to 'val'. Return 0 on
1318 * success; return -1 and set the error code on 'inp' on failure.
1320 int tor_extended_socks_auth_response_set_status(tor_extended_socks_auth_response_t *inp, uint8_t val);
1321 /** Return the value of the npairs field of the
1322 * tor_extended_socks_auth_response_t in 'inp'
1324 uint16_t tor_extended_socks_auth_response_get_npairs(const tor_extended_socks_auth_response_t *inp);
1325 /** Set the value of the npairs field of the
1326 * tor_extended_socks_auth_response_t in 'inp' to 'val'. Return 0 on
1327 * success; return -1 and set the error code on 'inp' on failure.
1329 int tor_extended_socks_auth_response_set_npairs(tor_extended_socks_auth_response_t *inp, uint16_t val);
1330 /** Return the length of the dynamic array holding the pairs field of
1331 * the tor_extended_socks_auth_response_t in 'inp'.
1333 size_t tor_extended_socks_auth_response_getlen_pairs(const tor_extended_socks_auth_response_t *inp);
1334 /** Return the element at position 'idx' of the dynamic array field
1335 * pairs of the tor_extended_socks_auth_response_t in 'inp'.
1337 struct tor_socksauth_keyval_st * tor_extended_socks_auth_response_get_pairs(tor_extended_socks_auth_response_t *inp, size_t idx);
1338 /** As tor_extended_socks_auth_response_get_pairs, but take and return
1339 * a const pointer
1341 const struct tor_socksauth_keyval_st * tor_extended_socks_auth_response_getconst_pairs(const tor_extended_socks_auth_response_t *inp, size_t idx);
1342 /** Change the element at position 'idx' of the dynamic array field
1343 * pairs of the tor_extended_socks_auth_response_t in 'inp', so that
1344 * it will hold the value 'elt'. Free the previous value, if any.
1346 int tor_extended_socks_auth_response_set_pairs(tor_extended_socks_auth_response_t *inp, size_t idx, struct tor_socksauth_keyval_st * elt);
1347 /** As tor_extended_socks_auth_response_set_pairs, but does not free
1348 * the previous value.
1350 int tor_extended_socks_auth_response_set0_pairs(tor_extended_socks_auth_response_t *inp, size_t idx, struct tor_socksauth_keyval_st * elt);
1351 /** Append a new element 'elt' to the dynamic array field pairs of the
1352 * tor_extended_socks_auth_response_t in 'inp'.
1354 int tor_extended_socks_auth_response_add_pairs(tor_extended_socks_auth_response_t *inp, struct tor_socksauth_keyval_st * elt);
1355 /** Return a pointer to the variable-length array field pairs of
1356 * 'inp'.
1358 struct tor_socksauth_keyval_st * * tor_extended_socks_auth_response_getarray_pairs(tor_extended_socks_auth_response_t *inp);
1359 /** As tor_extended_socks_auth_response_get_pairs, but take and return
1360 * a const pointer
1362 const struct tor_socksauth_keyval_st * const * tor_extended_socks_auth_response_getconstarray_pairs(const tor_extended_socks_auth_response_t *inp);
1363 /** Change the length of the variable-length array field pairs of
1364 * 'inp' to 'newlen'.Fill extra elements with NULL; free removed
1365 * elements. Return 0 on success; return -1 and set the error code on
1366 * 'inp' on failure.
1368 int tor_extended_socks_auth_response_setlen_pairs(tor_extended_socks_auth_response_t *inp, size_t newlen);
1371 #endif