cell_rendezvous.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* cell_rendezvous.h -- generated by by Trunnel v1.5.1.
  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. #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_TRN_CELL_RENDEZVOUS1)
  11. struct trn_cell_rendezvous1_st {
  12. uint8_t rendezvous_cookie[TRUNNEL_REND_COOKIE_LEN];
  13. TRUNNEL_DYNARRAY_HEAD(, uint8_t) handshake_info;
  14. uint8_t trunnel_error_code_;
  15. };
  16. #endif
  17. typedef struct trn_cell_rendezvous1_st trn_cell_rendezvous1_t;
  18. /** Return a newly allocated trn_cell_rendezvous1 with all elements
  19. * set to zero.
  20. */
  21. trn_cell_rendezvous1_t *trn_cell_rendezvous1_new(void);
  22. /** Release all storage held by the trn_cell_rendezvous1 in 'victim'.
  23. * (Do nothing if 'victim' is NULL.)
  24. */
  25. void trn_cell_rendezvous1_free(trn_cell_rendezvous1_t *victim);
  26. /** Try to parse a trn_cell_rendezvous1 from the buffer in 'input',
  27. * using up to 'len_in' bytes from the input buffer. On success,
  28. * return the number of bytes consumed and set *output to the newly
  29. * allocated trn_cell_rendezvous1_t. On failure, return -2 if the
  30. * input appears truncated, and -1 if the input is otherwise invalid.
  31. */
  32. ssize_t trn_cell_rendezvous1_parse(trn_cell_rendezvous1_t **output, const uint8_t *input, const size_t len_in);
  33. /** Return the number of bytes we expect to need to encode the
  34. * trn_cell_rendezvous1 in 'obj'. On failure, return a negative value.
  35. * Note that this value may be an overestimate, and can even be an
  36. * underestimate for certain unencodeable objects.
  37. */
  38. ssize_t trn_cell_rendezvous1_encoded_len(const trn_cell_rendezvous1_t *obj);
  39. /** Try to encode the trn_cell_rendezvous1 from 'input' into the
  40. * buffer at 'output', using up to 'avail' bytes of the output buffer.
  41. * On success, return the number of bytes used. On failure, return -2
  42. * if the buffer was not long enough, and -1 if the input was invalid.
  43. */
  44. ssize_t trn_cell_rendezvous1_encode(uint8_t *output, size_t avail, const trn_cell_rendezvous1_t *input);
  45. /** Check whether the internal state of the trn_cell_rendezvous1 in
  46. * 'obj' is consistent. Return NULL if it is, and a short message if
  47. * it is not.
  48. */
  49. const char *trn_cell_rendezvous1_check(const trn_cell_rendezvous1_t *obj);
  50. /** Clear any errors that were set on the object 'obj' by its setter
  51. * functions. Return true iff errors were cleared.
  52. */
  53. int trn_cell_rendezvous1_clear_errors(trn_cell_rendezvous1_t *obj);
  54. /** Return the (constant) length of the array holding the
  55. * rendezvous_cookie field of the trn_cell_rendezvous1_t in 'inp'.
  56. */
  57. size_t trn_cell_rendezvous1_getlen_rendezvous_cookie(const trn_cell_rendezvous1_t *inp);
  58. /** Return the element at position 'idx' of the fixed array field
  59. * rendezvous_cookie of the trn_cell_rendezvous1_t in 'inp'.
  60. */
  61. uint8_t trn_cell_rendezvous1_get_rendezvous_cookie(trn_cell_rendezvous1_t *inp, size_t idx);
  62. /** As trn_cell_rendezvous1_get_rendezvous_cookie, but take and return
  63. * a const pointer
  64. */
  65. uint8_t trn_cell_rendezvous1_getconst_rendezvous_cookie(const trn_cell_rendezvous1_t *inp, size_t idx);
  66. /** Change the element at position 'idx' of the fixed array field
  67. * rendezvous_cookie of the trn_cell_rendezvous1_t in 'inp', so that
  68. * it will hold the value 'elt'.
  69. */
  70. int trn_cell_rendezvous1_set_rendezvous_cookie(trn_cell_rendezvous1_t *inp, size_t idx, uint8_t elt);
  71. /** Return a pointer to the TRUNNEL_REND_COOKIE_LEN-element array
  72. * field rendezvous_cookie of 'inp'.
  73. */
  74. uint8_t * trn_cell_rendezvous1_getarray_rendezvous_cookie(trn_cell_rendezvous1_t *inp);
  75. /** As trn_cell_rendezvous1_get_rendezvous_cookie, but take and return
  76. * a const pointer
  77. */
  78. const uint8_t * trn_cell_rendezvous1_getconstarray_rendezvous_cookie(const trn_cell_rendezvous1_t *inp);
  79. /** Return the length of the dynamic array holding the handshake_info
  80. * field of the trn_cell_rendezvous1_t in 'inp'.
  81. */
  82. size_t trn_cell_rendezvous1_getlen_handshake_info(const trn_cell_rendezvous1_t *inp);
  83. /** Return the element at position 'idx' of the dynamic array field
  84. * handshake_info of the trn_cell_rendezvous1_t in 'inp'.
  85. */
  86. uint8_t trn_cell_rendezvous1_get_handshake_info(trn_cell_rendezvous1_t *inp, size_t idx);
  87. /** As trn_cell_rendezvous1_get_handshake_info, but take and return a
  88. * const pointer
  89. */
  90. uint8_t trn_cell_rendezvous1_getconst_handshake_info(const trn_cell_rendezvous1_t *inp, size_t idx);
  91. /** Change the element at position 'idx' of the dynamic array field
  92. * handshake_info of the trn_cell_rendezvous1_t in 'inp', so that it
  93. * will hold the value 'elt'.
  94. */
  95. int trn_cell_rendezvous1_set_handshake_info(trn_cell_rendezvous1_t *inp, size_t idx, uint8_t elt);
  96. /** Append a new element 'elt' to the dynamic array field
  97. * handshake_info of the trn_cell_rendezvous1_t in 'inp'.
  98. */
  99. int trn_cell_rendezvous1_add_handshake_info(trn_cell_rendezvous1_t *inp, uint8_t elt);
  100. /** Return a pointer to the variable-length array field handshake_info
  101. * of 'inp'.
  102. */
  103. uint8_t * trn_cell_rendezvous1_getarray_handshake_info(trn_cell_rendezvous1_t *inp);
  104. /** As trn_cell_rendezvous1_get_handshake_info, but take and return a
  105. * const pointer
  106. */
  107. const uint8_t * trn_cell_rendezvous1_getconstarray_handshake_info(const trn_cell_rendezvous1_t *inp);
  108. /** Change the length of the variable-length array field
  109. * handshake_info of 'inp' to 'newlen'.Fill extra elements with 0.
  110. * Return 0 on success; return -1 and set the error code on 'inp' on
  111. * failure.
  112. */
  113. int trn_cell_rendezvous1_setlen_handshake_info(trn_cell_rendezvous1_t *inp, size_t newlen);
  114. #endif