/* Return a pointer to an unused buffer, marking the returned buffer as now in use.  */
static unsigned char * prvGetNextBuffer(void)
/* Return a pointer to an unused buffer, marking the returned buffer as now in use.  */
static unsigned char * prvGetNextBuffer(void)
{
portBASE_TYPE x;
unsigned char *ucReturn = NULL;
unsigned long ulAttempts = 0;
	while( ucReturn == NULL )
	{
		for( x = 0; x < uipNUM_BUFFERS; x++ )
		{
			if( ucBufferInUse[ x ] == pdFALSE )
			{
				ucBufferInUse[ x ] = pdTRUE;
				ucReturn = &( ucMACBuffers[ x ][ 0 ] );
				break;
			}
		}
		if( ucReturn == NULL )
		{
			ulAttempts++;
			if( ulAttempts >= uipBUFFER_WAIT_ATTEMPTS )
			{
				break;
			}
			vTaskDelay( uipBUFFER_WAIT_DELAY );
		}
	}
	return ucReturn;
}