Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add macro checks for DNS Cache to fix build issue #1200

Closed
wants to merge 2 commits into from

Conversation

kar-rahul-aws
Copy link
Member

Description

This PR addresses the issue for compilation issue when ipconfigUSE_DNS_CACHE is set to 0.

Test Steps

Build FreeRTOS_Plus_TCP_Echo_Posix_Demo .
Before applying the patch

/home/karahulx/FreeRTOS/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/source/FreeRTOS_DNS_Parser.c: In function ‘DNS_ReadNameField’:
/home/karahulx/FreeRTOS/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/source/FreeRTOS_DNS_Parser.c:104:26: error: ‘ParseSet_t’ {aka ‘struct xParseSet’} has no member named ‘pcName’
  104 |                     pxSet->pcName[ uxNameLen ] = '.';
      |                          ^~
/home/karahulx/FreeRTOS/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/source/FreeRTOS_DNS_Parser.c:133:26: error: ‘ParseSet_t’ {aka ‘struct xParseSet’} has no member named ‘pcName’
  133 |                     pxSet->pcName[ uxNameLen ] = ( char ) pucByte[ uxIndex ];
      |                          ^~
/home/karahulx/FreeRTOS/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/source/FreeRTOS_DNS_Parser.c:151:26: error: ‘ParseSet_t’ {aka ‘struct xParseSet’} has no member named ‘pcName’
  151 |                     pxSet->pcName[ uxNameLen ] = '\0';
      |                          ^~
/home/karahulx/FreeRTOS/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/source/FreeRTOS_DNS_Parser.c: In function ‘DNS_ParseDNSReply’:
/home/karahulx/FreeRTOS/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/source/FreeRTOS_DNS_Parser.c:470:94: error: ‘ParseSet_t’ {aka ‘struct xParseSet’} has no member named ‘pcName’
  470 |                             xDNSHookReturn = xApplicationDNSQueryHook_Multi( &xEndPoint, xSet.pcName );
      |                                                                                              ^
/home/karahulx/FreeRTOS/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/source/FreeRTOS_DNS_Parser.c: In function ‘parseDNSAnswer’:
/home/karahulx/FreeRTOS/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/source/FreeRTOS_DNS_Parser.c:740:65: error: ‘ParseSet_t’ {aka ‘struct xParseSet’} has no member named ‘pcName’
  740 |                             pxNewAddress = pxNew_AddrInfo( pxSet->pcName, FREERTOS_AF_INET6, xIP_Address.xIPAddress.xIP_IPv6.ucBytes );
      |                                                                 ^~
/home/karahulx/FreeRTOS/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/source/FreeRTOS_DNS_Parser.c:770:65: error: ‘ParseSet_t’ {aka ‘struct xParseSet’} has no member named ‘pcName’
  770 |                             pxNewAddress = pxNew_AddrInfo( pxSet->pcName, FREERTOS_AF_INET4, ucBytes );
      |                                                                 ^~
make: *** [Makefile:112: build//home/karahulx/FreeRTOS/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/source/FreeRTOS_DNS_Parser.o] Error 1

After applying the patch, the project compiles and runs successfully.

Checklist:

  • I have tested my changes. No regression in existing tests.
  • I have modified and/or added unit-tests to cover the code changes in this Pull Request.

Related Issue

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@kar-rahul-aws kar-rahul-aws requested a review from a team as a code owner October 28, 2024 18:23
Copy link
Member

@ActoryOu ActoryOu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides, could you add some UT to cover this scenario?

#else
xDNSHookReturn = xApplicationDNSQueryHook_Multi( &xEndPoint, xSet.pcName );
#endif
#if ( ( ipconfigUSE_DNS_CACHE == 1 ) || ( ipconfigDNS_USE_CALLBACKS == 1 ) )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change forces user to enable CACHE or CALLBACK while using MDNS/LLMNR, which I think is incorrect.

{
pxNewAddress = pxNew_AddrInfo( pxSet->pcName, FREERTOS_AF_INET6, xIP_Address.xIPAddress.xIP_IPv6.ucBytes );
}
#if ( ipconfigUSE_DNS_CACHE == 1 ) || ( ipconfigDNS_USE_CALLBACKS == 1 )
Copy link
Member

@ActoryOu ActoryOu Oct 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some more comments in the code to help developers understand why wrapping this is still working if pxNewAddress is NULL when CACHE/CALLBACK are disabled.

@ActoryOu
Copy link
Member

Closing because we have #1201 for this issue.

@ActoryOu ActoryOu closed this Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants