Skip to content
Snippets Groups Projects
Commit a163898a authored by Michael Tüxen's avatar Michael Tüxen
Browse files

Merge pull request #37 from TheAomx/master

This fixes #34.
parents bf931f61 499a5a8c
No related branches found
No related tags found
No related merge requests found
......@@ -1254,12 +1254,19 @@ sctp_error_chunk_spec
}
sctp_cookie_echo_chunk_spec
: COOKIE_ECHO '[' opt_flags ',' opt_len ',' VAL '=' ELLIPSIS ']' {
: COOKIE_ECHO '[' opt_flags ',' opt_len ',' opt_val ']' {
if (($5 != -1) &&
(!is_valid_u16($5) || ($5 < sizeof(struct sctp_cookie_echo_chunk)))) {
semantic_error("length value out of range");
}
$$ = sctp_cookie_echo_chunk_new($3, $5, NULL);
if (($5 != -1) && ($7 != NULL) &&
($5 != sizeof(struct sctp_cookie_echo_chunk) + $7->nr_entries)) {
semantic_error("length value incompatible with val");
}
if (($5 == -1) && ($7 != NULL)) {
semantic_error("length needs to be specified");
}
$$ = sctp_cookie_echo_chunk_new($3, $5, $7);
}
sctp_cookie_ack_chunk_spec
......
......@@ -2409,6 +2409,13 @@ static int do_inbound_script_packet(
}
break;
case SCTP_COOKIE_ECHO_CHUNK_TYPE:
if (!(item->flags & FLAG_CHUNK_VALUE_NOCHECK)) break; // if the cookie was explicitly
// added to the test script, we dont
// need to copy the saved cookie
// from the init_ack chunk ...
// TODO: can this be done in a more readable way?
if (socket->state == SOCKET_PASSIVE_INIT_ACK_SENT) {
temp_offset = socket->prepared_cookie_echo_length - item->length;
assert(packet->ip_bytes + temp_offset <= packet->buffer_bytes);
......
......@@ -939,11 +939,12 @@ sctp_error_chunk_new(s64 flgs, struct sctp_cause_list *list)
}
struct sctp_chunk_list_item *
sctp_cookie_echo_chunk_new(s64 flgs, s64 len, u8* cookie)
sctp_cookie_echo_chunk_new(s64 flgs, s64 len, struct sctp_byte_list *cookie)
{
struct sctp_cookie_echo_chunk *chunk;
struct sctp_byte_list_item *item;
u32 flags;
u16 chunk_length, cookie_length, padding_length;
u16 chunk_length, cookie_length, padding_length, i;
assert((len == -1) ||
(is_valid_u16(len) &&
......@@ -973,7 +974,11 @@ sctp_cookie_echo_chunk_new(s64 flgs, s64 len, u8* cookie)
}
chunk->length = htons(chunk_length);
if (cookie != NULL) {
memcpy(chunk->cookie, cookie, cookie_length);
for (i = 0, item = cookie->first;
item != NULL;
i++, item = item->next) {
chunk->cookie[i] = item->byte;
}
} else {
flags |= FLAG_CHUNK_VALUE_NOCHECK;
memset(chunk->cookie, 'A', cookie_length);
......
......@@ -257,7 +257,7 @@ struct sctp_chunk_list_item *
sctp_error_chunk_new(s64 flgs, struct sctp_cause_list *causes);
struct sctp_chunk_list_item *
sctp_cookie_echo_chunk_new(s64 flgs, s64 len, u8* cookie);
sctp_cookie_echo_chunk_new(s64 flgs, s64 len, struct sctp_byte_list *cookie);
struct sctp_chunk_list_item *
sctp_cookie_ack_chunk_new(s64 flgs);
......
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