@@ -134,23 +134,23 @@ static BaseType_t prvLoopback_Output( NetworkInterface_t * pxInterface,
134134 }
135135
136136 {
137- MACAddress_t xMACAddress ;
137+ const MACAddress_t * pxMACAddress = & ( pxDescriptor -> pxEndPoint -> xMACAddress ) ;
138138
139139 if ( pxDescriptor -> pxEndPoint -> bits .bIPv6 != 0 )
140140 {
141141 #if ( ipconfigUSE_IPv6 != 0 )
142- if ( xIsIPv6Loopback ( & ( pxDescriptor -> xIPAddress ) ) != pdFALSE )
142+ if ( xIsIPv6Loopback ( & ( pxDescriptor -> xIPAddress . xIP_IPv6 ) ) != pdFALSE )
143143 {
144- vNDRefreshCacheEntry ( & xMACAddress , & ( pxDescriptor -> xIPAddress .xIP_IPv6 ), pxDescriptor -> pxEndPoint );
144+ vNDRefreshCacheEntry ( pxMACAddress , & ( pxDescriptor -> xIPAddress .xIP_IPv6 ), pxDescriptor -> pxEndPoint );
145145 }
146146 #endif
147147 }
148148 else
149149 {
150150 #if ( ipconfigUSE_IPv4 != 0 )
151- if ( xIsIPv4Loopback ( pxDescriptor -> xIPAddress .ulIP_IPv4 ) )
151+ if ( xIsIPv4Loopback ( pxDescriptor -> xIPAddress .ulIP_IPv4 ) != pdFALSE )
152152 {
153- vARPRefreshCacheEntry ( & xMACAddress , pxDescriptor -> xIPAddress .ulIP_IPv4 , pxDescriptor -> pxEndPoint );
153+ vARPRefreshCacheEntry ( pxMACAddress , pxDescriptor -> xIPAddress .ulIP_IPv4 , pxDescriptor -> pxEndPoint );
154154 }
155155 #endif
156156 }
@@ -170,11 +170,21 @@ static BaseType_t prvLoopback_Output( NetworkInterface_t * pxInterface,
170170 xRxEvent .eEventType = eNetworkRxEvent ;
171171 xRxEvent .pvData = ( void * ) pxDescriptor ;
172172
173- if ( xSendEventStructToIPTask ( & xRxEvent , 0u ) != pdTRUE )
173+ pxDescriptor -> pxInterface = xLoopbackInterface ;
174+ pxDescriptor -> pxEndPoint = FreeRTOS_MatchingEndpoint ( xLoopbackInterface , pxDescriptor -> pucEthernetBuffer );
175+
176+ if ( pxDescriptor -> pxEndPoint == NULL )
177+ {
178+ vReleaseNetworkBufferAndDescriptor ( pxDescriptor );
179+ iptraceETHERNET_RX_EVENT_LOST ();
180+ FreeRTOS_printf ( ( "prvLoopback_Output: Can not find a proper endpoint\n" ) );
181+ }
182+ else if ( xSendEventStructToIPTask ( & xRxEvent , 0u ) != pdTRUE )
174183 {
184+ /* Sending failed, release the descriptor. */
175185 vReleaseNetworkBufferAndDescriptor ( pxDescriptor );
176186 iptraceETHERNET_RX_EVENT_LOST ();
177- FreeRTOS_printf ( ( "prvEMACRxPoll : Can not queue return packet!\n" ) );
187+ FreeRTOS_printf ( ( "prvLoopback_Output : Can not queue return packet!\n" ) );
178188 }
179189 }
180190
0 commit comments