Skip to content
Snippets Groups Projects
Commit 7d3e904a authored by David Goulet's avatar David Goulet :panda_face: Committed by Nick Mathewson
Browse files

trunnel: Remove INTRODUCE1 status code IN statement


We want to support parsing a cell with unknown status code so we are forward
compatible.

Part of #30454

Signed-off-by: David Goulet's avatarDavid Goulet <dgoulet@torproject.org>
parent 9f52b875
No related branches found
No related tags found
No related merge requests found
......@@ -520,7 +520,6 @@ trn_cell_introduce_ack_new(void)
trn_cell_introduce_ack_t *val = trunnel_calloc(1, sizeof(trn_cell_introduce_ack_t));
if (NULL == val)
return NULL;
val->status = TRUNNEL_HS_INTRO_ACK_STATUS_BAD_FORMAT;
return val;
}
......@@ -552,10 +551,6 @@ trn_cell_introduce_ack_get_status(const trn_cell_introduce_ack_t *inp)
int
trn_cell_introduce_ack_set_status(trn_cell_introduce_ack_t *inp, uint16_t val)
{
if (! ((val == TRUNNEL_HS_INTRO_ACK_STATUS_BAD_FORMAT || val == TRUNNEL_HS_INTRO_ACK_STATUS_SUCCESS || val == TRUNNEL_HS_INTRO_ACK_STATUS_UNKNOWN_ID))) {
TRUNNEL_SET_ERROR_CODE(inp);
return -1;
}
inp->status = val;
return 0;
}
......@@ -589,8 +584,6 @@ trn_cell_introduce_ack_check(const trn_cell_introduce_ack_t *obj)
return "Object was NULL";
if (obj->trunnel_error_code_)
return "A set function failed on this object";
if (! (obj->status == TRUNNEL_HS_INTRO_ACK_STATUS_BAD_FORMAT || obj->status == TRUNNEL_HS_INTRO_ACK_STATUS_SUCCESS || obj->status == TRUNNEL_HS_INTRO_ACK_STATUS_UNKNOWN_ID))
return "Integer out of bounds";
{
const char *msg;
if (NULL != (msg = trn_cell_extension_check(obj->extensions)))
......@@ -608,7 +601,7 @@ trn_cell_introduce_ack_encoded_len(const trn_cell_introduce_ack_t *obj)
return -1;
/* Length of u16 status IN [TRUNNEL_HS_INTRO_ACK_STATUS_BAD_FORMAT, TRUNNEL_HS_INTRO_ACK_STATUS_SUCCESS, TRUNNEL_HS_INTRO_ACK_STATUS_UNKNOWN_ID] */
/* Length of u16 status */
result += 2;
/* Length of struct trn_cell_extension extensions */
......@@ -640,7 +633,7 @@ trn_cell_introduce_ack_encode(uint8_t *output, const size_t avail, const trn_cel
trunnel_assert(encoded_len >= 0);
#endif
/* Encode u16 status IN [TRUNNEL_HS_INTRO_ACK_STATUS_BAD_FORMAT, TRUNNEL_HS_INTRO_ACK_STATUS_SUCCESS, TRUNNEL_HS_INTRO_ACK_STATUS_UNKNOWN_ID] */
/* Encode u16 status */
trunnel_assert(written <= avail);
if (avail - written < 2)
goto truncated;
......@@ -689,12 +682,10 @@ trn_cell_introduce_ack_parse_into(trn_cell_introduce_ack_t *obj, const uint8_t *
ssize_t result = 0;
(void)result;
/* Parse u16 status IN [TRUNNEL_HS_INTRO_ACK_STATUS_BAD_FORMAT, TRUNNEL_HS_INTRO_ACK_STATUS_SUCCESS, TRUNNEL_HS_INTRO_ACK_STATUS_UNKNOWN_ID] */
/* Parse u16 status */
CHECK_REMAINING(2, truncated);
obj->status = trunnel_ntohs(trunnel_get_uint16(ptr));
remaining -= 2; ptr += 2;
if (! (obj->status == TRUNNEL_HS_INTRO_ACK_STATUS_BAD_FORMAT || obj->status == TRUNNEL_HS_INTRO_ACK_STATUS_SUCCESS || obj->status == TRUNNEL_HS_INTRO_ACK_STATUS_UNKNOWN_ID))
goto fail;
/* Parse struct trn_cell_extension extensions */
result = trn_cell_extension_parse(&obj->extensions, ptr, remaining);
......@@ -710,9 +701,6 @@ trn_cell_introduce_ack_parse_into(trn_cell_introduce_ack_t *obj, const uint8_t *
relay_fail:
trunnel_assert(result < 0);
return result;
fail:
result = -1;
return result;
}
ssize_t
......
......@@ -44,9 +44,7 @@ struct trn_cell_introduce1 {
/* INTRODUCE_ACK payload. See details in section 3.2.2. */
struct trn_cell_introduce_ack {
/* Status of introduction. */
u16 status IN [TRUNNEL_HS_INTRO_ACK_STATUS_SUCCESS,
TRUNNEL_HS_INTRO_ACK_STATUS_UNKNOWN_ID,
TRUNNEL_HS_INTRO_ACK_STATUS_BAD_FORMAT];
u16 status;
/* Extension(s). Reserved fields. */
struct trn_cell_extension extensions;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment