Skip to content

Commit

Permalink
coap_session.c: Use existing constants for L4-specific header sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
kkrentz committed Sep 17, 2024
1 parent fde7193 commit 0814fe0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/coap_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,10 +604,14 @@ coap_session_max_pdu_size_internal(const coap_session_t *session,
size_t max_with_header) {
#if COAP_DISABLE_TCP
(void)session;
return max_with_header > 4 ? max_with_header - 4 : 0;
return max_with_header > COAP_PDU_MAX_UDP_HEADER_SIZE
? max_with_header - COAP_PDU_MAX_UDP_HEADER_SIZE
: 0;
#else /* !COAP_DISABLE_TCP */
if (COAP_PROTO_NOT_RELIABLE(session->proto))
return max_with_header > 4 ? max_with_header - 4 : 0;
return max_with_header > COAP_PDU_MAX_UDP_HEADER_SIZE
? max_with_header - COAP_PDU_MAX_UDP_HEADER_SIZE
: 0;
/* we must assume there is no token to be on the safe side */
if (max_with_header <= 2)
return 0;
Expand All @@ -618,7 +622,7 @@ coap_session_max_pdu_size_internal(const coap_session_t *session,
else if (max_with_header <= COAP_MAX_MESSAGE_SIZE_TCP16 + 4)
return max_with_header - 4;
else
return max_with_header - 6;
return max_with_header - COAP_PDU_MAX_TCP_HEADER_SIZE;
#endif /* !COAP_DISABLE_TCP */
}

Expand Down

0 comments on commit 0814fe0

Please sign in to comment.