channelpadding_negotiation.h 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* channelpadding_negotiation.h -- generated by by Trunnel v1.4.3.
  2. * https://gitweb.torproject.org/trunnel.git
  3. * You probably shouldn't edit this file.
  4. */
  5. #ifndef TRUNNEL_CHANNELPADDING_NEGOTIATION_H
  6. #define TRUNNEL_CHANNELPADDING_NEGOTIATION_H
  7. #include <stdint.h>
  8. #include "trunnel.h"
  9. #define CHANNELPADDING_COMMAND_STOP 1
  10. #define CHANNELPADDING_COMMAND_START 2
  11. #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_CHANNELPADDING_NEGOTIATE)
  12. struct channelpadding_negotiate_st {
  13. uint8_t version;
  14. uint8_t command;
  15. uint16_t ito_low_ms;
  16. uint16_t ito_high_ms;
  17. uint8_t trunnel_error_code_;
  18. };
  19. #endif
  20. typedef struct channelpadding_negotiate_st channelpadding_negotiate_t;
  21. /** Return a newly allocated channelpadding_negotiate with all
  22. * elements set to zero.
  23. */
  24. channelpadding_negotiate_t *channelpadding_negotiate_new(void);
  25. /** Release all storage held by the channelpadding_negotiate in
  26. * 'victim'. (Do nothing if 'victim' is NULL.)
  27. */
  28. void channelpadding_negotiate_free(channelpadding_negotiate_t *victim);
  29. /** Try to parse a channelpadding_negotiate from the buffer in
  30. * 'input', using up to 'len_in' bytes from the input buffer. On
  31. * success, return the number of bytes consumed and set *output to the
  32. * newly allocated channelpadding_negotiate_t. On failure, return -2
  33. * if the input appears truncated, and -1 if the input is otherwise
  34. * invalid.
  35. */
  36. ssize_t channelpadding_negotiate_parse(channelpadding_negotiate_t **output, const uint8_t *input, const size_t len_in);
  37. /** Return the number of bytes we expect to need to encode the
  38. * channelpadding_negotiate in 'obj'. On failure, return a negative
  39. * value. Note that this value may be an overestimate, and can even be
  40. * an underestimate for certain unencodeable objects.
  41. */
  42. ssize_t channelpadding_negotiate_encoded_len(const channelpadding_negotiate_t *obj);
  43. /** Try to encode the channelpadding_negotiate from 'input' into the
  44. * buffer at 'output', using up to 'avail' bytes of the output buffer.
  45. * On success, return the number of bytes used. On failure, return -2
  46. * if the buffer was not long enough, and -1 if the input was invalid.
  47. */
  48. ssize_t channelpadding_negotiate_encode(uint8_t *output, size_t avail, const channelpadding_negotiate_t *input);
  49. /** Check whether the internal state of the channelpadding_negotiate
  50. * in 'obj' is consistent. Return NULL if it is, and a short message
  51. * if it is not.
  52. */
  53. const char *channelpadding_negotiate_check(const channelpadding_negotiate_t *obj);
  54. /** Clear any errors that were set on the object 'obj' by its setter
  55. * functions. Return true iff errors were cleared.
  56. */
  57. int channelpadding_negotiate_clear_errors(channelpadding_negotiate_t *obj);
  58. /** Return the value of the version field of the
  59. * channelpadding_negotiate_t in 'inp'
  60. */
  61. uint8_t channelpadding_negotiate_get_version(channelpadding_negotiate_t *inp);
  62. /** Set the value of the version field of the
  63. * channelpadding_negotiate_t in 'inp' to 'val'. Return 0 on success;
  64. * return -1 and set the error code on 'inp' on failure.
  65. */
  66. int channelpadding_negotiate_set_version(channelpadding_negotiate_t *inp, uint8_t val);
  67. /** Return the value of the command field of the
  68. * channelpadding_negotiate_t in 'inp'
  69. */
  70. uint8_t channelpadding_negotiate_get_command(channelpadding_negotiate_t *inp);
  71. /** Set the value of the command field of the
  72. * channelpadding_negotiate_t in 'inp' to 'val'. Return 0 on success;
  73. * return -1 and set the error code on 'inp' on failure.
  74. */
  75. int channelpadding_negotiate_set_command(channelpadding_negotiate_t *inp, uint8_t val);
  76. /** Return the value of the ito_low_ms field of the
  77. * channelpadding_negotiate_t in 'inp'
  78. */
  79. uint16_t channelpadding_negotiate_get_ito_low_ms(channelpadding_negotiate_t *inp);
  80. /** Set the value of the ito_low_ms field of the
  81. * channelpadding_negotiate_t in 'inp' to 'val'. Return 0 on success;
  82. * return -1 and set the error code on 'inp' on failure.
  83. */
  84. int channelpadding_negotiate_set_ito_low_ms(channelpadding_negotiate_t *inp, uint16_t val);
  85. /** Return the value of the ito_high_ms field of the
  86. * channelpadding_negotiate_t in 'inp'
  87. */
  88. uint16_t channelpadding_negotiate_get_ito_high_ms(channelpadding_negotiate_t *inp);
  89. /** Set the value of the ito_high_ms field of the
  90. * channelpadding_negotiate_t in 'inp' to 'val'. Return 0 on success;
  91. * return -1 and set the error code on 'inp' on failure.
  92. */
  93. int channelpadding_negotiate_set_ito_high_ms(channelpadding_negotiate_t *inp, uint16_t val);
  94. #endif