Remove "text2pcap-scanner.obj" and "tools\lemon\lemon.obj" when a "nmake
[obnox/wireshark/wip.git] / packet-radius.c
1 /* packet-radius.c
2  * Routines for RADIUS packet disassembly
3  * Copyright 1999 Johan Feyaerts
4  *
5  * $Id: packet-radius.c,v 1.37 2001/10/23 04:11:56 guy Exp $
6  *
7  * Ethereal - Network traffic analyzer
8  * By Gerald Combs <gerald@ethereal.com>
9  * Copyright 1998 Gerald Combs
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  */
25
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29
30 #ifdef HAVE_SYS_TYPES_H
31 # include <sys/types.h>
32 #endif
33
34 #ifdef HAVE_NETINET_IN_H
35 #include <netinet/in.h>
36 #endif
37
38 #include <stdio.h>
39 #include <stdlib.h>
40 #include <string.h>
41 #include <ctype.h>
42 #include <glib.h>
43 #include <time.h>
44 #include "packet.h"
45 #include "resolv.h"
46
47 static int proto_radius = -1;
48 static int hf_radius_length = -1;
49 static int hf_radius_code = -1;
50 static int hf_radius_id =-1;
51
52 static gint ett_radius = -1;
53 static gint ett_radius_avp = -1;
54
55 #define UDP_PORT_RADIUS         1645
56 #define UDP_PORT_RADIUS_NEW     1812
57 #define UDP_PORT_RADACCT        1646
58 #define UDP_PORT_RADACCT_NEW    1813
59
60 typedef struct _e_radiushdr {
61         guint8 rh_code;
62         guint8 rh_ident;
63         guint16 rh_pktlength;
64 } e_radiushdr;
65
66 typedef struct _e_avphdr {
67         guint8 avp_type;
68         guint8 avp_length;
69 } e_avphdr;
70
71 typedef struct _value_value_pair {
72         guint16 val1;
73         guint16 val2;
74 } value_value_pair;
75
76 #define RADIUS_ACCESS_REQUEST 1
77 #define RADIUS_ACCESS_ACCEPT  2
78 #define RADIUS_ACCESS_REJECT  3
79 #define RADIUS_ACCOUNTING_REQUEST 4
80 #define RADIUS_ACCOUNTING_RESPONSE 5
81 #define RADIUS_ACCESS_CHALLENGE 11
82 #define RADIUS_STATUS_SERVER 12
83 #define RADIUS_STATUS_CLIENT 13
84 #define RADIUS_RESERVED 255
85
86 #define RD_TP_USER_NAME 1
87 #define RD_TP_USER_PASSWORD 2
88 #define RD_TP_CHAP_PASSWORD 3
89 #define RD_TP_NAS_IP_ADDRESS 4
90 #define RD_TP_NAS_PORT 5
91 #define RD_TP_SERVICE_TYPE 6
92 #define RD_TP_FRAMED_PROTOCOL 7
93 #define RD_TP_FRAMED_IP_ADDRESS 8
94 #define RD_TP_FRAMED_IP_NETMASK 9
95 #define RD_TP_FRAMED_ROUTING 10
96 #define RD_TP_FILTER_ID 11
97 #define RD_TP_FRAMED_MTU 12
98 #define RD_TP_FRAMED_COMPRESSION 13
99 #define RD_TP_LOGIN_IP_HOST 14
100 #define RD_TP_LOGIN_SERVICE 15
101 #define RD_TP_LOGIN_TCP_PORT 16
102 #define RD_TP_UNASSIGNED 17
103 #define RD_TP_REPLY_MESSAGE 18
104 #define RD_TP_CALLBACK_NUMBER 19
105 #define RD_TP_CALLBACK_ID 20
106 #define RD_TP_UNASSIGNED2 21
107 #define RD_TP_FRAMED_ROUTE 22
108 #define RD_TP_FRAMED_IPX_NETWORK 23
109 #define RD_TP_STATE 24
110 #define RD_TP_CLASS 25
111 #define RD_TP_VENDOR_SPECIFIC 26
112 #define RD_TP_SESSION_TIMEOUT 27
113 #define RD_TP_IDLE_TIMEOUT 28
114 #define RD_TP_TERMINATING_ACTION 29
115 #define RD_TP_CALLED_STATION_ID 30
116 #define RD_TP_CALLING_STATION_ID 31
117 #define RD_TP_NAS_IDENTIFIER 32
118 #define RD_TP_PROXY_STATE 33
119 #define RD_TP_LOGIN_LAT_SERVICE 34
120 #define RD_TP_LOGIN_LAT_NODE 35
121 #define RD_TP_LOGIN_LAT_GROUP 36
122 #define RD_TP_FRAMED_APPLETALK_LINK 37
123 #define RD_TP_FRAMED_APPLETALK_NETWORK 38
124 #define RD_TP_FRAMED_APPLETALK_ZONE 39
125 #define RD_TP_ACCT_STATUS_TYPE 40
126 #define RD_TP_ACCT_DELAY_TIME 41
127 #define RD_TP_ACCT_INPUT_OCTETS 42
128 #define RD_TP_ACCT_OUTPUT_OCTETS 43
129 #define RD_TP_ACCT_SESSION_ID 44
130 #define RD_TP_ACCT_AUTHENTIC 45
131 #define RD_TP_ACCT_SESSION_TIME 46
132 #define RD_TP_ACCT_INPUT_PACKETS 47
133 #define RD_TP_ACCT_OUTPUT_PACKETS 48
134 #define RD_TP_ACCT_TERMINATE_CAUSE 49
135 #define RD_TP_ACCT_MULTI_SESSION_ID 50
136 #define RD_TP_ACCT_LINK_COUNT 51
137 #define RD_TP_ACCT_INPUT_GIGAWORDS 52
138 #define RD_TP_ACCT_OUTPUT_GIGAWORDS 53
139 #define RD_TP_EVENT_TIMESTAMP 55
140 #define RD_TP_CHAP_CHALLENGE 60
141 #define RD_TP_NAS_PORT_TYPE 61
142 #define RD_TP_PORT_LIMIT 62
143 #define RD_TP_LOGIN_LAT_PORT 63
144 #define RD_TP_TUNNEL_TYPE 64
145 #define RD_TP_TUNNEL_MEDIUM_TYPE 65
146 #define RD_TP_TUNNEL_CLIENT_ENDPOINT 66
147 #define RD_TP_TUNNEL_SERVER_ENDPOINT 67
148 #define RD_TP_TUNNEL_CONNECTION 68
149 #define RD_TP_TUNNEL_PASSWORD 69
150 #define RD_TP_CONNECT_INFO 77
151 #define RD_TP_MESSAGE_AUTHENTICATOR 80
152 #define RD_TP_TUNNEL_PRIVATE_GROUP_ID 81
153 #define RD_TP_TUNNEL_ASSIGNMENT_ID 82
154 #define RD_TP_TUNNEL_TUNNEL_PREFERENCE 83
155 #define RD_TP_TUNNEL_PACKETS_LOST 86
156 #define RD_TP_NAS_PORT_ID 87
157 #define RD_TP_TUNNEL_CLIENT_AUTH_ID 90
158 #define RD_TP_TUNNEL_SERVER_AUTH_ID 91
159 #define RD_TP_ASCEND_MODEM_PORTNO 120
160 #define RD_TP_ASCEND_MODEM_SLOTNO 121
161 #define RD_TP_ASCEND_MULTILINK_ID 187
162 #define RD_TP_ASCEND_NUM_IN_MULTILINK 188
163 #define RD_TP_ASCEND_FIRST_DEST 189
164 #define RD_TP_ASCEND_PRE_INPUT_OCTETS 190
165 #define RD_TP_ASCEND_PRE_OUTPUT_OCTETS 191
166 #define RD_TP_ASCEND_PRE_INPUT_PACKETS 192
167 #define RD_TP_ASCEND_PRE_OUTPUT_PACKETS 193
168 #define RD_TP_ASCEND_MAXIMUM_TIME 194
169 #define RD_TP_ASCEND_DISCONNECT_CAUSE 195
170 #define RD_TP_ASCEND_CONNECT_PROGRESS 196
171 #define RD_TP_ASCEND_DATA_RATE 197
172 #define RD_TP_ASCEND_PRESESSION_TIME 198
173 #define RD_TP_ASCEND_ASSIGN_IP_POOL 218
174 #define RD_TP_ASCEND_XMIT_RATE 255
175
176
177
178
179
180 #define AUTHENTICATOR_LENGTH 16
181 #define RD_HDR_LENGTH 4
182
183
184 #define RADIUS_STRING 1
185 #define RADIUS_BINSTRING 2
186 #define RADIUS_INTEGER4 3
187 #define RADIUS_IP_ADDRESS 4
188 #define RADIUS_SERVICE_TYPE 5
189 #define RADIUS_FRAMED_PROTOCOL 6
190 #define RADIUS_FRAMED_ROUTING 7
191 #define RADIUS_FRAMED_COMPRESSION 8
192 #define RADIUS_LOGIN_SERVICE 9
193 #define RADIUS_UNKNOWN 10
194 #define RADIUS_IPX_ADDRESS 11
195 #define RADIUS_TERMINATING_ACTION 12
196 #define RADIUS_ACCOUNTING_STATUS_TYPE 13
197 #define RADIUS_ACCT_AUTHENTIC 14
198 #define RADIUS_ACCT_TERMINATE_CAUSE 15
199 #define RADIUS_NAS_PORT_TYPE 16
200 #define RADIUS_TUNNEL_TYPE 17
201 #define RADIUS_TUNNEL_MEDIUM_TYPE 18
202 #define RADIUS_STRING_TAGGED 19
203 #define RADIUS_VENDOR_SPECIFIC 20
204 #define RADIUS_TIMESTAMP 21
205 #define RADIUS_INTEGER4_TAGGED 22
206
207 static value_string radius_vals[] = {
208  {RADIUS_ACCESS_REQUEST, "Access Request"},
209  {RADIUS_ACCESS_ACCEPT, "Access Accept"},
210  {RADIUS_ACCESS_REJECT, "Access Reject"},
211  {RADIUS_ACCOUNTING_REQUEST, "Accounting Request"},
212  {RADIUS_ACCOUNTING_RESPONSE, "Accounting Response"},
213  {RADIUS_ACCESS_CHALLENGE, "Accounting challenge"},
214  {RADIUS_STATUS_SERVER, "StatusServer"},
215  {RADIUS_STATUS_CLIENT, "StatusClient"},
216  {RADIUS_RESERVED, "Reserved"},
217 {0, NULL}};
218
219 static value_string radius_service_type_vals[]=
220 {{1, "Login"},
221 {2, "Framed"},
222 {3, "Callback Login"},
223 {4, "Callback Framed"},
224 {5, "Outbound"},
225 {6, "Administrative"},
226 {7, "NAS Prompt"},
227 {8, "Authenticate Only"},
228 {9, "Callback NAS Prompt"},
229 {10, "Call Check"},
230 {0,NULL}};
231
232 /*
233  * These are SMI Network Management Private Enterprise Codes for
234  * organizations; see
235  *
236  *      http://www.isi.edu/in-notes/iana/assignments/enterprise-numbers
237  *
238  * for a list.
239  */
240 #define VENDOR_ACC 5
241 #define VENDOR_CISCO 9
242 #define VENDOR_SHIVA 166
243 #define VENDOR_LIVINGSTON 307
244 #define VENDOR_3COM 429
245 #define VENDOR_ASCEND 529
246 #define VENDOR_BAY 1584
247 #define VENDOR_JUNIPER 2636
248 #define VENDOR_COSINE 3085
249 #define VENDOR_UNISPHERE 4874
250
251 static value_string radius_vendor_specific_vendors[]=
252 {{VENDOR_ACC,"ACC"},
253 {VENDOR_CISCO,"Cisco"},
254 {VENDOR_SHIVA,"Shiva"},
255 {VENDOR_LIVINGSTON,"Livingston"},
256 {VENDOR_3COM,"3Com"},
257 {VENDOR_ASCEND,"Ascend"},
258 {VENDOR_BAY,"Bay Networks"},
259 {VENDOR_JUNIPER,"Juniper Networks"},
260 {VENDOR_COSINE,"CoSine Communications"},
261 {VENDOR_UNISPHERE,"Unisphere Networks"},
262 {0,NULL}};
263
264 #define VENDOR_COSINE_VSA_CONNECION_PROFILE_NAME 1
265 #define VENDOR_COSINE_VSA_ENTERPRISE_ID 2
266 #define VENDOR_COSINE_VSA_ADDRESS_POOL_NAME 3
267 #define VENDOR_COSINE_VSA_DS_BYTE 4
268 #define VENDOR_COSINE_VSA_VPI_VCI 5
269 #define VENDOR_COSINE_VSA_DLCI 6
270 #define VENDOR_COSINE_VSA_LNS_IP_ADDRESS 7
271 #define VENDOR_COSINE_VSA_CLI_USER_PERMISSION_ID 8
272
273 static value_string radius_vendor_cosine_types[]=
274 {{VENDOR_COSINE_VSA_CONNECION_PROFILE_NAME,"Connection Profile Name"},
275 {VENDOR_COSINE_VSA_ENTERPRISE_ID,"Enterprise ID"},
276 {VENDOR_COSINE_VSA_ADDRESS_POOL_NAME,"Address Pool Name"},
277 {VENDOR_COSINE_VSA_DS_BYTE,"DS Byte"},
278 {VENDOR_COSINE_VSA_VPI_VCI,"VPI/VCI"},
279 {VENDOR_COSINE_VSA_DLCI,"DLCI"},
280 {VENDOR_COSINE_VSA_LNS_IP_ADDRESS,"LNS IP Address"},
281 {VENDOR_COSINE_VSA_CLI_USER_PERMISSION_ID,"CLI User Permission ID"},
282 {0,NULL}};
283
284 static value_string radius_framed_protocol_vals[]=
285 {{1, "PPP"},
286 {2, "SLIP"},
287 {3, "Appletalk Remote Access Protocol (ARAP)"},
288 {4, "Gandalf proprietary Singlelink/Multilink Protocol"},
289 {5, "Xylogics proprietary IPX/SLIP"},
290 {6, "X.75 Synchronous"},
291 {256, "Ascend MPP"},
292 {262, "Ascend MP"},
293 {0,NULL}};
294
295 static value_string radius_framed_routing_vals[]=
296 {{1, "Send Routing Packets"},
297 {2, "Listen for routing packets"},
298 {3, "Send and Listen"},
299 {0,"None"},
300 {0,NULL}};
301
302 static value_string radius_framed_compression_vals[]=
303 {{1, "VJ TCP/IP Header Compression"},
304 {2, "IPX Header Compression"},
305 {3, "Stac-LZS compression"},
306 {0, "None"},
307 {0,NULL}};
308
309 static value_string radius_login_service_vals[]=
310 {{1, "Rlogin"},
311 {2, "TCP Clear"},
312 {3, "Portmaster"},
313 {4, "LAT"},
314 {5, "X.25-PAD"},
315 {6, "X.25T3POS"},
316 {8, "TCP Clear Quit"},
317 {0, "Telnet"},
318 {0,NULL}};
319
320 static value_string radius_terminating_action_vals[]=
321 {{1, "RADIUS-Request"},
322 {0, "Default"},
323 {0,NULL}};
324
325 static value_string radius_accounting_status_type_vals[]=
326 {{1, "Start"},
327 {2, "Stop"},
328 {3, "Interim-Update"},
329 {7,"Accounting-On"},
330 {8,"Accounting-Off"},
331 {9, "Tunnel-Start"}, /* Tunnel accounting */
332 {10, "Tunnel-Stop"}, /* Tunnel accounting */
333 {11, "Tunnel-Reject"}, /* Tunnel accounting */
334 {12, "Tunnel-Link-Start"}, /* Tunnel accounting */
335 {13, "Tunnel-Link-Stop"}, /* Tunnel accounting */
336 {14, "Tunnel-Link-Reject"}, /* Tunnel accounting */
337 {0,NULL}};
338
339 static value_string radius_accounting_authentication_vals[]=
340 {{1, "Radius"},
341 {2, "Local"},
342 {3,"Remote"},
343 /* RFC 2866 says 3 is Remote. Is 7 a mistake? */
344 {7,"Remote"},
345 {0,NULL}};
346
347 static value_string radius_acct_terminate_cause_vals[]=
348 {{1, "User Request"},
349 {2, "Lost Carrier"},
350 {3,"Lost Service"},
351 {4, "Idle Timeout"},
352 {5,"Session Timeout"},
353 {6, "Admin Reset"},
354 {7, "Admin Reboot"},
355 {8, "Port Error"},
356 {9, "NAS Error"},
357 {10, "NAS Request"},
358 {11,"NAS Reboot"},
359 {12, "Port Unneeded"},
360 {13, "Port Preempted"},
361 {14,"Port Suspended"},
362 {15,"Service Unavailable"},
363 {16,"Callback"},
364 {17, "User Error"},
365 {18,"Host Request"},
366 {0,NULL}};
367
368 static value_string radius_tunnel_type_vals[]=
369 {{1,"PPTP"},
370 {2,"L2F"},
371 {3,"L2TP"},
372 {4,"ATMP"},
373 {5,"VTP"},
374 {6,"AH"},
375 {7,"IP-IP-Encap"},
376 {8,"MIN-IP-IP"},
377 {9,"ESP"},
378 {10,"GRE"},
379 {11,"DVS"},
380 {12,"IP-IP"},
381 {0,NULL}};
382
383 static value_string radius_tunnel_medium_type_vals[]=
384 {{1,"IPv4"}, 
385 {2,"IPv6"},
386 {3,"NSAP"},
387 {4,"HDLC"},
388 {5,"BBN"},
389 {6,"IEEE-802"},
390 {7,"E-163"},
391 {8,"E-164"},
392 {9,"F-69"},
393 {10,"X-121"},
394 {11,"IPX"},
395 {12,"Appletalk"},
396 {13,"Decnet4"},
397 {14,"Vines"},
398 {15,"E-164-NSAP"},
399 {0,NULL}};
400
401 static value_string radius_nas_port_type_vals[]=
402 {{0, "Async"},
403 {1, "Sync"},
404 {2,"ISDN Sync"},
405 {3, "ISDN Async V.120"},
406 {4,"ISDN Async V.110"},
407 {5, "Virtual"},
408 {6, "PIAFS"},
409 {7, "HDLC Clear Channel"},
410 {8, "X.25"},
411 {9,"X.75"},
412 {10, "G.3 Fax"},
413 {11,"SDSL"},
414 {12, "ADSL-CAP"},
415 {13, "ADSL-DMT"},
416 {14,"IDSL - ISDN"},
417 {15,"Ethernet"},
418 {16,"xDSL"},
419 {17,"Cable"},
420 {18,"Wireless Other"},
421 {19,"Wireless IEEE 802.11"},
422 {0,NULL}};
423
424 static value_value_pair radius_printinfo[] = {
425 { RD_TP_USER_NAME, RADIUS_STRING },
426 { RD_TP_USER_PASSWORD,RADIUS_BINSTRING },
427 { RD_TP_CHAP_PASSWORD, RADIUS_BINSTRING },
428 { RD_TP_NAS_IP_ADDRESS, RADIUS_IP_ADDRESS },
429 { RD_TP_NAS_PORT, RADIUS_INTEGER4},
430 { RD_TP_SERVICE_TYPE, RADIUS_SERVICE_TYPE},
431 { RD_TP_FRAMED_PROTOCOL, RADIUS_FRAMED_PROTOCOL},
432 { RD_TP_FRAMED_IP_ADDRESS, RADIUS_IP_ADDRESS},
433 { RD_TP_FRAMED_IP_NETMASK, RADIUS_IP_ADDRESS},
434 { RD_TP_FRAMED_ROUTING, RADIUS_FRAMED_ROUTING},
435 { RD_TP_FILTER_ID, RADIUS_STRING},
436 { RD_TP_FRAMED_MTU, RADIUS_INTEGER4},
437 { RD_TP_FRAMED_COMPRESSION, RADIUS_FRAMED_COMPRESSION},
438 { RD_TP_LOGIN_IP_HOST, RADIUS_IP_ADDRESS},
439 { RD_TP_LOGIN_SERVICE, RADIUS_LOGIN_SERVICE},
440 { RD_TP_LOGIN_TCP_PORT, RADIUS_INTEGER4},
441 { RD_TP_UNASSIGNED, RADIUS_UNKNOWN},
442 { RD_TP_REPLY_MESSAGE, RADIUS_STRING},
443 { RD_TP_CALLBACK_NUMBER, RADIUS_BINSTRING},
444 { RD_TP_CALLBACK_ID, RADIUS_BINSTRING},
445 { RD_TP_UNASSIGNED2, RADIUS_UNKNOWN},
446 { RD_TP_FRAMED_ROUTE, RADIUS_STRING},
447 { RD_TP_FRAMED_IPX_NETWORK, RADIUS_IPX_ADDRESS},
448 { RD_TP_STATE, RADIUS_BINSTRING},
449 { RD_TP_CLASS, RADIUS_BINSTRING},
450 { RD_TP_VENDOR_SPECIFIC, RADIUS_VENDOR_SPECIFIC},
451 { RD_TP_SESSION_TIMEOUT, RADIUS_INTEGER4},
452 { RD_TP_IDLE_TIMEOUT, RADIUS_INTEGER4},
453 { RD_TP_TERMINATING_ACTION, RADIUS_TERMINATING_ACTION},
454 { RD_TP_CALLED_STATION_ID, RADIUS_BINSTRING},
455 { RD_TP_CALLING_STATION_ID, RADIUS_BINSTRING},
456 { RD_TP_NAS_IDENTIFIER, RADIUS_BINSTRING},
457 { RD_TP_PROXY_STATE, RADIUS_BINSTRING},
458 { RD_TP_LOGIN_LAT_SERVICE, RADIUS_BINSTRING},
459 { RD_TP_LOGIN_LAT_NODE, RADIUS_BINSTRING},
460 { RD_TP_LOGIN_LAT_GROUP, RADIUS_BINSTRING},
461 { RD_TP_FRAMED_APPLETALK_LINK, RADIUS_INTEGER4},
462 { RD_TP_FRAMED_APPLETALK_NETWORK, RADIUS_INTEGER4},
463 { RD_TP_FRAMED_APPLETALK_ZONE, RADIUS_BINSTRING},
464 { RD_TP_ACCT_STATUS_TYPE, RADIUS_ACCOUNTING_STATUS_TYPE},
465 { RD_TP_ACCT_DELAY_TIME, RADIUS_INTEGER4},
466 { RD_TP_ACCT_INPUT_OCTETS, RADIUS_INTEGER4},
467 { RD_TP_ACCT_OUTPUT_OCTETS, RADIUS_INTEGER4},
468 { RD_TP_ACCT_SESSION_ID, RADIUS_STRING},
469 { RD_TP_ACCT_AUTHENTIC, RADIUS_ACCT_AUTHENTIC},
470 { RD_TP_ACCT_SESSION_TIME, RADIUS_INTEGER4},
471 { RD_TP_ACCT_INPUT_PACKETS, RADIUS_INTEGER4},
472 { RD_TP_ACCT_OUTPUT_PACKETS, RADIUS_INTEGER4},
473 { RD_TP_ACCT_TERMINATE_CAUSE, RADIUS_ACCT_TERMINATE_CAUSE},
474 { RD_TP_ACCT_MULTI_SESSION_ID, RADIUS_STRING},
475 { RD_TP_ACCT_LINK_COUNT, RADIUS_INTEGER4},
476 { RD_TP_ACCT_INPUT_GIGAWORDS, RADIUS_INTEGER4},
477 { RD_TP_ACCT_OUTPUT_GIGAWORDS, RADIUS_INTEGER4},
478 { RD_TP_EVENT_TIMESTAMP, RADIUS_TIMESTAMP},
479 { RD_TP_CHAP_CHALLENGE, RADIUS_BINSTRING},
480 { RD_TP_NAS_PORT_TYPE, RADIUS_NAS_PORT_TYPE},
481 { RD_TP_PORT_LIMIT, RADIUS_INTEGER4},
482 { RD_TP_LOGIN_LAT_PORT, RADIUS_BINSTRING},
483 { RD_TP_TUNNEL_TYPE, RADIUS_TUNNEL_TYPE},
484 { RD_TP_TUNNEL_MEDIUM_TYPE, RADIUS_TUNNEL_MEDIUM_TYPE},
485 { RD_TP_TUNNEL_CLIENT_ENDPOINT, RADIUS_STRING_TAGGED},
486 { RD_TP_TUNNEL_SERVER_ENDPOINT, RADIUS_STRING_TAGGED},
487 { RD_TP_TUNNEL_CONNECTION, RADIUS_BINSTRING},
488 { RD_TP_TUNNEL_PASSWORD, RADIUS_STRING_TAGGED},
489 { RD_TP_CONNECT_INFO, RADIUS_STRING_TAGGED},
490 { RD_TP_MESSAGE_AUTHENTICATOR, RADIUS_BINSTRING},
491 { RD_TP_TUNNEL_PRIVATE_GROUP_ID, RADIUS_STRING_TAGGED},
492 { RD_TP_TUNNEL_ASSIGNMENT_ID, RADIUS_STRING_TAGGED},
493 { RD_TP_TUNNEL_TUNNEL_PREFERENCE, RADIUS_INTEGER4_TAGGED},
494 { RD_TP_TUNNEL_PACKETS_LOST, RADIUS_INTEGER4},
495 { RD_TP_NAS_PORT_ID, RADIUS_STRING},
496 { RD_TP_TUNNEL_CLIENT_AUTH_ID, RADIUS_STRING_TAGGED},
497 { RD_TP_TUNNEL_SERVER_AUTH_ID, RADIUS_STRING_TAGGED},
498 { RD_TP_ASCEND_MODEM_PORTNO, RADIUS_INTEGER4},
499 { RD_TP_ASCEND_MODEM_SLOTNO, RADIUS_INTEGER4},
500 { RD_TP_ASCEND_MULTILINK_ID, RADIUS_INTEGER4},
501 { RD_TP_ASCEND_NUM_IN_MULTILINK, RADIUS_INTEGER4},
502 { RD_TP_ASCEND_FIRST_DEST, RADIUS_IP_ADDRESS},
503 { RD_TP_ASCEND_PRE_INPUT_OCTETS, RADIUS_INTEGER4},
504 { RD_TP_ASCEND_PRE_OUTPUT_OCTETS, RADIUS_INTEGER4},
505 { RD_TP_ASCEND_PRE_INPUT_PACKETS, RADIUS_INTEGER4},
506 { RD_TP_ASCEND_PRE_OUTPUT_PACKETS, RADIUS_INTEGER4},
507 { RD_TP_ASCEND_MAXIMUM_TIME, RADIUS_INTEGER4},
508 { RD_TP_ASCEND_DISCONNECT_CAUSE, RADIUS_INTEGER4},
509 { RD_TP_ASCEND_CONNECT_PROGRESS, RADIUS_INTEGER4},
510 { RD_TP_ASCEND_DATA_RATE, RADIUS_INTEGER4},
511 { RD_TP_ASCEND_PRESESSION_TIME, RADIUS_INTEGER4},
512 { RD_TP_ASCEND_ASSIGN_IP_POOL, RADIUS_INTEGER4},
513 { RD_TP_ASCEND_XMIT_RATE, RADIUS_INTEGER4},
514 {0,0},
515 };
516
517 static value_string radius_attrib_type_vals[] = {
518 { RD_TP_USER_NAME, "User Name"},
519 { RD_TP_USER_PASSWORD, "User Password"},
520 { RD_TP_CHAP_PASSWORD, "Chap Password"},
521 { RD_TP_NAS_IP_ADDRESS, "NAS IP Address"},
522 { RD_TP_NAS_PORT, "NAS Port"},
523 { RD_TP_SERVICE_TYPE, "Service Type"},
524 { RD_TP_FRAMED_PROTOCOL, "Framed Protocol"},
525 { RD_TP_FRAMED_IP_ADDRESS, "Framed IP Address"},
526 { RD_TP_FRAMED_IP_NETMASK, "Framed IP Netmask"},
527 { RD_TP_FRAMED_ROUTING, "Framed Routing"},
528 { RD_TP_FILTER_ID, "Filter Id"},
529 { RD_TP_FRAMED_MTU, "Framed MTU"},
530 { RD_TP_FRAMED_COMPRESSION, "Framed Compression"},
531 { RD_TP_LOGIN_IP_HOST, "Login IP Host"},
532 { RD_TP_LOGIN_SERVICE, "Login Service"},
533 { RD_TP_LOGIN_TCP_PORT, "Login TCP Port"},
534 { RD_TP_UNASSIGNED, "Unassigned"},
535 { RD_TP_REPLY_MESSAGE, "Reply Message"},
536 { RD_TP_CALLBACK_NUMBER, "Callback Number"},
537 { RD_TP_CALLBACK_ID, "Callback Id"},
538 { RD_TP_UNASSIGNED2, "Unassigned"},
539 { RD_TP_FRAMED_ROUTE, "Framed Route"},
540 { RD_TP_FRAMED_IPX_NETWORK, "Framed IPX network"},
541 { RD_TP_STATE, "State"},
542 { RD_TP_CLASS, "Class"},
543 { RD_TP_VENDOR_SPECIFIC, "Vendor Specific" },
544 { RD_TP_SESSION_TIMEOUT, "Session Timeout"},
545 { RD_TP_IDLE_TIMEOUT, "Idle Timeout"},
546 { RD_TP_TERMINATING_ACTION, "Terminating Action"},
547 { RD_TP_CALLED_STATION_ID, "Called Station Id"},
548 { RD_TP_CALLING_STATION_ID, "Calling Station Id"},
549 { RD_TP_NAS_IDENTIFIER, "NAS identifier"},
550 { RD_TP_PROXY_STATE, "Proxy State"},
551 { RD_TP_LOGIN_LAT_SERVICE, "Login LAT Service"},
552 { RD_TP_LOGIN_LAT_NODE, "Login LAT Node"},
553 { RD_TP_LOGIN_LAT_GROUP, "Login LAT Group"},
554 { RD_TP_FRAMED_APPLETALK_LINK, "Framed Appletalk Link"},
555 { RD_TP_FRAMED_APPLETALK_NETWORK, "Framed Appletalk Network"},
556 { RD_TP_FRAMED_APPLETALK_ZONE, "Framed Appletalk Zone"},
557 { RD_TP_ACCT_STATUS_TYPE, "Acct Status Type"},
558 { RD_TP_ACCT_DELAY_TIME, "Acct Delay Time"},
559 { RD_TP_ACCT_INPUT_OCTETS, "Acct Input Octets"},
560 { RD_TP_ACCT_OUTPUT_OCTETS, "Acct Output Octets"},
561 { RD_TP_ACCT_SESSION_ID, "Acct Session Id"},
562 { RD_TP_ACCT_AUTHENTIC, "Acct Authentic"},
563 { RD_TP_ACCT_SESSION_TIME, "Acct Session Time"},
564 { RD_TP_ACCT_INPUT_PACKETS, "Acct Input Packets"},
565 { RD_TP_ACCT_OUTPUT_PACKETS, "Acct Output Packets"},
566 { RD_TP_ACCT_TERMINATE_CAUSE, "Acct Terminate Cause"},
567 { RD_TP_ACCT_MULTI_SESSION_ID, "Acct Multi Session Id"},
568 { RD_TP_ACCT_LINK_COUNT, "Acct Link Count"},
569 { RD_TP_ACCT_INPUT_GIGAWORDS, "Acct Input Gigawords"},
570 { RD_TP_ACCT_OUTPUT_GIGAWORDS, "Acct Output Gigawords"},
571 { RD_TP_EVENT_TIMESTAMP, "Event Timestamp"},
572 { RD_TP_CHAP_CHALLENGE, "Chap Challenge"},
573 { RD_TP_NAS_PORT_TYPE, "NAS Port Type"},
574 { RD_TP_PORT_LIMIT, "Port Limit"},
575 { RD_TP_LOGIN_LAT_PORT, "Login LAT Port"},
576 { RD_TP_TUNNEL_TYPE, "Tunnel Type"},
577 { RD_TP_TUNNEL_MEDIUM_TYPE, "Tunnel Medium Type"},
578 { RD_TP_TUNNEL_CLIENT_ENDPOINT, "Tunnel Client Endpoint"},
579 { RD_TP_TUNNEL_SERVER_ENDPOINT, "Tunnel Server Endpoint"},
580 { RD_TP_TUNNEL_CONNECTION, "Tunnel Connection"},
581 { RD_TP_TUNNEL_PASSWORD, "Tunnel Password"},
582 { RD_TP_CONNECT_INFO, "Connect-Info"},
583 { RD_TP_MESSAGE_AUTHENTICATOR, "Message Authenticator"},
584 { RD_TP_TUNNEL_PRIVATE_GROUP_ID, "Tunnel Private Group ID"},
585 { RD_TP_TUNNEL_ASSIGNMENT_ID, "Tunnel Assignment ID"},
586 { RD_TP_TUNNEL_TUNNEL_PREFERENCE, "Tunnel Preference"},
587 { RD_TP_TUNNEL_PACKETS_LOST, "Tunnel Packets Lost"},
588 { RD_TP_NAS_PORT_ID, "NAS Port ID"},
589 { RD_TP_TUNNEL_CLIENT_AUTH_ID, "Tunnel Client Auth ID"},
590 { RD_TP_TUNNEL_SERVER_AUTH_ID, "Tunnel Server Auth ID"},
591 { RD_TP_ASCEND_MODEM_PORTNO, "Ascend Modem Port No"},
592 { RD_TP_ASCEND_MODEM_SLOTNO, "Ascend Modem Slot No"},
593 { RD_TP_ASCEND_MULTILINK_ID, "Ascend Multilink ID"},
594 { RD_TP_ASCEND_NUM_IN_MULTILINK, "Ascend Num In Multilink"},
595 { RD_TP_ASCEND_FIRST_DEST, "Ascend First Dest"},
596 { RD_TP_ASCEND_PRE_INPUT_OCTETS, "Ascend Pre Input Octets"},
597 { RD_TP_ASCEND_PRE_OUTPUT_OCTETS, "Ascend Pre Output Octets"},
598 { RD_TP_ASCEND_PRE_INPUT_PACKETS, "Ascend Pre Input Packets"},
599 { RD_TP_ASCEND_PRE_OUTPUT_PACKETS, "Ascend Pre Output Packets"},
600 { RD_TP_ASCEND_MAXIMUM_TIME, "Ascend Maximum Time"},
601 { RD_TP_ASCEND_DISCONNECT_CAUSE, "Ascend Disconnect Cause"},
602 { RD_TP_ASCEND_CONNECT_PROGRESS, "Ascend Connect Progress"},
603 { RD_TP_ASCEND_DATA_RATE, "Ascend Data Rate"},
604 { RD_TP_ASCEND_PRESESSION_TIME, "Ascend PreSession Time"},
605 { RD_TP_ASCEND_ASSIGN_IP_POOL, "Ascend Assign IP Pool"},
606 { RD_TP_ASCEND_XMIT_RATE, "Ascend Xmit Rate"},
607 {0,NULL},
608 };
609
610 guint32 match_numval(guint32 val, const value_value_pair *vs)
611 {
612   guint32 i = 0;
613
614   while (vs[i].val1) {
615     if (vs[i].val1 == val)
616       return(vs[i].val2);
617     i++;
618   }
619
620   return(0);
621 }
622
623 static gchar textbuffer[2000];
624
625 gchar *rdconvertbufftostr(gchar *dest, tvbuff_t *tvb, int offset, int length)
626 {
627 /*converts the raw buffer into printable text */
628         guint32 i;
629         guint32 totlen=0;
630         const guint8 *pd = tvb_get_ptr(tvb, offset, length);
631
632         dest[0]='"';
633         dest[1]=0;
634         totlen=1;
635         for (i=0; i < (guint32)length; i++)
636         {
637                 if( isalnum((int)pd[i])||ispunct((int)pd[i])
638                                 ||((int)pd[i]==' '))            {
639                         dest[totlen]=(gchar)pd[i];
640                         totlen++;
641                 }
642                 else
643                 {
644                         sprintf(&(dest[totlen]), "\\%03u", pd[i]);
645                         totlen=totlen+strlen(&(dest[totlen]));
646                 }
647         }
648         dest[totlen]='"';
649         dest[totlen+1]=0;
650         return dest;
651 }
652
653 gchar *rd_match_strval(guint32 val, const value_string *vs) {
654         return val_to_str(val, vs, "Undefined (%u)");
655 }
656
657 gchar *rd_value_to_str(e_avphdr *avph, tvbuff_t *tvb, int offset)
658 {
659   int print_type;
660   gchar *cont;
661   value_string *valstrarr;
662   guint32 intval;
663   const guint8 *pd;
664   guint8 tag;
665   guint8 vtype;
666   char *rtimestamp;
667   extern char *tzname[2];
668
669 /* prints the values of the attribute value pairs into a text buffer */
670   print_type=match_numval(avph->avp_type,radius_printinfo);
671
672   /* Default begin */
673   strcpy(textbuffer,"Value:");
674   cont=&textbuffer[strlen(textbuffer)];
675   switch(print_type)
676   {
677         case( RADIUS_STRING ):
678         case( RADIUS_BINSTRING ):
679                 rdconvertbufftostr(cont,tvb,offset+2,avph->avp_length-2);
680                 break;
681         case( RADIUS_INTEGER4 ):
682                 sprintf(cont,"%u", tvb_get_ntohl(tvb,offset+2));
683                 break;
684         case( RADIUS_IP_ADDRESS ):
685                 ip_to_str_buf(tvb_get_ptr(tvb,offset+2,4),cont);
686                 break;
687         case( RADIUS_SERVICE_TYPE ):
688                 valstrarr=radius_service_type_vals;
689                 strcpy(cont,rd_match_strval(tvb_get_ntohl(tvb,offset+2),valstrarr));
690                 break;
691         case( RADIUS_FRAMED_PROTOCOL ):
692                 valstrarr= radius_framed_protocol_vals;
693                 strcpy(cont,rd_match_strval(tvb_get_ntohl(tvb,offset+2),valstrarr));
694                 break;
695         case( RADIUS_FRAMED_ROUTING ):
696                 valstrarr=radius_framed_routing_vals;
697                 strcpy(cont,rd_match_strval(tvb_get_ntohl(tvb,offset+2),valstrarr));
698                 break;
699         case( RADIUS_FRAMED_COMPRESSION ):
700                 valstrarr=radius_framed_compression_vals;
701                 strcpy(cont,rd_match_strval(tvb_get_ntohl(tvb,offset+2),valstrarr));
702                 break;
703         case( RADIUS_LOGIN_SERVICE ):
704                 valstrarr=radius_login_service_vals;
705                 strcpy(cont,rd_match_strval(tvb_get_ntohl(tvb,offset+2),valstrarr));
706                 break;
707         case( RADIUS_IPX_ADDRESS ):
708                 pd = tvb_get_ptr(tvb,offset+2,4);
709                 sprintf(cont,"%u:%u:%u:%u",(guint8)pd[offset+2],
710                         (guint8)pd[offset+3],(guint8)pd[offset+4],
711                         (guint8)pd[offset+5]);
712         case( RADIUS_TERMINATING_ACTION ):
713                 valstrarr=radius_terminating_action_vals;
714                 strcpy(cont,rd_match_strval(tvb_get_ntohl(tvb,offset+2),valstrarr));
715                 break;
716         case( RADIUS_ACCOUNTING_STATUS_TYPE ):
717                 valstrarr=radius_accounting_status_type_vals;
718                 strcpy(cont,rd_match_strval(tvb_get_ntohl(tvb,offset+2),valstrarr));
719                 break;
720         case( RADIUS_ACCT_AUTHENTIC ):
721                 valstrarr=radius_accounting_authentication_vals;
722                 strcpy(cont,rd_match_strval(tvb_get_ntohl(tvb,offset+2),valstrarr));
723                 break;
724         case( RADIUS_ACCT_TERMINATE_CAUSE ):
725                 valstrarr=radius_acct_terminate_cause_vals;
726                 strcpy(cont,rd_match_strval(tvb_get_ntohl(tvb,offset+2),valstrarr));
727                 break;
728         case( RADIUS_NAS_PORT_TYPE ):
729                 valstrarr=radius_nas_port_type_vals;
730                 strcpy(cont,rd_match_strval(tvb_get_ntohl(tvb,offset+2),valstrarr));
731                 break;
732         case( RADIUS_TUNNEL_TYPE ):
733                 valstrarr=radius_tunnel_type_vals;
734                 /* Tagged ? */
735                 intval = tvb_get_ntohl(tvb,offset+2);
736                 if (intval >> 24) {
737                         sprintf(textbuffer, "Tag:%u, Value:%s",
738                                 intval >> 24,
739                                 rd_match_strval(intval & 0xffffff,valstrarr));
740                         break;
741                 }
742                 strcpy(cont,rd_match_strval(intval,valstrarr));
743                 break;
744         case( RADIUS_TUNNEL_MEDIUM_TYPE ):
745                 valstrarr=radius_tunnel_medium_type_vals;
746                 intval = tvb_get_ntohl(tvb,offset+2);
747                 /* Tagged ? */
748                 if (intval >> 24) {
749                         sprintf(textbuffer, "Tag:%u, Value:%s",
750                                 intval >> 24,
751                                 rd_match_strval(intval & 0xffffff,valstrarr));
752                         break;
753                 }
754                 strcpy(cont,rd_match_strval(intval,valstrarr));
755                 break;
756         case( RADIUS_STRING_TAGGED ):
757                 /* Tagged ? */
758                 tag = tvb_get_guint8(tvb,offset+2);
759                 if (tag <= 0x1f) {
760                         sprintf(textbuffer, "Tag:%u, Value:",
761                                         tag);
762                         cont=&textbuffer[strlen(textbuffer)];   
763                         rdconvertbufftostr(cont,tvb,offset+3,avph->avp_length-3);
764                         break;
765                 }
766                 rdconvertbufftostr(cont,tvb,offset+2,avph->avp_length-2);
767                 break;
768         case ( RADIUS_VENDOR_SPECIFIC ):
769                 valstrarr=radius_vendor_specific_vendors;
770                 sprintf(textbuffer,"Vendor:%s,",
771                         rd_match_strval(tvb_get_ntohl(tvb,offset+2),valstrarr));
772                 cont=&textbuffer[strlen(textbuffer)];
773                 switch (tvb_get_ntohl(tvb,offset+2)) {
774                 case ( VENDOR_COSINE ):
775                         vtype = tvb_get_guint8(tvb,offset+6);
776                         switch (vtype) {
777                         case ( VENDOR_COSINE_VSA_CONNECION_PROFILE_NAME ):
778                         case ( VENDOR_COSINE_VSA_ENTERPRISE_ID ):
779                         case ( VENDOR_COSINE_VSA_ADDRESS_POOL_NAME ):
780                         case ( VENDOR_COSINE_VSA_CLI_USER_PERMISSION_ID ):
781                                 sprintf(cont," Type:%s, Value:",
782                                         rd_match_strval(vtype, radius_vendor_cosine_types));
783                                 cont=&textbuffer[strlen(textbuffer)];
784                                 rdconvertbufftostr(cont,tvb,offset+8,avph->avp_length-8);
785                                 break;
786                         case ( VENDOR_COSINE_VSA_VPI_VCI ):
787                                 sprintf(cont," Type:%s, Value:%u/%u",
788                                         rd_match_strval(vtype, radius_vendor_cosine_types),
789                                         tvb_get_ntohs(tvb,offset+8),
790                                         tvb_get_ntohs(tvb,offset+10));
791                                 break;
792                         case ( VENDOR_COSINE_VSA_DS_BYTE ):
793                         case ( VENDOR_COSINE_VSA_DLCI ):
794                                 sprintf(cont," Type:%s, Value:%u",
795                                         rd_match_strval(vtype, radius_vendor_cosine_types),
796                                         tvb_get_ntohl(tvb,offset+8));
797                                 break;
798                         case ( VENDOR_COSINE_VSA_LNS_IP_ADDRESS ):
799                                 sprintf(cont," Type:%s, Value:",
800                                         rd_match_strval(vtype, radius_vendor_cosine_types));
801                                 cont=&textbuffer[strlen(textbuffer)];
802                                 ip_to_str_buf(tvb_get_ptr(tvb,offset+8,4),cont);
803                                 break;
804                         default:
805                                 sprintf(cont," Unknown Value Type");
806                                 break;
807                         }
808                         break;
809                 default: 
810                         sprintf(cont, " Value:");
811                         rdconvertbufftostr(cont,tvb,offset+6,avph->avp_length-6);
812                         break;
813                 }
814                 break;
815         case( RADIUS_TIMESTAMP ):
816                 intval=tvb_get_ntohl(tvb,offset+2);
817                 rtimestamp=ctime((time_t*)&intval);
818                 rtimestamp[strlen(rtimestamp)-1]=0;
819                 sprintf(cont,"%d (%s %s)", tvb_get_ntohl(tvb,offset+2), rtimestamp, *tzname);
820                 break;
821         case( RADIUS_INTEGER4_TAGGED ):
822                 intval = tvb_get_ntohl(tvb,offset+2);
823                 /* Tagged ? */
824                 if (intval >> 24) {
825                         sprintf(textbuffer, "Tag:%u, Value:%u",
826                                 intval >> 24,
827                                 intval & 0xffffff);
828                         break;
829                 }
830                 sprintf(cont,"%u", intval);
831                 break;
832         case( RADIUS_UNKNOWN ):
833         default:
834                 strcpy(textbuffer,"Unknown Value Type");
835                 break;
836   }
837   if (cont == textbuffer) {
838         strcpy(cont,"Unknown Value");
839   }
840   return textbuffer;
841 }
842
843
844 void dissect_attribute_value_pairs(tvbuff_t *tvb, int offset, proto_tree *tree,
845                                    int avplength)
846 {
847 /* adds the attribute value pairs to the tree */
848   e_avphdr avph;
849   gchar *avptpstrval;
850   gchar *valstr;
851   if (avplength==0)
852   {
853         proto_tree_add_text(tree, tvb,offset,0,"No Attribute Value Pairs Found");
854         return;
855   }
856
857   while (avplength > 0 )
858   {
859
860      tvb_memcpy(tvb,(guint8 *)&avph,offset,sizeof(e_avphdr));
861      avplength=avplength-avph.avp_length;
862      avptpstrval=match_strval(avph.avp_type, radius_attrib_type_vals);
863      if (avptpstrval == NULL) avptpstrval="Unknown Type";
864      valstr=rd_value_to_str(&avph, tvb, offset);
865      proto_tree_add_text(tree, tvb,offset,avph.avp_length,
866         "t:%s(%u) l:%u, %s",
867         avptpstrval,avph.avp_type,avph.avp_length,valstr);
868      offset=offset+avph.avp_length;
869      if (avph.avp_length == 0) {
870         break;
871      }
872   }
873 }
874
875 static void dissect_radius(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
876 {
877   proto_tree *radius_tree,*avptree;
878   proto_item *ti,*avptf;
879   int rhlength;
880   int rhcode;
881   int rhident;
882   int avplength,hdrlength;
883   e_radiushdr rh;
884
885   gchar *codestrval;
886
887   if (check_col(pinfo->fd, COL_PROTOCOL))
888         col_set_str(pinfo->fd, COL_PROTOCOL, "RADIUS");
889   if (check_col(pinfo->fd, COL_INFO))
890         col_clear(pinfo->fd, COL_INFO);
891
892   tvb_memcpy(tvb,(guint8 *)&rh,0,sizeof(e_radiushdr));
893
894   rhcode= (int)rh.rh_code;
895   rhident= (int)rh.rh_ident;
896   rhlength= (int)ntohs(rh.rh_pktlength);
897   codestrval=  match_strval(rhcode,radius_vals);
898   if (codestrval==NULL)
899   {
900         codestrval="Unknown Packet";
901   }
902   if (check_col(pinfo->fd, COL_INFO))
903   {
904         col_add_fstr(pinfo->fd,COL_INFO,"%s(%d) (id=%d, l=%d)",
905                 codestrval, rhcode, rhident, rhlength);
906   }
907
908   if (tree)
909   {
910         ti = proto_tree_add_item(tree,proto_radius, tvb, 0, rhlength, FALSE);
911
912         radius_tree = proto_item_add_subtree(ti, ett_radius);
913
914         proto_tree_add_uint(radius_tree,hf_radius_code, tvb, 0, 1,
915                 rh.rh_code);
916         proto_tree_add_uint_format(radius_tree,hf_radius_id, tvb, 1, 1,
917                 rh.rh_ident, "Packet identifier: 0x%01x (%d)",
918                         rhident,rhident);         
919
920         proto_tree_add_uint(radius_tree, hf_radius_length, tvb,
921                         2, 2, rhlength);
922         proto_tree_add_text(radius_tree, tvb, 4,
923                         AUTHENTICATOR_LENGTH,
924                          "Authenticator");
925    
926         hdrlength=RD_HDR_LENGTH+AUTHENTICATOR_LENGTH;
927         avplength= rhlength -hdrlength;
928
929         if (avplength > 0) {
930                 /* list the attribute value pairs */
931
932                 avptf = proto_tree_add_text(radius_tree,
933                                 tvb,hdrlength,avplength,
934                                 "Attribute value pairs");
935                 avptree = proto_item_add_subtree(avptf, ett_radius_avp);
936
937                 if (avptree !=NULL)
938                 {
939                         dissect_attribute_value_pairs(tvb, hdrlength,
940                                 avptree,avplength);
941                 }
942         }
943   }
944 }
945 /* registration with the filtering engine */
946 void
947 proto_register_radius(void)
948 {
949         static hf_register_info hf[] = {
950                 { &hf_radius_code,
951                 { "Code","radius.code", FT_UINT8, BASE_DEC, VALS(radius_vals), 0x0,
952                         "", HFILL }},
953
954                 { &hf_radius_id,
955                 { "Identifier", "radius.id", FT_UINT8, BASE_DEC, NULL, 0x0,
956                         "", HFILL }},
957
958                 { &hf_radius_length,
959                 { "Length","radius.length", FT_UINT16, BASE_DEC, NULL, 0x0,
960                         "", HFILL }}
961         };
962         static gint *ett[] = {
963                 &ett_radius,
964                 &ett_radius_avp,
965         };
966
967         proto_radius = proto_register_protocol("Radius Protocol", "RADIUS",
968             "radius");
969         proto_register_field_array(proto_radius, hf, array_length(hf));
970         proto_register_subtree_array(ett, array_length(ett));
971 }
972
973 void
974 proto_reg_handoff_radius(void)
975 {
976         dissector_add("udp.port", UDP_PORT_RADIUS, dissect_radius,
977             proto_radius);
978         dissector_add("udp.port", UDP_PORT_RADIUS_NEW, dissect_radius,
979             proto_radius);
980         dissector_add("udp.port", UDP_PORT_RADACCT, dissect_radius,
981             proto_radius);
982         dissector_add("udp.port", UDP_PORT_RADACCT_NEW, dissect_radius,
983             proto_radius);
984 }