- /* Find the next available port using the random seed as a starting \r
- point. */\r
- do\r
- {\r
- /* Generate a random seed. */\r
- ulRandomSeed = ipconfigRAND32( );\r
-\r
- /* Only proceed if the random number generator succeeded. */\r
- if( 0 == ulRandomSeed )\r
- {\r
- if( pdFALSE == xGotZeroOnce )\r
- {\r
- xGotZeroOnce = pdTRUE;\r
- continue;\r
- }\r
- else\r
- {\r
- break;\r
- }\r
- }\r
-\r
- /* Map the random to a candidate port. */\r
- usResult =\r
- socketAUTO_PORT_ALLOCATION_START_NUMBER +\r
- ( ( ( uint16_t )ulRandomSeed ) % usEphemeralPortCount );\r
-\r
- /* Check if there's already an open socket with the same protocol\r
- and port. */\r
- if( NULL == pxListFindListItemWithValue( \r
- pxList, \r
- ( TickType_t )FreeRTOS_htons( usResult ) ) )\r
- {\r
- usResult = FreeRTOS_htons( usResult );\r
- break;\r
- }\r
- else\r
- {\r
- usResult = 0;\r
- }\r
-\r
- usIterations--;\r
- }\r
- while( usIterations > 0 );\r
- \r
- return usResult;\r
-} \r
+ /* Find the next available port using the random seed as a starting\r
+ point. */\r
+ do\r
+ {\r
+ /* Generate a random seed. */\r
+ ulRandomSeed = ipconfigRAND32( );\r
+\r
+ /* Only proceed if the random number generator succeeded. */\r
+ if( 0 == ulRandomSeed )\r
+ {\r
+ if( pdFALSE == xGotZeroOnce )\r
+ {\r
+ xGotZeroOnce = pdTRUE;\r
+ continue;\r
+ }\r
+ else\r
+ {\r
+ break;\r
+ }\r
+ }\r
+\r
+ /* Map the random to a candidate port. */\r
+ usResult =\r
+ socketAUTO_PORT_ALLOCATION_START_NUMBER +\r
+ ( ( ( uint16_t )ulRandomSeed ) % usEphemeralPortCount );\r
+\r
+ /* Check if there's already an open socket with the same protocol\r
+ and port. */\r
+ if( NULL == pxListFindListItemWithValue(\r
+ pxList,\r
+ ( TickType_t )FreeRTOS_htons( usResult ) ) )\r
+ {\r
+ usResult = FreeRTOS_htons( usResult );\r
+ break;\r
+ }\r
+ else\r
+ {\r
+ usResult = 0;\r
+ }\r
+\r
+ usIterations--;\r
+ }\r
+ while( usIterations > 0 );\r
+\r
+ return usResult;\r
+}\r