generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 208
FreeRTOS_ARP.c : store local addresses only #120
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
Merged
AniruddhaKanhere
merged 15 commits into
FreeRTOS:main
from
htibosch:dhcp_store_local_addresses_only
Jan 15, 2021
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
72b16b0
FreeRTOS_ARP.c : store local addresses only
36cc8f8
Added the function xARPWaitResolution()
1aff4bf
Added an entry to lexicon.txt.
8f92f6f
Merge branch 'main' into dhcp_store_local_addresses_only
AniruddhaKanhere ec769b2
Merge branch 'main' into dhcp_store_local_addresses_only
AniruddhaKanhere 5127d2d
Merge branch 'main' into dhcp_store_local_addresses_only
AniruddhaKanhere 1f276dd
Merge branch 'main' into dhcp_store_local_addresses_only
AniruddhaKanhere cfd75e9
Merge branch 'main' into dhcp_store_local_addresses_only
AniruddhaKanhere d7c9479
Ran Uncrustify
3946927
Update unit test file
AniruddhaKanhere fd98fbc
Update
AniruddhaKanhere 8f61010
Declared xARPWaitResolution() in FreeRTOS_IP.h
7cc70c2
Compare the result of xIsCallingFromIPTask() with pdFALSE in stead of 0
d205902
Merge branch 'main' into dhcp_store_local_addresses_only
AniruddhaKanhere 09a9f3c
Merge branch 'main' into dhcp_store_local_addresses_only
AniruddhaKanhere File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -271,12 +271,8 @@ void vARPRefreshCacheEntry( const MACAddress_t * pxMACAddress, | |
| uint8_t ucMinAgeFound = 0U; | ||
|
|
||
| #if ( ipconfigARP_STORES_REMOTE_ADDRESSES == 0 ) | ||
|
|
||
| /* Only process the IP address if it is on the local network. | ||
| * Unless: when '*ipLOCAL_IP_ADDRESS_POINTER' equals zero, the IP-address | ||
| * and netmask are still unknown. */ | ||
| if( ( ( ulIPAddress & xNetworkAddressing.ulNetMask ) == ( ( *ipLOCAL_IP_ADDRESS_POINTER ) & xNetworkAddressing.ulNetMask ) ) || | ||
| ( *ipLOCAL_IP_ADDRESS_POINTER == 0UL ) ) | ||
| /* Only process the IP address if it is on the local network. */ | ||
| if( ( ulIPAddress & xNetworkAddressing.ulNetMask ) == ( ( *ipLOCAL_IP_ADDRESS_POINTER ) & xNetworkAddressing.ulNetMask ) ) | ||
| #else | ||
|
|
||
| /* If ipconfigARP_STORES_REMOTE_ADDRESSES is non-zero, IP addresses with | ||
|
|
@@ -492,16 +488,6 @@ eARPLookupResult_t eARPGetCacheEntry( uint32_t * pulIPAddress, | |
|
|
||
| ulAddressToLookup = *pulIPAddress; | ||
|
|
||
| #if ( ipconfigUSE_LLMNR == 1 ) | ||
| if( ulAddressToLookup == ipLLMNR_IP_ADDR ) /* Is in network byte order. */ | ||
| { | ||
| /* The LLMNR IP-address has a fixed virtual MAC address. */ | ||
| ( void ) memcpy( pxMACAddress->ucBytes, xLLMNR_MacAdress.ucBytes, sizeof( MACAddress_t ) ); | ||
| eReturn = eARPCacheHit; | ||
| } | ||
| else | ||
| #endif | ||
|
|
||
| if( xIsIPv4Multicast( ulAddressToLookup ) != 0 ) | ||
| { | ||
| /* Get the lowest 23 bits of the IP-address. */ | ||
|
|
@@ -522,6 +508,12 @@ eARPLookupResult_t eARPGetCacheEntry( uint32_t * pulIPAddress, | |
| * can be done. */ | ||
| eReturn = eCantSendPacket; | ||
| } | ||
| else if( *ipLOCAL_IP_ADDRESS_POINTER == *pulIPAddress ) | ||
| { | ||
| /* The address of this device. May be useful for the loopback device. */ | ||
| eReturn = eARPCacheHit; | ||
| memcpy( pxMACAddress->ucBytes, ipLOCAL_MAC_ADDRESS, sizeof( pxMACAddress->ucBytes ) ); | ||
| } | ||
| else | ||
| { | ||
| eReturn = eARPCacheMiss; | ||
|
|
@@ -747,7 +739,7 @@ void FreeRTOS_OutputARPRequest( uint32_t ulIPAddress ) | |
| } | ||
| #endif /* if defined( ipconfigETHERNET_MINIMUM_PACKET_BYTES ) */ | ||
|
|
||
| if( xIsCallingFromIPTask() != 0 ) | ||
| if( xIsCallingFromIPTask() != pdFALSE ) | ||
| { | ||
| iptraceNETWORK_INTERFACE_OUTPUT( pxNetworkBuffer->xDataLength, pxNetworkBuffer->pucEthernetBuffer ); | ||
| /* Only the IP-task is allowed to call this function directly. */ | ||
|
|
@@ -769,7 +761,63 @@ void FreeRTOS_OutputARPRequest( uint32_t ulIPAddress ) | |
| } | ||
| } | ||
| } | ||
| /*--------------------------------------*/ | ||
| /*-----------------------------------------------------------*/ | ||
|
|
||
| /** | ||
| * @brief Wait for address resolution: look-up the IP-address in the ARP-cache, and if | ||
| * needed send an ARP request, and wait for a reply. This function is useful when | ||
| * called before FreeRTOS_sendto(). | ||
| * | ||
| * @param[in] ulIPAddress: The IP-address to look-up. | ||
| * @param[in] uxTicksToWait: The maximum number of clock ticks to wait for a reply. | ||
| * | ||
| * @return Zero when successful. | ||
| */ | ||
| BaseType_t xARPWaitResolution( uint32_t ulIPAddress, | ||
| TickType_t uxTicksToWait ) | ||
| { | ||
| BaseType_t xResult = -pdFREERTOS_ERRNO_EADDRNOTAVAIL; | ||
| TimeOut_t xTimeOut; | ||
| MACAddress_t xMACAddress; | ||
| eARPLookupResult_t xLookupResult; | ||
| size_t uxSendCount = ipconfigMAX_ARP_RETRANSMISSIONS; | ||
|
|
||
| /* The IP-task is not supposed to call this function. */ | ||
| configASSERT( xIsCallingFromIPTask() == pdFALSE ); | ||
|
|
||
| xLookupResult = eARPGetCacheEntry( &( ulIPAddress ), &( xMACAddress ) ); | ||
|
|
||
| if( xLookupResult == eARPCacheMiss ) | ||
| { | ||
| const TickType_t uxSleepTime = pdMS_TO_TICKS( 250U ); | ||
|
|
||
| /* We might use ipconfigMAX_ARP_RETRANSMISSIONS here. */ | ||
| vTaskSetTimeOutState( &xTimeOut ); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are |
||
|
|
||
| while( uxSendCount > 0 ) | ||
| { | ||
| FreeRTOS_OutputARPRequest( ulIPAddress ); | ||
|
|
||
| vTaskDelay( uxSleepTime ); | ||
|
|
||
| xLookupResult = eARPGetCacheEntry( &( ulIPAddress ), &( xMACAddress ) ); | ||
|
|
||
| if( ( xTaskCheckForTimeOut( &( xTimeOut ), &( uxTicksToWait ) ) == pdTRUE ) || | ||
| ( xLookupResult != eARPCacheMiss ) ) | ||
| { | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if( xLookupResult == eARPCacheHit ) | ||
| { | ||
| xResult = 0; | ||
| } | ||
|
|
||
| return xResult; | ||
| } | ||
| /*-----------------------------------------------------------*/ | ||
|
|
||
| /** | ||
| * @brief Generate an ARP request packet by copying various constant details to | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this function declared? What I mean to say is that how can one use this function? What header file is required to add this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry, I had declared it in FreeRTOS_IP.h, now updated.