cell_rendezvous.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /* cell_rendezvous.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_CELL_RENDEZVOUS_H
  6. #define TRUNNEL_CELL_RENDEZVOUS_H
  7. #include <stdint.h>
  8. #include "trunnel.h"
  9. #define TRUNNEL_REND_COOKIE_LEN 20
  10. #define TRUNNEL_HANDSHAKE_INFO_LEN 64
  11. #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_TRN_CELL_RENDEZVOUS1)
  12. struct trn_cell_rendezvous1_st {
  13. uint8_t rendezvous_cookie[TRUNNEL_REND_COOKIE_LEN];
  14. TRUNNEL_DYNARRAY_HEAD(, uint8_t) handshake_info;
  15. uint8_t trunnel_error_code_;
  16. };
  17. #endif
  18. typedef struct trn_cell_rendezvous1_st trn_cell_rendezvous1_t;
  19. #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_TRN_CELL_RENDEZVOUS2)
  20. struct trn_cell_rendezvous2_st {
  21. uint8_t handshake_info[TRUNNEL_HANDSHAKE_INFO_LEN];
  22. uint8_t trunnel_error_code_;
  23. };
  24. #endif
  25. typedef struct trn_cell_rendezvous2_st trn_cell_rendezvous2_t;
  26. /** Return a newly allocated trn_cell_rendezvous1 with all elements
  27. * set to zero.
  28. */
  29. trn_cell_rendezvous1_t *trn_cell_rendezvous1_new(void);
  30. /** Release all storage held by the trn_cell_rendezvous1 in 'victim'.
  31. * (Do nothing if 'victim' is NULL.)
  32. */
  33. void trn_cell_rendezvous1_free(trn_cell_rendezvous1_t *victim);
  34. /** Try to parse a trn_cell_rendezvous1 from the buffer in 'input',
  35. * using up to 'len_in' bytes from the input buffer. On success,
  36. * return the number of bytes consumed and set *output to the newly
  37. * allocated trn_cell_rendezvous1_t. On failure, return -2 if the
  38. * input appears truncated, and -1 if the input is otherwise invalid.
  39. */
  40. ssize_t trn_cell_rendezvous1_parse(trn_cell_rendezvous1_t **output, const uint8_t *input, const size_t len_in);
  41. /** Return the number of bytes we expect to need to encode the
  42. * trn_cell_rendezvous1 in 'obj'. On failure, return a negative value.
  43. * Note that this value may be an overestimate, and can even be an
  44. * underestimate for certain unencodeable objects.
  45. */
  46. ssize_t trn_cell_rendezvous1_encoded_len(const trn_cell_rendezvous1_t *obj);
  47. /** Try to encode the trn_cell_rendezvous1 from 'input' into the
  48. * buffer at 'output', using up to 'avail' bytes of the output buffer.
  49. * On success, return the number of bytes used. On failure, return -2
  50. * if the buffer was not long enough, and -1 if the input was invalid.
  51. */
  52. ssize_t trn_cell_rendezvous1_encode(uint8_t *output, size_t avail, const trn_cell_rendezvous1_t *input);
  53. /** Check whether the internal state of the trn_cell_rendezvous1 in
  54. * 'obj' is consistent. Return NULL if it is, and a short message if
  55. * it is not.
  56. */
  57. const char *trn_cell_rendezvous1_check(const trn_cell_rendezvous1_t *obj);
  58. /** Clear any errors that were set on the object 'obj' by its setter
  59. * functions. Return true iff errors were cleared.
  60. */
  61. int trn_cell_rendezvous1_clear_errors(trn_cell_rendezvous1_t *obj);
  62. /** Return the (constant) length of the array holding the
  63. * rendezvous_cookie field of the trn_cell_rendezvous1_t in 'inp'.
  64. */
  65. size_t trn_cell_rendezvous1_getlen_rendezvous_cookie(const trn_cell_rendezvous1_t *inp);
  66. /** Return the element at position 'idx' of the fixed array field
  67. * rendezvous_cookie of the trn_cell_rendezvous1_t in 'inp'.
  68. */
  69. uint8_t trn_cell_rendezvous1_get_rendezvous_cookie(trn_cell_rendezvous1_t *inp, size_t idx);
  70. /** As trn_cell_rendezvous1_get_rendezvous_cookie, but take and return
  71. * a const pointer
  72. */
  73. uint8_t trn_cell_rendezvous1_getconst_rendezvous_cookie(const trn_cell_rendezvous1_t *inp, size_t idx);
  74. /** Change the element at position 'idx' of the fixed array field
  75. * rendezvous_cookie of the trn_cell_rendezvous1_t in 'inp', so that
  76. * it will hold the value 'elt'.
  77. */
  78. int trn_cell_rendezvous1_set_rendezvous_cookie(trn_cell_rendezvous1_t *inp, size_t idx, uint8_t elt);
  79. /** Return a pointer to the TRUNNEL_REND_COOKIE_LEN-element array
  80. * field rendezvous_cookie of 'inp'.
  81. */
  82. uint8_t * trn_cell_rendezvous1_getarray_rendezvous_cookie(trn_cell_rendezvous1_t *inp);
  83. /** As trn_cell_rendezvous1_get_rendezvous_cookie, but take and return
  84. * a const pointer
  85. */
  86. const uint8_t * trn_cell_rendezvous1_getconstarray_rendezvous_cookie(const trn_cell_rendezvous1_t *inp);
  87. /** Return the length of the dynamic array holding the handshake_info
  88. * field of the trn_cell_rendezvous1_t in 'inp'.
  89. */
  90. size_t trn_cell_rendezvous1_getlen_handshake_info(const trn_cell_rendezvous1_t *inp);
  91. /** Return the element at position 'idx' of the dynamic array field
  92. * handshake_info of the trn_cell_rendezvous1_t in 'inp'.
  93. */
  94. uint8_t trn_cell_rendezvous1_get_handshake_info(trn_cell_rendezvous1_t *inp, size_t idx);
  95. /** As trn_cell_rendezvous1_get_handshake_info, but take and return a
  96. * const pointer
  97. */
  98. uint8_t trn_cell_rendezvous1_getconst_handshake_info(const trn_cell_rendezvous1_t *inp, size_t idx);
  99. /** Change the element at position 'idx' of the dynamic array field
  100. * handshake_info of the trn_cell_rendezvous1_t in 'inp', so that it
  101. * will hold the value 'elt'.
  102. */
  103. int trn_cell_rendezvous1_set_handshake_info(trn_cell_rendezvous1_t *inp, size_t idx, uint8_t elt);
  104. /** Append a new element 'elt' to the dynamic array field
  105. * handshake_info of the trn_cell_rendezvous1_t in 'inp'.
  106. */
  107. int trn_cell_rendezvous1_add_handshake_info(trn_cell_rendezvous1_t *inp, uint8_t elt);
  108. /** Return a pointer to the variable-length array field handshake_info
  109. * of 'inp'.
  110. */
  111. uint8_t * trn_cell_rendezvous1_getarray_handshake_info(trn_cell_rendezvous1_t *inp);
  112. /** As trn_cell_rendezvous1_get_handshake_info, but take and return a
  113. * const pointer
  114. */
  115. const uint8_t * trn_cell_rendezvous1_getconstarray_handshake_info(const trn_cell_rendezvous1_t *inp);
  116. /** Change the length of the variable-length array field
  117. * handshake_info of 'inp' to 'newlen'.Fill extra elements with 0.
  118. * Return 0 on success; return -1 and set the error code on 'inp' on
  119. * failure.
  120. */
  121. int trn_cell_rendezvous1_setlen_handshake_info(trn_cell_rendezvous1_t *inp, size_t newlen);
  122. /** Return a newly allocated trn_cell_rendezvous2 with all elements
  123. * set to zero.
  124. */
  125. trn_cell_rendezvous2_t *trn_cell_rendezvous2_new(void);
  126. /** Release all storage held by the trn_cell_rendezvous2 in 'victim'.
  127. * (Do nothing if 'victim' is NULL.)
  128. */
  129. void trn_cell_rendezvous2_free(trn_cell_rendezvous2_t *victim);
  130. /** Try to parse a trn_cell_rendezvous2 from the buffer in 'input',
  131. * using up to 'len_in' bytes from the input buffer. On success,
  132. * return the number of bytes consumed and set *output to the newly
  133. * allocated trn_cell_rendezvous2_t. On failure, return -2 if the
  134. * input appears truncated, and -1 if the input is otherwise invalid.
  135. */
  136. ssize_t trn_cell_rendezvous2_parse(trn_cell_rendezvous2_t **output, const uint8_t *input, const size_t len_in);
  137. /** Return the number of bytes we expect to need to encode the
  138. * trn_cell_rendezvous2 in 'obj'. On failure, return a negative value.
  139. * Note that this value may be an overestimate, and can even be an
  140. * underestimate for certain unencodeable objects.
  141. */
  142. ssize_t trn_cell_rendezvous2_encoded_len(const trn_cell_rendezvous2_t *obj);
  143. /** Try to encode the trn_cell_rendezvous2 from 'input' into the
  144. * buffer at 'output', using up to 'avail' bytes of the output buffer.
  145. * On success, return the number of bytes used. On failure, return -2
  146. * if the buffer was not long enough, and -1 if the input was invalid.
  147. */
  148. ssize_t trn_cell_rendezvous2_encode(uint8_t *output, size_t avail, const trn_cell_rendezvous2_t *input);
  149. /** Check whether the internal state of the trn_cell_rendezvous2 in
  150. * 'obj' is consistent. Return NULL if it is, and a short message if
  151. * it is not.
  152. */
  153. const char *trn_cell_rendezvous2_check(const trn_cell_rendezvous2_t *obj);
  154. /** Clear any errors that were set on the object 'obj' by its setter
  155. * functions. Return true iff errors were cleared.
  156. */
  157. int trn_cell_rendezvous2_clear_errors(trn_cell_rendezvous2_t *obj);
  158. /** Return the (constant) length of the array holding the
  159. * handshake_info field of the trn_cell_rendezvous2_t in 'inp'.
  160. */
  161. size_t trn_cell_rendezvous2_getlen_handshake_info(const trn_cell_rendezvous2_t *inp);
  162. /** Return the element at position 'idx' of the fixed array field
  163. * handshake_info of the trn_cell_rendezvous2_t in 'inp'.
  164. */
  165. uint8_t trn_cell_rendezvous2_get_handshake_info(trn_cell_rendezvous2_t *inp, size_t idx);
  166. /** As trn_cell_rendezvous2_get_handshake_info, but take and return a
  167. * const pointer
  168. */
  169. uint8_t trn_cell_rendezvous2_getconst_handshake_info(const trn_cell_rendezvous2_t *inp, size_t idx);
  170. /** Change the element at position 'idx' of the fixed array field
  171. * handshake_info of the trn_cell_rendezvous2_t in 'inp', so that it
  172. * will hold the value 'elt'.
  173. */
  174. int trn_cell_rendezvous2_set_handshake_info(trn_cell_rendezvous2_t *inp, size_t idx, uint8_t elt);
  175. /** Return a pointer to the TRUNNEL_HANDSHAKE_INFO_LEN-element array
  176. * field handshake_info of 'inp'.
  177. */
  178. uint8_t * trn_cell_rendezvous2_getarray_handshake_info(trn_cell_rendezvous2_t *inp);
  179. /** As trn_cell_rendezvous2_get_handshake_info, but take and return a
  180. * const pointer
  181. */
  182. const uint8_t * trn_cell_rendezvous2_getconstarray_handshake_info(const trn_cell_rendezvous2_t *inp);
  183. #endif