00247940bb0308202ce9bfcf6912b0af5e9be6c5
[freeradius.git] / src / tests / unit / rfc.txt
1 #  All attribute lengths are implicit, and are calculated automatically
2 #
3 #  Input is of the form:
4 #
5 #       WORD ...
6 #
7 #  The WORD is a keyword which indicates the format of the following text.
8 #  WORD is one of:
9 #
10 #       raw - read the grammar defined below, and encode an attribute.
11 #             The grammar supports a trivial way of describing RADIUS
12 #             attributes, without reference to dictionaries or fancy
13 #             parsers
14 #
15 #       encode - reads "Attribute-Name = value", encodes it, and prints
16 #                the result as text.
17 #               use "-" to encode the output of the last command
18 #
19 #       decode - reads hex, and decodes it "Attribute-Name = value"
20 #               use "-" to decode the output of the last command
21 #
22 #       data - the expected output of the previous command, in ASCII form.
23 #              if the actual command output is different, an error message
24 #              is produced, and the program terminates.
25 #
26 #
27 #  The "raw" input satisfies the following grammar:
28 #
29 #       Identifier = 1*DIGIT *( "." 1*DIGIT )
30 #
31 #       HEXCHAR = HEXDIG HEXDIG 
32 #
33 #       STRING = DQUOTE *CHAR DQUOTE
34 #
35 #       TLV = "{" 1*DIGIT DATA "}"
36 #
37 #       DATA = 1*HEXCHAR / 1*TLV / STRING
38 #
39 #       LINE = Identifier DATA
40 #
41 #  The "Identifier" is a RADIUS attribute identifier, as given in the draft.
42 #
43 #       e.g.    1               for User-Name
44 #               26.9.1          Vendor-Specific, Cisco, Cisco-AVPAir
45 #               241.1           Extended Attribute, number 1
46 #               241.2.3         Extended Attribute 2, data type TLV, TLV type 3
47 #               etc.
48 #
49 #  The "DATA" portion is the contents of the RADIUS Attribute.
50 #
51 #               123456789abcdef hex string
52 #               12 34 56 ab     with spaces for clarity
53 #               "hello"         Text string
54 #               { 1 abcdef }    TLV, TLV-Type 1, data "abcdef"
55 #
56 #  TLVs can be nested:
57 #
58 #       { tlv-type { tlv-type data } }          { 3 { 4 01020304 } }
59 #
60 #  TLVs can be concatencated
61 #
62 #       {tlv-type data } { tlv-type data}       { 3 040506 } { 8 aabbcc }
63 #
64 #  The "raw" data is encoded without reference to dictionaries.  Any
65 #  valid string is parsed to a RADIUS attribute.  The resulting RADIUS
66 #  attribute *may not* be correctly formatted to the relevant RADIUS
67 #  specifications.  i.e. you can use this tool to create attribute 1
68 #  (User-Name), which is encoded as a series of TLVs.  That's up to you.
69 #
70 #  The purpose of the "raw" command is to have a simple way of encoding
71 #  attributes which is independent of any dictionaries or packet processing
72 #  routines.
73 #
74 #  The output data is the hex version of the encoded attribute.
75 #
76
77 encode User-Name = "bob"
78 data 01 05 62 6f 62
79
80 decode -
81 data User-Name = "bob"
82
83 decode 01 05 62 6f 62
84 data User-Name = "bob"
85
86 #
87 #  The Type/Length is OK, but the attribute data is of the wrong size.
88 #
89 decode 04 04 ab cd
90 data Attr-4 = 0xabcd
91
92 #  Zero-length attributes
93 decode 01 02
94 data 
95
96 # don't encode zero-length attributes
97 encode User-Name = ""
98 data 
99
100 # except for CUI.  Thank you, WiMAX!
101 decode 59 02
102 data Chargeable-User-Identity = 0x
103
104 # Hah! Thought you had it figured out, didn't you?
105 encode -
106 data 59 02
107
108 attribute Framed-IP-Address = 127.0.0.1/32
109 data Framed-IP-Address = 127.0.0.1
110
111 attribute Framed-IP-Address = 127.0.0.1/323
112 data Invalid IPv4 mask length "/323".  Should be between 0-32
113
114 attribute Framed-IP-Address = 127.0.0.1/30
115 data Invalid IPv4 mask length "/30".  Only "/32" permitted for non-prefix types
116
117 attribute Framed-IP-Address = *
118 data Framed-IP-Address = 0.0.0.0
119
120 attribute Framed-IP-Address = 127
121 data Framed-IP-Address = 0.0.0.127
122
123 attribute Framed-IP-Address = 127.0
124 data Framed-IP-Address = 127.0.0.0
125
126 attribute Framed-IPv6-Prefix = ::1
127 data Framed-IPv6-Prefix = ::1/128
128
129 attribute Framed-IPv6-Prefix = ::1/200
130 data Invalid IPv6 mask length "/200".  Should be between 0-128
131
132 attribute Framed-IPv6-Prefix = ::1/200
133 data Invalid IPv6 mask length "/200".  Should be between 0-128
134
135 attribute Framed-IPv6-Prefix = 11:22:33:44:55:66:77:88/128
136 data Framed-IPv6-Prefix = 11:22:33:44:55:66:77:88/128
137
138 attribute Framed-IPv6-Prefix = *
139 data Framed-IPv6-Prefix = ::/128
140
141 attribute PMIP6-Home-IPv4-HoA = 127/8
142 data PMIP6-Home-IPv4-HoA = 127.0.0.0/8
143
144 attribute PMIP6-Home-IPv4-HoA = 127/8
145 data PMIP6-Home-IPv4-HoA = 127.0.0.0/8
146
147 #
148 #  Octets outside of the mask are OK, but
149 #  are mashed to zero.
150 #
151 attribute PMIP6-Home-IPv4-HoA = 127.63/8
152 data PMIP6-Home-IPv4-HoA = 127.0.0.0/8
153
154 #
155 #  Unless you give a good mask.
156 #
157 attribute PMIP6-Home-IPv4-HoA = 127.63/16
158 data PMIP6-Home-IPv4-HoA = 127.63.0.0/16
159
160 attribute PMIP6-Home-IPv4-HoA = 127.999/16
161 data Failed to parse IPv4 address string "127.999/16"
162
163 attribute PMIP6-Home-IPv4-HoA = 127.bob/16
164 data Failed to parse IPv4 address string "127.bob/16"
165
166 attribute PMIP6-Home-IPv4-HoA = 127.63/15
167 data PMIP6-Home-IPv4-HoA = 127.62.0.0/15
168
169 attribute PMIP6-Home-IPv4-HoA = 127.63.1/24
170 data PMIP6-Home-IPv4-HoA = 127.63.1.0/24
171
172 attribute PMIP6-Home-IPv4-HoA = 127.63.1.6
173 data PMIP6-Home-IPv4-HoA = 127.63.1.6/32
174
175 attribute PMIP6-Home-IPv4-HoA = 256/8
176 data Failed to parse IPv4 address string "256/8"
177
178 attribute PMIP6-Home-IPv4-HoA = bob/8
179 data Failed to parse IPv4 address string "bob/8"
180
181 $INCLUDE tunnel.txt
182 $INCLUDE errors.txt
183 $INCLUDE extended.txt
184 $INCLUDE lucent.txt
185 $INCLUDE wimax.txt