xref: /freebsd/contrib/tcpdump/print-radius.c (revision 0a7e5f1f02aad2ff5fff1c60f44c6975fd07e1d9)
1685295f4SBill Fenner /*
2a90e161bSBill Fenner  * Copyright (C) 2000 Alfredo Andres Omella.  All rights reserved.
3a90e161bSBill Fenner  *
4a90e161bSBill Fenner  * Redistribution and use in source and binary forms, with or without
5a90e161bSBill Fenner  * modification, are permitted provided that the following conditions
6a90e161bSBill Fenner  * are met:
7a90e161bSBill Fenner  *
8a90e161bSBill Fenner  *   1. Redistributions of source code must retain the above copyright
9a90e161bSBill Fenner  *      notice, this list of conditions and the following disclaimer.
10a90e161bSBill Fenner  *   2. Redistributions in binary form must reproduce the above copyright
11a90e161bSBill Fenner  *      notice, this list of conditions and the following disclaimer in
12a90e161bSBill Fenner  *      the documentation and/or other materials provided with the
13a90e161bSBill Fenner  *      distribution.
14a90e161bSBill Fenner  *   3. The names of the authors may not be used to endorse or promote
15a90e161bSBill Fenner  *      products derived from this software without specific prior
16a90e161bSBill Fenner  *      written permission.
17a90e161bSBill Fenner  *
18a90e161bSBill Fenner  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
19a90e161bSBill Fenner  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
20a90e161bSBill Fenner  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21a90e161bSBill Fenner  */
223340d773SGleb Smirnoff 
233340d773SGleb Smirnoff /* \summary: Radius protocol printer */
243340d773SGleb Smirnoff 
25a90e161bSBill Fenner /*
26685295f4SBill Fenner  * Radius printer routines as specified on:
27685295f4SBill Fenner  *
28685295f4SBill Fenner  * RFC 2865:
29685295f4SBill Fenner  *      "Remote Authentication Dial In User Service (RADIUS)"
30685295f4SBill Fenner  *
31685295f4SBill Fenner  * RFC 2866:
32685295f4SBill Fenner  *      "RADIUS Accounting"
33685295f4SBill Fenner  *
34685295f4SBill Fenner  * RFC 2867:
35685295f4SBill Fenner  *      "RADIUS Accounting Modifications for Tunnel Protocol Support"
36685295f4SBill Fenner  *
37685295f4SBill Fenner  * RFC 2868:
38685295f4SBill Fenner  *      "RADIUS Attributes for Tunnel Protocol Support"
39685295f4SBill Fenner  *
40685295f4SBill Fenner  * RFC 2869:
41685295f4SBill Fenner  *      "RADIUS Extensions"
42685295f4SBill Fenner  *
43ee67461eSJoseph Mingrone  * RFC 3162:
44ee67461eSJoseph Mingrone  *      "RADIUS and IPv6"
45ee67461eSJoseph Mingrone  *
463340d773SGleb Smirnoff  * RFC 3580:
473340d773SGleb Smirnoff  *      "IEEE 802.1X Remote Authentication Dial In User Service (RADIUS)"
483340d773SGleb Smirnoff  *      "Usage Guidelines"
493340d773SGleb Smirnoff  *
50ee67461eSJoseph Mingrone  * RFC 4072:
51ee67461eSJoseph Mingrone  *      "Diameter Extensible Authentication Protocol (EAP) Application"
52ee67461eSJoseph Mingrone  *
538bdc5a62SPatrick Kelsey  * RFC 4675:
548bdc5a62SPatrick Kelsey  *      "RADIUS Attributes for Virtual LAN and Priority Support"
558bdc5a62SPatrick Kelsey  *
56ee67461eSJoseph Mingrone  * RFC 4818:
57ee67461eSJoseph Mingrone  *      "RADIUS Delegated-IPv6-Prefix Attribute"
58ee67461eSJoseph Mingrone  *
59ee67461eSJoseph Mingrone  * RFC 4849:
60ee67461eSJoseph Mingrone  *      "RADIUS Filter Rule Attribute"
61ee67461eSJoseph Mingrone  *
62ee67461eSJoseph Mingrone  * RFC 5090:
63ee67461eSJoseph Mingrone  *      "RADIUS Extension for Digest Authentication"
64ee67461eSJoseph Mingrone  *
658bdc5a62SPatrick Kelsey  * RFC 5176:
668bdc5a62SPatrick Kelsey  *      "Dynamic Authorization Extensions to RADIUS"
678bdc5a62SPatrick Kelsey  *
68ee67461eSJoseph Mingrone  * RFC 5447:
69ee67461eSJoseph Mingrone  *      "Diameter Mobile IPv6"
70ee67461eSJoseph Mingrone  *
71ee67461eSJoseph Mingrone  * RFC 5580:
72ee67461eSJoseph Mingrone  *      "Carrying Location Objects in RADIUS and Diameter"
73ee67461eSJoseph Mingrone  *
74ee67461eSJoseph Mingrone  * RFC 6572:
75ee67461eSJoseph Mingrone  *      "RADIUS Support for Proxy Mobile IPv6"
76ee67461eSJoseph Mingrone  *
77ee67461eSJoseph Mingrone  * RFC 7155:
78ee67461eSJoseph Mingrone  *      "Diameter Network Access Server Application"
79ee67461eSJoseph Mingrone  *
80685295f4SBill Fenner  * Alfredo Andres Omella (aandres@s21sec.com) v0.1 2000/09/15
81685295f4SBill Fenner  *
82685295f4SBill Fenner  * TODO: Among other things to print ok MacIntosh and Vendor values
83685295f4SBill Fenner  */
84685295f4SBill Fenner 
85ee67461eSJoseph Mingrone #include <config.h>
86685295f4SBill Fenner 
87ee67461eSJoseph Mingrone #include "netdissect-stdinc.h"
885b0fe478SBruce M Simpson 
89a90e161bSBill Fenner #include <string.h>
90a90e161bSBill Fenner 
91ee67461eSJoseph Mingrone #include "netdissect-ctype.h"
92ee67461eSJoseph Mingrone 
933340d773SGleb Smirnoff #include "netdissect.h"
94685295f4SBill Fenner #include "addrtoname.h"
95685295f4SBill Fenner #include "extract.h"
965b0fe478SBruce M Simpson #include "oui.h"
97ee67461eSJoseph Mingrone #include "ntp.h"
98685295f4SBill Fenner 
993c602fabSXin LI 
100685295f4SBill Fenner #define TAM_SIZE(x) (sizeof(x)/sizeof(x[0]) )
101685295f4SBill Fenner 
102685295f4SBill Fenner #define PRINT_HEX(bytes_len, ptr_data)                               \
103685295f4SBill Fenner            while(bytes_len)                                          \
104685295f4SBill Fenner            {                                                         \
105ee67461eSJoseph Mingrone               ND_PRINT("%02X", GET_U_1(ptr_data));                   \
106685295f4SBill Fenner               ptr_data++;                                            \
107685295f4SBill Fenner               bytes_len--;                                           \
108685295f4SBill Fenner            }
109685295f4SBill Fenner 
110685295f4SBill Fenner 
111685295f4SBill Fenner /* Radius packet codes */
112ee67461eSJoseph Mingrone /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-27 */
113685295f4SBill Fenner #define RADCMD_ACCESS_REQ    1 /* Access-Request      */
114685295f4SBill Fenner #define RADCMD_ACCESS_ACC    2 /* Access-Accept       */
115685295f4SBill Fenner #define RADCMD_ACCESS_REJ    3 /* Access-Reject       */
116*0a7e5f1fSJoseph Mingrone #define RADCMD_ACCOUNT_REQ   4 /* Accounting-Request  */
117*0a7e5f1fSJoseph Mingrone #define RADCMD_ACCOUNT_RES   5 /* Accounting-Response */
118685295f4SBill Fenner #define RADCMD_ACCESS_CHA   11 /* Access-Challenge    */
119685295f4SBill Fenner #define RADCMD_STATUS_SER   12 /* Status-Server       */
120685295f4SBill Fenner #define RADCMD_STATUS_CLI   13 /* Status-Client       */
1218bdc5a62SPatrick Kelsey #define RADCMD_DISCON_REQ   40 /* Disconnect-Request  */
1228bdc5a62SPatrick Kelsey #define RADCMD_DISCON_ACK   41 /* Disconnect-ACK      */
1238bdc5a62SPatrick Kelsey #define RADCMD_DISCON_NAK   42 /* Disconnect-NAK      */
1248bdc5a62SPatrick Kelsey #define RADCMD_COA_REQ      43 /* CoA-Request         */
1258bdc5a62SPatrick Kelsey #define RADCMD_COA_ACK      44 /* CoA-ACK             */
1268bdc5a62SPatrick Kelsey #define RADCMD_COA_NAK      45 /* CoA-NAK             */
127685295f4SBill Fenner #define RADCMD_RESERVED    255 /* Reserved            */
128685295f4SBill Fenner 
1293c602fabSXin LI static const struct tok radius_command_values[] = {
1308bdc5a62SPatrick Kelsey     { RADCMD_ACCESS_REQ,  "Access-Request" },
1318bdc5a62SPatrick Kelsey     { RADCMD_ACCESS_ACC,  "Access-Accept" },
1328bdc5a62SPatrick Kelsey     { RADCMD_ACCESS_REJ,  "Access-Reject" },
133*0a7e5f1fSJoseph Mingrone     { RADCMD_ACCOUNT_REQ, "Accounting-Request" },
134*0a7e5f1fSJoseph Mingrone     { RADCMD_ACCOUNT_RES, "Accounting-Response" },
1358bdc5a62SPatrick Kelsey     { RADCMD_ACCESS_CHA,  "Access-Challenge" },
1368bdc5a62SPatrick Kelsey     { RADCMD_STATUS_SER,  "Status-Server" },
1378bdc5a62SPatrick Kelsey     { RADCMD_STATUS_CLI,  "Status-Client" },
1388bdc5a62SPatrick Kelsey     { RADCMD_DISCON_REQ,  "Disconnect-Request" },
1398bdc5a62SPatrick Kelsey     { RADCMD_DISCON_ACK,  "Disconnect-ACK" },
1408bdc5a62SPatrick Kelsey     { RADCMD_DISCON_NAK,  "Disconnect-NAK" },
1418bdc5a62SPatrick Kelsey     { RADCMD_COA_REQ,     "CoA-Request" },
1428bdc5a62SPatrick Kelsey     { RADCMD_COA_ACK,     "CoA-ACK" },
1438bdc5a62SPatrick Kelsey     { RADCMD_COA_NAK,     "CoA-NAK" },
1445b0fe478SBruce M Simpson     { RADCMD_RESERVED,    "Reserved" },
1455b0fe478SBruce M Simpson     { 0, NULL}
1465b0fe478SBruce M Simpson };
147685295f4SBill Fenner 
148685295f4SBill Fenner /********************************/
149685295f4SBill Fenner /* Begin Radius Attribute types */
150685295f4SBill Fenner /********************************/
151685295f4SBill Fenner #define SERV_TYPE    6
152685295f4SBill Fenner #define FRM_IPADDR   8
153685295f4SBill Fenner #define LOG_IPHOST  14
154685295f4SBill Fenner #define LOG_SERVICE 15
155685295f4SBill Fenner #define FRM_IPX     23
156685295f4SBill Fenner #define SESSION_TIMEOUT   27
157685295f4SBill Fenner #define IDLE_TIMEOUT      28
158685295f4SBill Fenner #define FRM_ATALK_LINK    37
159685295f4SBill Fenner #define FRM_ATALK_NETWORK 38
160685295f4SBill Fenner 
161685295f4SBill Fenner #define ACCT_DELAY        41
162685295f4SBill Fenner #define ACCT_SESSION_TIME 46
163685295f4SBill Fenner 
1648bdc5a62SPatrick Kelsey #define EGRESS_VLAN_ID   56
1658bdc5a62SPatrick Kelsey #define EGRESS_VLAN_NAME 58
1668bdc5a62SPatrick Kelsey 
167685295f4SBill Fenner #define TUNNEL_TYPE        64
168685295f4SBill Fenner #define TUNNEL_MEDIUM      65
169685295f4SBill Fenner #define TUNNEL_CLIENT_END  66
170685295f4SBill Fenner #define TUNNEL_SERVER_END  67
171685295f4SBill Fenner #define TUNNEL_PASS        69
172685295f4SBill Fenner 
173685295f4SBill Fenner #define ARAP_PASS          70
174685295f4SBill Fenner #define ARAP_FEATURES      71
175685295f4SBill Fenner 
176ee67461eSJoseph Mingrone #define EAP_MESSAGE        79
177ee67461eSJoseph Mingrone 
178685295f4SBill Fenner #define TUNNEL_PRIV_GROUP  81
179685295f4SBill Fenner #define TUNNEL_ASSIGN_ID   82
180685295f4SBill Fenner #define TUNNEL_PREFERENCE  83
181685295f4SBill Fenner 
182685295f4SBill Fenner #define ARAP_CHALLENGE_RESP 84
183685295f4SBill Fenner #define ACCT_INT_INTERVAL   85
184685295f4SBill Fenner 
185685295f4SBill Fenner #define TUNNEL_CLIENT_AUTH 90
186685295f4SBill Fenner #define TUNNEL_SERVER_AUTH 91
187ee67461eSJoseph Mingrone 
188ee67461eSJoseph Mingrone #define ERROR_CAUSE 101
189685295f4SBill Fenner /********************************/
190685295f4SBill Fenner /* End Radius Attribute types */
191685295f4SBill Fenner /********************************/
192685295f4SBill Fenner 
1938bdc5a62SPatrick Kelsey #define RFC4675_TAGGED   0x31
1948bdc5a62SPatrick Kelsey #define RFC4675_UNTAGGED 0x32
1958bdc5a62SPatrick Kelsey 
1968bdc5a62SPatrick Kelsey static const struct tok rfc4675_tagged[] = {
1978bdc5a62SPatrick Kelsey     { RFC4675_TAGGED,   "Tagged" },
1988bdc5a62SPatrick Kelsey     { RFC4675_UNTAGGED, "Untagged" },
1998bdc5a62SPatrick Kelsey     { 0, NULL}
2008bdc5a62SPatrick Kelsey };
2018bdc5a62SPatrick Kelsey 
202685295f4SBill Fenner 
203ee67461eSJoseph Mingrone static void print_attr_string(netdissect_options *, const u_char *, u_int, u_short );
204ee67461eSJoseph Mingrone static void print_attr_num(netdissect_options *, const u_char *, u_int, u_short );
205ee67461eSJoseph Mingrone static void print_vendor_attr(netdissect_options *, const u_char *, u_int, u_short );
206ee67461eSJoseph Mingrone static void print_attr_address(netdissect_options *, const u_char *, u_int, u_short);
207ee67461eSJoseph Mingrone static void print_attr_address6(netdissect_options *, const u_char *, u_int, u_short);
208ee67461eSJoseph Mingrone static void print_attr_netmask6(netdissect_options *, const u_char *, u_int, u_short);
209ee67461eSJoseph Mingrone static void print_attr_mip6_home_link_prefix(netdissect_options *, const u_char *, u_int, u_short);
210ee67461eSJoseph Mingrone static void print_attr_operator_name(netdissect_options *, const u_char *, u_int, u_short);
211ee67461eSJoseph Mingrone static void print_attr_location_information(netdissect_options *, const u_char *, u_int, u_short);
212ee67461eSJoseph Mingrone static void print_attr_location_data(netdissect_options *, const u_char *, u_int, u_short);
213ee67461eSJoseph Mingrone static void print_basic_location_policy_rules(netdissect_options *, const u_char *, u_int, u_short);
214ee67461eSJoseph Mingrone static void print_attr_time(netdissect_options *, const u_char *, u_int, u_short);
215*0a7e5f1fSJoseph Mingrone static void print_attr_vector64(netdissect_options *, const u_char *, u_int, u_short);
216ee67461eSJoseph Mingrone static void print_attr_strange(netdissect_options *, const u_char *, u_int, u_short);
217685295f4SBill Fenner 
218685295f4SBill Fenner 
219ee67461eSJoseph Mingrone struct radius_hdr { nd_uint8_t  code;     /* Radius packet code  */
220ee67461eSJoseph Mingrone                     nd_uint8_t  id;       /* Radius packet id    */
221ee67461eSJoseph Mingrone                     nd_uint16_t len;      /* Radius total length */
222ee67461eSJoseph Mingrone                     nd_byte     auth[16]; /* Authenticator   */
223685295f4SBill Fenner                   };
224685295f4SBill Fenner 
225a90e161bSBill Fenner #define MIN_RADIUS_LEN	20
226685295f4SBill Fenner 
227ee67461eSJoseph Mingrone struct radius_attr { nd_uint8_t type; /* Attribute type   */
228ee67461eSJoseph Mingrone                      nd_uint8_t len;  /* Attribute length */
229685295f4SBill Fenner                    };
230685295f4SBill Fenner 
231685295f4SBill Fenner 
232685295f4SBill Fenner /* Service-Type Attribute standard values */
233ee67461eSJoseph Mingrone /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-4 */
234685295f4SBill Fenner static const char *serv_type[]={ NULL,
235685295f4SBill Fenner                                 "Login",
236685295f4SBill Fenner                                 "Framed",
237685295f4SBill Fenner                                 "Callback Login",
238685295f4SBill Fenner                                 "Callback Framed",
239685295f4SBill Fenner                                 "Outbound",
240685295f4SBill Fenner                                 "Administrative",
241685295f4SBill Fenner                                 "NAS Prompt",
242685295f4SBill Fenner                                 "Authenticate Only",
243685295f4SBill Fenner                                 "Callback NAS Prompt",
244ee67461eSJoseph Mingrone                                 /* ^ [0, 9] ^ */
245685295f4SBill Fenner                                 "Call Check",
246685295f4SBill Fenner                                 "Callback Administrative",
247ee67461eSJoseph Mingrone                                 "Voice",
248ee67461eSJoseph Mingrone                                 "Fax",
249ee67461eSJoseph Mingrone                                 "Modem Relay",
250ee67461eSJoseph Mingrone                                 "IAPP-Register",
251ee67461eSJoseph Mingrone                                 "IAPP-AP-Check",
252ee67461eSJoseph Mingrone                                 "Authorize Only",
253ee67461eSJoseph Mingrone                                 "Framed-Management",
254ee67461eSJoseph Mingrone                                 "Additional-Authorization",
255ee67461eSJoseph Mingrone                                 /* ^ [10, 19] ^ */
256685295f4SBill Fenner                                };
257685295f4SBill Fenner 
258685295f4SBill Fenner /* Framed-Protocol Attribute standard values */
259ee67461eSJoseph Mingrone /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-5 */
260685295f4SBill Fenner static const char *frm_proto[]={ NULL,
261685295f4SBill Fenner                                  "PPP",
262685295f4SBill Fenner                                  "SLIP",
263685295f4SBill Fenner                                  "ARAP",
264685295f4SBill Fenner                                  "Gandalf proprietary",
265685295f4SBill Fenner                                  "Xylogics IPX/SLIP",
266685295f4SBill Fenner                                  "X.75 Synchronous",
267ee67461eSJoseph Mingrone                                  "GPRS PDP Context",
268685295f4SBill Fenner                                };
269685295f4SBill Fenner 
270685295f4SBill Fenner /* Framed-Routing Attribute standard values */
271ee67461eSJoseph Mingrone /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-6 */
272685295f4SBill Fenner static const char *frm_routing[]={ "None",
273685295f4SBill Fenner                                    "Send",
274685295f4SBill Fenner                                    "Listen",
275685295f4SBill Fenner                                    "Send&Listen",
276685295f4SBill Fenner                                  };
277685295f4SBill Fenner 
278685295f4SBill Fenner /* Framed-Compression Attribute standard values */
279ee67461eSJoseph Mingrone /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-7 */
280685295f4SBill Fenner static const char *frm_comp[]={ "None",
281685295f4SBill Fenner                                 "VJ TCP/IP",
282685295f4SBill Fenner                                 "IPX",
283685295f4SBill Fenner                                 "Stac-LZS",
284685295f4SBill Fenner                               };
285685295f4SBill Fenner 
286685295f4SBill Fenner /* Login-Service Attribute standard values */
287ee67461eSJoseph Mingrone /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-8 */
288685295f4SBill Fenner static const char *login_serv[]={ "Telnet",
289685295f4SBill Fenner                                   "Rlogin",
290685295f4SBill Fenner                                   "TCP Clear",
291685295f4SBill Fenner                                   "PortMaster(proprietary)",
292685295f4SBill Fenner                                   "LAT",
293685295f4SBill Fenner                                   "X.25-PAD",
294685295f4SBill Fenner                                   "X.25-T3POS",
295685295f4SBill Fenner                                   "Unassigned",
296685295f4SBill Fenner                                   "TCP Clear Quiet",
297685295f4SBill Fenner                                 };
298685295f4SBill Fenner 
299685295f4SBill Fenner 
300685295f4SBill Fenner /* Termination-Action Attribute standard values */
301ee67461eSJoseph Mingrone /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-9 */
302685295f4SBill Fenner static const char *term_action[]={ "Default",
303685295f4SBill Fenner                                    "RADIUS-Request",
304685295f4SBill Fenner                                  };
305685295f4SBill Fenner 
3068bdc5a62SPatrick Kelsey /* Ingress-Filters Attribute standard values */
3078bdc5a62SPatrick Kelsey static const char *ingress_filters[]={ NULL,
3088bdc5a62SPatrick Kelsey                                        "Enabled",
3098bdc5a62SPatrick Kelsey                                        "Disabled",
3108bdc5a62SPatrick Kelsey                                      };
3118bdc5a62SPatrick Kelsey 
312685295f4SBill Fenner /* NAS-Port-Type Attribute standard values */
313ee67461eSJoseph Mingrone /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-13 */
314685295f4SBill Fenner static const char *nas_port_type[]={ "Async",
315685295f4SBill Fenner                                      "Sync",
316685295f4SBill Fenner                                      "ISDN Sync",
317685295f4SBill Fenner                                      "ISDN Async V.120",
318685295f4SBill Fenner                                      "ISDN Async V.110",
319685295f4SBill Fenner                                      "Virtual",
320685295f4SBill Fenner                                      "PIAFS",
321685295f4SBill Fenner                                      "HDLC Clear Channel",
322685295f4SBill Fenner                                      "X.25",
323685295f4SBill Fenner                                      "X.75",
324ee67461eSJoseph Mingrone                                      /* ^ [0, 9] ^ */
325685295f4SBill Fenner                                      "G.3 Fax",
326685295f4SBill Fenner                                      "SDSL",
327685295f4SBill Fenner                                      "ADSL-CAP",
328685295f4SBill Fenner                                      "ADSL-DMT",
329685295f4SBill Fenner                                      "ISDN-DSL",
330685295f4SBill Fenner                                      "Ethernet",
331685295f4SBill Fenner                                      "xDSL",
332685295f4SBill Fenner                                      "Cable",
333685295f4SBill Fenner                                      "Wireless - Other",
334685295f4SBill Fenner                                      "Wireless - IEEE 802.11",
335ee67461eSJoseph Mingrone                                      /* ^ [10, 19] ^ */
336ee67461eSJoseph Mingrone                                      "Token-Ring",
337ee67461eSJoseph Mingrone                                      "FDDI",
338ee67461eSJoseph Mingrone                                      "Wireless - CDMA200",
339ee67461eSJoseph Mingrone                                      "Wireless - UMTS",
340ee67461eSJoseph Mingrone                                      "Wireless - 1X-EV",
341ee67461eSJoseph Mingrone                                      "IAPP",
342ee67461eSJoseph Mingrone                                      "FTTP",
343ee67461eSJoseph Mingrone                                      "Wireless - IEEE 802.16",
344ee67461eSJoseph Mingrone                                      "Wireless - IEEE 802.20",
345ee67461eSJoseph Mingrone                                      "Wireless - IEEE 802.22",
346ee67461eSJoseph Mingrone                                      /* ^ [20, 29] ^ */
347ee67461eSJoseph Mingrone                                      "PPPoA",
348ee67461eSJoseph Mingrone                                      "PPPoEoA",
349ee67461eSJoseph Mingrone                                      "PPPoEoE",
350ee67461eSJoseph Mingrone                                      "PPPoEoVLAN",
351ee67461eSJoseph Mingrone                                      "PPPoEoQinQ",
352ee67461eSJoseph Mingrone                                      "xPON",
353ee67461eSJoseph Mingrone                                      "Wireless - XGP",
354ee67461eSJoseph Mingrone                                      "WiMAX Pre-Release 8 IWK Function",
355ee67461eSJoseph Mingrone                                      "WIMAX-WIFI-IWK",
356ee67461eSJoseph Mingrone                                      "WIMAX-SFF",
357ee67461eSJoseph Mingrone                                      /* ^ [30, 39] ^ */
358ee67461eSJoseph Mingrone                                      "WIMAX-HA-LMA",
359ee67461eSJoseph Mingrone                                      "WIMAX-DHCP",
360ee67461eSJoseph Mingrone                                      "WIMAX-LBS",
361ee67461eSJoseph Mingrone                                      "WIMAX-WVS",
362685295f4SBill Fenner                                    };
363685295f4SBill Fenner 
364685295f4SBill Fenner /* Acct-Status-Type Accounting Attribute standard values */
365ee67461eSJoseph Mingrone /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-10 */
366685295f4SBill Fenner static const char *acct_status[]={ NULL,
367685295f4SBill Fenner                                    "Start",
368685295f4SBill Fenner                                    "Stop",
369685295f4SBill Fenner                                    "Interim-Update",
370685295f4SBill Fenner                                    "Unassigned",
371685295f4SBill Fenner                                    "Unassigned",
372685295f4SBill Fenner                                    "Unassigned",
373685295f4SBill Fenner                                    "Accounting-On",
374685295f4SBill Fenner                                    "Accounting-Off",
375685295f4SBill Fenner                                    "Tunnel-Start",
376ee67461eSJoseph Mingrone                                      /* ^ [0, 9] ^ */
377685295f4SBill Fenner                                    "Tunnel-Stop",
378685295f4SBill Fenner                                    "Tunnel-Reject",
379685295f4SBill Fenner                                    "Tunnel-Link-Start",
380685295f4SBill Fenner                                    "Tunnel-Link-Stop",
381685295f4SBill Fenner                                    "Tunnel-Link-Reject",
382685295f4SBill Fenner                                    "Failed",
383685295f4SBill Fenner                                  };
384685295f4SBill Fenner 
385685295f4SBill Fenner /* Acct-Authentic Accounting Attribute standard values */
386ee67461eSJoseph Mingrone /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-11 */
387685295f4SBill Fenner static const char *acct_auth[]={ NULL,
388685295f4SBill Fenner                                  "RADIUS",
389685295f4SBill Fenner                                  "Local",
390685295f4SBill Fenner                                  "Remote",
391ee67461eSJoseph Mingrone                                  "Diameter",
392685295f4SBill Fenner                                };
393685295f4SBill Fenner 
394685295f4SBill Fenner /* Acct-Terminate-Cause Accounting Attribute standard values */
395ee67461eSJoseph Mingrone /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-12 */
396685295f4SBill Fenner static const char *acct_term[]={ NULL,
397685295f4SBill Fenner                                  "User Request",
398685295f4SBill Fenner                                  "Lost Carrier",
399685295f4SBill Fenner                                  "Lost Service",
400685295f4SBill Fenner                                  "Idle Timeout",
401685295f4SBill Fenner                                  "Session Timeout",
402685295f4SBill Fenner                                  "Admin Reset",
403685295f4SBill Fenner                                  "Admin Reboot",
404685295f4SBill Fenner                                  "Port Error",
405685295f4SBill Fenner                                  "NAS Error",
406ee67461eSJoseph Mingrone                                  /* ^ [0, 9] ^ */
407685295f4SBill Fenner                                  "NAS Request",
408685295f4SBill Fenner                                  "NAS Reboot",
409685295f4SBill Fenner                                  "Port Unneeded",
410685295f4SBill Fenner                                  "Port Preempted",
411685295f4SBill Fenner                                  "Port Suspended",
412685295f4SBill Fenner                                  "Service Unavailable",
413685295f4SBill Fenner                                  "Callback",
414685295f4SBill Fenner                                  "User Error",
415685295f4SBill Fenner                                  "Host Request",
416ee67461eSJoseph Mingrone                                  "Supplicant Restart",
417ee67461eSJoseph Mingrone                                  /* ^ [10, 19] ^ */
418ee67461eSJoseph Mingrone                                  "Reauthentication Failure",
419ee67461eSJoseph Mingrone                                  "Port Reinitialized",
420ee67461eSJoseph Mingrone                                  "Port Administratively Disabled",
421ee67461eSJoseph Mingrone                                  "Lost Power",
422685295f4SBill Fenner                                };
423685295f4SBill Fenner 
424685295f4SBill Fenner /* Tunnel-Type Attribute standard values */
425ee67461eSJoseph Mingrone /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-14 */
426685295f4SBill Fenner static const char *tunnel_type[]={ NULL,
427685295f4SBill Fenner                                    "PPTP",
428685295f4SBill Fenner                                    "L2F",
429685295f4SBill Fenner                                    "L2TP",
430685295f4SBill Fenner                                    "ATMP",
431685295f4SBill Fenner                                    "VTP",
432685295f4SBill Fenner                                    "AH",
433685295f4SBill Fenner                                    "IP-IP",
434685295f4SBill Fenner                                    "MIN-IP-IP",
435685295f4SBill Fenner                                    "ESP",
436ee67461eSJoseph Mingrone                                    /* ^ [0, 9] ^ */
437685295f4SBill Fenner                                    "GRE",
438685295f4SBill Fenner                                    "DVS",
439685295f4SBill Fenner                                    "IP-in-IP Tunneling",
4403340d773SGleb Smirnoff                                    "VLAN",
441685295f4SBill Fenner                                  };
442685295f4SBill Fenner 
443685295f4SBill Fenner /* Tunnel-Medium-Type Attribute standard values */
444ee67461eSJoseph Mingrone /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-15 */
445685295f4SBill Fenner static const char *tunnel_medium[]={ NULL,
446685295f4SBill Fenner                                      "IPv4",
447685295f4SBill Fenner                                      "IPv6",
448685295f4SBill Fenner                                      "NSAP",
449685295f4SBill Fenner                                      "HDLC",
450685295f4SBill Fenner                                      "BBN 1822",
451685295f4SBill Fenner                                      "802",
452685295f4SBill Fenner                                      "E.163",
453685295f4SBill Fenner                                      "E.164",
454685295f4SBill Fenner                                      "F.69",
455ee67461eSJoseph Mingrone                                      /* ^ [0, 9] ^ */
456685295f4SBill Fenner                                      "X.121",
457685295f4SBill Fenner                                      "IPX",
458685295f4SBill Fenner                                      "Appletalk",
459685295f4SBill Fenner                                      "Decnet IV",
460685295f4SBill Fenner                                      "Banyan Vines",
461685295f4SBill Fenner                                      "E.164 with NSAP subaddress",
462685295f4SBill Fenner                                    };
463685295f4SBill Fenner 
464685295f4SBill Fenner /* ARAP-Zone-Access Attribute standard values */
465ee67461eSJoseph Mingrone /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-16 */
466685295f4SBill Fenner static const char *arap_zone[]={ NULL,
467685295f4SBill Fenner                                  "Only access to dfl zone",
468685295f4SBill Fenner                                  "Use zone filter inc.",
469685295f4SBill Fenner                                  "Not used",
470685295f4SBill Fenner                                  "Use zone filter exc.",
471685295f4SBill Fenner                                };
472685295f4SBill Fenner 
473ee67461eSJoseph Mingrone /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-17 */
474685295f4SBill Fenner static const char *prompt[]={ "No Echo",
475685295f4SBill Fenner                               "Echo",
476685295f4SBill Fenner                             };
477685295f4SBill Fenner 
478ee67461eSJoseph Mingrone /* Error-Cause standard values */
479ee67461eSJoseph Mingrone /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-18 */
480ee67461eSJoseph Mingrone #define ERROR_CAUSE_RESIDUAL_CONTEXT_REMOVED 201
481ee67461eSJoseph Mingrone #define ERROR_CAUSE_INVALID_EAP_PACKET 202
482ee67461eSJoseph Mingrone #define ERROR_CAUSE_UNSUPPORTED_ATTRIBUTE 401
483ee67461eSJoseph Mingrone #define ERROR_CAUSE_MISSING_ATTRIBUTE 402
484ee67461eSJoseph Mingrone #define ERROR_CAUSE_NAS_IDENTIFICATION_MISMATCH 403
485ee67461eSJoseph Mingrone #define ERROR_CAUSE_INVALID_REQUEST 404
486ee67461eSJoseph Mingrone #define ERROR_CAUSE_UNSUPPORTED_SERVICE 405
487ee67461eSJoseph Mingrone #define ERROR_CAUSE_UNSUPPORTED_EXTENSION 406
488ee67461eSJoseph Mingrone #define ERROR_CAUSE_INVALID_ATTRIBUTE_VALUE 407
489ee67461eSJoseph Mingrone #define ERROR_CAUSE_ADMINISTRATIVELY_PROHIBITED 501
490ee67461eSJoseph Mingrone #define ERROR_CAUSE_PROXY_REQUEST_NOT_ROUTABLE 502
491ee67461eSJoseph Mingrone #define ERROR_CAUSE_SESSION_CONTEXT_NOT_FOUND 503
492ee67461eSJoseph Mingrone #define ERROR_CAUSE_SESSION_CONTEXT_NOT_REMOVABLE 504
493ee67461eSJoseph Mingrone #define ERROR_CAUSE_PROXY_PROCESSING_ERROR 505
494ee67461eSJoseph Mingrone #define ERROR_CAUSE_RESOURCES_UNAVAILABLE 506
495ee67461eSJoseph Mingrone #define ERROR_CAUSE_REQUEST_INITIATED 507
496ee67461eSJoseph Mingrone #define ERROR_CAUSE_MULTIPLE_SESSION_SELECTION_UNSUPPORTED 508
497ee67461eSJoseph Mingrone #define ERROR_CAUSE_LOCATION_INFO_REQUIRED 509
498ee67461eSJoseph Mingrone static const struct tok errorcausetype[] = {
499ee67461eSJoseph Mingrone                                  { ERROR_CAUSE_RESIDUAL_CONTEXT_REMOVED,               "Residual Session Context Removed" },
500ee67461eSJoseph Mingrone                                  { ERROR_CAUSE_INVALID_EAP_PACKET,                     "Invalid EAP Packet (Ignored)" },
501ee67461eSJoseph Mingrone                                  { ERROR_CAUSE_UNSUPPORTED_ATTRIBUTE,                  "Unsupported Attribute" },
502ee67461eSJoseph Mingrone                                  { ERROR_CAUSE_MISSING_ATTRIBUTE,                      "Missing Attribute" },
503ee67461eSJoseph Mingrone                                  { ERROR_CAUSE_NAS_IDENTIFICATION_MISMATCH,            "NAS Identification Mismatch" },
504ee67461eSJoseph Mingrone                                  { ERROR_CAUSE_INVALID_REQUEST,                        "Invalid Request" },
505ee67461eSJoseph Mingrone                                  { ERROR_CAUSE_UNSUPPORTED_SERVICE,                    "Unsupported Service" },
506ee67461eSJoseph Mingrone                                  { ERROR_CAUSE_UNSUPPORTED_EXTENSION,                  "Unsupported Extension" },
507ee67461eSJoseph Mingrone                                  { ERROR_CAUSE_INVALID_ATTRIBUTE_VALUE,                "Invalid Attribute Value" },
508ee67461eSJoseph Mingrone                                  { ERROR_CAUSE_ADMINISTRATIVELY_PROHIBITED,            "Administratively Prohibited" },
509ee67461eSJoseph Mingrone                                  { ERROR_CAUSE_PROXY_REQUEST_NOT_ROUTABLE,             "Request Not Routable (Proxy)" },
510ee67461eSJoseph Mingrone                                  { ERROR_CAUSE_SESSION_CONTEXT_NOT_FOUND,              "Session Context Not Found" },
511ee67461eSJoseph Mingrone                                  { ERROR_CAUSE_SESSION_CONTEXT_NOT_REMOVABLE,          "Session Context Not Removable" },
512ee67461eSJoseph Mingrone                                  { ERROR_CAUSE_PROXY_PROCESSING_ERROR,                 "Other Proxy Processing Error" },
513ee67461eSJoseph Mingrone                                  { ERROR_CAUSE_RESOURCES_UNAVAILABLE,                  "Resources Unavailable" },
514ee67461eSJoseph Mingrone                                  { ERROR_CAUSE_REQUEST_INITIATED,                      "Request Initiated" },
515ee67461eSJoseph Mingrone                                  { ERROR_CAUSE_MULTIPLE_SESSION_SELECTION_UNSUPPORTED, "Multiple Session Selection Unsupported" },
516ee67461eSJoseph Mingrone                                  { ERROR_CAUSE_LOCATION_INFO_REQUIRED,                 "Location Info Required" },
517ee67461eSJoseph Mingrone 																 { 0, NULL }
518ee67461eSJoseph Mingrone                                };
519685295f4SBill Fenner 
520ee67461eSJoseph Mingrone /* MIP6-Feature-Vector standard values */
521ee67461eSJoseph Mingrone /* https://www.iana.org/assignments/aaa-parameters/aaa-parameters.xhtml */
522ee67461eSJoseph Mingrone #define MIP6_INTEGRATED 0x0000000000000001
523ee67461eSJoseph Mingrone #define LOCAL_HOME_AGENT_ASSIGNMENT 0x0000000000000002
524ee67461eSJoseph Mingrone #define PMIP6_SUPPORTED 0x0000010000000000
525ee67461eSJoseph Mingrone #define IP4_HOA_SUPPORTED 0x0000020000000000
526ee67461eSJoseph Mingrone #define LOCAL_MAG_ROUTING_SUPPORTED 0x0000040000000000
527ee67461eSJoseph Mingrone #define ASSIGN_LOCAL_IP 0x0000080000000000
528ee67461eSJoseph Mingrone #define MIP4_SUPPORTED 0x0000100000000000
529ee67461eSJoseph Mingrone #define OPTIMIZED_IDLE_MODE_MOBILITY 0x0000200000000000
530ee67461eSJoseph Mingrone #define GTPv2_SUPPORTED 0x0000400000000000
531ee67461eSJoseph Mingrone #define IP4_TRANSPORT_SUPPORTED 0x0000800000000000
532ee67461eSJoseph Mingrone #define IP4_HOA_ONLY_SUPPORTED 0x0001000000000000
533ee67461eSJoseph Mingrone #define INTER_MAG_ROUTING_SUPPORTED 0x0002000000000000
534ee67461eSJoseph Mingrone static const struct mip6_feature_vector {
535ee67461eSJoseph Mingrone                   uint64_t v;
536ee67461eSJoseph Mingrone                   const char *s;
537ee67461eSJoseph Mingrone                 } mip6_feature_vector[] = {
538ee67461eSJoseph Mingrone                                  { MIP6_INTEGRATED,             "MIP6_INTEGRATED" },
539ee67461eSJoseph Mingrone                                  { LOCAL_HOME_AGENT_ASSIGNMENT, "LOCAL_HOME_AGENT_ASSIGNMENT" },
540ee67461eSJoseph Mingrone                                  { PMIP6_SUPPORTED,             "PMIP6_SUPPORTED" },
541ee67461eSJoseph Mingrone                                  { IP4_HOA_SUPPORTED,           "IP4_HOA_SUPPORTED" },
542ee67461eSJoseph Mingrone                                  { LOCAL_MAG_ROUTING_SUPPORTED, "LOCAL_MAG_ROUTING_SUPPORTED" },
543ee67461eSJoseph Mingrone                                  { ASSIGN_LOCAL_IP,             "ASSIGN_LOCAL_IP" },
544ee67461eSJoseph Mingrone                                  { MIP4_SUPPORTED,              "MIP4_SUPPORTED" },
545ee67461eSJoseph Mingrone                                  { OPTIMIZED_IDLE_MODE_MOBILITY, "OPTIMIZED_IDLE_MODE_MOBILITY" },
546ee67461eSJoseph Mingrone                                  { GTPv2_SUPPORTED,             "GTPv2_SUPPORTED" },
547ee67461eSJoseph Mingrone                                  { IP4_TRANSPORT_SUPPORTED,     "IP4_TRANSPORT_SUPPORTED" },
548ee67461eSJoseph Mingrone                                  { IP4_HOA_ONLY_SUPPORTED,      "IP4_HOA_ONLY_SUPPORTED" },
549ee67461eSJoseph Mingrone                                  { INTER_MAG_ROUTING_SUPPORTED, "INTER_MAG_ROUTING_SUPPORTED" },
550ee67461eSJoseph Mingrone                                };
551ee67461eSJoseph Mingrone 
552ee67461eSJoseph Mingrone /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-19 */
553ee67461eSJoseph Mingrone #define OPERATOR_NAME_TADIG 0x30
554ee67461eSJoseph Mingrone #define OPERATOR_NAME_REALM 0x31
555ee67461eSJoseph Mingrone #define OPERATOR_NAME_E212  0x32
556ee67461eSJoseph Mingrone #define OPERATOR_NAME_ICC   0x33
557ee67461eSJoseph Mingrone static const struct tok operator_name_vector[] = {
558ee67461eSJoseph Mingrone                                  { OPERATOR_NAME_TADIG, "TADIG" },
559ee67461eSJoseph Mingrone                                  { OPERATOR_NAME_REALM, "REALM" },
560ee67461eSJoseph Mingrone                                  { OPERATOR_NAME_E212,  "E212"  },
561ee67461eSJoseph Mingrone                                  { OPERATOR_NAME_ICC,   "ICC"   },
562ee67461eSJoseph Mingrone                                  { 0, NULL }
563ee67461eSJoseph Mingrone                                };
564ee67461eSJoseph Mingrone 
565ee67461eSJoseph Mingrone /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-20 */
566ee67461eSJoseph Mingrone #define LOCATION_INFORMATION_CODE_CIVIC      0
567ee67461eSJoseph Mingrone #define LOCATION_INFORMATION_CODE_GEOSPATIAL 1
568ee67461eSJoseph Mingrone static const struct tok location_information_code_vector[] = {
569ee67461eSJoseph Mingrone                                  { LOCATION_INFORMATION_CODE_CIVIC     , "Civic"      },
570ee67461eSJoseph Mingrone                                  { LOCATION_INFORMATION_CODE_GEOSPATIAL, "Geospatial" },
571ee67461eSJoseph Mingrone                                  { 0, NULL }
572ee67461eSJoseph Mingrone                                };
573ee67461eSJoseph Mingrone 
574ee67461eSJoseph Mingrone /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-21 */
575ee67461eSJoseph Mingrone #define LOCATION_INFORMATION_ENTITY_USER   0
576ee67461eSJoseph Mingrone #define LOCATION_INFORMATION_ENTITY_RADIUS 1
577ee67461eSJoseph Mingrone static const struct tok location_information_entity_vector[] = {
578ee67461eSJoseph Mingrone                                  { LOCATION_INFORMATION_ENTITY_USER,   "User"   },
579ee67461eSJoseph Mingrone                                  { LOCATION_INFORMATION_ENTITY_RADIUS, "RADIUS" },
580ee67461eSJoseph Mingrone                                  { 0, NULL }
581ee67461eSJoseph Mingrone                                };
582ee67461eSJoseph Mingrone 
583ee67461eSJoseph Mingrone /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-22 */
584ee67461eSJoseph Mingrone static const struct tok blpr_bm[] = {
585ee67461eSJoseph Mingrone                                  { 0x0001, "MBZ-15" },
586ee67461eSJoseph Mingrone                                  { 0x0002, "MBZ-14" },
587ee67461eSJoseph Mingrone                                  { 0x0004, "MBZ-13" },
588ee67461eSJoseph Mingrone                                  { 0x0008, "MBZ-12" },
589ee67461eSJoseph Mingrone                                  { 0x0010, "MBZ-11" },
590ee67461eSJoseph Mingrone                                  { 0x0020, "MBZ-10" },
591ee67461eSJoseph Mingrone                                  { 0x0040, "MBZ-9" },
592ee67461eSJoseph Mingrone                                  { 0x0080, "MBZ-8" },
593ee67461eSJoseph Mingrone                                  { 0x0100, "MBZ-7" },
594ee67461eSJoseph Mingrone                                  { 0x0200, "MBZ-6" },
595ee67461eSJoseph Mingrone                                  { 0x0400, "MBZ-5" },
596ee67461eSJoseph Mingrone                                  { 0x0800, "MBZ-4" },
597ee67461eSJoseph Mingrone                                  { 0x1000, "MBZ-3" },
598ee67461eSJoseph Mingrone                                  { 0x2000, "MBZ-2" },
599ee67461eSJoseph Mingrone                                  { 0x4000, "MBZ-1" },
600ee67461eSJoseph Mingrone                                  { 0x8000, "Retransmission Allowed" },
601ee67461eSJoseph Mingrone                                  { 0, NULL }
602ee67461eSJoseph Mingrone                                };
603ee67461eSJoseph Mingrone 
604ee67461eSJoseph Mingrone /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-2 */
605ee67461eSJoseph Mingrone static const struct attrtype {
6063340d773SGleb Smirnoff                   const char *name;      /* Attribute name                 */
607685295f4SBill Fenner                   const char **subtypes; /* Standard Values (if any)       */
608685295f4SBill Fenner                   u_char siz_subtypes;   /* Size of total standard values  */
609685295f4SBill Fenner                   u_char first_subtype;  /* First standard value is 0 or 1 */
610ee67461eSJoseph Mingrone                   void (*print_func)(netdissect_options *, const u_char *, u_int, u_short);
611685295f4SBill Fenner                 } attr_type[]=
612685295f4SBill Fenner   {
613685295f4SBill Fenner      { NULL,                              NULL, 0, 0, NULL               },
6148bdc5a62SPatrick Kelsey      { "User-Name",                       NULL, 0, 0, print_attr_string  },
6158bdc5a62SPatrick Kelsey      { "User-Password",                   NULL, 0, 0, NULL               },
6168bdc5a62SPatrick Kelsey      { "CHAP-Password",                   NULL, 0, 0, NULL               },
6178bdc5a62SPatrick Kelsey      { "NAS-IP-Address",                  NULL, 0, 0, print_attr_address },
6188bdc5a62SPatrick Kelsey      { "NAS-Port",                        NULL, 0, 0, print_attr_num     },
6198bdc5a62SPatrick Kelsey      { "Service-Type",                    serv_type, TAM_SIZE(serv_type)-1, 1, print_attr_num },
6208bdc5a62SPatrick Kelsey      { "Framed-Protocol",                 frm_proto, TAM_SIZE(frm_proto)-1, 1, print_attr_num },
6218bdc5a62SPatrick Kelsey      { "Framed-IP-Address",               NULL, 0, 0, print_attr_address },
6228bdc5a62SPatrick Kelsey      { "Framed-IP-Netmask",               NULL, 0, 0, print_attr_address },
623ee67461eSJoseph Mingrone      /* ^ [0, 9] ^ */
6248bdc5a62SPatrick Kelsey      { "Framed-Routing",                  frm_routing, TAM_SIZE(frm_routing), 0, print_attr_num },
6258bdc5a62SPatrick Kelsey      { "Filter-Id",                       NULL, 0, 0, print_attr_string  },
6268bdc5a62SPatrick Kelsey      { "Framed-MTU",                      NULL, 0, 0, print_attr_num     },
6278bdc5a62SPatrick Kelsey      { "Framed-Compression",              frm_comp, TAM_SIZE(frm_comp),   0, print_attr_num },
6288bdc5a62SPatrick Kelsey      { "Login-IP-Host",                   NULL, 0, 0, print_attr_address },
6298bdc5a62SPatrick Kelsey      { "Login-Service",                   login_serv, TAM_SIZE(login_serv), 0, print_attr_num },
6308bdc5a62SPatrick Kelsey      { "Login-TCP-Port",                  NULL, 0, 0, print_attr_num     },
6315b0fe478SBruce M Simpson      { "Unassigned",                      NULL, 0, 0, NULL }, /*17*/
6328bdc5a62SPatrick Kelsey      { "Reply-Message",                   NULL, 0, 0, print_attr_string },
6338bdc5a62SPatrick Kelsey      { "Callback-Number",                 NULL, 0, 0, print_attr_string },
634ee67461eSJoseph Mingrone      /* ^ [10, 19] ^ */
6358bdc5a62SPatrick Kelsey      { "Callback-Id",                     NULL, 0, 0, print_attr_string },
6365b0fe478SBruce M Simpson      { "Unassigned",                      NULL, 0, 0, NULL }, /*21*/
6378bdc5a62SPatrick Kelsey      { "Framed-Route",                    NULL, 0, 0, print_attr_string },
6388bdc5a62SPatrick Kelsey      { "Framed-IPX-Network",              NULL, 0, 0, print_attr_num    },
639685295f4SBill Fenner      { "State",                           NULL, 0, 0, print_attr_string },
640685295f4SBill Fenner      { "Class",                           NULL, 0, 0, print_attr_string },
6418bdc5a62SPatrick Kelsey      { "Vendor-Specific",                 NULL, 0, 0, print_vendor_attr },
6428bdc5a62SPatrick Kelsey      { "Session-Timeout",                 NULL, 0, 0, print_attr_num    },
6438bdc5a62SPatrick Kelsey      { "Idle-Timeout",                    NULL, 0, 0, print_attr_num    },
6448bdc5a62SPatrick Kelsey      { "Termination-Action",              term_action, TAM_SIZE(term_action), 0, print_attr_num },
645ee67461eSJoseph Mingrone      /* ^ [20, 29] ^ */
6468bdc5a62SPatrick Kelsey      { "Called-Station-Id",               NULL, 0, 0, print_attr_string },
6478bdc5a62SPatrick Kelsey      { "Calling-Station-Id",              NULL, 0, 0, print_attr_string },
6488bdc5a62SPatrick Kelsey      { "NAS-Identifier",                  NULL, 0, 0, print_attr_string },
6498bdc5a62SPatrick Kelsey      { "Proxy-State",                     NULL, 0, 0, print_attr_string },
6508bdc5a62SPatrick Kelsey      { "Login-LAT-Service",               NULL, 0, 0, print_attr_string },
6518bdc5a62SPatrick Kelsey      { "Login-LAT-Node",                  NULL, 0, 0, print_attr_string },
6528bdc5a62SPatrick Kelsey      { "Login-LAT-Group",                 NULL, 0, 0, print_attr_string },
6538bdc5a62SPatrick Kelsey      { "Framed-AppleTalk-Link",           NULL, 0, 0, print_attr_num    },
6548bdc5a62SPatrick Kelsey      { "Framed-AppleTalk-Network",        NULL, 0, 0, print_attr_num    },
6558bdc5a62SPatrick Kelsey      { "Framed-AppleTalk-Zone",           NULL, 0, 0, print_attr_string },
656ee67461eSJoseph Mingrone      /* ^ [30, 39] ^ */
6578bdc5a62SPatrick Kelsey      { "Acct-Status-Type",                acct_status, TAM_SIZE(acct_status)-1, 1, print_attr_num },
6588bdc5a62SPatrick Kelsey      { "Acct-Delay-Time",                 NULL, 0, 0, print_attr_num    },
6598bdc5a62SPatrick Kelsey      { "Acct-Input-Octets",               NULL, 0, 0, print_attr_num    },
6608bdc5a62SPatrick Kelsey      { "Acct-Output-Octets",              NULL, 0, 0, print_attr_num    },
6618bdc5a62SPatrick Kelsey      { "Acct-Session-Id",                 NULL, 0, 0, print_attr_string },
6628bdc5a62SPatrick Kelsey      { "Acct-Authentic",                  acct_auth, TAM_SIZE(acct_auth)-1, 1, print_attr_num },
6638bdc5a62SPatrick Kelsey      { "Acct-Session-Time",               NULL, 0, 0, print_attr_num },
6648bdc5a62SPatrick Kelsey      { "Acct-Input-Packets",              NULL, 0, 0, print_attr_num },
6658bdc5a62SPatrick Kelsey      { "Acct-Output-Packets",             NULL, 0, 0, print_attr_num },
6668bdc5a62SPatrick Kelsey      { "Acct-Terminate-Cause",            acct_term, TAM_SIZE(acct_term)-1, 1, print_attr_num },
667ee67461eSJoseph Mingrone      /* ^ [40, 49] ^ */
6688bdc5a62SPatrick Kelsey      { "Acct-Multi-Session-Id",           NULL, 0, 0, print_attr_string },
6698bdc5a62SPatrick Kelsey      { "Acct-Link-Count",                 NULL, 0, 0, print_attr_num },
6708bdc5a62SPatrick Kelsey      { "Acct-Input-Gigawords",            NULL, 0, 0, print_attr_num },
6718bdc5a62SPatrick Kelsey      { "Acct-Output-Gigawords",           NULL, 0, 0, print_attr_num },
6725b0fe478SBruce M Simpson      { "Unassigned",                      NULL, 0, 0, NULL }, /*54*/
6738bdc5a62SPatrick Kelsey      { "Event-Timestamp",                 NULL, 0, 0, print_attr_time },
6748bdc5a62SPatrick Kelsey      { "Egress-VLANID",                   NULL, 0, 0, print_attr_num },
6758bdc5a62SPatrick Kelsey      { "Ingress-Filters",                 ingress_filters, TAM_SIZE(ingress_filters)-1, 1, print_attr_num },
6768bdc5a62SPatrick Kelsey      { "Egress-VLAN-Name",                NULL, 0, 0, print_attr_string },
6778bdc5a62SPatrick Kelsey      { "User-Priority-Table",             NULL, 0, 0, NULL },
678ee67461eSJoseph Mingrone      /* ^ [50, 59] ^ */
6798bdc5a62SPatrick Kelsey      { "CHAP-Challenge",                  NULL, 0, 0, print_attr_string },
6808bdc5a62SPatrick Kelsey      { "NAS-Port-Type",                   nas_port_type, TAM_SIZE(nas_port_type), 0, print_attr_num },
6818bdc5a62SPatrick Kelsey      { "Port-Limit",                      NULL, 0, 0, print_attr_num },
6828bdc5a62SPatrick Kelsey      { "Login-LAT-Port",                  NULL, 0, 0, print_attr_string }, /*63*/
6838bdc5a62SPatrick Kelsey      { "Tunnel-Type",                     tunnel_type, TAM_SIZE(tunnel_type)-1, 1, print_attr_num },
6848bdc5a62SPatrick Kelsey      { "Tunnel-Medium-Type",              tunnel_medium, TAM_SIZE(tunnel_medium)-1, 1, print_attr_num },
6858bdc5a62SPatrick Kelsey      { "Tunnel-Client-Endpoint",          NULL, 0, 0, print_attr_string },
6868bdc5a62SPatrick Kelsey      { "Tunnel-Server-Endpoint",          NULL, 0, 0, print_attr_string },
6878bdc5a62SPatrick Kelsey      { "Acct-Tunnel-Connection",          NULL, 0, 0, print_attr_string },
6888bdc5a62SPatrick Kelsey      { "Tunnel-Password",                 NULL, 0, 0, print_attr_string  },
689ee67461eSJoseph Mingrone      /* ^ [60, 69] ^ */
6908bdc5a62SPatrick Kelsey      { "ARAP-Password",                   NULL, 0, 0, print_attr_strange },
6918bdc5a62SPatrick Kelsey      { "ARAP-Features",                   NULL, 0, 0, print_attr_strange },
6928bdc5a62SPatrick Kelsey      { "ARAP-Zone-Access",                arap_zone, TAM_SIZE(arap_zone)-1, 1, print_attr_num }, /*72*/
6938bdc5a62SPatrick Kelsey      { "ARAP-Security",                   NULL, 0, 0, print_attr_string },
6948bdc5a62SPatrick Kelsey      { "ARAP-Security-Data",              NULL, 0, 0, print_attr_string },
6958bdc5a62SPatrick Kelsey      { "Password-Retry",                  NULL, 0, 0, print_attr_num    },
696685295f4SBill Fenner      { "Prompt",                          prompt, TAM_SIZE(prompt), 0, print_attr_num },
6978bdc5a62SPatrick Kelsey      { "Connect-Info",                    NULL, 0, 0, print_attr_string   },
6988bdc5a62SPatrick Kelsey      { "Configuration-Token",             NULL, 0, 0, print_attr_string   },
6998bdc5a62SPatrick Kelsey      { "EAP-Message",                     NULL, 0, 0, print_attr_string   },
700ee67461eSJoseph Mingrone      /* ^ [70, 79] ^ */
7018bdc5a62SPatrick Kelsey      { "Message-Authenticator",           NULL, 0, 0, print_attr_string }, /*80*/
7028bdc5a62SPatrick Kelsey      { "Tunnel-Private-Group-ID",         NULL, 0, 0, print_attr_string },
7038bdc5a62SPatrick Kelsey      { "Tunnel-Assignment-ID",            NULL, 0, 0, print_attr_string },
7048bdc5a62SPatrick Kelsey      { "Tunnel-Preference",               NULL, 0, 0, print_attr_num    },
7058bdc5a62SPatrick Kelsey      { "ARAP-Challenge-Response",         NULL, 0, 0, print_attr_strange },
7068bdc5a62SPatrick Kelsey      { "Acct-Interim-Interval",           NULL, 0, 0, print_attr_num     },
7078bdc5a62SPatrick Kelsey      { "Acct-Tunnel-Packets-Lost",        NULL, 0, 0, print_attr_num }, /*86*/
7088bdc5a62SPatrick Kelsey      { "NAS-Port-Id",                     NULL, 0, 0, print_attr_string },
7098bdc5a62SPatrick Kelsey      { "Framed-Pool",                     NULL, 0, 0, print_attr_string },
7108bdc5a62SPatrick Kelsey      { "CUI",                             NULL, 0, 0, print_attr_string },
711ee67461eSJoseph Mingrone      /* ^ [80, 89] ^ */
7128bdc5a62SPatrick Kelsey      { "Tunnel-Client-Auth-ID",           NULL, 0, 0, print_attr_string },
7138bdc5a62SPatrick Kelsey      { "Tunnel-Server-Auth-ID",           NULL, 0, 0, print_attr_string },
714ee67461eSJoseph Mingrone      { "NAS-Filter-Rule",                 NULL, 0, 0, print_attr_string },
715ee67461eSJoseph Mingrone      { "Unassigned",                      NULL, 0, 0, NULL },  /*93*/
716ee67461eSJoseph Mingrone      { "Originating-Line-Info",           NULL, 0, 0, NULL },
717ee67461eSJoseph Mingrone      { "NAS-IPv6-Address",                NULL, 0, 0, print_attr_address6 },
718ee67461eSJoseph Mingrone      { "Framed-Interface-ID",             NULL, 0, 0, NULL },
719ee67461eSJoseph Mingrone      { "Framed-IPv6-Prefix",              NULL, 0, 0, print_attr_netmask6 },
720ee67461eSJoseph Mingrone      { "Login-IPv6-Host",                 NULL, 0, 0, print_attr_address6 },
721ee67461eSJoseph Mingrone      { "Framed-IPv6-Route",               NULL, 0, 0, print_attr_string },
722ee67461eSJoseph Mingrone      /* ^ [90, 99] ^ */
723ee67461eSJoseph Mingrone      { "Framed-IPv6-Pool",                NULL, 0, 0, print_attr_string },
724ee67461eSJoseph Mingrone      { "Error-Cause",                     NULL, 0, 0, print_attr_strange },
725ee67461eSJoseph Mingrone      { "EAP-Key-Name",                    NULL, 0, 0, NULL },
726ee67461eSJoseph Mingrone      { "Digest-Response",                 NULL, 0, 0, print_attr_string },
727ee67461eSJoseph Mingrone      { "Digest-Realm",                    NULL, 0, 0, print_attr_string },
728ee67461eSJoseph Mingrone      { "Digest-Nonce",                    NULL, 0, 0, print_attr_string },
729ee67461eSJoseph Mingrone      { "Digest-Response-Auth",            NULL, 0, 0, print_attr_string },
730ee67461eSJoseph Mingrone      { "Digest-Nextnonce",                NULL, 0, 0, print_attr_string },
731ee67461eSJoseph Mingrone      { "Digest-Method",                   NULL, 0, 0, print_attr_string },
732ee67461eSJoseph Mingrone      { "Digest-URI",                      NULL, 0, 0, print_attr_string },
733ee67461eSJoseph Mingrone      /* ^ [100, 109] ^ */
734ee67461eSJoseph Mingrone      { "Digest-Qop",                      NULL, 0, 0, print_attr_string },
735ee67461eSJoseph Mingrone      { "Digest-Algorithm",                NULL, 0, 0, print_attr_string },
736ee67461eSJoseph Mingrone      { "Digest-Entity-Body-Hash",         NULL, 0, 0, print_attr_string },
737ee67461eSJoseph Mingrone      { "Digest-CNonce",                   NULL, 0, 0, print_attr_string },
738ee67461eSJoseph Mingrone      { "Digest-Nonce-Count",              NULL, 0, 0, print_attr_string },
739ee67461eSJoseph Mingrone      { "Digest-Username",                 NULL, 0, 0, print_attr_string },
740ee67461eSJoseph Mingrone      { "Digest-Opaque",                   NULL, 0, 0, print_attr_string },
741ee67461eSJoseph Mingrone      { "Digest-Auth-Param",               NULL, 0, 0, print_attr_string },
742ee67461eSJoseph Mingrone      { "Digest-AKA-Auts",                 NULL, 0, 0, print_attr_string },
743ee67461eSJoseph Mingrone      { "Digest-Domain",                   NULL, 0, 0, print_attr_string },
744ee67461eSJoseph Mingrone      /* ^ [110, 119] ^ */
745ee67461eSJoseph Mingrone      { "Digest-Stale",                    NULL, 0, 0, print_attr_string },
746ee67461eSJoseph Mingrone      { "Digest-HA1",                      NULL, 0, 0, print_attr_string },
747ee67461eSJoseph Mingrone      { "SIP-AOR",                         NULL, 0, 0, print_attr_string },
748ee67461eSJoseph Mingrone      { "Delegated-IPv6-Prefix",           NULL, 0, 0, print_attr_netmask6 },
749ee67461eSJoseph Mingrone      { "MIP6-Feature-Vector",             NULL, 0, 0, print_attr_vector64 },
750ee67461eSJoseph Mingrone      { "MIP6-Home-Link-Prefix",           NULL, 0, 0, print_attr_mip6_home_link_prefix },
751ee67461eSJoseph Mingrone      { "Operator-Name",                   NULL, 0, 0, print_attr_operator_name },
752ee67461eSJoseph Mingrone      { "Location-Information",            NULL, 0, 0, print_attr_location_information },
753ee67461eSJoseph Mingrone      { "Location-Data",                   NULL, 0, 0, print_attr_location_data },
754ee67461eSJoseph Mingrone      { "Basic-Location-Policy-Rules",     NULL, 0, 0, print_basic_location_policy_rules }
755ee67461eSJoseph Mingrone      /* ^ [120, 129] ^ */
756685295f4SBill Fenner   };
757685295f4SBill Fenner 
758685295f4SBill Fenner 
759685295f4SBill Fenner /*****************************/
760685295f4SBill Fenner /* Print an attribute string */
761685295f4SBill Fenner /* value pointed by 'data'   */
762685295f4SBill Fenner /* and 'length' size.        */
763685295f4SBill Fenner /*****************************/
764685295f4SBill Fenner /* Returns nothing.          */
765685295f4SBill Fenner /*****************************/
766685295f4SBill Fenner static void
print_attr_string(netdissect_options * ndo,const u_char * data,u_int length,u_short attr_code)7673c602fabSXin LI print_attr_string(netdissect_options *ndo,
768ee67461eSJoseph Mingrone                   const u_char *data, u_int length, u_short attr_code)
769685295f4SBill Fenner {
770ee67461eSJoseph Mingrone    u_int i;
771685295f4SBill Fenner 
772ee67461eSJoseph Mingrone    ND_TCHECK_LEN(data, length);
773685295f4SBill Fenner 
774*0a7e5f1fSJoseph Mingrone    switch(attr_code) {
775685295f4SBill Fenner       case TUNNEL_PASS:
7762ebc47dbSSam Leffler            if (length < 3)
7770bff6a5aSEd Maste               goto trunc;
778ee67461eSJoseph Mingrone            if (GET_U_1(data) && (GET_U_1(data) <= 0x1F))
779ee67461eSJoseph Mingrone               ND_PRINT("Tag[%u] ", GET_U_1(data));
7808bdc5a62SPatrick Kelsey            else
781ee67461eSJoseph Mingrone               ND_PRINT("Tag[Unused] ");
782685295f4SBill Fenner            data++;
7832ebc47dbSSam Leffler            length--;
784ee67461eSJoseph Mingrone            ND_PRINT("Salt %u ", GET_BE_U_2(data));
785685295f4SBill Fenner            data+=2;
786685295f4SBill Fenner            length-=2;
787685295f4SBill Fenner         break;
788685295f4SBill Fenner       case TUNNEL_CLIENT_END:
789685295f4SBill Fenner       case TUNNEL_SERVER_END:
790685295f4SBill Fenner       case TUNNEL_PRIV_GROUP:
791685295f4SBill Fenner       case TUNNEL_ASSIGN_ID:
792685295f4SBill Fenner       case TUNNEL_CLIENT_AUTH:
793685295f4SBill Fenner       case TUNNEL_SERVER_AUTH:
794*0a7e5f1fSJoseph Mingrone            if (GET_U_1(data) <= 0x1F) {
7952ebc47dbSSam Leffler               if (length < 1)
7960bff6a5aSEd Maste                  goto trunc;
797ee67461eSJoseph Mingrone               if (GET_U_1(data))
798ee67461eSJoseph Mingrone                 ND_PRINT("Tag[%u] ", GET_U_1(data));
7998bdc5a62SPatrick Kelsey               else
800ee67461eSJoseph Mingrone                 ND_PRINT("Tag[Unused] ");
801685295f4SBill Fenner               data++;
802685295f4SBill Fenner               length--;
803685295f4SBill Fenner            }
804685295f4SBill Fenner         break;
8058bdc5a62SPatrick Kelsey       case EGRESS_VLAN_NAME:
8060bff6a5aSEd Maste            if (length < 1)
8070bff6a5aSEd Maste               goto trunc;
808ee67461eSJoseph Mingrone            ND_PRINT("%s (0x%02x) ",
809ee67461eSJoseph Mingrone                   tok2str(rfc4675_tagged,"Unknown tag",GET_U_1(data)),
810ee67461eSJoseph Mingrone                   GET_U_1(data));
8118bdc5a62SPatrick Kelsey            data++;
8128bdc5a62SPatrick Kelsey            length--;
8138bdc5a62SPatrick Kelsey         break;
814ee67461eSJoseph Mingrone       case EAP_MESSAGE:
815ee67461eSJoseph Mingrone            if (length < 1)
816ee67461eSJoseph Mingrone               goto trunc;
817ee67461eSJoseph Mingrone            eap_print(ndo, data, length);
818ee67461eSJoseph Mingrone            return;
819685295f4SBill Fenner    }
820685295f4SBill Fenner 
821ee67461eSJoseph Mingrone    for (i=0; i < length && GET_U_1(data); i++, data++)
822ee67461eSJoseph Mingrone        ND_PRINT("%c", ND_ASCII_ISPRINT(GET_U_1(data)) ? GET_U_1(data) : '.');
823685295f4SBill Fenner 
824685295f4SBill Fenner    return;
825685295f4SBill Fenner 
826685295f4SBill Fenner    trunc:
827ee67461eSJoseph Mingrone       nd_print_trunc(ndo);
828685295f4SBill Fenner }
829685295f4SBill Fenner 
8305b0fe478SBruce M Simpson /*
8315b0fe478SBruce M Simpson  * print vendor specific attributes
8325b0fe478SBruce M Simpson  */
8335b0fe478SBruce M Simpson static void
print_vendor_attr(netdissect_options * ndo,const u_char * data,u_int length,u_short attr_code _U_)8343c602fabSXin LI print_vendor_attr(netdissect_options *ndo,
835ee67461eSJoseph Mingrone                   const u_char *data, u_int length, u_short attr_code _U_)
8365b0fe478SBruce M Simpson {
8375b0fe478SBruce M Simpson     u_int idx;
8385b0fe478SBruce M Simpson     u_int vendor_id;
8395b0fe478SBruce M Simpson     u_int vendor_type;
8405b0fe478SBruce M Simpson     u_int vendor_length;
8415b0fe478SBruce M Simpson 
8422ebc47dbSSam Leffler     if (length < 4)
8432ebc47dbSSam Leffler         goto trunc;
844ee67461eSJoseph Mingrone     vendor_id = GET_BE_U_4(data);
8455b0fe478SBruce M Simpson     data+=4;
8465b0fe478SBruce M Simpson     length-=4;
8475b0fe478SBruce M Simpson 
848ee67461eSJoseph Mingrone     ND_PRINT("Vendor: %s (%u)",
8495b0fe478SBruce M Simpson            tok2str(smi_values,"Unknown",vendor_id),
850ee67461eSJoseph Mingrone            vendor_id);
8515b0fe478SBruce M Simpson 
8525b0fe478SBruce M Simpson     while (length >= 2) {
853ee67461eSJoseph Mingrone         vendor_type = GET_U_1(data);
854ee67461eSJoseph Mingrone         vendor_length = GET_U_1(data + 1);
8555b0fe478SBruce M Simpson 
856*0a7e5f1fSJoseph Mingrone         if (vendor_length < 2) {
857ee67461eSJoseph Mingrone             ND_PRINT("\n\t    Vendor Attribute: %u, Length: %u (bogus, must be >= 2)",
8582ebc47dbSSam Leffler                    vendor_type,
859ee67461eSJoseph Mingrone                    vendor_length);
8605b0fe478SBruce M Simpson             return;
8612ebc47dbSSam Leffler         }
862*0a7e5f1fSJoseph Mingrone         if (vendor_length > length) {
863ee67461eSJoseph Mingrone             ND_PRINT("\n\t    Vendor Attribute: %u, Length: %u (bogus, goes past end of vendor-specific attribute)",
8642ebc47dbSSam Leffler                    vendor_type,
865ee67461eSJoseph Mingrone                    vendor_length);
8662ebc47dbSSam Leffler             return;
8672ebc47dbSSam Leffler         }
8682ebc47dbSSam Leffler         data+=2;
8692ebc47dbSSam Leffler         vendor_length-=2;
8702ebc47dbSSam Leffler         length-=2;
871ee67461eSJoseph Mingrone 	ND_TCHECK_LEN(data, vendor_length);
8725b0fe478SBruce M Simpson 
873ee67461eSJoseph Mingrone         ND_PRINT("\n\t    Vendor Attribute: %u, Length: %u, Value: ",
8745b0fe478SBruce M Simpson                vendor_type,
875ee67461eSJoseph Mingrone                vendor_length);
8765b0fe478SBruce M Simpson         for (idx = 0; idx < vendor_length ; idx++, data++)
877ee67461eSJoseph Mingrone             ND_PRINT("%c", ND_ASCII_ISPRINT(GET_U_1(data)) ? GET_U_1(data) : '.');
8785b0fe478SBruce M Simpson         length-=vendor_length;
8795b0fe478SBruce M Simpson     }
8802ebc47dbSSam Leffler     return;
8812ebc47dbSSam Leffler 
8822ebc47dbSSam Leffler    trunc:
883ee67461eSJoseph Mingrone      nd_print_trunc(ndo);
8845b0fe478SBruce M Simpson }
8855b0fe478SBruce M Simpson 
886685295f4SBill Fenner /******************************/
887685295f4SBill Fenner /* Print an attribute numeric */
888685295f4SBill Fenner /* value pointed by 'data'    */
889685295f4SBill Fenner /* and 'length' size.         */
890685295f4SBill Fenner /******************************/
891685295f4SBill Fenner /* Returns nothing.           */
892685295f4SBill Fenner /******************************/
893685295f4SBill Fenner static void
print_attr_num(netdissect_options * ndo,const u_char * data,u_int length,u_short attr_code)8943c602fabSXin LI print_attr_num(netdissect_options *ndo,
895ee67461eSJoseph Mingrone                const u_char *data, u_int length, u_short attr_code)
896685295f4SBill Fenner {
8973c602fabSXin LI    uint32_t timeout;
898685295f4SBill Fenner 
899*0a7e5f1fSJoseph Mingrone    if (length != 4) {
900ee67461eSJoseph Mingrone        ND_PRINT("ERROR: length %u != 4", length);
901685295f4SBill Fenner        return;
902685295f4SBill Fenner    }
903685295f4SBill Fenner 
904685295f4SBill Fenner                           /* This attribute has standard values */
905*0a7e5f1fSJoseph Mingrone    if (attr_type[attr_code].siz_subtypes) {
906685295f4SBill Fenner       static const char **table;
9073c602fabSXin LI       uint32_t data_value;
908685295f4SBill Fenner       table = attr_type[attr_code].subtypes;
909685295f4SBill Fenner 
910*0a7e5f1fSJoseph Mingrone       if ( (attr_code == TUNNEL_TYPE) || (attr_code == TUNNEL_MEDIUM) ) {
911ee67461eSJoseph Mingrone          if (!GET_U_1(data))
912ee67461eSJoseph Mingrone             ND_PRINT("Tag[Unused] ");
913685295f4SBill Fenner          else
914ee67461eSJoseph Mingrone             ND_PRINT("Tag[%u] ", GET_U_1(data));
915685295f4SBill Fenner          data++;
916ee67461eSJoseph Mingrone          data_value = GET_BE_U_3(data);
917*0a7e5f1fSJoseph Mingrone       } else {
918ee67461eSJoseph Mingrone          data_value = GET_BE_U_4(data);
919685295f4SBill Fenner       }
9203c602fabSXin LI       if ( data_value <= (uint32_t)(attr_type[attr_code].siz_subtypes - 1 +
9219afd0c29SBill Fenner             attr_type[attr_code].first_subtype) &&
9229afd0c29SBill Fenner 	   data_value >= attr_type[attr_code].first_subtype )
923ee67461eSJoseph Mingrone          ND_PRINT("%s", table[data_value]);
924685295f4SBill Fenner       else
925ee67461eSJoseph Mingrone          ND_PRINT("#%u", data_value);
926*0a7e5f1fSJoseph Mingrone    } else {
927685295f4SBill Fenner       switch(attr_code) /* Be aware of special cases... */
928685295f4SBill Fenner       {
929685295f4SBill Fenner         case FRM_IPX:
930ee67461eSJoseph Mingrone              if (GET_BE_U_4(data) == 0xFFFFFFFE )
931ee67461eSJoseph Mingrone                 ND_PRINT("NAS Select");
932685295f4SBill Fenner              else
933ee67461eSJoseph Mingrone                 ND_PRINT("%u", GET_BE_U_4(data));
934685295f4SBill Fenner           break;
935685295f4SBill Fenner 
936685295f4SBill Fenner         case SESSION_TIMEOUT:
937685295f4SBill Fenner         case IDLE_TIMEOUT:
938685295f4SBill Fenner         case ACCT_DELAY:
939685295f4SBill Fenner         case ACCT_SESSION_TIME:
940685295f4SBill Fenner         case ACCT_INT_INTERVAL:
941ee67461eSJoseph Mingrone              timeout = GET_BE_U_4(data);
942685295f4SBill Fenner              if ( timeout < 60 )
943ee67461eSJoseph Mingrone                 ND_PRINT("%02d secs", timeout);
944*0a7e5f1fSJoseph Mingrone              else {
945685295f4SBill Fenner                 if ( timeout < 3600 )
946ee67461eSJoseph Mingrone                    ND_PRINT("%02d:%02d min",
947ee67461eSJoseph Mingrone                           timeout / 60, timeout % 60);
948685295f4SBill Fenner                 else
949ee67461eSJoseph Mingrone                    ND_PRINT("%02d:%02d:%02d hours",
950685295f4SBill Fenner                           timeout / 3600, (timeout % 3600) / 60,
951ee67461eSJoseph Mingrone                           timeout % 60);
952685295f4SBill Fenner              }
953685295f4SBill Fenner           break;
954685295f4SBill Fenner 
955685295f4SBill Fenner         case FRM_ATALK_LINK:
956ee67461eSJoseph Mingrone              if (GET_BE_U_4(data))
957ee67461eSJoseph Mingrone                 ND_PRINT("%u", GET_BE_U_4(data));
958685295f4SBill Fenner              else
959ee67461eSJoseph Mingrone                 ND_PRINT("Unnumbered");
960685295f4SBill Fenner           break;
961685295f4SBill Fenner 
962685295f4SBill Fenner         case FRM_ATALK_NETWORK:
963ee67461eSJoseph Mingrone              if (GET_BE_U_4(data))
964ee67461eSJoseph Mingrone                 ND_PRINT("%u", GET_BE_U_4(data));
965685295f4SBill Fenner              else
966ee67461eSJoseph Mingrone                 ND_PRINT("NAS assigned");
967685295f4SBill Fenner           break;
968685295f4SBill Fenner 
969685295f4SBill Fenner         case TUNNEL_PREFERENCE:
970ee67461eSJoseph Mingrone             if (GET_U_1(data))
971ee67461eSJoseph Mingrone                ND_PRINT("Tag[%u] ", GET_U_1(data));
972685295f4SBill Fenner             else
973ee67461eSJoseph Mingrone                ND_PRINT("Tag[Unused] ");
9748bdc5a62SPatrick Kelsey             data++;
975ee67461eSJoseph Mingrone             ND_PRINT("%u", GET_BE_U_3(data));
9768bdc5a62SPatrick Kelsey           break;
9778bdc5a62SPatrick Kelsey 
9788bdc5a62SPatrick Kelsey         case EGRESS_VLAN_ID:
979ee67461eSJoseph Mingrone             ND_PRINT("%s (0x%02x) ",
980ee67461eSJoseph Mingrone                    tok2str(rfc4675_tagged,"Unknown tag",GET_U_1(data)),
981ee67461eSJoseph Mingrone                    GET_U_1(data));
9828bdc5a62SPatrick Kelsey             data++;
983ee67461eSJoseph Mingrone             ND_PRINT("%u", GET_BE_U_3(data));
984685295f4SBill Fenner           break;
985685295f4SBill Fenner 
986685295f4SBill Fenner         default:
987ee67461eSJoseph Mingrone              ND_PRINT("%u", GET_BE_U_4(data));
988685295f4SBill Fenner           break;
989685295f4SBill Fenner 
990685295f4SBill Fenner       } /* switch */
991685295f4SBill Fenner 
992685295f4SBill Fenner    } /* if-else */
993685295f4SBill Fenner }
994685295f4SBill Fenner 
995685295f4SBill Fenner /*****************************/
996685295f4SBill Fenner /* Print an attribute IPv4   */
997685295f4SBill Fenner /* address value pointed by  */
998685295f4SBill Fenner /* 'data' and 'length' size. */
999685295f4SBill Fenner /*****************************/
1000685295f4SBill Fenner /* Returns nothing.          */
1001685295f4SBill Fenner /*****************************/
1002685295f4SBill Fenner static void
print_attr_address(netdissect_options * ndo,const u_char * data,u_int length,u_short attr_code)10033c602fabSXin LI print_attr_address(netdissect_options *ndo,
1004ee67461eSJoseph Mingrone                    const u_char *data, u_int length, u_short attr_code)
1005685295f4SBill Fenner {
1006*0a7e5f1fSJoseph Mingrone    if (length != 4) {
1007ee67461eSJoseph Mingrone        ND_PRINT("ERROR: length %u != 4", length);
1008685295f4SBill Fenner        return;
1009685295f4SBill Fenner    }
1010685295f4SBill Fenner 
1011*0a7e5f1fSJoseph Mingrone    switch(attr_code) {
1012685295f4SBill Fenner       case FRM_IPADDR:
1013685295f4SBill Fenner       case LOG_IPHOST:
1014ee67461eSJoseph Mingrone            if (GET_BE_U_4(data) == 0xFFFFFFFF )
1015ee67461eSJoseph Mingrone               ND_PRINT("User Selected");
1016685295f4SBill Fenner            else
1017ee67461eSJoseph Mingrone               if (GET_BE_U_4(data) == 0xFFFFFFFE )
1018ee67461eSJoseph Mingrone                  ND_PRINT("NAS Select");
1019685295f4SBill Fenner               else
1020ee67461eSJoseph Mingrone                  ND_PRINT("%s",GET_IPADDR_STRING(data));
1021685295f4SBill Fenner       break;
1022685295f4SBill Fenner 
1023685295f4SBill Fenner       default:
1024ee67461eSJoseph Mingrone           ND_PRINT("%s", GET_IPADDR_STRING(data));
1025685295f4SBill Fenner       break;
1026685295f4SBill Fenner    }
1027ee67461eSJoseph Mingrone }
1028ee67461eSJoseph Mingrone 
1029ee67461eSJoseph Mingrone /*****************************/
1030ee67461eSJoseph Mingrone /* Print an attribute IPv6   */
1031ee67461eSJoseph Mingrone /* address value pointed by  */
1032ee67461eSJoseph Mingrone /* 'data' and 'length' size. */
1033ee67461eSJoseph Mingrone /*****************************/
1034ee67461eSJoseph Mingrone /* Returns nothing.          */
1035ee67461eSJoseph Mingrone /*****************************/
1036ee67461eSJoseph Mingrone static void
print_attr_address6(netdissect_options * ndo,const u_char * data,u_int length,u_short attr_code _U_)1037ee67461eSJoseph Mingrone print_attr_address6(netdissect_options *ndo,
1038ee67461eSJoseph Mingrone                    const u_char *data, u_int length, u_short attr_code _U_)
1039ee67461eSJoseph Mingrone {
1040*0a7e5f1fSJoseph Mingrone    if (length != 16) {
1041ee67461eSJoseph Mingrone        ND_PRINT("ERROR: length %u != 16", length);
1042ee67461eSJoseph Mingrone        return;
1043ee67461eSJoseph Mingrone    }
1044ee67461eSJoseph Mingrone 
1045ee67461eSJoseph Mingrone    ND_PRINT("%s", GET_IP6ADDR_STRING(data));
1046ee67461eSJoseph Mingrone }
1047ee67461eSJoseph Mingrone 
1048ee67461eSJoseph Mingrone static void
print_attr_netmask6(netdissect_options * ndo,const u_char * data,u_int length,u_short attr_code _U_)1049ee67461eSJoseph Mingrone print_attr_netmask6(netdissect_options *ndo,
1050ee67461eSJoseph Mingrone                     const u_char *data, u_int length, u_short attr_code _U_)
1051ee67461eSJoseph Mingrone {
1052ee67461eSJoseph Mingrone    u_char data2[16];
1053ee67461eSJoseph Mingrone 
1054*0a7e5f1fSJoseph Mingrone    if (length < 2 || length > 18) {
1055ee67461eSJoseph Mingrone        ND_PRINT("ERROR: length %u not in range (2..18)", length);
1056ee67461eSJoseph Mingrone        return;
1057ee67461eSJoseph Mingrone    }
1058ee67461eSJoseph Mingrone    ND_TCHECK_LEN(data, length);
1059*0a7e5f1fSJoseph Mingrone    if (GET_U_1(data + 1) > 128) {
1060ee67461eSJoseph Mingrone       ND_PRINT("ERROR: netmask %u not in range (0..128)", GET_U_1(data + 1));
1061ee67461eSJoseph Mingrone       return;
1062ee67461eSJoseph Mingrone    }
1063ee67461eSJoseph Mingrone 
1064ee67461eSJoseph Mingrone    memset(data2, 0, sizeof(data2));
1065ee67461eSJoseph Mingrone    if (length > 2)
1066ee67461eSJoseph Mingrone       memcpy(data2, data+2, length-2);
1067ee67461eSJoseph Mingrone 
1068ee67461eSJoseph Mingrone    ND_PRINT("%s/%u", ip6addr_string(ndo, data2), GET_U_1(data + 1)); /* local buffer, not packet data; don't use GET_IP6ADDR_STRING() */
1069ee67461eSJoseph Mingrone 
1070ee67461eSJoseph Mingrone    if (GET_U_1(data + 1) > 8 * (length - 2))
1071ee67461eSJoseph Mingrone       ND_PRINT(" (inconsistent prefix length)");
1072ee67461eSJoseph Mingrone 
1073ee67461eSJoseph Mingrone    return;
1074ee67461eSJoseph Mingrone 
1075ee67461eSJoseph Mingrone    trunc:
1076ee67461eSJoseph Mingrone      nd_print_trunc(ndo);
1077ee67461eSJoseph Mingrone }
1078ee67461eSJoseph Mingrone 
1079ee67461eSJoseph Mingrone static void
print_attr_mip6_home_link_prefix(netdissect_options * ndo,const u_char * data,u_int length,u_short attr_code _U_)1080ee67461eSJoseph Mingrone print_attr_mip6_home_link_prefix(netdissect_options *ndo,
1081ee67461eSJoseph Mingrone                     const u_char *data, u_int length, u_short attr_code _U_)
1082ee67461eSJoseph Mingrone {
1083*0a7e5f1fSJoseph Mingrone    if (length != 17) {
1084ee67461eSJoseph Mingrone       ND_PRINT("ERROR: length %u != 17", length);
1085ee67461eSJoseph Mingrone       return;
1086ee67461eSJoseph Mingrone    }
1087ee67461eSJoseph Mingrone    ND_TCHECK_LEN(data, length);
1088*0a7e5f1fSJoseph Mingrone    if (GET_U_1(data) > 128) {
1089ee67461eSJoseph Mingrone       ND_PRINT("ERROR: netmask %u not in range (0..128)", GET_U_1(data));
1090ee67461eSJoseph Mingrone       return;
1091ee67461eSJoseph Mingrone    }
1092ee67461eSJoseph Mingrone 
1093ee67461eSJoseph Mingrone    ND_PRINT("%s/%u", GET_IP6ADDR_STRING(data + 1), GET_U_1(data));
1094ee67461eSJoseph Mingrone 
1095ee67461eSJoseph Mingrone    return;
1096ee67461eSJoseph Mingrone 
1097ee67461eSJoseph Mingrone    trunc:
1098ee67461eSJoseph Mingrone      nd_print_trunc(ndo);
1099ee67461eSJoseph Mingrone }
1100ee67461eSJoseph Mingrone 
1101ee67461eSJoseph Mingrone static void
print_attr_operator_name(netdissect_options * ndo,const u_char * data,u_int length,u_short attr_code _U_)1102ee67461eSJoseph Mingrone print_attr_operator_name(netdissect_options *ndo,
1103ee67461eSJoseph Mingrone                     const u_char *data, u_int length, u_short attr_code _U_)
1104ee67461eSJoseph Mingrone {
1105ee67461eSJoseph Mingrone    u_int namespace_value;
1106ee67461eSJoseph Mingrone 
1107ee67461eSJoseph Mingrone    ND_TCHECK_LEN(data, length);
1108*0a7e5f1fSJoseph Mingrone    if (length < 2) {
1109ee67461eSJoseph Mingrone       ND_PRINT("ERROR: length %u < 2", length);
1110ee67461eSJoseph Mingrone       return;
1111ee67461eSJoseph Mingrone    }
1112ee67461eSJoseph Mingrone    namespace_value = GET_U_1(data);
1113ee67461eSJoseph Mingrone    data++;
1114ee67461eSJoseph Mingrone    ND_PRINT("[%s] ", tok2str(operator_name_vector, "unknown namespace %u", namespace_value));
1115ee67461eSJoseph Mingrone 
1116ee67461eSJoseph Mingrone    (void)nd_printn(ndo, data, length - 1, NULL);
1117ee67461eSJoseph Mingrone 
1118ee67461eSJoseph Mingrone    return;
1119ee67461eSJoseph Mingrone 
1120ee67461eSJoseph Mingrone    trunc:
1121ee67461eSJoseph Mingrone       nd_print_trunc(ndo);
1122ee67461eSJoseph Mingrone }
1123ee67461eSJoseph Mingrone 
1124ee67461eSJoseph Mingrone static void
print_attr_location_information(netdissect_options * ndo,const u_char * data,u_int length,u_short attr_code _U_)1125ee67461eSJoseph Mingrone print_attr_location_information(netdissect_options *ndo,
1126ee67461eSJoseph Mingrone                     const u_char *data, u_int length, u_short attr_code _U_)
1127ee67461eSJoseph Mingrone {
1128ee67461eSJoseph Mingrone    uint16_t index;
1129ee67461eSJoseph Mingrone    uint8_t code, entity;
1130ee67461eSJoseph Mingrone 
1131ee67461eSJoseph Mingrone    ND_TCHECK_LEN(data, length);
1132*0a7e5f1fSJoseph Mingrone    if (length < 21) {
1133ee67461eSJoseph Mingrone      ND_PRINT("ERROR: length %u < 21", length);
1134ee67461eSJoseph Mingrone       return;
1135ee67461eSJoseph Mingrone    }
1136ee67461eSJoseph Mingrone 
1137ee67461eSJoseph Mingrone    index = GET_BE_U_2(data);
1138ee67461eSJoseph Mingrone    data += 2;
1139ee67461eSJoseph Mingrone 
1140ee67461eSJoseph Mingrone    code = GET_U_1(data);
1141ee67461eSJoseph Mingrone    data++;
1142ee67461eSJoseph Mingrone 
1143ee67461eSJoseph Mingrone    entity = GET_U_1(data);
1144ee67461eSJoseph Mingrone    data++;
1145ee67461eSJoseph Mingrone 
1146ee67461eSJoseph Mingrone    ND_PRINT("index %u, code %s, entity %s, ",
1147ee67461eSJoseph Mingrone        index,
1148ee67461eSJoseph Mingrone        tok2str(location_information_code_vector, "Unknown (%u)", code),
1149ee67461eSJoseph Mingrone        tok2str(location_information_entity_vector, "Unknown (%u)", entity)
1150ee67461eSJoseph Mingrone    );
1151ee67461eSJoseph Mingrone 
1152ee67461eSJoseph Mingrone    ND_PRINT("sighting time ");
1153ee67461eSJoseph Mingrone    p_ntp_time(ndo, (const struct l_fixedpt *)data);
1154ee67461eSJoseph Mingrone    ND_PRINT(", ");
1155ee67461eSJoseph Mingrone    data += 8;
1156ee67461eSJoseph Mingrone 
1157ee67461eSJoseph Mingrone    ND_PRINT("time to live ");
1158ee67461eSJoseph Mingrone    p_ntp_time(ndo, (const struct l_fixedpt *)data);
1159ee67461eSJoseph Mingrone    ND_PRINT(", ");
1160ee67461eSJoseph Mingrone    data += 8;
1161ee67461eSJoseph Mingrone 
1162ee67461eSJoseph Mingrone    ND_PRINT("method \"");
1163ee67461eSJoseph Mingrone    (void)nd_printn(ndo, data, length - 20, NULL);
1164ee67461eSJoseph Mingrone    ND_PRINT("\"");
1165ee67461eSJoseph Mingrone 
1166ee67461eSJoseph Mingrone    return;
1167ee67461eSJoseph Mingrone 
1168ee67461eSJoseph Mingrone    trunc:
1169ee67461eSJoseph Mingrone       nd_print_trunc(ndo);
1170ee67461eSJoseph Mingrone }
1171ee67461eSJoseph Mingrone 
1172ee67461eSJoseph Mingrone static void
print_attr_location_data(netdissect_options * ndo,const u_char * data,u_int length,u_short attr_code _U_)1173ee67461eSJoseph Mingrone print_attr_location_data(netdissect_options *ndo,
1174ee67461eSJoseph Mingrone                     const u_char *data, u_int length, u_short attr_code _U_)
1175ee67461eSJoseph Mingrone {
1176ee67461eSJoseph Mingrone    uint16_t index;
1177ee67461eSJoseph Mingrone 
1178ee67461eSJoseph Mingrone    ND_TCHECK_LEN(data, length);
1179*0a7e5f1fSJoseph Mingrone    if (length < 3) {
1180ee67461eSJoseph Mingrone      ND_PRINT("ERROR: length %u < 3", length);
1181ee67461eSJoseph Mingrone       return;
1182ee67461eSJoseph Mingrone    }
1183ee67461eSJoseph Mingrone 
1184ee67461eSJoseph Mingrone    index = GET_BE_U_2(data);
1185ee67461eSJoseph Mingrone    data += 2;
1186ee67461eSJoseph Mingrone    ND_PRINT("index %u, location", index);
1187ee67461eSJoseph Mingrone 
1188ee67461eSJoseph Mingrone    /* The Location field of the String field of the Location-Data attribute
1189ee67461eSJoseph Mingrone     * can have two completely different structures depending on the value of
1190ee67461eSJoseph Mingrone     * the Code field of a Location-Info attribute, which supposedly precedes
1191ee67461eSJoseph Mingrone     * the current attribute. Unfortunately, this choice of encoding makes it
1192ee67461eSJoseph Mingrone     * non-trivial to decode the Location field without preserving some state
1193ee67461eSJoseph Mingrone     * between the attributes.
1194ee67461eSJoseph Mingrone     */
1195ee67461eSJoseph Mingrone    hex_and_ascii_print(ndo, "\n\t    ", data, length - 2);
1196ee67461eSJoseph Mingrone 
1197ee67461eSJoseph Mingrone    return;
1198ee67461eSJoseph Mingrone 
1199ee67461eSJoseph Mingrone    trunc:
1200ee67461eSJoseph Mingrone       nd_print_trunc(ndo);
1201ee67461eSJoseph Mingrone }
1202ee67461eSJoseph Mingrone 
1203ee67461eSJoseph Mingrone static void
print_basic_location_policy_rules(netdissect_options * ndo,const u_char * data,u_int length,u_short attr_code _U_)1204ee67461eSJoseph Mingrone print_basic_location_policy_rules(netdissect_options *ndo,
1205ee67461eSJoseph Mingrone                     const u_char *data, u_int length, u_short attr_code _U_)
1206ee67461eSJoseph Mingrone {
1207ee67461eSJoseph Mingrone    uint16_t flags;
1208ee67461eSJoseph Mingrone 
1209ee67461eSJoseph Mingrone    ND_TCHECK_LEN(data, length);
1210*0a7e5f1fSJoseph Mingrone    if (length < 10) {
1211ee67461eSJoseph Mingrone      ND_PRINT("ERROR: length %u < 10", length);
1212ee67461eSJoseph Mingrone       return;
1213ee67461eSJoseph Mingrone    }
1214ee67461eSJoseph Mingrone 
1215ee67461eSJoseph Mingrone    flags = GET_BE_U_2(data);
1216ee67461eSJoseph Mingrone    data += 2;
1217ee67461eSJoseph Mingrone    ND_PRINT("flags [%s], ", bittok2str(blpr_bm, "none", flags));
1218ee67461eSJoseph Mingrone 
1219ee67461eSJoseph Mingrone    ND_PRINT("retention expires ");
1220ee67461eSJoseph Mingrone    p_ntp_time(ndo, (const struct l_fixedpt *)data);
1221ee67461eSJoseph Mingrone    data += 8;
1222ee67461eSJoseph Mingrone 
1223ee67461eSJoseph Mingrone    if (length > 10) {
1224ee67461eSJoseph Mingrone       ND_PRINT(", note well \"");
1225ee67461eSJoseph Mingrone       (void)nd_printn(ndo, data, length - 10, NULL);
1226ee67461eSJoseph Mingrone       ND_PRINT("\"");
1227ee67461eSJoseph Mingrone    }
1228685295f4SBill Fenner 
1229685295f4SBill Fenner    return;
1230685295f4SBill Fenner 
1231685295f4SBill Fenner    trunc:
1232ee67461eSJoseph Mingrone       nd_print_trunc(ndo);
1233685295f4SBill Fenner }
1234685295f4SBill Fenner 
1235ee67461eSJoseph Mingrone 
1236685295f4SBill Fenner /*************************************/
1237685295f4SBill Fenner /* Print an attribute of 'secs since */
1238685295f4SBill Fenner /* January 1, 1970 00:00 UTC' value  */
1239685295f4SBill Fenner /* pointed by 'data' and 'length'    */
1240685295f4SBill Fenner /* size.                             */
1241685295f4SBill Fenner /*************************************/
1242685295f4SBill Fenner /* Returns nothing.                  */
1243685295f4SBill Fenner /*************************************/
12443c602fabSXin LI static void
print_attr_time(netdissect_options * ndo,const u_char * data,u_int length,u_short attr_code _U_)12453c602fabSXin LI print_attr_time(netdissect_options *ndo,
1246ee67461eSJoseph Mingrone                 const u_char *data, u_int length, u_short attr_code _U_)
1247685295f4SBill Fenner {
1248685295f4SBill Fenner    time_t attr_time;
1249685295f4SBill Fenner    char string[26];
1250685295f4SBill Fenner 
1251*0a7e5f1fSJoseph Mingrone    if (length != 4) {
1252ee67461eSJoseph Mingrone        ND_PRINT("ERROR: length %u != 4", length);
1253685295f4SBill Fenner        return;
1254685295f4SBill Fenner    }
1255685295f4SBill Fenner 
1256ee67461eSJoseph Mingrone    attr_time = GET_BE_U_4(data);
1257a90e161bSBill Fenner    strlcpy(string, ctime(&attr_time), sizeof(string));
1258685295f4SBill Fenner    /* Get rid of the newline */
1259685295f4SBill Fenner    string[24] = '\0';
1260ee67461eSJoseph Mingrone    ND_PRINT("%.24s", string);
1261ee67461eSJoseph Mingrone }
1262685295f4SBill Fenner 
1263ee67461eSJoseph Mingrone static void
print_attr_vector64(netdissect_options * ndo,const u_char * data,u_int length,u_short attr_code _U_)1264ee67461eSJoseph Mingrone print_attr_vector64(netdissect_options *ndo,
1265*0a7e5f1fSJoseph Mingrone 		    const u_char *data, u_int length, u_short attr_code _U_)
1266ee67461eSJoseph Mingrone {
1267ee67461eSJoseph Mingrone    uint64_t data_value, i;
1268ee67461eSJoseph Mingrone    const char *sep = "";
1269ee67461eSJoseph Mingrone 
1270*0a7e5f1fSJoseph Mingrone    if (length != 8) {
1271ee67461eSJoseph Mingrone        ND_PRINT("ERROR: length %u != 8", length);
1272ee67461eSJoseph Mingrone        return;
1273ee67461eSJoseph Mingrone    }
1274ee67461eSJoseph Mingrone 
1275ee67461eSJoseph Mingrone    ND_PRINT("[");
1276ee67461eSJoseph Mingrone 
1277ee67461eSJoseph Mingrone    data_value = GET_BE_U_8(data);
1278ee67461eSJoseph Mingrone    /* Print the 64-bit field in a format similar to bittok2str(), less
1279ee67461eSJoseph Mingrone     * flagging any unknown bits. This way it should be easier to replace
1280ee67461eSJoseph Mingrone     * the custom code with a library function later.
1281ee67461eSJoseph Mingrone     */
1282ee67461eSJoseph Mingrone    for (i = 0; i < TAM_SIZE(mip6_feature_vector); i++) {
1283ee67461eSJoseph Mingrone        if (data_value & mip6_feature_vector[i].v) {
1284ee67461eSJoseph Mingrone            ND_PRINT("%s%s", sep, mip6_feature_vector[i].s);
1285ee67461eSJoseph Mingrone            sep = ", ";
1286ee67461eSJoseph Mingrone        }
1287ee67461eSJoseph Mingrone    }
1288ee67461eSJoseph Mingrone 
1289ee67461eSJoseph Mingrone    ND_PRINT("]");
1290685295f4SBill Fenner }
1291685295f4SBill Fenner 
1292685295f4SBill Fenner /***********************************/
1293685295f4SBill Fenner /* Print an attribute of 'strange' */
1294685295f4SBill Fenner /* data format pointed by 'data'   */
1295685295f4SBill Fenner /* and 'length' size.              */
1296685295f4SBill Fenner /***********************************/
1297685295f4SBill Fenner /* Returns nothing.                */
1298685295f4SBill Fenner /***********************************/
12993c602fabSXin LI static void
print_attr_strange(netdissect_options * ndo,const u_char * data,u_int length,u_short attr_code)13003c602fabSXin LI print_attr_strange(netdissect_options *ndo,
1301ee67461eSJoseph Mingrone                    const u_char *data, u_int length, u_short attr_code)
1302685295f4SBill Fenner {
1303685295f4SBill Fenner    u_short len_data;
1304ee67461eSJoseph Mingrone    u_int error_cause_value;
1305685295f4SBill Fenner 
1306*0a7e5f1fSJoseph Mingrone    switch(attr_code) {
1307685295f4SBill Fenner       case ARAP_PASS:
1308*0a7e5f1fSJoseph Mingrone            if (length != 16) {
1309ee67461eSJoseph Mingrone                ND_PRINT("ERROR: length %u != 16", length);
1310685295f4SBill Fenner                return;
1311685295f4SBill Fenner            }
1312ee67461eSJoseph Mingrone            ND_PRINT("User_challenge (");
1313685295f4SBill Fenner            len_data = 8;
1314685295f4SBill Fenner            PRINT_HEX(len_data, data);
1315ee67461eSJoseph Mingrone            ND_PRINT(") User_resp(");
1316685295f4SBill Fenner            len_data = 8;
1317685295f4SBill Fenner            PRINT_HEX(len_data, data);
1318ee67461eSJoseph Mingrone            ND_PRINT(")");
1319685295f4SBill Fenner         break;
1320685295f4SBill Fenner 
1321685295f4SBill Fenner       case ARAP_FEATURES:
1322*0a7e5f1fSJoseph Mingrone            if (length != 14) {
1323ee67461eSJoseph Mingrone                ND_PRINT("ERROR: length %u != 14", length);
1324685295f4SBill Fenner                return;
1325685295f4SBill Fenner            }
1326ee67461eSJoseph Mingrone            if (GET_U_1(data))
1327ee67461eSJoseph Mingrone               ND_PRINT("User can change password");
1328685295f4SBill Fenner            else
1329ee67461eSJoseph Mingrone               ND_PRINT("User cannot change password");
1330685295f4SBill Fenner            data++;
1331ee67461eSJoseph Mingrone            ND_PRINT(", Min password length: %u", GET_U_1(data));
1332685295f4SBill Fenner            data++;
1333ee67461eSJoseph Mingrone            ND_PRINT(", created at: ");
1334685295f4SBill Fenner            len_data = 4;
1335685295f4SBill Fenner            PRINT_HEX(len_data, data);
1336ee67461eSJoseph Mingrone            ND_PRINT(", expires in: ");
1337685295f4SBill Fenner            len_data = 4;
1338685295f4SBill Fenner            PRINT_HEX(len_data, data);
1339ee67461eSJoseph Mingrone            ND_PRINT(", Current Time: ");
13402ebc47dbSSam Leffler            len_data = 4;
1341685295f4SBill Fenner            PRINT_HEX(len_data, data);
1342685295f4SBill Fenner         break;
1343685295f4SBill Fenner 
1344685295f4SBill Fenner       case ARAP_CHALLENGE_RESP:
1345*0a7e5f1fSJoseph Mingrone            if (length < 8) {
1346ee67461eSJoseph Mingrone                ND_PRINT("ERROR: length %u != 8", length);
1347685295f4SBill Fenner                return;
1348685295f4SBill Fenner            }
1349685295f4SBill Fenner            len_data = 8;
1350685295f4SBill Fenner            PRINT_HEX(len_data, data);
1351685295f4SBill Fenner         break;
1352ee67461eSJoseph Mingrone 
1353ee67461eSJoseph Mingrone       case ERROR_CAUSE:
1354*0a7e5f1fSJoseph Mingrone            if (length != 4) {
1355ee67461eSJoseph Mingrone                ND_PRINT("Error: length %u != 4", length);
1356ee67461eSJoseph Mingrone                return;
1357ee67461eSJoseph Mingrone            }
1358ee67461eSJoseph Mingrone 
1359ee67461eSJoseph Mingrone            error_cause_value = GET_BE_U_4(data);
1360ee67461eSJoseph Mingrone            ND_PRINT("Error cause %u: %s", error_cause_value, tok2str(errorcausetype, "Error-Cause %u not known", error_cause_value));
1361ee67461eSJoseph Mingrone         break;
1362685295f4SBill Fenner    }
13632ebc47dbSSam Leffler    return;
1364685295f4SBill Fenner }
1365685295f4SBill Fenner 
1366685295f4SBill Fenner static void
radius_attrs_print(netdissect_options * ndo,const u_char * attr,u_int length)13673c602fabSXin LI radius_attrs_print(netdissect_options *ndo,
1368ee67461eSJoseph Mingrone                    const u_char *attr, u_int length)
1369685295f4SBill Fenner {
1370ee67461eSJoseph Mingrone    const struct radius_attr *rad_attr = (const struct radius_attr *)attr;
13712ebc47dbSSam Leffler    const char *attr_string;
1372ee67461eSJoseph Mingrone    uint8_t type, len;
1373685295f4SBill Fenner 
1374*0a7e5f1fSJoseph Mingrone    while (length > 0) {
13752ebc47dbSSam Leffler      if (length < 2)
13762ebc47dbSSam Leffler         goto trunc;
1377ee67461eSJoseph Mingrone      ND_TCHECK_SIZE(rad_attr);
13782ebc47dbSSam Leffler 
1379ee67461eSJoseph Mingrone      type = GET_U_1(rad_attr->type);
1380ee67461eSJoseph Mingrone      len = GET_U_1(rad_attr->len);
1381ee67461eSJoseph Mingrone      if (type != 0 && type < TAM_SIZE(attr_type))
1382ee67461eSJoseph Mingrone 	attr_string = attr_type[type].name;
13832ebc47dbSSam Leffler      else
13842ebc47dbSSam Leffler 	attr_string = "Unknown";
1385685295f4SBill Fenner 
1386ee67461eSJoseph Mingrone      ND_PRINT("\n\t  %s Attribute (%u), length: %u",
1387ee67461eSJoseph Mingrone                attr_string,
1388ee67461eSJoseph Mingrone                type,
1389ee67461eSJoseph Mingrone                len);
1390*0a7e5f1fSJoseph Mingrone      if (len < 2) {
1391ee67461eSJoseph Mingrone        ND_PRINT(" (bogus, must be >= 2)");
1392ee67461eSJoseph Mingrone        return;
1393ee67461eSJoseph Mingrone      }
1394*0a7e5f1fSJoseph Mingrone      if (len > length) {
1395ee67461eSJoseph Mingrone         ND_PRINT(" (bogus, goes past end of packet)");
1396ee67461eSJoseph Mingrone         return;
1397ee67461eSJoseph Mingrone      }
1398ee67461eSJoseph Mingrone      ND_PRINT(", Value: ");
1399ee67461eSJoseph Mingrone 
1400*0a7e5f1fSJoseph Mingrone      if (type < TAM_SIZE(attr_type)) {
1401*0a7e5f1fSJoseph Mingrone          if (len > 2) {
1402ee67461eSJoseph Mingrone              if ( attr_type[type].print_func )
1403ee67461eSJoseph Mingrone                  (*attr_type[type].print_func)(
14043340d773SGleb Smirnoff                      ndo, ((const u_char *)(rad_attr+1)),
1405ee67461eSJoseph Mingrone                      len - 2, type);
1406685295f4SBill Fenner          }
1407685295f4SBill Fenner      }
14081de50e9fSSam Leffler      /* do we also want to see a hex dump ? */
14093c602fabSXin LI      if (ndo->ndo_vflag> 1)
1410ee67461eSJoseph Mingrone          print_unknown_data(ndo, (const u_char *)rad_attr+2, "\n\t    ", (len)-2);
14115b0fe478SBruce M Simpson 
1412ee67461eSJoseph Mingrone      length-=(len);
1413ee67461eSJoseph Mingrone      rad_attr = (const struct radius_attr *)( ((const char *)(rad_attr))+len);
1414685295f4SBill Fenner    }
14152ebc47dbSSam Leffler    return;
14162ebc47dbSSam Leffler 
14172ebc47dbSSam Leffler trunc:
1418ee67461eSJoseph Mingrone    nd_print_trunc(ndo);
1419685295f4SBill Fenner }
1420685295f4SBill Fenner 
1421685295f4SBill Fenner void
radius_print(netdissect_options * ndo,const u_char * dat,u_int length)14223c602fabSXin LI radius_print(netdissect_options *ndo,
14233c602fabSXin LI              const u_char *dat, u_int length)
1424685295f4SBill Fenner {
1425ee67461eSJoseph Mingrone    const struct radius_hdr *rad;
14265b0fe478SBruce M Simpson    u_int len, auth_idx;
1427685295f4SBill Fenner 
1428ee67461eSJoseph Mingrone    ndo->ndo_protocol = "radius";
1429ee67461eSJoseph Mingrone    ND_TCHECK_LEN(dat, MIN_RADIUS_LEN);
14303340d773SGleb Smirnoff    rad = (const struct radius_hdr *)dat;
1431ee67461eSJoseph Mingrone    len = GET_BE_U_2(rad->len);
1432a90e161bSBill Fenner 
1433*0a7e5f1fSJoseph Mingrone    if (len < MIN_RADIUS_LEN) {
1434ee67461eSJoseph Mingrone 	  nd_print_trunc(ndo);
1435a90e161bSBill Fenner 	  return;
1436a90e161bSBill Fenner    }
1437a90e161bSBill Fenner 
14382ebc47dbSSam Leffler    if (len > length)
14392ebc47dbSSam Leffler 	  len = length;
1440685295f4SBill Fenner 
14413c602fabSXin LI    if (ndo->ndo_vflag < 1) {
1442ee67461eSJoseph Mingrone        ND_PRINT("RADIUS, %s (%u), id: 0x%02x length: %u",
1443ee67461eSJoseph Mingrone               tok2str(radius_command_values,"Unknown Command",GET_U_1(rad->code)),
1444ee67461eSJoseph Mingrone               GET_U_1(rad->code),
1445ee67461eSJoseph Mingrone               GET_U_1(rad->id),
1446ee67461eSJoseph Mingrone               len);
14475b0fe478SBruce M Simpson        return;
1448*0a7e5f1fSJoseph Mingrone    } else {
1449ee67461eSJoseph Mingrone        ND_PRINT("RADIUS, length: %u\n\t%s (%u), id: 0x%02x, Authenticator: ",
14502ebc47dbSSam Leffler               len,
1451ee67461eSJoseph Mingrone               tok2str(radius_command_values,"Unknown Command",GET_U_1(rad->code)),
1452ee67461eSJoseph Mingrone               GET_U_1(rad->code),
1453ee67461eSJoseph Mingrone               GET_U_1(rad->id));
14545b0fe478SBruce M Simpson 
14555b0fe478SBruce M Simpson        for(auth_idx=0; auth_idx < 16; auth_idx++)
1456ee67461eSJoseph Mingrone             ND_PRINT("%02x", rad->auth[auth_idx]);
14575b0fe478SBruce M Simpson    }
1458685295f4SBill Fenner 
14592ebc47dbSSam Leffler    if (len > MIN_RADIUS_LEN)
14603c602fabSXin LI       radius_attrs_print(ndo, dat + MIN_RADIUS_LEN, len - MIN_RADIUS_LEN);
14612ebc47dbSSam Leffler    return;
14622ebc47dbSSam Leffler 
14632ebc47dbSSam Leffler trunc:
1464ee67461eSJoseph Mingrone    nd_print_trunc(ndo);
1465685295f4SBill Fenner }
1466