summaryrefslogtreecommitdiffstats
path: root/doc/antora/modules/unlang/pages/attr.adoc
blob: 70afce41af06a992f3461355860f28b6c552952f (plain)
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
= &Attribute References

.Syntax
[source,unlang]
----
[&]Attribute-Name
----

The `&Attribute-Name` operator returns a reference to the named
attribute.

When used as an existence check in a condition, the condition
evaluates to `true` if the attribute exists.  Otherwise, the condition
evaluates to `false`.

When used elsewhere, such as in xref:switch.adoc[switch], it returns
the value of the named attribute.

.Examples
[source,unlang]
----
&User-Name
&NAS-IP-Address
----

== Lists

The attribute reference can also be qualified with a
xref:list.adoc[list] reference.  When no list is given, the server
looks in the input packet list for the named attribute.

.Examples

[source,unlang]
----
&request:User-Name
&reply:NAS-IP-Address
----

== Array References

.Syntax
[source,unlang]
----
&Attribute-Name[<integer>]
----

When an attribute appears multiple times in a list, this syntax allows
you to address the attributes as if they were array entries.  The
`<integer>` value defines which attribute to address.  The `[0]` value
refers to the first attributes, `[1]` refers to the second attribute,
etc.

.Examples
[source,unlang]
----
&EAP-Message[1]
&reply:NAS-IP-Address[2]
----

== Removing ambuguity from the configuration files

The server does not use the `&` character to distinguish attribute names
from other strings.  

Without the `&`, it is more difficult to parse the configuration file
clearly. You could interpret a string as `hello-there`
either as a literal string "hello-there", or as a reference to an
attribute named `hello-there`.  

Adding the leading `&` character means that attribute references are
now easily distinguishable from literal strings.  The use of the leading 
`&` character is highly recommended.


// Copyright (C) 2020 Network RADIUS SAS.  Licenced under CC-by-NC 4.0.
// Development of this documentation was sponsored by Network RADIUS SAS.