Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
UDP: Add ipconfigUDP_PASS_ZERO_CHECKSUM_PACKETS compile time constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Hein Tibosch committed Jul 3, 2020
1 parent 44f2f1c commit df9b39d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,11 @@ from the FreeRTOSIPConfig.h configuration header file. */
#endif

#ifndef ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND
#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
#define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1
#endif

#ifndef ipconfigUDP_PASS_ZERO_CHECKSUM_PACKETS
#define ipconfigUDP_PASS_ZERO_CHECKSUM_PACKETS 0
#endif

#ifndef ipconfigUDP_TIME_TO_LIVE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,12 @@ events are posted to the network event queue. */
handled. The value is chosen simply to be easy to spot when debugging. */
#define ipUNHANDLED_PROTOCOL 0x4321U

/* Returned to indicate a valid checksum when the checksum does not need to be
calculated. */
/* Returned to indicate a valid checksum. */
#define ipCORRECT_CRC 0xffffU

/* Returned to indicate incorrect checksum. */
#define ipWRONG_CRC 0x0000U

/* Returned as the (invalid) checksum when the length of the data being checked
had an invalid length. */
#define ipINVALID_LENGTH 0x1234U
Expand Down Expand Up @@ -2029,8 +2031,18 @@ BaseType_t location = 0;
}
else if( ( *pusChecksum == 0U ) && ( ucProtocol == ( uint8_t ) ipPROTOCOL_UDP ) )
{
/* Sender hasn't set the checksum, no use to calculate it. */
usChecksum = ipCORRECT_CRC;
#if( ipconfigUDP_PASS_ZERO_CHECKSUM_PACKETS == 0 )
{
/* Sender hasn't set the checksum, drop the packet because
ipconfigUDP_PASS_ZERO_CHECKSUM_PACKETS is not set. */
usChecksum = ipWRONG_CRC;
}
#else
{
/* Sender hasn't set the checksum, no use to calculate it. */
usChecksum = ipCORRECT_CRC;
}
#endif
location = 8;
goto error_exit;
}
Expand Down

0 comments on commit df9b39d

Please sign in to comment.