Improve DCHP handling by removing the yiaddr field from outgoing DHCP packets and adding the broadcast bit in the flags field.

Correct the check to ensure the application network event hook is not called when the first network down event is sent.
Add in defaults for the Nabto task stack and priority.
pull/4/head
Richard Barry 11 years ago
parent 7ec4773131
commit be44f8aaa7

@ -135,10 +135,12 @@ made up of the length byte, and minimum one byte value. */
#define dhcpCLIENT_PORT 0x4400
#define dhcpSERVER_PORT 0x4300
#define dhcpCOOKIE 0x63538263
#define dhcpBROADCAST 0x0080
#else
#define dhcpCLIENT_PORT 0x0044
#define dhcpSERVER_PORT 0x0043
#define dhcpCOOKIE 0x63825363
#define dhcpBROADCAST 0x8000
#endif /* ipconfigBYTE_ORDER */
#include "pack_struct_start.h"
@ -296,7 +298,9 @@ void vDHCPProcess( portBASE_TYPE xReset, xMACAddress_t *pxMACAddress, uint32_t *
/* Static configuration is being used, so the network is now up. */
#if ipconfigFREERTOS_PLUS_NABTO == 1
{
vStartNabtoTask();
/* Return value is used in configASSERT() inside the
function. */
( void ) xStartNabtoTask();
}
#endif /* ipconfigFREERTOS_PLUS_NABTO */
@ -324,10 +328,13 @@ void vDHCPProcess( portBASE_TYPE xReset, xMACAddress_t *pxMACAddress, uint32_t *
}
#endif
/* Static configuration is being used, so the network is now up. */
/* Static configuration is being used, so the network is now
up. */
#if ipconfigFREERTOS_PLUS_NABTO == 1
{
vStartNabtoTask();
/* Return value is used in configASSERT() inside the
function. */
( void ) xStartNabtoTask();
}
#endif /* ipconfigFREERTOS_PLUS_NABTO */
@ -640,8 +647,8 @@ uint8_t *pucUDPPayloadBuffer;
pxDHCPMessage->ucAddressType = dhcpADDRESS_TYPE_ETHERNET;
pxDHCPMessage->ucAddressLength = dhcpETHERNET_ADDRESS_LENGTH;
pxDHCPMessage->ulTransactionID = ulTransactionId;
pxDHCPMessage->ulYourIPAddress_yiaddr = ulOfferedIPAddress;
pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE;
pxDHCPMessage->usFlags = dhcpBROADCAST;
memcpy( ( void * ) &( pxDHCPMessage->ucClientHardwareAddress[ 0 ] ), ( void * ) pxMACAddress, sizeof( xMACAddress_t ) );
/* Copy in the const part of the options options. */

@ -1355,7 +1355,7 @@ static void prvProcessNetworkDownEvent( void )
/* The first network down event is generated by the IP stack
itself to initialise the network hardware, so do not call the
network down event the first time through. */
if( xCallEventHook == pdFALSE )
if( xCallEventHook == pdTRUE )
{
vApplicationIPNetworkEventHook( eNetworkDown );
}
@ -1398,7 +1398,9 @@ static void prvProcessNetworkDownEvent( void )
/* Static configuration is being used, so the network is now up. */
#if ipconfigFREERTOS_PLUS_NABTO == 1
{
vStartNabtoTask();
/* Return value is used in configASSERT() inside the
function. */
( void ) xStartNabtoTask();
}
#endif /* ipconfigFREERTOS_PLUS_NABTO */
}

@ -139,4 +139,12 @@ from the FreeRTOSIPConfig.h configuration header file. */
#define ipconfigFREERTOS_PLUS_NABTO 0
#endif
#ifndef ipconfigNABTO_TASK_STACK_SIZE
#define ipconfigNABTO_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 )
#endif
#ifndef ipconfigNABTO_TASK_PRIORITY
#define ipconfigNABTO_TASK_PRIORITY ( ipconfigUDP_TASK_PRIORITY + 1 )
#endif
#endif /* FREERTOS_DEFAULT_IP_CONFIG_H */

@ -106,6 +106,10 @@ void vApplicationPingReplyHook( ePingReplyStatus_t eStatus, uint16_t usIdentifie
void FreeRTOS_ReleaseUDPPayloadBuffer( void *pvBuffer );
uint8_t * FreeRTOS_GetMACAddress( void );
#if ( ipconfigFREERTOS_PLUS_NABTO == 1 )
portBASE_TYPE xStartNabtoTask( void );
#endif
#endif /* FREERTOS_IP_H */

@ -203,6 +203,10 @@ pcap_if_t *pxAllNetworkInterfaces;
vNetworkBufferRelease( pxNetworkBuffer );
iptraceETHERNET_RX_EVENT_LOST();
}
else
{
iptraceNETWORK_INTERFACE_RECEIVE();
}
}
else
{
@ -436,6 +440,10 @@ eFrameProcessingResult_t eResult;
vNetworkBufferRelease( pxNetworkBuffer );
iptraceETHERNET_RX_EVENT_LOST();
}
else
{
iptraceNETWORK_INTERFACE_RECEIVE();
}
}
else
{

Loading…
Cancel
Save