-
Notifications
You must be signed in to change notification settings - Fork 322
/
Copy pathclick.5
878 lines (878 loc) · 25.3 KB
/
click.5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
.\" -*- mode: nroff -*-
.ds V 1.1
.ds E " \-\-
.if t .ds E \(em
.de OP
.BR "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
..
.de OA
.IR "\fB\\$1\& \|\fI\\$2" "\\$3" "\\$4" "\\$5" "\\$6"
..
.de QO
.RB ` "\\$1" "'\\$2"
..
.de Sp
.if n .sp
.if t .sp 0.4
..
.de Es
.Sp
.RS 5
.nf
..
.de Ee
.fi
.RE
.PP
..
.de M
.BR "\\$1" "(\\$2)\\$3"
..
.de Rs
.RS
.Sp
..
.de Re
.Sp
.RE
..
.TH CLICK 5 "16/Mar/2004" "Version \*V"
.SH NAME
click \- Click configuration language
'
.SH DESCRIPTION
The Click language describes Click router configurations.
.LP
Two basic statements can implement any router.
.IR Declaration
statements create elements, and
.IR connection
statements define packet flow among them.
Think of a Click router configuration as a directed graph of elements.
Then declarations list the graph's vertices and connections list its edges.
.LP
A declaration looks like this:
.Rs
.IR "name" " :: " "class" ( "config" );
.Re
This introduces an element called
.IR name
with element class
.IR class
and configuration arguments
.IR config .
.LP
A connection looks like this:
.Rs
.IR "name1" " [" "port1" "] -> [" "port2" "] " "name2" ;
.Re
This connects
.IR name1 "'s output port " port1
and
.IR name2 "'s input port " port2 .
The two
.IR name s
must refer to previously declared elements, and the two
.IR port s
must be nonnegative integers.
.LP
Each element must be declared exactly once before being used in
any connection. It is an error to declare an element name more than
once in the same scope. It is not an error to repeat a connection,
however.
.LP
Lexically, Click identifiers, such as element names and class names,
are sequences of letters, numbers, underscores, at-signs, and slashes
that do not begin or end with a slash. Configuration strings are
sequences of characters delimited by parentheses, possibly including
balanced parentheses and quoted strings. The semicolons that
terminate statements are generally optional (in some cases described
later they are required to avoid ambiguity). Lexical issues are
described in more depth below.
.LP
Any configuration can be completely defined with these statements.
The rest of the Click language offers extensive shorthand and
abstraction features that simplify router programming.
'
.SH "SHORTHAND"
.SS "Declaration shorthand"
'
Empty configuration strings can be omitted.
.Rs
.IR "name" " :: " "class" ;
.Re
Multiple elements can be declared using a comma-separated list of names.
.Rs
.IR "name1" ", " "name2" ", ..., " "nameN" " ::"
.IR "class" ( "config" );
.Re
You may also declare an element without specifying its name. The
system will choose an element name for you. Such elements are called
.IR anonymous .
For example:
.Rs
.IR class "(" config ");"
.Re
is equivalent to
.Rs
.IR generatedname " :: " class ( config );
.Re
The
.I generatedname
has the form
.RI ` class "@" number ';
Click chooses the
.IR number
so that the name is unique. These numbers are predictable: when the
system parses a Click file twice, that file's anonymous elements will get
the same generated names each time. Users may also declare elements with names
like
.RI ` class "@" number ',
though we suggest that users avoid the `@'
character in their element names.
'
.SS "Connection shorthand"
'
You can string together several connections into a single statement if the
output element of one is the same as the input element of the other:
.Rs
.IR "a" " [1] -> [2] " "x"
.RI "[3] -> [4] " "b" ;
.Re
means
.Rs
.IR "a" " [1] -> [2] " "x" ;
.br
.IR "x" " [3] -> [4] " "b" ;
.Re
A missing port number implies port [0]. These two lines mean the same thing:
.Rs
.IR "n1" " [0] -> [0] " "n2" ;
.br
.IR "n1" " -> " "n2" ;
.Re
.PP
Elements may also be declared inside connections, either with names or
anonymously. For instance,
.Rs
.RI "... -> [" "p1" "] " "name" " ::"
.IR "class" ( "config" ") [" "p2" "] -> ...;"
.Re
means
.Rs
.IR "name" " :: " "class" ( "config" );
.br
.RI "... -> [" "p1" "] " "name" " [" "p2" "] -> ...;"
.Re
Similarly,
.Rs
.RI "... -> [" p1 "] " class ( config )
.RI "[" p2 "] -> ...;"
.Re
means
.Rs
.IR generatedname " :: " class ( config );
.br
.RI "... -> [" p1 "] " generatedname " [" p2 "] -> ...;"
.Re
.SS "Many-to-one connections"
'
A many-to-one connection connects many elements to the same port.
.Rs
.IR "n1" ", " "n2" ", " "n3" " -> " "x" ;
.Re
means
.Rs
.IR "n1" " -> " x ";"
.br
.IR "n2" " -> " x ";"
.br
.IR "n3" " -> " x ";"
.Re
Port numbers are supported:
.Rs
.IR "n1" " [\fIp1\fR], " "n2" " [\fIp2\fR] -> [\fIp3\fR] " "x" ;
.Re
means
.Rs
.IR "n1" " [\fIp1\fR] -> [\fIp3\fR] " "x" ;
.br
.IR "n2" " [\fIp2\fR] -> [\fIp3\fR] " "x" ;
.Re
One-to-many connections are also allowed; put the comma-separated
list on the right.
.LP
You may declare elements within a many-to-one connection, but unlike with declaration shorthand,
each declaration applies to only one name. For example
.Rs
.IR "n1" ", " "n2" " :: " "class" " -> " "n3" ";"
.Re
means
.Rs
.IR "n2" " :: " "class" ";"
.br
.IR "n1" " -> " "n3" ";"
.br
.IR "n2" " -> " "n3" ";"
.Re
Note that
.IR n1
was not declared.
'
.SS "Many-to-many connections"
'
A many-to-many connection connects many outputs to many
inputs. For example, consider a simple Classifier. This code:
.Rs
.IR c " :: Classifier(00/01, 00/02, 00/03);"
.br
.IR next " :: " class ";"
.Sp
.br
.IR c " [0] -> Paint(0) -> " "next" ";"
.br
.IR c " [1] -> Paint(1) -> " "next" ";"
.br
.IR c " [2] -> Paint(2) -> " "next" ";"
.Re
can more concisely be written like this, using the `=>' many-to-many connector:
.Rs
.IR c " [0], " c " [1], " c " [2] => Paint(0), Paint(1), Paint(2) -> " next ";"
.Re
or, even more concisely, any of the following:
.Rs
.IR c " [0,1,2] => Paint(0), Paint(1), Paint(2) -> " next ";"
.br
.IR c " [0-2] => Paint(0), Paint(1), Paint(2) -> " next ";"
.br
.IR c " => Paint(0), Paint(1), Paint(2) -> " next ";"
.Re
Each many-to-many connection must list the same number of output ports (on the left) as input ports (on the right).
However, if one side of the connection has exactly one element and no port, Click implicitly assigns that
element's ports sequentially starting from 0.
'
.SS "Element groups"
'
Element groups cleanly express small detours from a connection path.
For example, consider:
.Rs
.IR c " :: Classifier(00/01);"
.br
.IR x " -> " c " -> " y ;
.br
.IR c " [1] -> Paint(1) -> " y ;
.Re
Expressing the detour with an element group preserves the
configuration's overall linear flow:
.Rs
.IR x " -> " c " :: Classifier(00/01) => (
.br
.RI "\~\~\~\~input [0] -> output;"
.br
.RI "\~\~\~\~input [1] -> Paint(1) -> output"
.br
.RI ") -> " y ";"
.Re
An element group is one or more Click statements enclosed in parentheses.
Within the parentheses, the special pseudoelements "input" and
"output" refer to connections from outside the group. Click expands
the group at parse time, so connections through "input" and "output"
have no run-time overhead. The following five lines are equivalent:
.Rs
.IR x " -> " y ";"
.br
.IR x " -> ( input -> output ) -> " y ";"
.br
.IR x " -> ( [0] -> [0] ) -> " y ";"
.br
.IR x " -> (->) -> " y ";"
.br
.IR x " -> ( [0]->[0]; [1]->[1] ) => ( [0]->[0]; [1]->[1] ) -> " y ";"
.Re
Lines three through five use the fact that Click infers "input" at the
beginning of a connection, and "output" at the end of a connection,
when element names are missing. (This language feature
can require explicit semicolons to avoid ambiguity.) Line five also
uses the fact that connections may be repeated without error (the line
expands to "\fIx\fR -> \fIy\fR; \fIx\fR -> \fIy\fR"). It is an error
to use an "input" pseudoelement's input ports or an "output"
pseudoelement's output ports.
.LP
Element groups have implicit, overridable port specifications that
list all their ports in sequential order. For example, these three
lines are equivalent:
.Rs
.IR x " => ( [0]->[0]; [1]->[1] ) -> " "y" ";"
.br
.IR x " => [0,1] ( [0]->[0]; [1]->[1] ) [0,1] -> " "y" ";"
.br
.IR x " -> " y "; " x " [1] -> " y ";"
.Re
It is an error to define an element group with nonsequential ports, or
to leave one or more of its ports unconnected:
.Rs
.IR x " => [0] ( [0]->[0]; [1]->Idle ) -> " "y" "; /* Error! */"
.br
.IR x " => ( [0]->[0]; [2]->Idle ) -> " "y" "; /* Error! */"
.Re
.LP
An element group does not define a new scope. Its contents may refer
to elements declared outside of the group, and declarations inside the
group are visible after the group closes. This differs from compound
elements, described next, which have a related syntax but
introduce a new scope.
'
.SH "COMPOUND ELEMENTS"
'
A
.I compound element
is a scoped collection of elements that behaves like a single element.
A compound element can be used anywhere an element class is
expected (that is, in a declaration or connection). Syntactically, a
compound element is a set of Click statements enclosed in braces `{ }'.
Inside the braces, the special names `input' and `output' represent
connections from or to the outside. Before a router is put on line,
compound elements are systematically expanded until none remain; thus, they
have no run-time overhead.
.PP
Here are some examples. This code, with a compound element,
.Rs
a -> { input -> X -> output } -> b;
.Re
expands to
.Rs
a -> X -> b;
.Re
Here is a more complicated example, with multiple ports:
.Rs
compound :: {
.br
\% input -> X -> output;
.br
\% input [1] -> Y -> [1] output;
.br
};
.br
a -> compound -> b;
.br
c -> [1] compound [1] -> d;
.Re
expands to
.Rs
a -> X -> b;
.br
c -> Y -> d;
.Re
.PP
The "input" and "output" pseudoelements incur no run-time overhead.
.PP
The actual expansions will differ from these examples because the elements
will have different names. A prefix is prepended to the components' names,
providing locality relative to other names in the configuration. The new
names have the form
.RI ` "compoundname" / "componentname" ',
where
.I compoundname
is the name of the compound element being expanded, and
.I componentname
is the name of the component element inside that compound. For example,
.Rs
compound :: { input -> x :: X -> output };
.br
a -> compound -> b;
.Re
is really expanded to
.Rs
a -> compound/x :: X -> b;
.Re
For this purpose, anonymous compound elements are given constructed names
like
.RI `@ number '.
Nothing prevents a user from declaring an element named like a compound
element component. We suggest that users generally avoid using the "/"
character in their element names.
.PP
It is an error to use an "input" pseudoelement's input ports or an
"output" pseudoelement's output ports. It is also an error to leave an
intermediate port unused\*Efor example, to use "input [0]" and "input [2]"
but not "input [1]".
'
.SS "The `elementclass' statement"
'
The `elementclass' statement lets the user name a frequently-occurring
compound element, and use the name as if it were a primitive element class.
Syntactically, it looks like this:
.Rs
elementclass
.I identifier
.I compoundelement
;
.Re
After this statement, every occurrence of the
.I identifier
will be replaced with the
.IR compoundelement .
For example, this code, with an `elementclass':
.Rs
elementclass MyQueue {
.br
\% input -> Queue -> Shaper(1000) -> output;
.br
}
.br
q :: MyQueue;
.br
a -> q -> b;
.Re
is equivalent to this code, without it:
.Rs
q :: { input -> Queue -> Shaper(1000) -> output };
.br
a -> q -> b;
.Re
which roughly expands to:
.Rs
a -> Queue -> Shaper(1000) -> b;
.Re
.PP
The user can declare element classes that have the names of previously
existing element classes:
.Rs
elementclass Queue {
.br
\% input -> Queue -> Shaper(1000) -> output;
.br
}
.Re
Element classes are nonrecursive and lexically scoped, so the `Queue'
inside this definition refers to the original `Queue'. The scope of an
element class definition extends from immediately after its closing right
brace to the end of the enclosing scope.
.PP
A variant of the elementclass statement makes synonyms for preexisting
element classes. For example, this statement
.Rs
elementclass MyQueue Queue;
.Re
makes MyQueue a synonym for Queue.
'
.SS "Configuration parameters"
'
Compound elements may take configuration parameters, which are expanded
into the configuration strings of its components. The parameters are named
at the beginning of the compound element. Each parameter looks like a Perl
variable\*Ea dollar sign followed by one or more letters, numbers, and
underscores. For example, this compound element
.Rs
{ $a, $b | ... }
.Re
takes two configuration parameters, named `$a' and `$b'. Keyword arguments
are also supported. For example, this compound element
.Rs
{ COUNT $count | ... }
.Re
takes a COUNT keyword parameter. Mismatched configuration parameters cause
errors; for example:
.Rs
\%{ $a, $b | ... } (1) // Error: too few arguments
.br
\%{ $a, $b | ... } (1, 2, 3) // Error: too many arguments
.br
\%{ COUNT $count | ... } (1) // Error: missing 'COUNT' parameter
.Re
The special keyword `__REST__' matches any additional arguments supplied to
the compound element. For example:
.Rs
\%{ $a, COUNT $count, __REST__ $rest | ... }
.br
\% (1, 2, COUNT 3, FOO 4)
.Re
This compound element will be expanded with `$a' set to `1', `$count' set
to `3', and `$rest' set to `2, FOO 4'.
.PP
In a compound element definition, all positional parameters must precede
any keyword parameters, and `__REST__', if present, must appear last of
all.
.PP
As the compound is expanded, its components' configuration strings are
searched for references to the parameters. Any such references are replaced
with the supplied arguments. For example, this code:
.Rs
\&... -> { $a | input ->
.br
\% A(1, $a, 3) -> output } (100) -> ...
.Re
expands to this:
.Rs
\&... -> A(1, 100, 3) -> ...
.Re
You can avoid substitution by putting the dollar sign inside single quotes.
.PP
Use braces, like `${a}', to avoid including following letters in a variable
name. Click also supports the shell-like `${VAR-DEFAULT}' syntax, which
substitutes the value of `$VAR', or `DEFAULT' if that variable was not set.
See also PARAMETER DEFINITIONS, below.
'
.SS "Overloading"
'
A single compound element may contain multiple overloaded definitions
separated from one another by two vertical bars "\f(CW||\fR". Different
definitions may have different numbers of input ports, different numbers of
output ports, or different sets of configuration arguments. For example,
this extended MyQueue compound element takes an optional capacity argument,
just like Queue itself:
.Rs
elementclass MyQueue {
.br
\% input -> Queue -> Shaper(1000) -> output;
.br
\%||
.br
\% $cap | input -> Queue($cap)
.br
\% -> Shaper(1000) -> output;
.br
}
.Re
For each use of an overloaded compound element, Click will choose the first
definition that matches the provided number of input ports, number of
output ports, and configuration arguments. It is an error if no definition
matches these properties exactly.
.PP
It is also possible to extend an existing element class with new overloaded
definitions with "\f(CW...\fR". For example, this definition introduces a
two-argument version of Queue:
.Rs
elementclass Queue {
.br
\% $cap, $rate | input -> Queue($cap)
.br
\% -> Shaper($rate) -> output;
.br
\%|| ...
.br
}
.Re
(The ellipsis in this example must be typed verbatim.) The overloadings
visible at a given declaration are those that lexically precede that
declaration. For example, the following example is an error since the
two-argument version of Test is not visible at the declaration where it is
required:
.Rs
elementclass Test { $a | /* nothing */ }
.br
test :: Test(1, 2);
.br
elementclass Test { $a, $b | /* nothing */ || ... }
.Re
'
.SH "CONFIGURATION STRINGS"
'
Click configuration strings are comma-separated lists of arguments, where
each argument is a space-separated list of objects. This section describes
some common object types. See the element documentation for argument types
expected by a particular element.
.PP
Configuration strings may contain comments (`// ... EOL' and `/* ... */'),
which are replaced with single space characters. Inside single- or
double-quoted strings, commas, spaces, and comment-starting sequences lose
their regular meaning and are treated as normal characters.
.PP
The most common object types are:
.TP 3
\(bu
.B Strings.
Any sequence of characters. Single- or double-quoted strings are allowed
(and required, if the string contains a space or comma). Inside
double-quoted strings, backslash substitutions are performed; see below.
You can concatenate strings by juxtaposing them. For example, `a"b"c' is
equivalent to `abc'.
.TP
\(bu
.B Booleans.
`0', `false', and `no' mean false; `1', `true', and `yes' mean true.
.TP
\(bu
.B Integers
preceded by an optional `+' or `\-' sign. Decimal, octal (first digit `0'),
and hexadecimal (starting with `0x') are allowed.
.TP
\(bu
.B Real numbers
in decimal notation.
.TP
\(bu
.B Times and delays
in decimal real notation, followed by an optional unit: `s'/`sec', `ms',
`us', `ns', `m'/`min', `h'/`hr'.
.TP
\(bu
.B Bandwidths
in decimal real notation, followed by an optional unit: `bps' or `Bps' for
bits or bytes per second, with an optional SI prefix `k', `M', or `G'. The
default unit is generally `Bps'.
.TP
\(bu
.B IP addresses
in the conventional `n.n.n.n' form (for example, `18.26.4.15').
.TP
\(bu
.B IP network prefixes
in the CIDR form `n.n.n.n/k' (for example, `18.26.4/24').
.TP
\(bu
.B IPv6 addresses
in any of the conventional forms (for example, `::',
`1080::8:800:200C:417A', or `::18.26.4.15').
.TP
\(bu
.B Ethernet addresses
in the standard `x-x-x-x-x-x' form (for example,
`0-a0-c9-9c-fd-9c'), or the more conventional `x:x:x:x:x:x' form.
.TP
\(bu
.B Element names.
.PD
.PP
Some elements, like
.IR Classifier ,
take arguments that don't fit any of these types. See the element
documentation for details.
.PP
If the last argument in a configuration string is empty (containing only
whitespace and comments), then it is ignored. Thus, `Element(1, )',
`Element(1, /* comment */)', and `Element(1)' behave exactly alike.
.PP
Configuration strings may also contain parameter references, such as
`$interface'. The parameter values are substituted in. Parameters may be
defined either by compound element arguments, by explicit `define'
statements, or on the command line.
'
.SS "Backslash Substitutions"
.PP
The following backslash substitutions are performed inside double quotes.
Additionally, as a special case, a bare data substitution sequence `\e<
\&... >' acts as if it were enclosed in double quotes. (Inside single
quotes, `\e< ... >' is not special.)
.TP 4
1.
'
C-like substitutions. Specifically, `\ea', `\eb', `\et', `\en', `\ev',
`\ef', `\er', `\e\e', and `\e[1, 2, or 3 octal digits]' have their C
meanings. `\ex[any number of hex digits]' is replaced with the byte
defined by the last 2 hex digits.
.TP 4
2.
Data substitutions. An escape sequence `\e< ... hex digits and spaces ...
>' is replaced with the data represented by the hex digits. For example,
the sequence `\e< 48 45 4c 4C 4f >' is replaced with `HELLO'.
.TP
3.
Backlash-newline sequences (`\e[LF]', `\e[CR]', or `\e[CR][LF]') are removed.
.TP
4.
Any other `\e[CHAR]' sequence is replaced with `[CHAR]'.
'
.SH "REQUIREMENTS"
'
The `require' statement is used to link a configuration with optional
packages and libraries. Its argument is a comma-separated list of
requirements.
.PP
Packages, which are dynamic objects including new compiled element
definitions, are included with `require(package)' declarations:
.Rs
require(package fastclassifier, package specialcode);
.Re
Installation programs can use the package names to find and upload any
necessary package code. The required package names are also checked against
a list of currently active packages when a configuration is installed. If
any required packages are unavailable, an error is reported.
.PP
Libraries, which are Click configuration files that (for instance) might
declare new compound element definitions, are included with
`require(library)' declarations:
.Rs
require(library mycompounds.click);
.Re
Installation programs search CLICKPATH for the named library
file. `require(library)' can only be used at file scope, and a given
library file is included at most once, no matter how many times it is
mentioned in `require' statements.
'
.SH "PARAMETER DEFINITIONS"
'
Parameters are defined using the `define' statement. Its argument is a
comma-separated list of pairs, each pair consisting of a configuration
variable and a value:
.Rs
define($DEVNAME eth0, $COUNT 1);
.Re
This sets the `$DEVNAME' parameter to `eth0' and the `$COUNT' parameter to
`1'. Definitions are lexically scoped, so definitions inside a compound
element are not visible outside it. However, all definitions in a given
scope take place simultaneously, regardless of their ordering. The
following two configurations have the same effect:
.Rs
1) define($a 2); Message($a)
.br
2) Message($a); define($a 2)
.Re
It is an error to define a parameter more than once in any single
scope. Click programs such as
.M click 1
and
.M click-install 1
allow parameters to specified on the command line; these override any
global parameters with the same names.
'
.SH "LEXICAL ISSUES"
'
Click identifiers are nonempty sequences of letters, numbers, underscores
`_', at-signs `@', and slashes `/' that do not begin or end with a slash.
The system uses `@' and `/' for special purposes: `@' in constructed names
for anonymous elements and prefixes, and `/' in names for components of
compound elements. Users are discouraged from using these characters in
their own identifiers. Identifiers are case-sensitive. No component of an
identifier may consist solely of numbers; for example, `1/x' is an illegal
identifier.
.PP
The keywords `elementclass', `require', `provide', and `define'
may not be used as identifiers. The normal identifiers `input' and `output'
have special meaning inside compound element definitions.
.PP
The following characters and multi-character sequences are single Click
tokens:
.RS
->\~\~=>\~\~::\~\~;\~\~,\~\~(\~\~)\~\~[\~\~]\~\~{\~\~}\~\~|\~\~||\~\~...
.RE
.PP
Whitespace (using the C definition) and comments separate Click tokens.
Click uses C++-style comments: from `//' to the end of the line, or from
`/*' to the next `*/'. Either form of comment terminates an identifier, so
this Click fragment
.RS
an/identifier/with/slashes//too/many
.RE
has an identifier `an/identifier/with/slashes' and a comment
`//too/many'. No identifier contains two consecutive slashes.
.PP
Parameters, which are used in compound elements, look like Perl variables. A
parameter consists of a dollar sign `$' followed by one or more letters,
numbers, and underscores.
.PP
A configuration string starts immediately following a left parenthesis `(',
and continues up to the next unbalanced right parenthesis `)'. However,
parentheses inside single or double quotes or comments do not affect
balancing. Here are several examples; in each case, the configuration
string consists of the text between the `#' marks (including the `#' marks
themselves).
.Rs
C1(#simple string#)
.br
C2(#string with (balanced parens)#)
.br
C3(#string with ")quoted" paren#)
.br
C4(#// end-of-line comment)
.br
\% still going!#)
.br
C5(#/* slash-star comment) */ and backslash \e#)
.Re
.PP
A Click program may contain C preprocessor-style line directives. These
lines start with `#' and have the form `# \fIlinenumber\fP
"\fIfilename\fP"' or `#line \fIlinenumber\fP "\fIfilename\fP"'; they change
the filenames and line numbers used for error messages. The filename
portion is optional. Line directives are not recognized inside
configuration strings.
'
.SH "ARCHIVES"
Many Click programs also accept
.M ar 1
archives as configurations. The archive must contain a member called
`config', which is treated as a Click-language configuration. The archive
may also contain package code required by the configuration. The
.M click-install 1
and
.M click 1
programs will decompose the archive and install any package code before
installing the configuration itself. The
.M click.o 8
kernel module will not accept archives; use
.M click-install 1 .
'
.SH "BNF GRAMMAR"
'
.IR stmts " ::= " stmts " " stmt " | " empty
.br
.IR stmt " ::= " connection
.br
.RI " | " elementclassstmt " | " requirestmt
.br
.RI " | " definestmt " | "";"""
.br
.IR connection " ::= " elements " " opt-conntail " | " conntail
.br
.IR opt-conntail " ::= " conntail " | " empty
.br
.IR conntail " ::= " arrow " " elements " " opt-conntail " | " arrow
.br
.IR arrow " ::= ""->"" | ""=>"""
.br
.IR elements " ::= " element " | " elements " "","" " element
.br
.IR element " ::= " opt-port " " element-reference " " opt-port
.br
.IR element-reference " ::= " element-name
.br
.RI " | " element-name " ""::"" " class " " opt-config
.br
.RI " | " class " " opt-config
.br
.RI " | " group
.br
.IR element-name " ::= identifier"
.br
.IR opt-port " ::= ""["" " ports " ""]"" | " empty
.br
.IR ports " ::= portnumber | " ports " "","" portnumber"
.br
.IR opt-config " ::= ""("" configstring "")"" | " empty
.br
.IR class " ::= identifier | ""{"" " compounds " ""}"""
.br
.RI " | ""{"" " compounds " ""||"" ""..."" ""}"""
.br
.IR compounds " ::= " compound " | " compounds " ""||"" " compound
.br
.IR compound " ::= " stmts " | " opt-formals " ""|"" " stmts
.br
.IR opt-formals " ::= " formals " | " empty
.br
.IR formals " ::= " formal " | " formals " "","" " formal
.br
.IR formal " ::= parameter | identifier parameter"
.br
.IR group " ::= ""("" " stmts " "")"""
.br
.IR elementclassstmt " ::= ""elementclass"" identifier " class
.br
.IR requirestmt " ::= ""require"" ""("" configstring "")"""
.br
.IR definestmt " ::= ""define"" ""("" configstring "")"""
.br
.IR empty " ::= "
'
.SH "SEE ALSO"
.M click 1 ,
.M click-install 1 ,
.M click.o 8
'
.SH AUTHOR
.na
Eddie Kohler, [email protected]
.br
http://www.pdos.lcs.mit.edu/click/
'