socks5.h 66 KB

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