Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/lexicon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ dw
dword
dzpq
eagain
eapplicationprocesscustomframehook
earpcachehit
earpcachemiss
earptimerevent
Expand Down
24 changes: 22 additions & 2 deletions FreeRTOS_IP.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,21 @@ static void prvIPTask( void * pvParameters );
*/
static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetworkBuffer );

#if ( ipconfigPROCESS_CUSTOM_ETHERNET_FRAMES != 0 )

/*
* The stack will call this user hook for all Ethernet frames that it
* does not support, i.e. other than IPv4, IPv6 and ARP ( for the moment )
* If this hook returns eReleaseBuffer or eProcessBuffer, the stack will
* release and reuse the network buffer. If this hook returns
* eReturnEthernetFrame, that means user code has reused the network buffer
* to generate a response and the stack will send that response out.
* If this hook returns eFrameConsumed, the user code has ownership of the
* network buffer and has to release it when it’s done.
*/
extern eFrameProcessingResult_t eApplicationProcessCustomFrameHook( NetworkBufferDescriptor_t * const pxNetworkBuffer );
#endif /* ( ipconfigPROCESS_CUSTOM_ETHERNET_FRAMES != 0 ) */
Copy link
Contributor

Choose a reason for hiding this comment

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

Hello @evpopov , thanks for this PR. It extends the possibilities of the stack without adding any real code.
As we already have discussed it on the FreeRTOS forum, and I think it is good.


/*
* Process incoming IP packets.
*/
Expand Down Expand Up @@ -1727,8 +1742,13 @@ static void prvProcessEthernetPacket( NetworkBufferDescriptor_t * const pxNetwor
break;

default:
/* No other packet types are handled. Nothing to do. */
eReturned = eReleaseBuffer;
#if ( ipconfigPROCESS_CUSTOM_ETHERNET_FRAMES != 0 )
/* Custom frame handler. */
eReturned = eApplicationProcessCustomFrameHook( pxNetworkBuffer );
#else
/* No other packet types are handled. Nothing to do. */
eReturned = eReleaseBuffer;
#endif
break;
}
}
Expand Down
8 changes: 8 additions & 0 deletions include/FreeRTOSIPConfigDefaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -633,4 +633,12 @@
#define ipconfigSELECT_USES_NOTIFY 0
#endif

/* Set to 1 if you plan on processing custom Ethernet protocols or protocols
* that are not yet supported by the FreeRTOS+TCP stack. If set to 1,
* the user must define eFrameProcessingResult_t eApplicationProcessCustomFrameHook( NetworkBufferDescriptor_t * const pxNetworkBuffer )
* which will be called by the stack for any frame with an unsupported EtherType. */
#ifndef ipconfigPROCESS_CUSTOM_ETHERNET_FRAMES
#define ipconfigPROCESS_CUSTOM_ETHERNET_FRAMES 0
#endif

#endif /* FREERTOS_DEFAULT_IP_CONFIG_H */