diff options
author | David Goulet <dgoulet@torproject.org> | 2017-07-21 17:06:04 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2017-08-24 13:03:28 -0400 |
commit | cb336a7062f87c5c306549a4f4a26eab66c5b825 (patch) | |
tree | 98bbdeba5938c46e530919916a9ee9ca7ee5bebd /src/or/hs_cell.c | |
parent | e7c06e694766c6e2fb1f06ed5e1bf9c216e7a976 (diff) | |
download | tor-cb336a7062f87c5c306549a4f4a26eab66c5b825.tar.gz tor-cb336a7062f87c5c306549a4f4a26eab66c5b825.zip |
prop224: Parse INTRODUCE_ACK cell
Add a function to parse an INTRODUCE_ACK cell in hs_cell.c. Furthermore, add
an enum that lists all possible expected status code.
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/hs_cell.c')
-rw-r--r-- | src/or/hs_cell.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/or/hs_cell.c b/src/or/hs_cell.c index 64e164c061..1f9df825f0 100644 --- a/src/or/hs_cell.c +++ b/src/or/hs_cell.c @@ -864,3 +864,26 @@ hs_cell_build_establish_rendezvous(const uint8_t *rendezvous_cookie, return HS_REND_COOKIE_LEN; } +/* Handle an INTRODUCE_ACK cell encoded in payload of length payload_len. + * Return the status code on success else a negative value if the cell as not + * decodable. */ +int +hs_cell_parse_introduce_ack(const uint8_t *payload, size_t payload_len) +{ + int ret = -1; + trn_cell_introduce_ack_t *cell = NULL; + + tor_assert(payload); + + if (trn_cell_introduce_ack_parse(&cell, payload, payload_len) < 0) { + log_info(LD_REND, "Invalid INTRODUCE_ACK cell. Unable to parse it."); + goto end; + } + + ret = trn_cell_introduce_ack_get_status(cell); + + end: + trn_cell_introduce_ack_free(cell); + return ret; +} + |