[Click] Double-quotes in Click WRITE/WRITEDATA config

Pavlin Radoslavov pavlin at icir.org
Sun Dec 16 23:21:58 EST 2007


If I use the ControlSocket to configure Click (I am using
Click-1.6.0), then quotes in regular Click config might need to be
changed to double-quotes when "WRITE hotconfig" or "WRITEDATA
hotconfig" are used.

In the example below I am using the following sample config. Note
that it must have a string with a space in the middle:

InfiniteSource(DATA <00>, LIMIT 5, STOP true) -> Print("ok FOO") -> Discard;

First, userland Click is started:
./click -f /dev/null -p 13000 -R

[Note: the unrelated lines from the outputs below have been removed
for clarity]

If I use "WRITE hotconfig" (with Click-1.6.0) then everything is
fine:

$ telnet localhost 13000
WRITE hotconfig InfiniteSource(DATA <00>, LIMIT 5, STOP true) -> Print("ok FOO") -> Discard;
200 Write handler 'hotconfig' OK

If I use "WRITEDATA hotconfig", then Click doesn't like the quoted
string:

$ telnet localhost 13000
WRITEDATA hotconfig 76
InfiniteSource(DATA <00>, LIMIT 5, STOP true) -> Print("ok FOO") -> Discard;
520-Write handler 'hotconfig' error:
520-<expr>:1: While configuring 'Print at 2 :: Print':
520-  type mismatch: LABEL requires string (got ok FOO)
520 Router could not be initialized!

I need to use double-quotes to make it working:
$ telnet localhost 13000
WRITEDATA hotconfig 80
InfiniteSource(DATA <00>, LIMIT 5, STOP true) -> Print("\"ok FOO\"") -> Discard;
200 Write handler 'hotconfig' OK

It appears the following code inside lib/router.cc method
Handler::call_write() is the reason the outer quotes around the
string are stripped so as a result double-quotes are needed to
protect the string with a space in the middle:

    String value_copy(value);
    if ((_flags & RAW) && !raw)
        value_copy = cp_unquote(value_copy);

In case of WRITEDATA, then cp_unquote() is called to unquote the
configuration.


I just did same experiment with latest Click code (from CVS) and it
appears that in both cases (WRITE and WRITEDATA) I need to use
double-quotes around the string.

Is the double-quotes the intended behavior or am I hitting a bug
somewhere else?
>From user's perspective it will be simpler if the double-quotes are
not required (as was the case with Click-1.4.3 I believe), but I
might be missing some technical reasons that now mandate them with
WRITE and WRITEDATA.

Thanks,
Pavlin


More information about the click mailing list