lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Re: bug fix


From: K.J. Mansley
Subject: [lwip-users] Re: bug fix
Date: 09 Sep 2004 08:41:11 +0100

Thanks for your contribution!

Could you provide some more explanation about the problem and the fix
please?  The use of unsigned arithmetic to do < and > comparisons is
fairly standard.  In particular, examples of where the existing code
gets it wrong would be very helpful.

Thanks

Kieran

PS. Things such as this are generally best sent to one of the mailing
lists rather than to me personally, as there are many more people
involved in the project who might be interested or more able to help.

On Thu, 2004-09-09 at 06:51, Brett Jones wrote:
> this code seems to fix a que full error that occurs durring large
> transfers of data.
>  
> use it however you wish :)
>  
> //#define TCP_SEQ_LT(a,b)     ((S32)((a)-(b)) < 0)
> //#define TCP_SEQ_LEQ(a,b)    ((S32)((a)-(b)) <= 0)
> //#define TCP_SEQ_GT(a,b)     ((S32)((a)-(b)) > 0)
> //#define TCP_SEQ_GEQ(a,b)    ((S32)((a)-(b)) >= 0)
> S32 TCP_SEQ_LT( U32 a, U32 b )
> {
>  //determine if a is less than b
>  if( a == b )
>  {
>   return FALSE;
>  }
>  if( a > b )
>  {
>   if( a-b <= 0x7fffffff )
>   {
>    //no rollover
>    return FALSE;
>   }
>   //rolled over
>   return TRUE;
>  }
>  else
>  {
>   if( b-a <= 0x7fffffff )
>   {
>    //no rollover
>    return TRUE;
>   }
>   //rolled over
>   return FALSE;
>  }
> }
> S32 TCP_SEQ_LEQ( U32 a, U32 b )
> {
>  if( a == b )
>  {
>   return TRUE;
>  }
>  if( a > b )
>  {
>   if( a-b <= 0x7fffffff )
>   {
>    //no rollover
>    return FALSE;
>   }
>   //rolled over
>   r eturn TRUE;
>  }
>  else
>  {
>   if( b-a <= 0x7fffffff )
>   {
>    //no rollover
>    return TRUE;
>   }
>   //rolled over
>   return FALSE;
>  }
> }
> S32 TCP_SEQ_GT( U32 a, U32 b )
> {
>  if( a == b )
>  {
>   return FALSE;
>  }
>  if( a > b )
>  {
>   if( a-b <= 0x7fffffff )
>   {
>    //no rollover
>    return TRUE;
>   }
>   return FALSE;
>  }
>  else
>  {
>   if( b-a <= 0x7fffffff )
>   {
>    //no rollover
>    return FALSE;
>   }
>   //rolled over
>   return TRUE;
>  }
> }
> S32 TCP_SEQ_GEQ( U32 a, U32 b )
> {
>  if( a == b )
>  {
>   return TRUE;
>  }
>  if( a > b )
>  {
>   if( a-b <= 0x7fffffff )
>   {
>    //no rollover
>    return TRUE;
>   }
>   //rolled over
>   return FALSE;
>  }
>  else
>  {
>   if( b-a <= 0x7fffffff )
>   {
>    //no rollover
>    return FALSE;
>   }
>   //rolled over
>   return TRUE;
>  }
> }
> 
> 
> 
> ______________________________________________________________________
> Do you Yahoo!?
> Yahoo! Mail - You care about security. So do we.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]