socks5.h 66 KB

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