diff options
author | David Goulet <dgoulet@torproject.org> | 2017-07-23 13:01:00 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2017-08-24 13:03:28 -0400 |
commit | ee15c16742aecb4795ce12847068b7907be9e8a2 (patch) | |
tree | c937b4961910ff8d5fc4aaee766a357d75bbe2e3 /src/or/hs_cell.c | |
parent | 2f1b3d647ff1489f4cb0f25d96701eaf35e076da (diff) | |
download | tor-ee15c16742aecb4795ce12847068b7907be9e8a2.tar.gz tor-ee15c16742aecb4795ce12847068b7907be9e8a2.zip |
prop224: Parse RENDEZVOUS2 cell
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/hs_cell.c')
-rw-r--r-- | src/or/hs_cell.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/or/hs_cell.c b/src/or/hs_cell.c index c5ea6e4db7..482fa04e92 100644 --- a/src/or/hs_cell.c +++ b/src/or/hs_cell.c @@ -899,3 +899,35 @@ hs_cell_parse_introduce_ack(const uint8_t *payload, size_t payload_len) return ret; } +/* Handle a RENDEZVOUS2 cell encoded in payload of length payload_len. On + * success, handshake_info contains the data in the HANDSHAKE_INFO field, and + * 0 is returned. On error, a negative value is returned. */ +int +hs_cell_parse_rendezvous2(const uint8_t *payload, size_t payload_len, + uint8_t *handshake_info, size_t handshake_info_len) +{ + int ret = -1; + trn_cell_rendezvous2_t *cell = NULL; + + tor_assert(payload); + tor_assert(handshake_info); + + if (trn_cell_rendezvous2_parse(&cell, payload, payload_len) < 0) { + log_info(LD_REND, "Invalid RENDEZVOUS2 cell. Unable to parse it."); + goto end; + } + + /* Static size, we should never have an issue with this else we messed up + * our code flow. */ + tor_assert(trn_cell_rendezvous2_getlen_handshake_info(cell) == + handshake_info_len); + memcpy(handshake_info, + trn_cell_rendezvous2_getconstarray_handshake_info(cell), + handshake_info_len); + ret = 0; + + end: + trn_cell_rendezvous2_free(cell); + return ret; +} + |