diff options
Diffstat (limited to 'src/encrypted_packet.c')
-rw-r--r-- | src/encrypted_packet.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/encrypted_packet.c b/src/encrypted_packet.c index 7be3cd5..fdbc288 100644 --- a/src/encrypted_packet.c +++ b/src/encrypted_packet.c @@ -63,6 +63,21 @@ u_int32_t encrypted_packet_get_length(encrypted_packet_t* packet) return (packet->payload_length_ + sizeof(encrypted_packet_header_t)); } +void encrypted_packet_set_length(encrypted_packet_t* packet, u_int32_t len) +{ + if(!packet) + return; + + if(len > ENCRYPTED_PACKET_SIZE_MAX) + len = ENCRYPTED_PACKET_SIZE_MAX - sizeof(encrypted_packet_header_t); + else if(len < sizeof(encrypted_packet_header_t)) + len = 0; + else + len -= sizeof(encrypted_packet_header_t); + + packet->payload_length_ = len; +} + u_int8_t* encrypted_packet_get_payload(encrypted_packet_t* packet) { if(!packet) @@ -79,17 +94,6 @@ u_int32_t encrypted_packet_get_payload_length(encrypted_packet_t* packet) return packet->payload_length_; } -void encrypted_packet_set_payload_length(encrypted_packet_t* packet, u_int32_t len) -{ - if(!packet) - return; - - if(len > ENCRYPTED_PACKET_SIZE_MAX || (len + sizeof(encrypted_packet_header_t)) > ENCRYPTED_PACKET_SIZE_MAX) - len = ENCRYPTED_PACKET_SIZE_MAX - sizeof(encrypted_packet_header_t); - - packet->payload_length_ = len; -} - seq_nr_t encrypted_packet_get_seq_nr(encrypted_packet_t* packet) { if(!packet) |