"Fossies" - the Fresh Open Source Software Archive

Member "tor-0.4.1.6/src/trunnel/sendme.h" (10 Jun 2019, 4132 Bytes) of package /linux/misc/tor-0.4.1.6.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "sendme.h" see the Fossies "Dox" file reference documentation.

    1 /* sendme.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_SENDME_H
    6 #define TRUNNEL_SENDME_H
    7 
    8 #include <stdint.h>
    9 #include "trunnel.h"
   10 
   11 #define TRUNNEL_SENDME_V1_DIGEST_LEN 20
   12 #if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_SENDME_CELL)
   13 struct sendme_cell_st {
   14   uint8_t version;
   15   uint16_t data_len;
   16   uint8_t data_v1_digest[TRUNNEL_SENDME_V1_DIGEST_LEN];
   17   uint8_t trunnel_error_code_;
   18 };
   19 #endif
   20 typedef struct sendme_cell_st sendme_cell_t;
   21 /** Return a newly allocated sendme_cell with all elements set to
   22  * zero.
   23  */
   24 sendme_cell_t *sendme_cell_new(void);
   25 /** Release all storage held by the sendme_cell in 'victim'. (Do
   26  * nothing if 'victim' is NULL.)
   27  */
   28 void sendme_cell_free(sendme_cell_t *victim);
   29 /** Try to parse a sendme_cell from the buffer in 'input', using up to
   30  * 'len_in' bytes from the input buffer. On success, return the number
   31  * of bytes consumed and set *output to the newly allocated
   32  * sendme_cell_t. On failure, return -2 if the input appears
   33  * truncated, and -1 if the input is otherwise invalid.
   34  */
   35 ssize_t sendme_cell_parse(sendme_cell_t **output, const uint8_t *input, const size_t len_in);
   36 /** Return the number of bytes we expect to need to encode the
   37  * sendme_cell in 'obj'. On failure, return a negative value. Note
   38  * that this value may be an overestimate, and can even be an
   39  * underestimate for certain unencodeable objects.
   40  */
   41 ssize_t sendme_cell_encoded_len(const sendme_cell_t *obj);
   42 /** Try to encode the sendme_cell from 'input' into the buffer at
   43  * 'output', using up to 'avail' bytes of the output buffer. On
   44  * success, return the number of bytes used. On failure, return -2 if
   45  * the buffer was not long enough, and -1 if the input was invalid.
   46  */
   47 ssize_t sendme_cell_encode(uint8_t *output, size_t avail, const sendme_cell_t *input);
   48 /** Check whether the internal state of the sendme_cell in 'obj' is
   49  * consistent. Return NULL if it is, and a short message if it is not.
   50  */
   51 const char *sendme_cell_check(const sendme_cell_t *obj);
   52 /** Clear any errors that were set on the object 'obj' by its setter
   53  * functions. Return true iff errors were cleared.
   54  */
   55 int sendme_cell_clear_errors(sendme_cell_t *obj);
   56 /** Return the value of the version field of the sendme_cell_t in
   57  * 'inp'
   58  */
   59 uint8_t sendme_cell_get_version(const sendme_cell_t *inp);
   60 /** Set the value of the version field of the sendme_cell_t in 'inp'
   61  * to 'val'. Return 0 on success; return -1 and set the error code on
   62  * 'inp' on failure.
   63  */
   64 int sendme_cell_set_version(sendme_cell_t *inp, uint8_t val);
   65 /** Return the value of the data_len field of the sendme_cell_t in
   66  * 'inp'
   67  */
   68 uint16_t sendme_cell_get_data_len(const sendme_cell_t *inp);
   69 /** Set the value of the data_len field of the sendme_cell_t in 'inp'
   70  * to 'val'. Return 0 on success; return -1 and set the error code on
   71  * 'inp' on failure.
   72  */
   73 int sendme_cell_set_data_len(sendme_cell_t *inp, uint16_t val);
   74 /** Return the (constant) length of the array holding the
   75  * data_v1_digest field of the sendme_cell_t in 'inp'.
   76  */
   77 size_t sendme_cell_getlen_data_v1_digest(const sendme_cell_t *inp);
   78 /** Return the element at position 'idx' of the fixed array field
   79  * data_v1_digest of the sendme_cell_t in 'inp'.
   80  */
   81 uint8_t sendme_cell_get_data_v1_digest(sendme_cell_t *inp, size_t idx);
   82 /** As sendme_cell_get_data_v1_digest, but take and return a const
   83  * pointer
   84  */
   85 uint8_t sendme_cell_getconst_data_v1_digest(const sendme_cell_t *inp, size_t idx);
   86 /** Change the element at position 'idx' of the fixed array field
   87  * data_v1_digest of the sendme_cell_t in 'inp', so that it will hold
   88  * the value 'elt'.
   89  */
   90 int sendme_cell_set_data_v1_digest(sendme_cell_t *inp, size_t idx, uint8_t elt);
   91 /** Return a pointer to the TRUNNEL_SENDME_V1_DIGEST_LEN-element array
   92  * field data_v1_digest of 'inp'.
   93  */
   94 uint8_t * sendme_cell_getarray_data_v1_digest(sendme_cell_t *inp);
   95 /** As sendme_cell_get_data_v1_digest, but take and return a const
   96  * pointer
   97  */
   98 const uint8_t  * sendme_cell_getconstarray_data_v1_digest(const sendme_cell_t *inp);
   99 
  100 
  101 #endif