|
257 | 257 | pxIterator = NULL; |
258 | 258 | } |
259 | 259 |
|
260 | | - if( pxIterator != NULL ) |
| 260 | + if(( pxIterator != NULL ) && ( pxIterator->xDHCPData.eDHCPState == pxIterator->xDHCPData.eExpectedState ) ) |
261 | 261 | { |
262 | 262 | /* The second parameter pdTRUE tells to check for a UDP message. */ |
263 | 263 | vDHCPProcessEndPoint( pdFALSE, pdTRUE, pxIterator ); |
|
269 | 269 | } |
270 | 270 | else |
271 | 271 | { |
272 | | - /* Target not found, fetch the message and delete it. */ |
| 272 | + /* Target not found or there is a state mismatch, fetch the message and delete it. */ |
273 | 273 | /* PAss the address of a pointer pucUDPPayload, because zero-copy is used. */ |
274 | 274 | lBytes = FreeRTOS_recvfrom( EP_DHCPData.xDHCPSocket, &( pucUDPPayload ), 0, FREERTOS_ZERO_COPY, NULL, NULL ); |
275 | 275 |
|
276 | 276 | if( ( lBytes > 0 ) && ( pucUDPPayload != NULL ) ) |
277 | 277 | { |
278 | 278 | /* Remove it now, destination not found. */ |
279 | 279 | FreeRTOS_ReleaseUDPPayloadBuffer( pucUDPPayload ); |
280 | | - FreeRTOS_printf( ( "vDHCPProcess: Removed a %d-byte message: target not found\n", ( int ) lBytes ) ); |
| 280 | + if( pxIterator == NULL ) |
| 281 | + { |
| 282 | + FreeRTOS_printf( ( "vDHCPProcess: Removed a %d-byte message: target not found\n", ( int ) lBytes ) ); |
| 283 | + } |
| 284 | + else |
| 285 | + { |
| 286 | + FreeRTOS_printf( ( "vDHCPProcess: Wrong state: expected: %d got: %d : ignore\n", |
| 287 | + pxIterator->xDHCPData.eExpectedState, pxIterator->xDHCPData.eDHCPState ) ); |
| 288 | + } |
281 | 289 | } |
282 | 290 | } |
283 | 291 | } |
|
489 | 497 | { |
490 | 498 | /* Give up, start again. */ |
491 | 499 | EP_DHCPData.eDHCPState = eInitialWait; |
| 500 | + /* Reset expected state so that DHCP packets from |
| 501 | + different DHCP servers if available already in the DHCP socket can |
| 502 | + be processed */ |
| 503 | + EP_DHCPData.eExpectedState = eInitialWait; |
492 | 504 | } |
493 | 505 | } |
494 | 506 | } |
|
992 | 1004 | { |
993 | 1005 | /* Start again. */ |
994 | 1006 | EP_DHCPData.eDHCPState = eInitialWait; |
| 1007 | + /* Reset expected state so that DHCP packets from |
| 1008 | + different DHCP servers if available already in the DHCP socket can |
| 1009 | + be processed */ |
| 1010 | + EP_DHCPData.eExpectedState = eInitialWait; |
995 | 1011 | } |
996 | 1012 | } |
997 | 1013 |
|
|
0 commit comments