[olsr-dev] some Qs about exending the dyn_gw plugin

Andreas T√łnnesen (spam-protected)
Sat Nov 6 10:32:49 CET 2004


Hi,

Fist of all - I did some quick updates to the dyn_gw plugin last night. 
It should work fine with the new interface now. Extending it to take 
other subnets as parameters and work with IPv6 should not be too much 
work either.

Jens Nachtigall wrote:
> You mean, 
> int register_olsr_param(char *one,char *two)
> don't you?

In the plugin it must be called register_olsr_param yes - as I think I 
mentioned :-) I just pasted in the type it had in olsrd.

> 
> Afaics olsrd does not catch the return value from register_olsr_param:
>       while(params)
>  {
>    printf("\tKey:\"%s\" value:\"%s\"\n", params->key, params->value);
>    entry->register_param(params->key, params->value);
>         ^^^^^^^^^^^^^^
>    params = params->next;
>  }
> 
> I think, this would be a good idea, in case the users enters an option, 
> which is not available/allowed. I could, of course also call exit(), or 
> whatever myself. But giving back a return value from 
> register_olsr_param meaning "configuration error" (e.g. 0) , and having 
> then olsrd react according to its general policy is better imho.

Yes, that was my intention when I defined the function. There are a lot 
of those around ;-)
I've update it to pass a warning if returned 0, and exit if returned 
negative. In other words, you should return positive if the parameter 
was parsed ok, 0 if there was a minor error and negative on a fatal error.
I've checked it into CVS - but it takes a couple of hours before 
publically available. So - here is what it looks like if you want to 
have a go at it before that:

olsr_printf(1, "\"%s\"/\"%s\".... ", params->key, params->value);
   if((retval = entry->register_param(params->key, params->value)) < 0)
     {
       fprintf(stderr, "\nFatal error in plugin parameter 
\"%s\"/\"%s\"\n", params->key, params->value);
       exit(EXIT_FAILURE);
     }
   retval == 0 ? olsr_printf(1, "FAILED\n") : olsr_printf(1, "OK\n");

   params = params->next;



- Andreas

-- 
Andreas T√łnnesen
http://www.olsr.org



More information about the Olsr-dev mailing list