print-radius.c revision 1.5 1 1.1 christos /*
2 1.1 christos * Copyright (C) 2000 Alfredo Andres Omella. All rights reserved.
3 1.1 christos *
4 1.1 christos * Redistribution and use in source and binary forms, with or without
5 1.1 christos * modification, are permitted provided that the following conditions
6 1.1 christos * are met:
7 1.1 christos *
8 1.1 christos * 1. Redistributions of source code must retain the above copyright
9 1.1 christos * notice, this list of conditions and the following disclaimer.
10 1.1 christos * 2. Redistributions in binary form must reproduce the above copyright
11 1.1 christos * notice, this list of conditions and the following disclaimer in
12 1.1 christos * the documentation and/or other materials provided with the
13 1.1 christos * distribution.
14 1.1 christos * 3. The names of the authors may not be used to endorse or promote
15 1.1 christos * products derived from this software without specific prior
16 1.1 christos * written permission.
17 1.1 christos *
18 1.1 christos * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
19 1.1 christos * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
20 1.1 christos * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 1.1 christos */
22 1.1 christos /*
23 1.1 christos * Radius printer routines as specified on:
24 1.1 christos *
25 1.1 christos * RFC 2865:
26 1.1 christos * "Remote Authentication Dial In User Service (RADIUS)"
27 1.1 christos *
28 1.1 christos * RFC 2866:
29 1.1 christos * "RADIUS Accounting"
30 1.1 christos *
31 1.1 christos * RFC 2867:
32 1.1 christos * "RADIUS Accounting Modifications for Tunnel Protocol Support"
33 1.1 christos *
34 1.1 christos * RFC 2868:
35 1.1 christos * "RADIUS Attributes for Tunnel Protocol Support"
36 1.1 christos *
37 1.1 christos * RFC 2869:
38 1.1 christos * "RADIUS Extensions"
39 1.1 christos *
40 1.1 christos * Alfredo Andres Omella (aandres (at) s21sec.com) v0.1 2000/09/15
41 1.1 christos *
42 1.1 christos * TODO: Among other things to print ok MacIntosh and Vendor values
43 1.1 christos */
44 1.1 christos
45 1.5 christos #define NETDISSECT_REWORKED
46 1.1 christos #ifdef HAVE_CONFIG_H
47 1.1 christos #include "config.h"
48 1.1 christos #endif
49 1.1 christos
50 1.1 christos #include <tcpdump-stdinc.h>
51 1.1 christos
52 1.1 christos #include <string.h>
53 1.1 christos
54 1.1 christos #include "interface.h"
55 1.1 christos #include "addrtoname.h"
56 1.1 christos #include "extract.h"
57 1.1 christos #include "oui.h"
58 1.1 christos
59 1.5 christos static const char tstr[] = " [|radius]";
60 1.5 christos
61 1.1 christos #define TAM_SIZE(x) (sizeof(x)/sizeof(x[0]) )
62 1.1 christos
63 1.1 christos #define PRINT_HEX(bytes_len, ptr_data) \
64 1.1 christos while(bytes_len) \
65 1.1 christos { \
66 1.5 christos ND_PRINT((ndo, "%02X", *ptr_data )); \
67 1.1 christos ptr_data++; \
68 1.1 christos bytes_len--; \
69 1.1 christos }
70 1.1 christos
71 1.1 christos
72 1.1 christos /* Radius packet codes */
73 1.1 christos #define RADCMD_ACCESS_REQ 1 /* Access-Request */
74 1.1 christos #define RADCMD_ACCESS_ACC 2 /* Access-Accept */
75 1.1 christos #define RADCMD_ACCESS_REJ 3 /* Access-Reject */
76 1.1 christos #define RADCMD_ACCOUN_REQ 4 /* Accounting-Request */
77 1.1 christos #define RADCMD_ACCOUN_RES 5 /* Accounting-Response */
78 1.1 christos #define RADCMD_ACCESS_CHA 11 /* Access-Challenge */
79 1.1 christos #define RADCMD_STATUS_SER 12 /* Status-Server */
80 1.1 christos #define RADCMD_STATUS_CLI 13 /* Status-Client */
81 1.1 christos #define RADCMD_RESERVED 255 /* Reserved */
82 1.1 christos
83 1.4 christos static const struct tok radius_command_values[] = {
84 1.1 christos { RADCMD_ACCESS_REQ, "Access Request" },
85 1.1 christos { RADCMD_ACCESS_ACC, "Access Accept" },
86 1.1 christos { RADCMD_ACCESS_REJ, "Access Reject" },
87 1.1 christos { RADCMD_ACCOUN_REQ, "Accounting Request" },
88 1.1 christos { RADCMD_ACCOUN_RES, "Accounting Response" },
89 1.1 christos { RADCMD_ACCESS_CHA, "Access Challenge" },
90 1.1 christos { RADCMD_STATUS_SER, "Status Server" },
91 1.1 christos { RADCMD_STATUS_CLI, "Status Client" },
92 1.1 christos { RADCMD_RESERVED, "Reserved" },
93 1.1 christos { 0, NULL}
94 1.1 christos };
95 1.1 christos
96 1.1 christos /********************************/
97 1.1 christos /* Begin Radius Attribute types */
98 1.1 christos /********************************/
99 1.1 christos #define SERV_TYPE 6
100 1.1 christos #define FRM_IPADDR 8
101 1.1 christos #define LOG_IPHOST 14
102 1.1 christos #define LOG_SERVICE 15
103 1.1 christos #define FRM_IPX 23
104 1.1 christos #define SESSION_TIMEOUT 27
105 1.1 christos #define IDLE_TIMEOUT 28
106 1.1 christos #define FRM_ATALK_LINK 37
107 1.1 christos #define FRM_ATALK_NETWORK 38
108 1.1 christos
109 1.1 christos #define ACCT_DELAY 41
110 1.1 christos #define ACCT_SESSION_TIME 46
111 1.1 christos
112 1.1 christos #define TUNNEL_TYPE 64
113 1.1 christos #define TUNNEL_MEDIUM 65
114 1.1 christos #define TUNNEL_CLIENT_END 66
115 1.1 christos #define TUNNEL_SERVER_END 67
116 1.1 christos #define TUNNEL_PASS 69
117 1.1 christos
118 1.1 christos #define ARAP_PASS 70
119 1.1 christos #define ARAP_FEATURES 71
120 1.1 christos
121 1.1 christos #define TUNNEL_PRIV_GROUP 81
122 1.1 christos #define TUNNEL_ASSIGN_ID 82
123 1.1 christos #define TUNNEL_PREFERENCE 83
124 1.1 christos
125 1.1 christos #define ARAP_CHALLENGE_RESP 84
126 1.1 christos #define ACCT_INT_INTERVAL 85
127 1.1 christos
128 1.1 christos #define TUNNEL_CLIENT_AUTH 90
129 1.1 christos #define TUNNEL_SERVER_AUTH 91
130 1.1 christos /********************************/
131 1.1 christos /* End Radius Attribute types */
132 1.1 christos /********************************/
133 1.1 christos
134 1.1 christos
135 1.5 christos static void print_attr_string(netdissect_options *, register u_char *, u_int, u_short );
136 1.5 christos static void print_attr_num(netdissect_options *, register u_char *, u_int, u_short );
137 1.5 christos static void print_vendor_attr(netdissect_options *, register u_char *, u_int, u_short );
138 1.5 christos static void print_attr_address(netdissect_options *, register u_char *, u_int, u_short);
139 1.5 christos static void print_attr_time(netdissect_options *, register u_char *, u_int, u_short);
140 1.5 christos static void print_attr_strange(netdissect_options *, register u_char *, u_int, u_short);
141 1.1 christos
142 1.1 christos
143 1.5 christos struct radius_hdr { uint8_t code; /* Radius packet code */
144 1.5 christos uint8_t id; /* Radius packet id */
145 1.5 christos uint16_t len; /* Radius total length */
146 1.5 christos uint8_t auth[16]; /* Authenticator */
147 1.1 christos };
148 1.1 christos
149 1.1 christos #define MIN_RADIUS_LEN 20
150 1.1 christos
151 1.5 christos struct radius_attr { uint8_t type; /* Attribute type */
152 1.5 christos uint8_t len; /* Attribute length */
153 1.1 christos };
154 1.1 christos
155 1.1 christos
156 1.1 christos /* Service-Type Attribute standard values */
157 1.1 christos static const char *serv_type[]={ NULL,
158 1.1 christos "Login",
159 1.1 christos "Framed",
160 1.1 christos "Callback Login",
161 1.1 christos "Callback Framed",
162 1.1 christos "Outbound",
163 1.1 christos "Administrative",
164 1.1 christos "NAS Prompt",
165 1.1 christos "Authenticate Only",
166 1.1 christos "Callback NAS Prompt",
167 1.1 christos "Call Check",
168 1.1 christos "Callback Administrative",
169 1.1 christos };
170 1.1 christos
171 1.1 christos /* Framed-Protocol Attribute standard values */
172 1.1 christos static const char *frm_proto[]={ NULL,
173 1.1 christos "PPP",
174 1.1 christos "SLIP",
175 1.1 christos "ARAP",
176 1.1 christos "Gandalf proprietary",
177 1.1 christos "Xylogics IPX/SLIP",
178 1.1 christos "X.75 Synchronous",
179 1.1 christos };
180 1.1 christos
181 1.1 christos /* Framed-Routing Attribute standard values */
182 1.1 christos static const char *frm_routing[]={ "None",
183 1.1 christos "Send",
184 1.1 christos "Listen",
185 1.1 christos "Send&Listen",
186 1.1 christos };
187 1.1 christos
188 1.1 christos /* Framed-Compression Attribute standard values */
189 1.1 christos static const char *frm_comp[]={ "None",
190 1.1 christos "VJ TCP/IP",
191 1.1 christos "IPX",
192 1.1 christos "Stac-LZS",
193 1.1 christos };
194 1.1 christos
195 1.1 christos /* Login-Service Attribute standard values */
196 1.1 christos static const char *login_serv[]={ "Telnet",
197 1.1 christos "Rlogin",
198 1.1 christos "TCP Clear",
199 1.1 christos "PortMaster(proprietary)",
200 1.1 christos "LAT",
201 1.1 christos "X.25-PAD",
202 1.1 christos "X.25-T3POS",
203 1.1 christos "Unassigned",
204 1.1 christos "TCP Clear Quiet",
205 1.1 christos };
206 1.1 christos
207 1.1 christos
208 1.1 christos /* Termination-Action Attribute standard values */
209 1.1 christos static const char *term_action[]={ "Default",
210 1.1 christos "RADIUS-Request",
211 1.1 christos };
212 1.1 christos
213 1.1 christos /* NAS-Port-Type Attribute standard values */
214 1.1 christos static const char *nas_port_type[]={ "Async",
215 1.1 christos "Sync",
216 1.1 christos "ISDN Sync",
217 1.1 christos "ISDN Async V.120",
218 1.1 christos "ISDN Async V.110",
219 1.1 christos "Virtual",
220 1.1 christos "PIAFS",
221 1.1 christos "HDLC Clear Channel",
222 1.1 christos "X.25",
223 1.1 christos "X.75",
224 1.1 christos "G.3 Fax",
225 1.1 christos "SDSL",
226 1.1 christos "ADSL-CAP",
227 1.1 christos "ADSL-DMT",
228 1.1 christos "ISDN-DSL",
229 1.1 christos "Ethernet",
230 1.1 christos "xDSL",
231 1.1 christos "Cable",
232 1.1 christos "Wireless - Other",
233 1.1 christos "Wireless - IEEE 802.11",
234 1.1 christos };
235 1.1 christos
236 1.1 christos /* Acct-Status-Type Accounting Attribute standard values */
237 1.1 christos static const char *acct_status[]={ NULL,
238 1.1 christos "Start",
239 1.1 christos "Stop",
240 1.1 christos "Interim-Update",
241 1.1 christos "Unassigned",
242 1.1 christos "Unassigned",
243 1.1 christos "Unassigned",
244 1.1 christos "Accounting-On",
245 1.1 christos "Accounting-Off",
246 1.1 christos "Tunnel-Start",
247 1.1 christos "Tunnel-Stop",
248 1.1 christos "Tunnel-Reject",
249 1.1 christos "Tunnel-Link-Start",
250 1.1 christos "Tunnel-Link-Stop",
251 1.1 christos "Tunnel-Link-Reject",
252 1.1 christos "Failed",
253 1.1 christos };
254 1.1 christos
255 1.1 christos /* Acct-Authentic Accounting Attribute standard values */
256 1.1 christos static const char *acct_auth[]={ NULL,
257 1.1 christos "RADIUS",
258 1.1 christos "Local",
259 1.1 christos "Remote",
260 1.1 christos };
261 1.1 christos
262 1.1 christos /* Acct-Terminate-Cause Accounting Attribute standard values */
263 1.1 christos static const char *acct_term[]={ NULL,
264 1.1 christos "User Request",
265 1.1 christos "Lost Carrier",
266 1.1 christos "Lost Service",
267 1.1 christos "Idle Timeout",
268 1.1 christos "Session Timeout",
269 1.1 christos "Admin Reset",
270 1.1 christos "Admin Reboot",
271 1.1 christos "Port Error",
272 1.1 christos "NAS Error",
273 1.1 christos "NAS Request",
274 1.1 christos "NAS Reboot",
275 1.1 christos "Port Unneeded",
276 1.1 christos "Port Preempted",
277 1.1 christos "Port Suspended",
278 1.1 christos "Service Unavailable",
279 1.1 christos "Callback",
280 1.1 christos "User Error",
281 1.1 christos "Host Request",
282 1.1 christos };
283 1.1 christos
284 1.1 christos /* Tunnel-Type Attribute standard values */
285 1.1 christos static const char *tunnel_type[]={ NULL,
286 1.1 christos "PPTP",
287 1.1 christos "L2F",
288 1.1 christos "L2TP",
289 1.1 christos "ATMP",
290 1.1 christos "VTP",
291 1.1 christos "AH",
292 1.1 christos "IP-IP",
293 1.1 christos "MIN-IP-IP",
294 1.1 christos "ESP",
295 1.1 christos "GRE",
296 1.1 christos "DVS",
297 1.1 christos "IP-in-IP Tunneling",
298 1.1 christos };
299 1.1 christos
300 1.1 christos /* Tunnel-Medium-Type Attribute standard values */
301 1.1 christos static const char *tunnel_medium[]={ NULL,
302 1.1 christos "IPv4",
303 1.1 christos "IPv6",
304 1.1 christos "NSAP",
305 1.1 christos "HDLC",
306 1.1 christos "BBN 1822",
307 1.1 christos "802",
308 1.1 christos "E.163",
309 1.1 christos "E.164",
310 1.1 christos "F.69",
311 1.1 christos "X.121",
312 1.1 christos "IPX",
313 1.1 christos "Appletalk",
314 1.1 christos "Decnet IV",
315 1.1 christos "Banyan Vines",
316 1.1 christos "E.164 with NSAP subaddress",
317 1.1 christos };
318 1.1 christos
319 1.1 christos /* ARAP-Zone-Access Attribute standard values */
320 1.1 christos static const char *arap_zone[]={ NULL,
321 1.1 christos "Only access to dfl zone",
322 1.1 christos "Use zone filter inc.",
323 1.1 christos "Not used",
324 1.1 christos "Use zone filter exc.",
325 1.1 christos };
326 1.1 christos
327 1.1 christos static const char *prompt[]={ "No Echo",
328 1.1 christos "Echo",
329 1.1 christos };
330 1.1 christos
331 1.1 christos
332 1.1 christos struct attrtype { const char *name; /* Attribute name */
333 1.1 christos const char **subtypes; /* Standard Values (if any) */
334 1.1 christos u_char siz_subtypes; /* Size of total standard values */
335 1.1 christos u_char first_subtype; /* First standard value is 0 or 1 */
336 1.5 christos void (*print_func)(netdissect_options *, register u_char *, u_int, u_short);
337 1.1 christos } attr_type[]=
338 1.1 christos {
339 1.1 christos { NULL, NULL, 0, 0, NULL },
340 1.1 christos { "Username", NULL, 0, 0, print_attr_string },
341 1.1 christos { "Password", NULL, 0, 0, NULL },
342 1.1 christos { "CHAP Password", NULL, 0, 0, NULL },
343 1.1 christos { "NAS IP Address", NULL, 0, 0, print_attr_address },
344 1.1 christos { "NAS Port", NULL, 0, 0, print_attr_num },
345 1.1 christos { "Service Type", serv_type, TAM_SIZE(serv_type)-1, 1, print_attr_num },
346 1.1 christos { "Framed Protocol", frm_proto, TAM_SIZE(frm_proto)-1, 1, print_attr_num },
347 1.1 christos { "Framed IP Address", NULL, 0, 0, print_attr_address },
348 1.1 christos { "Framed IP Network", NULL, 0, 0, print_attr_address },
349 1.1 christos { "Framed Routing", frm_routing, TAM_SIZE(frm_routing), 0, print_attr_num },
350 1.1 christos { "Filter ID", NULL, 0, 0, print_attr_string },
351 1.1 christos { "Framed MTU", NULL, 0, 0, print_attr_num },
352 1.1 christos { "Framed Compression", frm_comp, TAM_SIZE(frm_comp), 0, print_attr_num },
353 1.1 christos { "Login IP Host", NULL, 0, 0, print_attr_address },
354 1.1 christos { "Login Service", login_serv, TAM_SIZE(login_serv), 0, print_attr_num },
355 1.1 christos { "Login TCP Port", NULL, 0, 0, print_attr_num },
356 1.1 christos { "Unassigned", NULL, 0, 0, NULL }, /*17*/
357 1.1 christos { "Reply", NULL, 0, 0, print_attr_string },
358 1.1 christos { "Callback-number", NULL, 0, 0, print_attr_string },
359 1.1 christos { "Callback-ID", NULL, 0, 0, print_attr_string },
360 1.1 christos { "Unassigned", NULL, 0, 0, NULL }, /*21*/
361 1.1 christos { "Framed Route", NULL, 0, 0, print_attr_string },
362 1.1 christos { "Framed IPX Network", NULL, 0, 0, print_attr_num },
363 1.1 christos { "State", NULL, 0, 0, print_attr_string },
364 1.1 christos { "Class", NULL, 0, 0, print_attr_string },
365 1.1 christos { "Vendor Specific", NULL, 0, 0, print_vendor_attr },
366 1.1 christos { "Session Timeout", NULL, 0, 0, print_attr_num },
367 1.1 christos { "Idle Timeout", NULL, 0, 0, print_attr_num },
368 1.1 christos { "Termination Action", term_action, TAM_SIZE(term_action), 0, print_attr_num },
369 1.1 christos { "Called Station", NULL, 0, 0, print_attr_string },
370 1.1 christos { "Calling Station", NULL, 0, 0, print_attr_string },
371 1.1 christos { "NAS ID", NULL, 0, 0, print_attr_string },
372 1.1 christos { "Proxy State", NULL, 0, 0, print_attr_string },
373 1.1 christos { "Login LAT Service", NULL, 0, 0, print_attr_string },
374 1.1 christos { "Login LAT Node", NULL, 0, 0, print_attr_string },
375 1.1 christos { "Login LAT Group", NULL, 0, 0, print_attr_string },
376 1.1 christos { "Framed Appletalk Link", NULL, 0, 0, print_attr_num },
377 1.1 christos { "Framed Appltalk Net", NULL, 0, 0, print_attr_num },
378 1.1 christos { "Framed Appletalk Zone", NULL, 0, 0, print_attr_string },
379 1.1 christos { "Accounting Status", acct_status, TAM_SIZE(acct_status)-1, 1, print_attr_num },
380 1.1 christos { "Accounting Delay", NULL, 0, 0, print_attr_num },
381 1.1 christos { "Accounting Input Octets", NULL, 0, 0, print_attr_num },
382 1.1 christos { "Accounting Output Octets", NULL, 0, 0, print_attr_num },
383 1.1 christos { "Accounting Session ID", NULL, 0, 0, print_attr_string },
384 1.1 christos { "Accounting Authentication", acct_auth, TAM_SIZE(acct_auth)-1, 1, print_attr_num },
385 1.1 christos { "Accounting Session Time", NULL, 0, 0, print_attr_num },
386 1.1 christos { "Accounting Input Packets", NULL, 0, 0, print_attr_num },
387 1.1 christos { "Accounting Output Packets", NULL, 0, 0, print_attr_num },
388 1.1 christos { "Accounting Termination Cause", acct_term, TAM_SIZE(acct_term)-1, 1, print_attr_num },
389 1.1 christos { "Accounting Multilink Session ID", NULL, 0, 0, print_attr_string },
390 1.1 christos { "Accounting Link Count", NULL, 0, 0, print_attr_num },
391 1.1 christos { "Accounting Input Giga", NULL, 0, 0, print_attr_num },
392 1.1 christos { "Accounting Output Giga", NULL, 0, 0, print_attr_num },
393 1.1 christos { "Unassigned", NULL, 0, 0, NULL }, /*54*/
394 1.1 christos { "Event Timestamp", NULL, 0, 0, print_attr_time },
395 1.1 christos { "Unassigned", NULL, 0, 0, NULL }, /*56*/
396 1.1 christos { "Unassigned", NULL, 0, 0, NULL }, /*57*/
397 1.1 christos { "Unassigned", NULL, 0, 0, NULL }, /*58*/
398 1.1 christos { "Unassigned", NULL, 0, 0, NULL }, /*59*/
399 1.1 christos { "CHAP challenge", NULL, 0, 0, print_attr_string },
400 1.1 christos { "NAS Port Type", nas_port_type, TAM_SIZE(nas_port_type), 0, print_attr_num },
401 1.1 christos { "Port Limit", NULL, 0, 0, print_attr_num },
402 1.1 christos { "Login LAT Port", NULL, 0, 0, print_attr_string }, /*63*/
403 1.1 christos { "Tunnel Type", tunnel_type, TAM_SIZE(tunnel_type)-1, 1, print_attr_num },
404 1.1 christos { "Tunnel Medium", tunnel_medium, TAM_SIZE(tunnel_medium)-1, 1, print_attr_num },
405 1.1 christos { "Tunnel Client End", NULL, 0, 0, print_attr_string },
406 1.1 christos { "Tunnel Server End", NULL, 0, 0, print_attr_string },
407 1.1 christos { "Accounting Tunnel connect", NULL, 0, 0, print_attr_string },
408 1.1 christos { "Tunnel Password", NULL, 0, 0, print_attr_string },
409 1.1 christos { "ARAP Password", NULL, 0, 0, print_attr_strange },
410 1.1 christos { "ARAP Feature", NULL, 0, 0, print_attr_strange },
411 1.1 christos { "ARAP Zone Acces", arap_zone, TAM_SIZE(arap_zone)-1, 1, print_attr_num }, /*72*/
412 1.1 christos { "ARAP Security", NULL, 0, 0, print_attr_string },
413 1.1 christos { "ARAP Security Data", NULL, 0, 0, print_attr_string },
414 1.1 christos { "Password Retry", NULL, 0, 0, print_attr_num },
415 1.1 christos { "Prompt", prompt, TAM_SIZE(prompt), 0, print_attr_num },
416 1.1 christos { "Connect Info", NULL, 0, 0, print_attr_string },
417 1.1 christos { "Config Token", NULL, 0, 0, print_attr_string },
418 1.1 christos { "EAP Message", NULL, 0, 0, print_attr_string },
419 1.1 christos { "Message Authentication", NULL, 0, 0, print_attr_string }, /*80*/
420 1.1 christos { "Tunnel Private Group", NULL, 0, 0, print_attr_string },
421 1.1 christos { "Tunnel Assigned ID", NULL, 0, 0, print_attr_string },
422 1.1 christos { "Tunnel Preference", NULL, 0, 0, print_attr_num },
423 1.1 christos { "ARAP Challenge Response", NULL, 0, 0, print_attr_strange },
424 1.1 christos { "Accounting Interim Interval", NULL, 0, 0, print_attr_num },
425 1.1 christos { "Accounting Tunnel packets lost", NULL, 0, 0, print_attr_num }, /*86*/
426 1.1 christos { "NAS Port ID", NULL, 0, 0, print_attr_string },
427 1.1 christos { "Framed Pool", NULL, 0, 0, print_attr_string },
428 1.5 christos { "Chargeable User Identity", NULL, 0, 0, print_attr_string },
429 1.1 christos { "Tunnel Client Authentication ID", NULL, 0, 0, print_attr_string },
430 1.1 christos { "Tunnel Server Authentication ID", NULL, 0, 0, print_attr_string },
431 1.1 christos { "Unassigned", NULL, 0, 0, NULL }, /*92*/
432 1.1 christos { "Unassigned", NULL, 0, 0, NULL } /*93*/
433 1.1 christos };
434 1.1 christos
435 1.1 christos
436 1.1 christos /*****************************/
437 1.1 christos /* Print an attribute string */
438 1.1 christos /* value pointed by 'data' */
439 1.1 christos /* and 'length' size. */
440 1.1 christos /*****************************/
441 1.1 christos /* Returns nothing. */
442 1.1 christos /*****************************/
443 1.1 christos static void
444 1.5 christos print_attr_string(netdissect_options *ndo,
445 1.5 christos register u_char *data, u_int length, u_short attr_code)
446 1.1 christos {
447 1.1 christos register u_int i;
448 1.1 christos
449 1.5 christos ND_TCHECK2(data[0],length);
450 1.1 christos
451 1.1 christos switch(attr_code)
452 1.1 christos {
453 1.1 christos case TUNNEL_PASS:
454 1.1 christos if (length < 3)
455 1.1 christos {
456 1.5 christos ND_PRINT((ndo, "%s", tstr));
457 1.1 christos return;
458 1.1 christos }
459 1.1 christos if (*data && (*data <=0x1F) )
460 1.5 christos ND_PRINT((ndo, "Tag %u, ",*data));
461 1.1 christos data++;
462 1.1 christos length--;
463 1.5 christos ND_PRINT((ndo, "Salt %u ", EXTRACT_16BITS(data)));
464 1.1 christos data+=2;
465 1.1 christos length-=2;
466 1.1 christos break;
467 1.1 christos case TUNNEL_CLIENT_END:
468 1.1 christos case TUNNEL_SERVER_END:
469 1.1 christos case TUNNEL_PRIV_GROUP:
470 1.1 christos case TUNNEL_ASSIGN_ID:
471 1.1 christos case TUNNEL_CLIENT_AUTH:
472 1.1 christos case TUNNEL_SERVER_AUTH:
473 1.1 christos if (*data <= 0x1F)
474 1.1 christos {
475 1.1 christos if (length < 1)
476 1.1 christos {
477 1.5 christos ND_PRINT((ndo, "%s", tstr));
478 1.1 christos return;
479 1.1 christos }
480 1.5 christos ND_PRINT((ndo, "Tag %u", *data));
481 1.1 christos data++;
482 1.1 christos length--;
483 1.1 christos }
484 1.1 christos break;
485 1.1 christos }
486 1.1 christos
487 1.1 christos for (i=0; *data && i < length ; i++, data++)
488 1.5 christos ND_PRINT((ndo, "%c", (*data < 32 || *data > 128) ? '.' : *data));
489 1.1 christos
490 1.1 christos return;
491 1.1 christos
492 1.1 christos trunc:
493 1.5 christos ND_PRINT((ndo, "%s", tstr));
494 1.1 christos }
495 1.1 christos
496 1.1 christos /*
497 1.1 christos * print vendor specific attributes
498 1.1 christos */
499 1.1 christos static void
500 1.5 christos print_vendor_attr(netdissect_options *ndo,
501 1.5 christos register u_char *data, u_int length, u_short attr_code _U_)
502 1.1 christos {
503 1.1 christos u_int idx;
504 1.1 christos u_int vendor_id;
505 1.1 christos u_int vendor_type;
506 1.1 christos u_int vendor_length;
507 1.1 christos
508 1.1 christos if (length < 4)
509 1.1 christos goto trunc;
510 1.5 christos ND_TCHECK2(*data, 4);
511 1.1 christos vendor_id = EXTRACT_32BITS(data);
512 1.1 christos data+=4;
513 1.1 christos length-=4;
514 1.1 christos
515 1.5 christos ND_PRINT((ndo, "Vendor: %s (%u)",
516 1.1 christos tok2str(smi_values,"Unknown",vendor_id),
517 1.5 christos vendor_id));
518 1.1 christos
519 1.1 christos while (length >= 2) {
520 1.5 christos ND_TCHECK2(*data, 2);
521 1.1 christos
522 1.1 christos vendor_type = *(data);
523 1.1 christos vendor_length = *(data+1);
524 1.1 christos
525 1.1 christos if (vendor_length < 2)
526 1.1 christos {
527 1.5 christos ND_PRINT((ndo, "\n\t Vendor Attribute: %u, Length: %u (bogus, must be >= 2)",
528 1.1 christos vendor_type,
529 1.5 christos vendor_length));
530 1.1 christos return;
531 1.1 christos }
532 1.1 christos if (vendor_length > length)
533 1.1 christos {
534 1.5 christos ND_PRINT((ndo, "\n\t Vendor Attribute: %u, Length: %u (bogus, goes past end of vendor-specific attribute)",
535 1.1 christos vendor_type,
536 1.5 christos vendor_length));
537 1.1 christos return;
538 1.1 christos }
539 1.1 christos data+=2;
540 1.1 christos vendor_length-=2;
541 1.1 christos length-=2;
542 1.5 christos ND_TCHECK2(*data, vendor_length);
543 1.1 christos
544 1.5 christos ND_PRINT((ndo, "\n\t Vendor Attribute: %u, Length: %u, Value: ",
545 1.1 christos vendor_type,
546 1.5 christos vendor_length));
547 1.1 christos for (idx = 0; idx < vendor_length ; idx++, data++)
548 1.5 christos ND_PRINT((ndo, "%c", (*data < 32 || *data > 128) ? '.' : *data));
549 1.1 christos length-=vendor_length;
550 1.1 christos }
551 1.1 christos return;
552 1.1 christos
553 1.1 christos trunc:
554 1.5 christos ND_PRINT((ndo, "%s", tstr));
555 1.1 christos }
556 1.1 christos
557 1.1 christos /******************************/
558 1.1 christos /* Print an attribute numeric */
559 1.1 christos /* value pointed by 'data' */
560 1.1 christos /* and 'length' size. */
561 1.1 christos /******************************/
562 1.1 christos /* Returns nothing. */
563 1.1 christos /******************************/
564 1.1 christos static void
565 1.5 christos print_attr_num(netdissect_options *ndo,
566 1.5 christos register u_char *data, u_int length, u_short attr_code)
567 1.1 christos {
568 1.5 christos uint8_t tag;
569 1.5 christos uint32_t timeout;
570 1.1 christos
571 1.1 christos if (length != 4)
572 1.1 christos {
573 1.5 christos ND_PRINT((ndo, "ERROR: length %u != 4", length));
574 1.1 christos return;
575 1.1 christos }
576 1.1 christos
577 1.5 christos ND_TCHECK2(data[0],4);
578 1.1 christos /* This attribute has standard values */
579 1.1 christos if (attr_type[attr_code].siz_subtypes)
580 1.1 christos {
581 1.1 christos static const char **table;
582 1.5 christos uint32_t data_value;
583 1.1 christos table = attr_type[attr_code].subtypes;
584 1.1 christos
585 1.1 christos if ( (attr_code == TUNNEL_TYPE) || (attr_code == TUNNEL_MEDIUM) )
586 1.1 christos {
587 1.1 christos if (!*data)
588 1.5 christos ND_PRINT((ndo, "Tag[Unused]"));
589 1.1 christos else
590 1.5 christos ND_PRINT((ndo, "Tag[%d]", *data));
591 1.1 christos data++;
592 1.1 christos data_value = EXTRACT_24BITS(data);
593 1.1 christos }
594 1.1 christos else
595 1.1 christos {
596 1.1 christos data_value = EXTRACT_32BITS(data);
597 1.1 christos }
598 1.5 christos if ( data_value <= (uint32_t)(attr_type[attr_code].siz_subtypes - 1 +
599 1.1 christos attr_type[attr_code].first_subtype) &&
600 1.1 christos data_value >= attr_type[attr_code].first_subtype )
601 1.5 christos ND_PRINT((ndo, "%s", table[data_value]));
602 1.1 christos else
603 1.5 christos ND_PRINT((ndo, "#%u", data_value));
604 1.1 christos }
605 1.1 christos else
606 1.1 christos {
607 1.1 christos switch(attr_code) /* Be aware of special cases... */
608 1.1 christos {
609 1.1 christos case FRM_IPX:
610 1.1 christos if (EXTRACT_32BITS( data) == 0xFFFFFFFE )
611 1.5 christos ND_PRINT((ndo, "NAS Select"));
612 1.1 christos else
613 1.5 christos ND_PRINT((ndo, "%d", EXTRACT_32BITS(data)));
614 1.1 christos break;
615 1.1 christos
616 1.1 christos case SESSION_TIMEOUT:
617 1.1 christos case IDLE_TIMEOUT:
618 1.1 christos case ACCT_DELAY:
619 1.1 christos case ACCT_SESSION_TIME:
620 1.1 christos case ACCT_INT_INTERVAL:
621 1.1 christos timeout = EXTRACT_32BITS( data);
622 1.1 christos if ( timeout < 60 )
623 1.5 christos ND_PRINT((ndo, "%02d secs", timeout));
624 1.1 christos else
625 1.1 christos {
626 1.1 christos if ( timeout < 3600 )
627 1.5 christos ND_PRINT((ndo, "%02d:%02d min",
628 1.5 christos timeout / 60, timeout % 60));
629 1.1 christos else
630 1.5 christos ND_PRINT((ndo, "%02d:%02d:%02d hours",
631 1.1 christos timeout / 3600, (timeout % 3600) / 60,
632 1.5 christos timeout % 60));
633 1.1 christos }
634 1.1 christos break;
635 1.1 christos
636 1.1 christos case FRM_ATALK_LINK:
637 1.1 christos if (EXTRACT_32BITS(data) )
638 1.5 christos ND_PRINT((ndo, "%d", EXTRACT_32BITS(data)));
639 1.1 christos else
640 1.5 christos ND_PRINT((ndo, "Unnumbered"));
641 1.1 christos break;
642 1.1 christos
643 1.1 christos case FRM_ATALK_NETWORK:
644 1.1 christos if (EXTRACT_32BITS(data) )
645 1.5 christos ND_PRINT((ndo, "%d", EXTRACT_32BITS(data)));
646 1.1 christos else
647 1.5 christos ND_PRINT((ndo, "NAS assigned"));
648 1.1 christos break;
649 1.1 christos
650 1.1 christos case TUNNEL_PREFERENCE:
651 1.1 christos tag = *data;
652 1.1 christos data++;
653 1.1 christos if (tag == 0)
654 1.5 christos ND_PRINT((ndo, "Tag (Unused) %d", EXTRACT_24BITS(data)));
655 1.1 christos else
656 1.5 christos ND_PRINT((ndo, "Tag (%d) %d", tag, EXTRACT_24BITS(data)));
657 1.1 christos break;
658 1.1 christos
659 1.1 christos default:
660 1.5 christos ND_PRINT((ndo, "%d", EXTRACT_32BITS(data)));
661 1.1 christos break;
662 1.1 christos
663 1.1 christos } /* switch */
664 1.1 christos
665 1.1 christos } /* if-else */
666 1.1 christos
667 1.1 christos return;
668 1.1 christos
669 1.1 christos trunc:
670 1.5 christos ND_PRINT((ndo, "%s", tstr));
671 1.1 christos }
672 1.1 christos
673 1.1 christos /*****************************/
674 1.1 christos /* Print an attribute IPv4 */
675 1.1 christos /* address value pointed by */
676 1.1 christos /* 'data' and 'length' size. */
677 1.1 christos /*****************************/
678 1.1 christos /* Returns nothing. */
679 1.1 christos /*****************************/
680 1.1 christos static void
681 1.5 christos print_attr_address(netdissect_options *ndo,
682 1.5 christos register u_char *data, u_int length, u_short attr_code)
683 1.1 christos {
684 1.1 christos if (length != 4)
685 1.1 christos {
686 1.5 christos ND_PRINT((ndo, "ERROR: length %u != 4", length));
687 1.1 christos return;
688 1.1 christos }
689 1.1 christos
690 1.5 christos ND_TCHECK2(data[0],4);
691 1.1 christos
692 1.1 christos switch(attr_code)
693 1.1 christos {
694 1.1 christos case FRM_IPADDR:
695 1.1 christos case LOG_IPHOST:
696 1.1 christos if (EXTRACT_32BITS(data) == 0xFFFFFFFF )
697 1.5 christos ND_PRINT((ndo, "User Selected"));
698 1.1 christos else
699 1.1 christos if (EXTRACT_32BITS(data) == 0xFFFFFFFE )
700 1.5 christos ND_PRINT((ndo, "NAS Select"));
701 1.1 christos else
702 1.5 christos ND_PRINT((ndo, "%s",ipaddr_string(ndo, data)));
703 1.1 christos break;
704 1.1 christos
705 1.1 christos default:
706 1.5 christos ND_PRINT((ndo, "%s", ipaddr_string(ndo, data)));
707 1.1 christos break;
708 1.1 christos }
709 1.1 christos
710 1.1 christos return;
711 1.1 christos
712 1.1 christos trunc:
713 1.5 christos ND_PRINT((ndo, "%s", tstr));
714 1.1 christos }
715 1.1 christos
716 1.1 christos /*************************************/
717 1.1 christos /* Print an attribute of 'secs since */
718 1.1 christos /* January 1, 1970 00:00 UTC' value */
719 1.1 christos /* pointed by 'data' and 'length' */
720 1.1 christos /* size. */
721 1.1 christos /*************************************/
722 1.1 christos /* Returns nothing. */
723 1.1 christos /*************************************/
724 1.5 christos static void
725 1.5 christos print_attr_time(netdissect_options *ndo,
726 1.5 christos register u_char *data, u_int length, u_short attr_code _U_)
727 1.1 christos {
728 1.1 christos time_t attr_time;
729 1.1 christos char string[26];
730 1.2 christos const char *p;
731 1.1 christos
732 1.1 christos if (length != 4)
733 1.1 christos {
734 1.5 christos ND_PRINT((ndo, "ERROR: length %u != 4", length));
735 1.1 christos return;
736 1.1 christos }
737 1.1 christos
738 1.5 christos ND_TCHECK2(data[0],4);
739 1.1 christos
740 1.1 christos attr_time = EXTRACT_32BITS(data);
741 1.2 christos if ((p = ctime(&attr_time)) == NULL)
742 1.2 christos p = "?";
743 1.2 christos strlcpy(string, p, sizeof(string));
744 1.1 christos /* Get rid of the newline */
745 1.1 christos string[24] = '\0';
746 1.5 christos ND_PRINT((ndo, "%.24s", string));
747 1.1 christos return;
748 1.1 christos
749 1.1 christos trunc:
750 1.5 christos ND_PRINT((ndo, "%s", tstr));
751 1.1 christos }
752 1.1 christos
753 1.1 christos /***********************************/
754 1.1 christos /* Print an attribute of 'strange' */
755 1.1 christos /* data format pointed by 'data' */
756 1.1 christos /* and 'length' size. */
757 1.1 christos /***********************************/
758 1.1 christos /* Returns nothing. */
759 1.1 christos /***********************************/
760 1.5 christos static void
761 1.5 christos print_attr_strange(netdissect_options *ndo,
762 1.5 christos register u_char *data, u_int length, u_short attr_code)
763 1.1 christos {
764 1.1 christos u_short len_data;
765 1.1 christos
766 1.1 christos switch(attr_code)
767 1.1 christos {
768 1.1 christos case ARAP_PASS:
769 1.1 christos if (length != 16)
770 1.1 christos {
771 1.5 christos ND_PRINT((ndo, "ERROR: length %u != 16", length));
772 1.1 christos return;
773 1.1 christos }
774 1.5 christos ND_PRINT((ndo, "User_challenge ("));
775 1.5 christos ND_TCHECK2(data[0],8);
776 1.1 christos len_data = 8;
777 1.1 christos PRINT_HEX(len_data, data);
778 1.5 christos ND_PRINT((ndo, ") User_resp("));
779 1.5 christos ND_TCHECK2(data[0],8);
780 1.1 christos len_data = 8;
781 1.1 christos PRINT_HEX(len_data, data);
782 1.5 christos ND_PRINT((ndo, ")"));
783 1.1 christos break;
784 1.1 christos
785 1.1 christos case ARAP_FEATURES:
786 1.1 christos if (length != 14)
787 1.1 christos {
788 1.5 christos ND_PRINT((ndo, "ERROR: length %u != 14", length));
789 1.1 christos return;
790 1.1 christos }
791 1.5 christos ND_TCHECK2(data[0],1);
792 1.1 christos if (*data)
793 1.5 christos ND_PRINT((ndo, "User can change password"));
794 1.1 christos else
795 1.5 christos ND_PRINT((ndo, "User cannot change password"));
796 1.1 christos data++;
797 1.5 christos ND_TCHECK2(data[0],1);
798 1.5 christos ND_PRINT((ndo, ", Min password length: %d", *data));
799 1.1 christos data++;
800 1.5 christos ND_PRINT((ndo, ", created at: "));
801 1.5 christos ND_TCHECK2(data[0],4);
802 1.1 christos len_data = 4;
803 1.1 christos PRINT_HEX(len_data, data);
804 1.5 christos ND_PRINT((ndo, ", expires in: "));
805 1.5 christos ND_TCHECK2(data[0],4);
806 1.1 christos len_data = 4;
807 1.1 christos PRINT_HEX(len_data, data);
808 1.5 christos ND_PRINT((ndo, ", Current Time: "));
809 1.5 christos ND_TCHECK2(data[0],4);
810 1.1 christos len_data = 4;
811 1.1 christos PRINT_HEX(len_data, data);
812 1.1 christos break;
813 1.1 christos
814 1.1 christos case ARAP_CHALLENGE_RESP:
815 1.1 christos if (length < 8)
816 1.1 christos {
817 1.5 christos ND_PRINT((ndo, "ERROR: length %u != 8", length));
818 1.1 christos return;
819 1.1 christos }
820 1.5 christos ND_TCHECK2(data[0],8);
821 1.1 christos len_data = 8;
822 1.1 christos PRINT_HEX(len_data, data);
823 1.1 christos break;
824 1.1 christos }
825 1.1 christos return;
826 1.1 christos
827 1.1 christos trunc:
828 1.5 christos ND_PRINT((ndo, "%s", tstr));
829 1.1 christos }
830 1.1 christos
831 1.1 christos static void
832 1.5 christos radius_attrs_print(netdissect_options *ndo,
833 1.5 christos register const u_char *attr, u_int length)
834 1.1 christos {
835 1.1 christos register const struct radius_attr *rad_attr = (struct radius_attr *)attr;
836 1.1 christos const char *attr_string;
837 1.1 christos
838 1.1 christos while (length > 0)
839 1.1 christos {
840 1.1 christos if (length < 2)
841 1.1 christos goto trunc;
842 1.5 christos ND_TCHECK(*rad_attr);
843 1.5 christos
844 1.1 christos if (rad_attr->type > 0 && rad_attr->type < TAM_SIZE(attr_type))
845 1.1 christos attr_string = attr_type[rad_attr->type].name;
846 1.1 christos else
847 1.1 christos attr_string = "Unknown";
848 1.1 christos if (rad_attr->len < 2)
849 1.1 christos {
850 1.5 christos ND_PRINT((ndo, "\n\t %s Attribute (%u), length: %u (bogus, must be >= 2)",
851 1.1 christos attr_string,
852 1.1 christos rad_attr->type,
853 1.5 christos rad_attr->len));
854 1.1 christos return;
855 1.1 christos }
856 1.1 christos if (rad_attr->len > length)
857 1.1 christos {
858 1.5 christos ND_PRINT((ndo, "\n\t %s Attribute (%u), length: %u (bogus, goes past end of packet)",
859 1.1 christos attr_string,
860 1.1 christos rad_attr->type,
861 1.5 christos rad_attr->len));
862 1.1 christos return;
863 1.1 christos }
864 1.5 christos ND_PRINT((ndo, "\n\t %s Attribute (%u), length: %u, Value: ",
865 1.1 christos attr_string,
866 1.1 christos rad_attr->type,
867 1.5 christos rad_attr->len));
868 1.1 christos
869 1.1 christos if (rad_attr->type < TAM_SIZE(attr_type))
870 1.1 christos {
871 1.1 christos if (rad_attr->len > 2)
872 1.1 christos {
873 1.1 christos if ( attr_type[rad_attr->type].print_func )
874 1.1 christos (*attr_type[rad_attr->type].print_func)(
875 1.5 christos ndo, ((u_char *)(rad_attr+1)),
876 1.1 christos rad_attr->len - 2, rad_attr->type);
877 1.1 christos }
878 1.1 christos }
879 1.1 christos /* do we also want to see a hex dump ? */
880 1.5 christos if (ndo->ndo_vflag> 1)
881 1.5 christos print_unknown_data(ndo, (u_char *)rad_attr+2, "\n\t ", (rad_attr->len)-2);
882 1.1 christos
883 1.1 christos length-=(rad_attr->len);
884 1.1 christos rad_attr = (struct radius_attr *)( ((char *)(rad_attr))+rad_attr->len);
885 1.1 christos }
886 1.1 christos return;
887 1.1 christos
888 1.1 christos trunc:
889 1.5 christos ND_PRINT((ndo, "%s", tstr));
890 1.1 christos }
891 1.1 christos
892 1.1 christos void
893 1.5 christos radius_print(netdissect_options *ndo,
894 1.5 christos const u_char *dat, u_int length)
895 1.1 christos {
896 1.1 christos register const struct radius_hdr *rad;
897 1.1 christos u_int len, auth_idx;
898 1.1 christos
899 1.5 christos ND_TCHECK2(*dat, MIN_RADIUS_LEN);
900 1.1 christos rad = (struct radius_hdr *)dat;
901 1.1 christos len = EXTRACT_16BITS(&rad->len);
902 1.1 christos
903 1.1 christos if (len < MIN_RADIUS_LEN)
904 1.1 christos {
905 1.5 christos ND_PRINT((ndo, "%s", tstr));
906 1.1 christos return;
907 1.1 christos }
908 1.1 christos
909 1.1 christos if (len > length)
910 1.1 christos len = length;
911 1.1 christos
912 1.5 christos if (ndo->ndo_vflag < 1) {
913 1.5 christos ND_PRINT((ndo, "RADIUS, %s (%u), id: 0x%02x length: %u",
914 1.1 christos tok2str(radius_command_values,"Unknown Command",rad->code),
915 1.1 christos rad->code,
916 1.1 christos rad->id,
917 1.5 christos len));
918 1.1 christos return;
919 1.1 christos }
920 1.1 christos else {
921 1.5 christos ND_PRINT((ndo, "RADIUS, length: %u\n\t%s (%u), id: 0x%02x, Authenticator: ",
922 1.1 christos len,
923 1.1 christos tok2str(radius_command_values,"Unknown Command",rad->code),
924 1.1 christos rad->code,
925 1.5 christos rad->id));
926 1.1 christos
927 1.1 christos for(auth_idx=0; auth_idx < 16; auth_idx++)
928 1.5 christos ND_PRINT((ndo, "%02x", rad->auth[auth_idx]));
929 1.1 christos }
930 1.1 christos
931 1.1 christos if (len > MIN_RADIUS_LEN)
932 1.5 christos radius_attrs_print(ndo, dat + MIN_RADIUS_LEN, len - MIN_RADIUS_LEN);
933 1.1 christos return;
934 1.1 christos
935 1.1 christos trunc:
936 1.5 christos ND_PRINT((ndo, "%s", tstr));
937 1.1 christos }
938