cancel_timeout?
Lennart Hellström (ERA)
Lennart.Hellstrom at era.ericsson.se
Fri Sep 24 08:39:32 UTC 1999
Hi,
As you might remember, I've been doing some modifications mainly on the client code to make
it suite my needs. The modifications are mostly adds in a seperate file that allow me to control when to discover new addresses, and to send DHCPRELEASEs.
Everything's working fine it seems, but I've got one question though - I'm not quite sure
where to call cancel_timeout in my functions...
Since they can be called at any time, I want the dhclient to drop anything it's currently doing and let my functions execute and take it to the following state. Will this require me to cancel _everything_ that is done before doing what I want?
Oh, I am aware of that this will change the state transitions of the client, but never mind that right now ;-)
Here's my function that discovers a new address on eth0:
****
int discover_addr ()
{
struct interface_info *ip;
struct client_state *sp;
for (ip = interfaces; ip; ip = ip -> next) {
if (strcmp(ip -> name,"eth0") == 0) {
sp = ip -> client;
sp -> state = S_INIT;
state_init (sp);
return 1; }}
return 0;
}
****
And a part of the one that sends releases, containing a lot of cancel_timeouts
****
int release_addr (struct iaddr ip_addr)
// struct iaddr;
{
struct interface_info *ip;
struct client_lease *lp;
struct client_state *sp;
for (ip = interfaces; ip; ip = ip -> next) {
/* switch taken from client_reinit handed through Ted.*/
/* What does it do, and is it complete? */
switch (ip -> client -> state) {
case S_SELECTING:
cancel_timeout (send_discover, ip);
break;
case S_BOUND:
cancel_timeout (state_bound, ip);
break;
case S_REBOOTING:
cancel_timeout (send_request, ip); /* added by me */
case S_REQUESTING:
cancel_timeout (send_request, ip); /* added by me */
case S_RENEWING:
cancel_timeout (send_request, ip);
break;
case S_INIT:
case S_REBINDING:
break;
}
....a bit of code that is not interresing for the moment....
****
Is this switch ok, and should I use it in the discover_addr too?
Thanx for all your help!
/ Lelle
----------------------<<<<<<¤¤¤¤¤¤¤¤¤¤¤¤>>>>>>------------------------------------
Lennart Hellström ERA/KA/TA email: Lennart.Hellstrom at era.ericsson.se
Ericsson Radio Systems AB tel: +46 (0)8-585 347 81
SE-164 80 Stockholm mobile: +46 (0)70-432 64 27
Sweden
More information about the dhcp-hackers
mailing list