Share

Freescale openTCP

Tracker: Bugs

5 dhcp times calculated incorrectly - ID: 1245784
Last Update: Comment added ( nobody )

When dhcp is first initalized, the times for renewal
are not calculated properly. The code reads:
dhcpc_t1 = (UINT32)((UINT16)(0.5)*temp);
dhcpc_t2 = (UINT32)((UINT16)(0.875)*temp);
due to the casting, the 0.5 and 0.875 will turn to 0,
resulting in dhcpc_t1 and dhcpc_t2 both being set to 0
which will cause a flurry of packets to be sent.

Changing those lines to read:
dhcpc_t1 = temp / 2;
dhcpc_t2 = ((temp << 3) >> 3) * 7 / 8;

fixes the problem, and now when starting up, only four
packets in total are sent instead of many more. (The
shift up/down is to clear out the top three bits so the
multiplication doesn't overflow.)

There are two sets of these lines to be changed.


John-Mark Gurney ( jmg ) - 2005-07-27 07:46

5

Open

None

Nobody/Anonymous

None

None

Public


Comment ( 1 )




Date: 2008-09-29 14:49
Sender: nobody

Many thanks for reporting and solving this issue.

/Andreas


Log in to comment.

Attached File

No Files Currently Attached

Change

No changes have been made to this artifact.