Home | History | Annotate | Line # | Download | only in dist
print-radius.c revision 1.10
      1   1.1  christos /*
      2   1.1  christos  * Copyright (C) 2000 Alfredo Andres Omella.  All rights reserved.
      3   1.1  christos  *
      4   1.1  christos  * Redistribution and use in source and binary forms, with or without
      5   1.1  christos  * modification, are permitted provided that the following conditions
      6   1.1  christos  * are met:
      7   1.1  christos  *
      8   1.1  christos  *   1. Redistributions of source code must retain the above copyright
      9   1.1  christos  *      notice, this list of conditions and the following disclaimer.
     10   1.1  christos  *   2. Redistributions in binary form must reproduce the above copyright
     11   1.1  christos  *      notice, this list of conditions and the following disclaimer in
     12   1.1  christos  *      the documentation and/or other materials provided with the
     13   1.1  christos  *      distribution.
     14   1.1  christos  *   3. The names of the authors may not be used to endorse or promote
     15   1.1  christos  *      products derived from this software without specific prior
     16   1.1  christos  *      written permission.
     17   1.1  christos  *
     18   1.1  christos  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
     19   1.1  christos  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
     20   1.1  christos  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
     21   1.1  christos  */
     22   1.8       spz 
     23   1.8       spz /* \summary: Radius protocol printer */
     24   1.8       spz 
     25   1.1  christos /*
     26   1.1  christos  * Radius printer routines as specified on:
     27   1.1  christos  *
     28   1.1  christos  * RFC 2865:
     29   1.1  christos  *      "Remote Authentication Dial In User Service (RADIUS)"
     30   1.1  christos  *
     31   1.1  christos  * RFC 2866:
     32   1.1  christos  *      "RADIUS Accounting"
     33   1.1  christos  *
     34   1.1  christos  * RFC 2867:
     35   1.1  christos  *      "RADIUS Accounting Modifications for Tunnel Protocol Support"
     36   1.1  christos  *
     37   1.1  christos  * RFC 2868:
     38   1.1  christos  *      "RADIUS Attributes for Tunnel Protocol Support"
     39   1.1  christos  *
     40   1.1  christos  * RFC 2869:
     41   1.1  christos  *      "RADIUS Extensions"
     42   1.1  christos  *
     43  1.10  christos  * RFC 3162:
     44  1.10  christos  *      "RADIUS and IPv6"
     45  1.10  christos  *
     46   1.7  christos  * RFC 3580:
     47   1.7  christos  *      "IEEE 802.1X Remote Authentication Dial In User Service (RADIUS)"
     48   1.7  christos  *      "Usage Guidelines"
     49   1.7  christos  *
     50  1.10  christos  * RFC 4072:
     51  1.10  christos  *      "Diameter Extensible Authentication Protocol (EAP) Application"
     52  1.10  christos  *
     53   1.6  christos  * RFC 4675:
     54   1.6  christos  *      "RADIUS Attributes for Virtual LAN and Priority Support"
     55   1.6  christos  *
     56  1.10  christos  * RFC 4818:
     57  1.10  christos  *      "RADIUS Delegated-IPv6-Prefix Attribute"
     58  1.10  christos  *
     59  1.10  christos  * RFC 4849:
     60  1.10  christos  *      "RADIUS Filter Rule Attribute"
     61  1.10  christos  *
     62  1.10  christos  * RFC 5090:
     63  1.10  christos  *      "RADIUS Extension for Digest Authentication"
     64  1.10  christos  *
     65   1.6  christos  * RFC 5176:
     66   1.6  christos  *      "Dynamic Authorization Extensions to RADIUS"
     67   1.6  christos  *
     68  1.10  christos  * RFC 5447:
     69  1.10  christos  *      "Diameter Mobile IPv6"
     70  1.10  christos  *
     71  1.10  christos  * RFC 5580:
     72  1.10  christos  *      "Carrying Location Objects in RADIUS and Diameter"
     73  1.10  christos  *
     74  1.10  christos  * RFC 6572:
     75  1.10  christos  *      "RADIUS Support for Proxy Mobile IPv6"
     76  1.10  christos  *
     77  1.10  christos  * RFC 7155:
     78  1.10  christos  *      "Diameter Network Access Server Application"
     79  1.10  christos  *
     80   1.1  christos  * Alfredo Andres Omella (aandres (at) s21sec.com) v0.1 2000/09/15
     81   1.1  christos  *
     82   1.1  christos  * TODO: Among other things to print ok MacIntosh and Vendor values
     83   1.1  christos  */
     84   1.1  christos 
     85   1.7  christos #include <sys/cdefs.h>
     86   1.7  christos #ifndef lint
     87  1.10  christos __RCSID("$NetBSD: print-radius.c,v 1.10 2023/08/17 20:19:40 christos Exp $");
     88   1.7  christos #endif
     89   1.7  christos 
     90   1.1  christos #ifdef HAVE_CONFIG_H
     91  1.10  christos #include <config.h>
     92   1.1  christos #endif
     93   1.1  christos 
     94  1.10  christos #include "netdissect-stdinc.h"
     95   1.1  christos 
     96   1.1  christos #include <string.h>
     97   1.1  christos 
     98  1.10  christos #include "netdissect-ctype.h"
     99  1.10  christos 
    100   1.7  christos #include "netdissect.h"
    101   1.1  christos #include "addrtoname.h"
    102   1.1  christos #include "extract.h"
    103   1.1  christos #include "oui.h"
    104  1.10  christos #include "ntp.h"
    105   1.1  christos 
    106   1.5  christos 
    107   1.1  christos #define TAM_SIZE(x) (sizeof(x)/sizeof(x[0]) )
    108   1.1  christos 
    109   1.1  christos #define PRINT_HEX(bytes_len, ptr_data)                               \
    110   1.1  christos            while(bytes_len)                                          \
    111   1.1  christos            {                                                         \
    112  1.10  christos               ND_PRINT("%02X", GET_U_1(ptr_data));                   \
    113   1.1  christos               ptr_data++;                                            \
    114   1.1  christos               bytes_len--;                                           \
    115   1.1  christos            }
    116   1.1  christos 
    117   1.1  christos 
    118   1.1  christos /* Radius packet codes */
    119  1.10  christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-27 */
    120   1.1  christos #define RADCMD_ACCESS_REQ   1 /* Access-Request      */
    121   1.1  christos #define RADCMD_ACCESS_ACC   2 /* Access-Accept       */
    122   1.1  christos #define RADCMD_ACCESS_REJ   3 /* Access-Reject       */
    123   1.1  christos #define RADCMD_ACCOUN_REQ   4 /* Accounting-Request  */
    124   1.1  christos #define RADCMD_ACCOUN_RES   5 /* Accounting-Response */
    125   1.1  christos #define RADCMD_ACCESS_CHA  11 /* Access-Challenge    */
    126   1.1  christos #define RADCMD_STATUS_SER  12 /* Status-Server       */
    127   1.1  christos #define RADCMD_STATUS_CLI  13 /* Status-Client       */
    128   1.6  christos #define RADCMD_DISCON_REQ  40 /* Disconnect-Request  */
    129   1.6  christos #define RADCMD_DISCON_ACK  41 /* Disconnect-ACK      */
    130   1.6  christos #define RADCMD_DISCON_NAK  42 /* Disconnect-NAK      */
    131   1.6  christos #define RADCMD_COA_REQ     43 /* CoA-Request         */
    132   1.6  christos #define RADCMD_COA_ACK     44 /* CoA-ACK             */
    133   1.6  christos #define RADCMD_COA_NAK     45 /* CoA-NAK             */
    134   1.1  christos #define RADCMD_RESERVED   255 /* Reserved            */
    135   1.1  christos 
    136   1.4  christos static const struct tok radius_command_values[] = {
    137   1.6  christos     { RADCMD_ACCESS_REQ, "Access-Request" },
    138   1.6  christos     { RADCMD_ACCESS_ACC, "Access-Accept" },
    139   1.6  christos     { RADCMD_ACCESS_REJ, "Access-Reject" },
    140   1.6  christos     { RADCMD_ACCOUN_REQ, "Accounting-Request" },
    141   1.6  christos     { RADCMD_ACCOUN_RES, "Accounting-Response" },
    142   1.6  christos     { RADCMD_ACCESS_CHA, "Access-Challenge" },
    143   1.6  christos     { RADCMD_STATUS_SER, "Status-Server" },
    144   1.6  christos     { RADCMD_STATUS_CLI, "Status-Client" },
    145   1.6  christos     { RADCMD_DISCON_REQ, "Disconnect-Request" },
    146   1.6  christos     { RADCMD_DISCON_ACK, "Disconnect-ACK" },
    147   1.6  christos     { RADCMD_DISCON_NAK, "Disconnect-NAK" },
    148   1.6  christos     { RADCMD_COA_REQ,    "CoA-Request" },
    149   1.6  christos     { RADCMD_COA_ACK,    "CoA-ACK" },
    150   1.6  christos     { RADCMD_COA_NAK,    "CoA-NAK" },
    151   1.1  christos     { RADCMD_RESERVED,   "Reserved" },
    152   1.1  christos     { 0, NULL}
    153   1.1  christos };
    154   1.1  christos 
    155   1.1  christos /********************************/
    156   1.1  christos /* Begin Radius Attribute types */
    157   1.1  christos /********************************/
    158   1.1  christos #define SERV_TYPE    6
    159   1.1  christos #define FRM_IPADDR   8
    160   1.1  christos #define LOG_IPHOST  14
    161   1.1  christos #define LOG_SERVICE 15
    162   1.1  christos #define FRM_IPX     23
    163   1.1  christos #define SESSION_TIMEOUT   27
    164   1.1  christos #define IDLE_TIMEOUT      28
    165   1.1  christos #define FRM_ATALK_LINK    37
    166   1.1  christos #define FRM_ATALK_NETWORK 38
    167   1.1  christos 
    168   1.1  christos #define ACCT_DELAY        41
    169   1.1  christos #define ACCT_SESSION_TIME 46
    170   1.1  christos 
    171   1.6  christos #define EGRESS_VLAN_ID   56
    172   1.6  christos #define EGRESS_VLAN_NAME 58
    173   1.6  christos 
    174   1.1  christos #define TUNNEL_TYPE        64
    175   1.1  christos #define TUNNEL_MEDIUM      65
    176   1.1  christos #define TUNNEL_CLIENT_END  66
    177   1.1  christos #define TUNNEL_SERVER_END  67
    178   1.1  christos #define TUNNEL_PASS        69
    179   1.1  christos 
    180   1.1  christos #define ARAP_PASS          70
    181   1.1  christos #define ARAP_FEATURES      71
    182   1.1  christos 
    183  1.10  christos #define EAP_MESSAGE        79
    184  1.10  christos 
    185   1.1  christos #define TUNNEL_PRIV_GROUP  81
    186   1.1  christos #define TUNNEL_ASSIGN_ID   82
    187   1.1  christos #define TUNNEL_PREFERENCE  83
    188   1.1  christos 
    189   1.1  christos #define ARAP_CHALLENGE_RESP 84
    190   1.1  christos #define ACCT_INT_INTERVAL   85
    191   1.1  christos 
    192   1.1  christos #define TUNNEL_CLIENT_AUTH 90
    193   1.1  christos #define TUNNEL_SERVER_AUTH 91
    194  1.10  christos 
    195  1.10  christos #define ERROR_CAUSE 101
    196   1.1  christos /********************************/
    197   1.1  christos /* End Radius Attribute types */
    198   1.1  christos /********************************/
    199   1.1  christos 
    200   1.6  christos #define RFC4675_TAGGED   0x31
    201   1.6  christos #define RFC4675_UNTAGGED 0x32
    202   1.6  christos 
    203   1.6  christos static const struct tok rfc4675_tagged[] = {
    204   1.6  christos     { RFC4675_TAGGED,   "Tagged" },
    205   1.6  christos     { RFC4675_UNTAGGED, "Untagged" },
    206   1.6  christos     { 0, NULL}
    207   1.6  christos };
    208   1.6  christos 
    209   1.1  christos 
    210  1.10  christos static void print_attr_string(netdissect_options *, const u_char *, u_int, u_short );
    211  1.10  christos static void print_attr_num(netdissect_options *, const u_char *, u_int, u_short );
    212  1.10  christos static void print_vendor_attr(netdissect_options *, const u_char *, u_int, u_short );
    213  1.10  christos static void print_attr_address(netdissect_options *, const u_char *, u_int, u_short);
    214  1.10  christos static void print_attr_address6(netdissect_options *, const u_char *, u_int, u_short);
    215  1.10  christos static void print_attr_netmask6(netdissect_options *, const u_char *, u_int, u_short);
    216  1.10  christos static void print_attr_mip6_home_link_prefix(netdissect_options *, const u_char *, u_int, u_short);
    217  1.10  christos static void print_attr_operator_name(netdissect_options *, const u_char *, u_int, u_short);
    218  1.10  christos static void print_attr_location_information(netdissect_options *, const u_char *, u_int, u_short);
    219  1.10  christos static void print_attr_location_data(netdissect_options *, const u_char *, u_int, u_short);
    220  1.10  christos static void print_basic_location_policy_rules(netdissect_options *, const u_char *, u_int, u_short);
    221  1.10  christos static void print_attr_time(netdissect_options *, const u_char *, u_int, u_short);
    222  1.10  christos static void print_attr_vector64(netdissect_options *, register const u_char *, u_int, u_short);
    223  1.10  christos static void print_attr_strange(netdissect_options *, const u_char *, u_int, u_short);
    224  1.10  christos 
    225  1.10  christos 
    226  1.10  christos struct radius_hdr { nd_uint8_t  code;     /* Radius packet code  */
    227  1.10  christos                     nd_uint8_t  id;       /* Radius packet id    */
    228  1.10  christos                     nd_uint16_t len;      /* Radius total length */
    229  1.10  christos                     nd_byte     auth[16]; /* Authenticator   */
    230   1.1  christos                   };
    231   1.1  christos 
    232   1.1  christos #define MIN_RADIUS_LEN	20
    233   1.1  christos 
    234  1.10  christos struct radius_attr { nd_uint8_t type; /* Attribute type   */
    235  1.10  christos                      nd_uint8_t len;  /* Attribute length */
    236   1.1  christos                    };
    237   1.1  christos 
    238   1.1  christos 
    239   1.1  christos /* Service-Type Attribute standard values */
    240  1.10  christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-4 */
    241   1.1  christos static const char *serv_type[]={ NULL,
    242   1.1  christos                                 "Login",
    243   1.1  christos                                 "Framed",
    244   1.1  christos                                 "Callback Login",
    245   1.1  christos                                 "Callback Framed",
    246   1.1  christos                                 "Outbound",
    247   1.1  christos                                 "Administrative",
    248   1.1  christos                                 "NAS Prompt",
    249   1.1  christos                                 "Authenticate Only",
    250   1.1  christos                                 "Callback NAS Prompt",
    251  1.10  christos                                 /* ^ [0, 9] ^ */
    252   1.1  christos                                 "Call Check",
    253   1.1  christos                                 "Callback Administrative",
    254  1.10  christos                                 "Voice",
    255  1.10  christos                                 "Fax",
    256  1.10  christos                                 "Modem Relay",
    257  1.10  christos                                 "IAPP-Register",
    258  1.10  christos                                 "IAPP-AP-Check",
    259  1.10  christos                                 "Authorize Only",
    260  1.10  christos                                 "Framed-Management",
    261  1.10  christos                                 "Additional-Authorization",
    262  1.10  christos                                 /* ^ [10, 19] ^ */
    263   1.1  christos                                };
    264   1.1  christos 
    265   1.1  christos /* Framed-Protocol Attribute standard values */
    266  1.10  christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-5 */
    267   1.1  christos static const char *frm_proto[]={ NULL,
    268   1.1  christos                                  "PPP",
    269   1.1  christos                                  "SLIP",
    270   1.1  christos                                  "ARAP",
    271   1.1  christos                                  "Gandalf proprietary",
    272   1.1  christos                                  "Xylogics IPX/SLIP",
    273   1.1  christos                                  "X.75 Synchronous",
    274  1.10  christos                                  "GPRS PDP Context",
    275   1.1  christos                                };
    276   1.1  christos 
    277   1.1  christos /* Framed-Routing Attribute standard values */
    278  1.10  christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-6 */
    279   1.1  christos static const char *frm_routing[]={ "None",
    280   1.1  christos                                    "Send",
    281   1.1  christos                                    "Listen",
    282   1.1  christos                                    "Send&Listen",
    283   1.1  christos                                  };
    284   1.1  christos 
    285   1.1  christos /* Framed-Compression Attribute standard values */
    286  1.10  christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-7 */
    287   1.1  christos static const char *frm_comp[]={ "None",
    288   1.1  christos                                 "VJ TCP/IP",
    289   1.1  christos                                 "IPX",
    290   1.1  christos                                 "Stac-LZS",
    291   1.1  christos                               };
    292   1.1  christos 
    293   1.1  christos /* Login-Service Attribute standard values */
    294  1.10  christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-8 */
    295   1.1  christos static const char *login_serv[]={ "Telnet",
    296   1.1  christos                                   "Rlogin",
    297   1.1  christos                                   "TCP Clear",
    298   1.1  christos                                   "PortMaster(proprietary)",
    299   1.1  christos                                   "LAT",
    300   1.1  christos                                   "X.25-PAD",
    301   1.1  christos                                   "X.25-T3POS",
    302   1.1  christos                                   "Unassigned",
    303   1.1  christos                                   "TCP Clear Quiet",
    304   1.1  christos                                 };
    305   1.1  christos 
    306   1.1  christos 
    307   1.1  christos /* Termination-Action Attribute standard values */
    308  1.10  christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-9 */
    309   1.1  christos static const char *term_action[]={ "Default",
    310   1.1  christos                                    "RADIUS-Request",
    311   1.1  christos                                  };
    312   1.1  christos 
    313   1.6  christos /* Ingress-Filters Attribute standard values */
    314   1.6  christos static const char *ingress_filters[]={ NULL,
    315   1.6  christos                                        "Enabled",
    316   1.6  christos                                        "Disabled",
    317   1.6  christos                                      };
    318   1.6  christos 
    319   1.1  christos /* NAS-Port-Type Attribute standard values */
    320  1.10  christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-13 */
    321   1.1  christos static const char *nas_port_type[]={ "Async",
    322   1.1  christos                                      "Sync",
    323   1.1  christos                                      "ISDN Sync",
    324   1.1  christos                                      "ISDN Async V.120",
    325   1.1  christos                                      "ISDN Async V.110",
    326   1.1  christos                                      "Virtual",
    327   1.1  christos                                      "PIAFS",
    328   1.1  christos                                      "HDLC Clear Channel",
    329   1.1  christos                                      "X.25",
    330   1.1  christos                                      "X.75",
    331  1.10  christos                                      /* ^ [0, 9] ^ */
    332   1.1  christos                                      "G.3 Fax",
    333   1.1  christos                                      "SDSL",
    334   1.1  christos                                      "ADSL-CAP",
    335   1.1  christos                                      "ADSL-DMT",
    336   1.1  christos                                      "ISDN-DSL",
    337   1.1  christos                                      "Ethernet",
    338   1.1  christos                                      "xDSL",
    339   1.1  christos                                      "Cable",
    340   1.1  christos                                      "Wireless - Other",
    341   1.1  christos                                      "Wireless - IEEE 802.11",
    342  1.10  christos                                      /* ^ [10, 19] ^ */
    343  1.10  christos                                      "Token-Ring",
    344  1.10  christos                                      "FDDI",
    345  1.10  christos                                      "Wireless - CDMA200",
    346  1.10  christos                                      "Wireless - UMTS",
    347  1.10  christos                                      "Wireless - 1X-EV",
    348  1.10  christos                                      "IAPP",
    349  1.10  christos                                      "FTTP",
    350  1.10  christos                                      "Wireless - IEEE 802.16",
    351  1.10  christos                                      "Wireless - IEEE 802.20",
    352  1.10  christos                                      "Wireless - IEEE 802.22",
    353  1.10  christos                                      /* ^ [20, 29] ^ */
    354  1.10  christos                                      "PPPoA",
    355  1.10  christos                                      "PPPoEoA",
    356  1.10  christos                                      "PPPoEoE",
    357  1.10  christos                                      "PPPoEoVLAN",
    358  1.10  christos                                      "PPPoEoQinQ",
    359  1.10  christos                                      "xPON",
    360  1.10  christos                                      "Wireless - XGP",
    361  1.10  christos                                      "WiMAX Pre-Release 8 IWK Function",
    362  1.10  christos                                      "WIMAX-WIFI-IWK",
    363  1.10  christos                                      "WIMAX-SFF",
    364  1.10  christos                                      /* ^ [30, 39] ^ */
    365  1.10  christos                                      "WIMAX-HA-LMA",
    366  1.10  christos                                      "WIMAX-DHCP",
    367  1.10  christos                                      "WIMAX-LBS",
    368  1.10  christos                                      "WIMAX-WVS",
    369   1.1  christos                                    };
    370   1.1  christos 
    371   1.1  christos /* Acct-Status-Type Accounting Attribute standard values */
    372  1.10  christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-10 */
    373   1.1  christos static const char *acct_status[]={ NULL,
    374   1.1  christos                                    "Start",
    375   1.1  christos                                    "Stop",
    376   1.1  christos                                    "Interim-Update",
    377   1.1  christos                                    "Unassigned",
    378   1.1  christos                                    "Unassigned",
    379   1.1  christos                                    "Unassigned",
    380   1.1  christos                                    "Accounting-On",
    381   1.1  christos                                    "Accounting-Off",
    382   1.1  christos                                    "Tunnel-Start",
    383  1.10  christos                                      /* ^ [0, 9] ^ */
    384   1.1  christos                                    "Tunnel-Stop",
    385   1.1  christos                                    "Tunnel-Reject",
    386   1.1  christos                                    "Tunnel-Link-Start",
    387   1.1  christos                                    "Tunnel-Link-Stop",
    388   1.1  christos                                    "Tunnel-Link-Reject",
    389   1.1  christos                                    "Failed",
    390   1.1  christos                                  };
    391   1.1  christos 
    392   1.1  christos /* Acct-Authentic Accounting Attribute standard values */
    393  1.10  christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-11 */
    394   1.1  christos static const char *acct_auth[]={ NULL,
    395   1.1  christos                                  "RADIUS",
    396   1.1  christos                                  "Local",
    397   1.1  christos                                  "Remote",
    398  1.10  christos                                  "Diameter",
    399   1.1  christos                                };
    400   1.1  christos 
    401   1.1  christos /* Acct-Terminate-Cause Accounting Attribute standard values */
    402  1.10  christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-12 */
    403   1.1  christos static const char *acct_term[]={ NULL,
    404   1.1  christos                                  "User Request",
    405   1.1  christos                                  "Lost Carrier",
    406   1.1  christos                                  "Lost Service",
    407   1.1  christos                                  "Idle Timeout",
    408   1.1  christos                                  "Session Timeout",
    409   1.1  christos                                  "Admin Reset",
    410   1.1  christos                                  "Admin Reboot",
    411   1.1  christos                                  "Port Error",
    412   1.1  christos                                  "NAS Error",
    413  1.10  christos                                  /* ^ [0, 9] ^ */
    414   1.1  christos                                  "NAS Request",
    415   1.1  christos                                  "NAS Reboot",
    416   1.1  christos                                  "Port Unneeded",
    417   1.1  christos                                  "Port Preempted",
    418   1.1  christos                                  "Port Suspended",
    419   1.1  christos                                  "Service Unavailable",
    420   1.1  christos                                  "Callback",
    421   1.1  christos                                  "User Error",
    422   1.1  christos                                  "Host Request",
    423  1.10  christos                                  "Supplicant Restart",
    424  1.10  christos                                  /* ^ [10, 19] ^ */
    425  1.10  christos                                  "Reauthentication Failure",
    426  1.10  christos                                  "Port Reinitialized",
    427  1.10  christos                                  "Port Administratively Disabled",
    428  1.10  christos                                  "Lost Power",
    429   1.1  christos                                };
    430   1.1  christos 
    431   1.1  christos /* Tunnel-Type Attribute standard values */
    432  1.10  christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-14 */
    433   1.1  christos static const char *tunnel_type[]={ NULL,
    434   1.1  christos                                    "PPTP",
    435   1.1  christos                                    "L2F",
    436   1.1  christos                                    "L2TP",
    437   1.1  christos                                    "ATMP",
    438   1.1  christos                                    "VTP",
    439   1.1  christos                                    "AH",
    440   1.1  christos                                    "IP-IP",
    441   1.1  christos                                    "MIN-IP-IP",
    442   1.1  christos                                    "ESP",
    443  1.10  christos                                    /* ^ [0, 9] ^ */
    444   1.1  christos                                    "GRE",
    445   1.1  christos                                    "DVS",
    446   1.1  christos                                    "IP-in-IP Tunneling",
    447   1.7  christos                                    "VLAN",
    448   1.1  christos                                  };
    449   1.1  christos 
    450   1.1  christos /* Tunnel-Medium-Type Attribute standard values */
    451  1.10  christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-15 */
    452   1.1  christos static const char *tunnel_medium[]={ NULL,
    453   1.1  christos                                      "IPv4",
    454   1.1  christos                                      "IPv6",
    455   1.1  christos                                      "NSAP",
    456   1.1  christos                                      "HDLC",
    457   1.1  christos                                      "BBN 1822",
    458   1.1  christos                                      "802",
    459   1.1  christos                                      "E.163",
    460   1.1  christos                                      "E.164",
    461   1.1  christos                                      "F.69",
    462  1.10  christos                                      /* ^ [0, 9] ^ */
    463   1.1  christos                                      "X.121",
    464   1.1  christos                                      "IPX",
    465   1.1  christos                                      "Appletalk",
    466   1.1  christos                                      "Decnet IV",
    467   1.1  christos                                      "Banyan Vines",
    468   1.1  christos                                      "E.164 with NSAP subaddress",
    469   1.1  christos                                    };
    470   1.1  christos 
    471   1.1  christos /* ARAP-Zone-Access Attribute standard values */
    472  1.10  christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-16 */
    473   1.1  christos static const char *arap_zone[]={ NULL,
    474   1.1  christos                                  "Only access to dfl zone",
    475   1.1  christos                                  "Use zone filter inc.",
    476   1.1  christos                                  "Not used",
    477   1.1  christos                                  "Use zone filter exc.",
    478   1.1  christos                                };
    479   1.1  christos 
    480  1.10  christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-17 */
    481   1.1  christos static const char *prompt[]={ "No Echo",
    482   1.1  christos                               "Echo",
    483   1.1  christos                             };
    484   1.1  christos 
    485  1.10  christos /* Error-Cause standard values */
    486  1.10  christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-18 */
    487  1.10  christos #define ERROR_CAUSE_RESIDUAL_CONTEXT_REMOVED 201
    488  1.10  christos #define ERROR_CAUSE_INVALID_EAP_PACKET 202
    489  1.10  christos #define ERROR_CAUSE_UNSUPPORTED_ATTRIBUTE 401
    490  1.10  christos #define ERROR_CAUSE_MISSING_ATTRIBUTE 402
    491  1.10  christos #define ERROR_CAUSE_NAS_IDENTIFICATION_MISMATCH 403
    492  1.10  christos #define ERROR_CAUSE_INVALID_REQUEST 404
    493  1.10  christos #define ERROR_CAUSE_UNSUPPORTED_SERVICE 405
    494  1.10  christos #define ERROR_CAUSE_UNSUPPORTED_EXTENSION 406
    495  1.10  christos #define ERROR_CAUSE_INVALID_ATTRIBUTE_VALUE 407
    496  1.10  christos #define ERROR_CAUSE_ADMINISTRATIVELY_PROHIBITED 501
    497  1.10  christos #define ERROR_CAUSE_PROXY_REQUEST_NOT_ROUTABLE 502
    498  1.10  christos #define ERROR_CAUSE_SESSION_CONTEXT_NOT_FOUND 503
    499  1.10  christos #define ERROR_CAUSE_SESSION_CONTEXT_NOT_REMOVABLE 504
    500  1.10  christos #define ERROR_CAUSE_PROXY_PROCESSING_ERROR 505
    501  1.10  christos #define ERROR_CAUSE_RESOURCES_UNAVAILABLE 506
    502  1.10  christos #define ERROR_CAUSE_REQUEST_INITIATED 507
    503  1.10  christos #define ERROR_CAUSE_MULTIPLE_SESSION_SELECTION_UNSUPPORTED 508
    504  1.10  christos #define ERROR_CAUSE_LOCATION_INFO_REQUIRED 509
    505  1.10  christos static const struct tok errorcausetype[] = {
    506  1.10  christos                                  { ERROR_CAUSE_RESIDUAL_CONTEXT_REMOVED,               "Residual Session Context Removed" },
    507  1.10  christos                                  { ERROR_CAUSE_INVALID_EAP_PACKET,                     "Invalid EAP Packet (Ignored)" },
    508  1.10  christos                                  { ERROR_CAUSE_UNSUPPORTED_ATTRIBUTE,                  "Unsupported Attribute" },
    509  1.10  christos                                  { ERROR_CAUSE_MISSING_ATTRIBUTE,                      "Missing Attribute" },
    510  1.10  christos                                  { ERROR_CAUSE_NAS_IDENTIFICATION_MISMATCH,            "NAS Identification Mismatch" },
    511  1.10  christos                                  { ERROR_CAUSE_INVALID_REQUEST,                        "Invalid Request" },
    512  1.10  christos                                  { ERROR_CAUSE_UNSUPPORTED_SERVICE,                    "Unsupported Service" },
    513  1.10  christos                                  { ERROR_CAUSE_UNSUPPORTED_EXTENSION,                  "Unsupported Extension" },
    514  1.10  christos                                  { ERROR_CAUSE_INVALID_ATTRIBUTE_VALUE,                "Invalid Attribute Value" },
    515  1.10  christos                                  { ERROR_CAUSE_ADMINISTRATIVELY_PROHIBITED,            "Administratively Prohibited" },
    516  1.10  christos                                  { ERROR_CAUSE_PROXY_REQUEST_NOT_ROUTABLE,             "Request Not Routable (Proxy)" },
    517  1.10  christos                                  { ERROR_CAUSE_SESSION_CONTEXT_NOT_FOUND,              "Session Context Not Found" },
    518  1.10  christos                                  { ERROR_CAUSE_SESSION_CONTEXT_NOT_REMOVABLE,          "Session Context Not Removable" },
    519  1.10  christos                                  { ERROR_CAUSE_PROXY_PROCESSING_ERROR,                 "Other Proxy Processing Error" },
    520  1.10  christos                                  { ERROR_CAUSE_RESOURCES_UNAVAILABLE,                  "Resources Unavailable" },
    521  1.10  christos                                  { ERROR_CAUSE_REQUEST_INITIATED,                      "Request Initiated" },
    522  1.10  christos                                  { ERROR_CAUSE_MULTIPLE_SESSION_SELECTION_UNSUPPORTED, "Multiple Session Selection Unsupported" },
    523  1.10  christos                                  { ERROR_CAUSE_LOCATION_INFO_REQUIRED,                 "Location Info Required" },
    524  1.10  christos 																 { 0, NULL }
    525  1.10  christos                                };
    526  1.10  christos 
    527  1.10  christos /* MIP6-Feature-Vector standard values */
    528  1.10  christos /* https://www.iana.org/assignments/aaa-parameters/aaa-parameters.xhtml */
    529  1.10  christos #define MIP6_INTEGRATED 0x0000000000000001
    530  1.10  christos #define LOCAL_HOME_AGENT_ASSIGNMENT 0x0000000000000002
    531  1.10  christos #define PMIP6_SUPPORTED 0x0000010000000000
    532  1.10  christos #define IP4_HOA_SUPPORTED 0x0000020000000000
    533  1.10  christos #define LOCAL_MAG_ROUTING_SUPPORTED 0x0000040000000000
    534  1.10  christos #define ASSIGN_LOCAL_IP 0x0000080000000000
    535  1.10  christos #define MIP4_SUPPORTED 0x0000100000000000
    536  1.10  christos #define OPTIMIZED_IDLE_MODE_MOBILITY 0x0000200000000000
    537  1.10  christos #define GTPv2_SUPPORTED 0x0000400000000000
    538  1.10  christos #define IP4_TRANSPORT_SUPPORTED 0x0000800000000000
    539  1.10  christos #define IP4_HOA_ONLY_SUPPORTED 0x0001000000000000
    540  1.10  christos #define INTER_MAG_ROUTING_SUPPORTED 0x0002000000000000
    541  1.10  christos static const struct mip6_feature_vector {
    542  1.10  christos                   uint64_t v;
    543  1.10  christos                   const char *s;
    544  1.10  christos                 } mip6_feature_vector[] = {
    545  1.10  christos                                  { MIP6_INTEGRATED,             "MIP6_INTEGRATED" },
    546  1.10  christos                                  { LOCAL_HOME_AGENT_ASSIGNMENT, "LOCAL_HOME_AGENT_ASSIGNMENT" },
    547  1.10  christos                                  { PMIP6_SUPPORTED,             "PMIP6_SUPPORTED" },
    548  1.10  christos                                  { IP4_HOA_SUPPORTED,           "IP4_HOA_SUPPORTED" },
    549  1.10  christos                                  { LOCAL_MAG_ROUTING_SUPPORTED, "LOCAL_MAG_ROUTING_SUPPORTED" },
    550  1.10  christos                                  { ASSIGN_LOCAL_IP,             "ASSIGN_LOCAL_IP" },
    551  1.10  christos                                  { MIP4_SUPPORTED,              "MIP4_SUPPORTED" },
    552  1.10  christos                                  { OPTIMIZED_IDLE_MODE_MOBILITY, "OPTIMIZED_IDLE_MODE_MOBILITY" },
    553  1.10  christos                                  { GTPv2_SUPPORTED,             "GTPv2_SUPPORTED" },
    554  1.10  christos                                  { IP4_TRANSPORT_SUPPORTED,     "IP4_TRANSPORT_SUPPORTED" },
    555  1.10  christos                                  { IP4_HOA_ONLY_SUPPORTED,      "IP4_HOA_ONLY_SUPPORTED" },
    556  1.10  christos                                  { INTER_MAG_ROUTING_SUPPORTED, "INTER_MAG_ROUTING_SUPPORTED" },
    557  1.10  christos                                };
    558   1.1  christos 
    559  1.10  christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-19 */
    560  1.10  christos #define OPERATOR_NAME_TADIG 0x30
    561  1.10  christos #define OPERATOR_NAME_REALM 0x31
    562  1.10  christos #define OPERATOR_NAME_E212  0x32
    563  1.10  christos #define OPERATOR_NAME_ICC   0x33
    564  1.10  christos static const struct tok operator_name_vector[] = {
    565  1.10  christos                                  { OPERATOR_NAME_TADIG, "TADIG" },
    566  1.10  christos                                  { OPERATOR_NAME_REALM, "REALM" },
    567  1.10  christos                                  { OPERATOR_NAME_E212,  "E212"  },
    568  1.10  christos                                  { OPERATOR_NAME_ICC,   "ICC"   },
    569  1.10  christos                                  { 0, NULL }
    570  1.10  christos                                };
    571  1.10  christos 
    572  1.10  christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-20 */
    573  1.10  christos #define LOCATION_INFORMATION_CODE_CIVIC      0
    574  1.10  christos #define LOCATION_INFORMATION_CODE_GEOSPATIAL 1
    575  1.10  christos static const struct tok location_information_code_vector[] = {
    576  1.10  christos                                  { LOCATION_INFORMATION_CODE_CIVIC     , "Civic"      },
    577  1.10  christos                                  { LOCATION_INFORMATION_CODE_GEOSPATIAL, "Geospatial" },
    578  1.10  christos                                  { 0, NULL }
    579  1.10  christos                                };
    580  1.10  christos 
    581  1.10  christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-21 */
    582  1.10  christos #define LOCATION_INFORMATION_ENTITY_USER   0
    583  1.10  christos #define LOCATION_INFORMATION_ENTITY_RADIUS 1
    584  1.10  christos static const struct tok location_information_entity_vector[] = {
    585  1.10  christos                                  { LOCATION_INFORMATION_ENTITY_USER,   "User"   },
    586  1.10  christos                                  { LOCATION_INFORMATION_ENTITY_RADIUS, "RADIUS" },
    587  1.10  christos                                  { 0, NULL }
    588  1.10  christos                                };
    589  1.10  christos 
    590  1.10  christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-22 */
    591  1.10  christos static const struct tok blpr_bm[] = {
    592  1.10  christos                                  { 0x0001, "MBZ-15" },
    593  1.10  christos                                  { 0x0002, "MBZ-14" },
    594  1.10  christos                                  { 0x0004, "MBZ-13" },
    595  1.10  christos                                  { 0x0008, "MBZ-12" },
    596  1.10  christos                                  { 0x0010, "MBZ-11" },
    597  1.10  christos                                  { 0x0020, "MBZ-10" },
    598  1.10  christos                                  { 0x0040, "MBZ-9" },
    599  1.10  christos                                  { 0x0080, "MBZ-8" },
    600  1.10  christos                                  { 0x0100, "MBZ-7" },
    601  1.10  christos                                  { 0x0200, "MBZ-6" },
    602  1.10  christos                                  { 0x0400, "MBZ-5" },
    603  1.10  christos                                  { 0x0800, "MBZ-4" },
    604  1.10  christos                                  { 0x1000, "MBZ-3" },
    605  1.10  christos                                  { 0x2000, "MBZ-2" },
    606  1.10  christos                                  { 0x4000, "MBZ-1" },
    607  1.10  christos                                  { 0x8000, "Retransmission Allowed" },
    608  1.10  christos                                  { 0, NULL }
    609  1.10  christos                                };
    610  1.10  christos 
    611  1.10  christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-2 */
    612  1.10  christos static const struct attrtype {
    613   1.8       spz                   const char *name;      /* Attribute name                 */
    614   1.1  christos                   const char **subtypes; /* Standard Values (if any)       */
    615   1.1  christos                   u_char siz_subtypes;   /* Size of total standard values  */
    616   1.1  christos                   u_char first_subtype;  /* First standard value is 0 or 1 */
    617  1.10  christos                   void (*print_func)(netdissect_options *, const u_char *, u_int, u_short);
    618   1.1  christos                 } attr_type[]=
    619   1.1  christos   {
    620   1.1  christos      { NULL,                              NULL, 0, 0, NULL               },
    621   1.6  christos      { "User-Name",                       NULL, 0, 0, print_attr_string  },
    622   1.6  christos      { "User-Password",                   NULL, 0, 0, NULL               },
    623   1.6  christos      { "CHAP-Password",                   NULL, 0, 0, NULL               },
    624   1.6  christos      { "NAS-IP-Address",                  NULL, 0, 0, print_attr_address },
    625   1.6  christos      { "NAS-Port",                        NULL, 0, 0, print_attr_num     },
    626   1.6  christos      { "Service-Type",                    serv_type, TAM_SIZE(serv_type)-1, 1, print_attr_num },
    627   1.6  christos      { "Framed-Protocol",                 frm_proto, TAM_SIZE(frm_proto)-1, 1, print_attr_num },
    628   1.6  christos      { "Framed-IP-Address",               NULL, 0, 0, print_attr_address },
    629   1.6  christos      { "Framed-IP-Netmask",               NULL, 0, 0, print_attr_address },
    630  1.10  christos      /* ^ [0, 9] ^ */
    631   1.6  christos      { "Framed-Routing",                  frm_routing, TAM_SIZE(frm_routing), 0, print_attr_num },
    632   1.6  christos      { "Filter-Id",                       NULL, 0, 0, print_attr_string  },
    633   1.6  christos      { "Framed-MTU",                      NULL, 0, 0, print_attr_num     },
    634   1.6  christos      { "Framed-Compression",              frm_comp, TAM_SIZE(frm_comp),   0, print_attr_num },
    635   1.6  christos      { "Login-IP-Host",                   NULL, 0, 0, print_attr_address },
    636   1.6  christos      { "Login-Service",                   login_serv, TAM_SIZE(login_serv), 0, print_attr_num },
    637   1.6  christos      { "Login-TCP-Port",                  NULL, 0, 0, print_attr_num     },
    638   1.1  christos      { "Unassigned",                      NULL, 0, 0, NULL }, /*17*/
    639   1.6  christos      { "Reply-Message",                   NULL, 0, 0, print_attr_string },
    640   1.6  christos      { "Callback-Number",                 NULL, 0, 0, print_attr_string },
    641  1.10  christos      /* ^ [10, 19] ^ */
    642   1.6  christos      { "Callback-Id",                     NULL, 0, 0, print_attr_string },
    643   1.1  christos      { "Unassigned",                      NULL, 0, 0, NULL }, /*21*/
    644   1.6  christos      { "Framed-Route",                    NULL, 0, 0, print_attr_string },
    645   1.6  christos      { "Framed-IPX-Network",              NULL, 0, 0, print_attr_num    },
    646   1.1  christos      { "State",                           NULL, 0, 0, print_attr_string },
    647   1.1  christos      { "Class",                           NULL, 0, 0, print_attr_string },
    648   1.6  christos      { "Vendor-Specific",                 NULL, 0, 0, print_vendor_attr },
    649   1.6  christos      { "Session-Timeout",                 NULL, 0, 0, print_attr_num    },
    650   1.6  christos      { "Idle-Timeout",                    NULL, 0, 0, print_attr_num    },
    651   1.6  christos      { "Termination-Action",              term_action, TAM_SIZE(term_action), 0, print_attr_num },
    652  1.10  christos      /* ^ [20, 29] ^ */
    653   1.6  christos      { "Called-Station-Id",               NULL, 0, 0, print_attr_string },
    654   1.6  christos      { "Calling-Station-Id",              NULL, 0, 0, print_attr_string },
    655   1.6  christos      { "NAS-Identifier",                  NULL, 0, 0, print_attr_string },
    656   1.6  christos      { "Proxy-State",                     NULL, 0, 0, print_attr_string },
    657   1.6  christos      { "Login-LAT-Service",               NULL, 0, 0, print_attr_string },
    658   1.6  christos      { "Login-LAT-Node",                  NULL, 0, 0, print_attr_string },
    659   1.6  christos      { "Login-LAT-Group",                 NULL, 0, 0, print_attr_string },
    660   1.6  christos      { "Framed-AppleTalk-Link",           NULL, 0, 0, print_attr_num    },
    661   1.6  christos      { "Framed-AppleTalk-Network",        NULL, 0, 0, print_attr_num    },
    662   1.6  christos      { "Framed-AppleTalk-Zone",           NULL, 0, 0, print_attr_string },
    663  1.10  christos      /* ^ [30, 39] ^ */
    664   1.6  christos      { "Acct-Status-Type",                acct_status, TAM_SIZE(acct_status)-1, 1, print_attr_num },
    665   1.6  christos      { "Acct-Delay-Time",                 NULL, 0, 0, print_attr_num    },
    666   1.6  christos      { "Acct-Input-Octets",               NULL, 0, 0, print_attr_num    },
    667   1.6  christos      { "Acct-Output-Octets",              NULL, 0, 0, print_attr_num    },
    668   1.6  christos      { "Acct-Session-Id",                 NULL, 0, 0, print_attr_string },
    669   1.6  christos      { "Acct-Authentic",                  acct_auth, TAM_SIZE(acct_auth)-1, 1, print_attr_num },
    670   1.6  christos      { "Acct-Session-Time",               NULL, 0, 0, print_attr_num },
    671   1.6  christos      { "Acct-Input-Packets",              NULL, 0, 0, print_attr_num },
    672   1.6  christos      { "Acct-Output-Packets",             NULL, 0, 0, print_attr_num },
    673   1.6  christos      { "Acct-Terminate-Cause",            acct_term, TAM_SIZE(acct_term)-1, 1, print_attr_num },
    674  1.10  christos      /* ^ [40, 49] ^ */
    675   1.6  christos      { "Acct-Multi-Session-Id",           NULL, 0, 0, print_attr_string },
    676   1.6  christos      { "Acct-Link-Count",                 NULL, 0, 0, print_attr_num },
    677   1.6  christos      { "Acct-Input-Gigawords",            NULL, 0, 0, print_attr_num },
    678   1.6  christos      { "Acct-Output-Gigawords",           NULL, 0, 0, print_attr_num },
    679   1.1  christos      { "Unassigned",                      NULL, 0, 0, NULL }, /*54*/
    680   1.6  christos      { "Event-Timestamp",                 NULL, 0, 0, print_attr_time },
    681   1.6  christos      { "Egress-VLANID",                   NULL, 0, 0, print_attr_num },
    682   1.6  christos      { "Ingress-Filters",                 ingress_filters, TAM_SIZE(ingress_filters)-1, 1, print_attr_num },
    683   1.6  christos      { "Egress-VLAN-Name",                NULL, 0, 0, print_attr_string },
    684   1.6  christos      { "User-Priority-Table",             NULL, 0, 0, NULL },
    685  1.10  christos      /* ^ [50, 59] ^ */
    686   1.6  christos      { "CHAP-Challenge",                  NULL, 0, 0, print_attr_string },
    687   1.6  christos      { "NAS-Port-Type",                   nas_port_type, TAM_SIZE(nas_port_type), 0, print_attr_num },
    688   1.6  christos      { "Port-Limit",                      NULL, 0, 0, print_attr_num },
    689   1.6  christos      { "Login-LAT-Port",                  NULL, 0, 0, print_attr_string }, /*63*/
    690   1.6  christos      { "Tunnel-Type",                     tunnel_type, TAM_SIZE(tunnel_type)-1, 1, print_attr_num },
    691   1.6  christos      { "Tunnel-Medium-Type",              tunnel_medium, TAM_SIZE(tunnel_medium)-1, 1, print_attr_num },
    692   1.6  christos      { "Tunnel-Client-Endpoint",          NULL, 0, 0, print_attr_string },
    693   1.6  christos      { "Tunnel-Server-Endpoint",          NULL, 0, 0, print_attr_string },
    694   1.6  christos      { "Acct-Tunnel-Connection",          NULL, 0, 0, print_attr_string },
    695   1.6  christos      { "Tunnel-Password",                 NULL, 0, 0, print_attr_string  },
    696  1.10  christos      /* ^ [60, 69] ^ */
    697   1.6  christos      { "ARAP-Password",                   NULL, 0, 0, print_attr_strange },
    698   1.6  christos      { "ARAP-Features",                   NULL, 0, 0, print_attr_strange },
    699   1.6  christos      { "ARAP-Zone-Access",                arap_zone, TAM_SIZE(arap_zone)-1, 1, print_attr_num }, /*72*/
    700   1.6  christos      { "ARAP-Security",                   NULL, 0, 0, print_attr_string },
    701   1.6  christos      { "ARAP-Security-Data",              NULL, 0, 0, print_attr_string },
    702   1.6  christos      { "Password-Retry",                  NULL, 0, 0, print_attr_num    },
    703   1.1  christos      { "Prompt",                          prompt, TAM_SIZE(prompt), 0, print_attr_num },
    704   1.6  christos      { "Connect-Info",                    NULL, 0, 0, print_attr_string   },
    705   1.6  christos      { "Configuration-Token",             NULL, 0, 0, print_attr_string   },
    706   1.6  christos      { "EAP-Message",                     NULL, 0, 0, print_attr_string   },
    707  1.10  christos      /* ^ [70, 79] ^ */
    708   1.6  christos      { "Message-Authenticator",           NULL, 0, 0, print_attr_string }, /*80*/
    709   1.6  christos      { "Tunnel-Private-Group-ID",         NULL, 0, 0, print_attr_string },
    710   1.6  christos      { "Tunnel-Assignment-ID",            NULL, 0, 0, print_attr_string },
    711   1.6  christos      { "Tunnel-Preference",               NULL, 0, 0, print_attr_num    },
    712   1.6  christos      { "ARAP-Challenge-Response",         NULL, 0, 0, print_attr_strange },
    713   1.6  christos      { "Acct-Interim-Interval",           NULL, 0, 0, print_attr_num     },
    714   1.6  christos      { "Acct-Tunnel-Packets-Lost",        NULL, 0, 0, print_attr_num }, /*86*/
    715   1.6  christos      { "NAS-Port-Id",                     NULL, 0, 0, print_attr_string },
    716   1.6  christos      { "Framed-Pool",                     NULL, 0, 0, print_attr_string },
    717   1.6  christos      { "CUI",                             NULL, 0, 0, print_attr_string },
    718  1.10  christos      /* ^ [80, 89] ^ */
    719   1.6  christos      { "Tunnel-Client-Auth-ID",           NULL, 0, 0, print_attr_string },
    720   1.6  christos      { "Tunnel-Server-Auth-ID",           NULL, 0, 0, print_attr_string },
    721  1.10  christos      { "NAS-Filter-Rule",                 NULL, 0, 0, print_attr_string },
    722  1.10  christos      { "Unassigned",                      NULL, 0, 0, NULL },  /*93*/
    723  1.10  christos      { "Originating-Line-Info",           NULL, 0, 0, NULL },
    724  1.10  christos      { "NAS-IPv6-Address",                NULL, 0, 0, print_attr_address6 },
    725  1.10  christos      { "Framed-Interface-ID",             NULL, 0, 0, NULL },
    726  1.10  christos      { "Framed-IPv6-Prefix",              NULL, 0, 0, print_attr_netmask6 },
    727  1.10  christos      { "Login-IPv6-Host",                 NULL, 0, 0, print_attr_address6 },
    728  1.10  christos      { "Framed-IPv6-Route",               NULL, 0, 0, print_attr_string },
    729  1.10  christos      /* ^ [90, 99] ^ */
    730  1.10  christos      { "Framed-IPv6-Pool",                NULL, 0, 0, print_attr_string },
    731  1.10  christos      { "Error-Cause",                     NULL, 0, 0, print_attr_strange },
    732  1.10  christos      { "EAP-Key-Name",                    NULL, 0, 0, NULL },
    733  1.10  christos      { "Digest-Response",                 NULL, 0, 0, print_attr_string },
    734  1.10  christos      { "Digest-Realm",                    NULL, 0, 0, print_attr_string },
    735  1.10  christos      { "Digest-Nonce",                    NULL, 0, 0, print_attr_string },
    736  1.10  christos      { "Digest-Response-Auth",            NULL, 0, 0, print_attr_string },
    737  1.10  christos      { "Digest-Nextnonce",                NULL, 0, 0, print_attr_string },
    738  1.10  christos      { "Digest-Method",                   NULL, 0, 0, print_attr_string },
    739  1.10  christos      { "Digest-URI",                      NULL, 0, 0, print_attr_string },
    740  1.10  christos      /* ^ [100, 109] ^ */
    741  1.10  christos      { "Digest-Qop",                      NULL, 0, 0, print_attr_string },
    742  1.10  christos      { "Digest-Algorithm",                NULL, 0, 0, print_attr_string },
    743  1.10  christos      { "Digest-Entity-Body-Hash",         NULL, 0, 0, print_attr_string },
    744  1.10  christos      { "Digest-CNonce",                   NULL, 0, 0, print_attr_string },
    745  1.10  christos      { "Digest-Nonce-Count",              NULL, 0, 0, print_attr_string },
    746  1.10  christos      { "Digest-Username",                 NULL, 0, 0, print_attr_string },
    747  1.10  christos      { "Digest-Opaque",                   NULL, 0, 0, print_attr_string },
    748  1.10  christos      { "Digest-Auth-Param",               NULL, 0, 0, print_attr_string },
    749  1.10  christos      { "Digest-AKA-Auts",                 NULL, 0, 0, print_attr_string },
    750  1.10  christos      { "Digest-Domain",                   NULL, 0, 0, print_attr_string },
    751  1.10  christos      /* ^ [110, 119] ^ */
    752  1.10  christos      { "Digest-Stale",                    NULL, 0, 0, print_attr_string },
    753  1.10  christos      { "Digest-HA1",                      NULL, 0, 0, print_attr_string },
    754  1.10  christos      { "SIP-AOR",                         NULL, 0, 0, print_attr_string },
    755  1.10  christos      { "Delegated-IPv6-Prefix",           NULL, 0, 0, print_attr_netmask6 },
    756  1.10  christos      { "MIP6-Feature-Vector",             NULL, 0, 0, print_attr_vector64 },
    757  1.10  christos      { "MIP6-Home-Link-Prefix",           NULL, 0, 0, print_attr_mip6_home_link_prefix },
    758  1.10  christos      { "Operator-Name",                   NULL, 0, 0, print_attr_operator_name },
    759  1.10  christos      { "Location-Information",            NULL, 0, 0, print_attr_location_information },
    760  1.10  christos      { "Location-Data",                   NULL, 0, 0, print_attr_location_data },
    761  1.10  christos      { "Basic-Location-Policy-Rules",     NULL, 0, 0, print_basic_location_policy_rules }
    762  1.10  christos      /* ^ [120, 129] ^ */
    763   1.1  christos   };
    764   1.1  christos 
    765   1.1  christos 
    766   1.1  christos /*****************************/
    767   1.1  christos /* Print an attribute string */
    768   1.1  christos /* value pointed by 'data'   */
    769   1.1  christos /* and 'length' size.        */
    770   1.1  christos /*****************************/
    771   1.1  christos /* Returns nothing.          */
    772   1.1  christos /*****************************/
    773   1.1  christos static void
    774   1.5  christos print_attr_string(netdissect_options *ndo,
    775  1.10  christos                   const u_char *data, u_int length, u_short attr_code)
    776   1.1  christos {
    777  1.10  christos    u_int i;
    778   1.1  christos 
    779  1.10  christos    ND_TCHECK_LEN(data, length);
    780   1.1  christos 
    781   1.1  christos    switch(attr_code)
    782   1.1  christos    {
    783   1.1  christos       case TUNNEL_PASS:
    784   1.1  christos            if (length < 3)
    785   1.9  christos               goto trunc;
    786  1.10  christos            if (GET_U_1(data) && (GET_U_1(data) <= 0x1F))
    787  1.10  christos               ND_PRINT("Tag[%u] ", GET_U_1(data));
    788   1.6  christos            else
    789  1.10  christos               ND_PRINT("Tag[Unused] ");
    790   1.1  christos            data++;
    791   1.1  christos            length--;
    792  1.10  christos            ND_PRINT("Salt %u ", GET_BE_U_2(data));
    793   1.1  christos            data+=2;
    794   1.1  christos            length-=2;
    795   1.1  christos         break;
    796   1.1  christos       case TUNNEL_CLIENT_END:
    797   1.1  christos       case TUNNEL_SERVER_END:
    798   1.1  christos       case TUNNEL_PRIV_GROUP:
    799   1.1  christos       case TUNNEL_ASSIGN_ID:
    800   1.1  christos       case TUNNEL_CLIENT_AUTH:
    801   1.1  christos       case TUNNEL_SERVER_AUTH:
    802  1.10  christos            if (GET_U_1(data) <= 0x1F)
    803   1.1  christos            {
    804   1.1  christos               if (length < 1)
    805   1.9  christos                  goto trunc;
    806  1.10  christos               if (GET_U_1(data))
    807  1.10  christos                 ND_PRINT("Tag[%u] ", GET_U_1(data));
    808   1.6  christos               else
    809  1.10  christos                 ND_PRINT("Tag[Unused] ");
    810   1.1  christos               data++;
    811   1.1  christos               length--;
    812   1.1  christos            }
    813   1.1  christos         break;
    814   1.6  christos       case EGRESS_VLAN_NAME:
    815   1.9  christos            if (length < 1)
    816   1.9  christos               goto trunc;
    817  1.10  christos            ND_PRINT("%s (0x%02x) ",
    818  1.10  christos                   tok2str(rfc4675_tagged,"Unknown tag",GET_U_1(data)),
    819  1.10  christos                   GET_U_1(data));
    820   1.6  christos            data++;
    821   1.6  christos            length--;
    822   1.6  christos         break;
    823  1.10  christos       case EAP_MESSAGE:
    824  1.10  christos            if (length < 1)
    825  1.10  christos               goto trunc;
    826  1.10  christos            eap_print(ndo, data, length);
    827  1.10  christos            return;
    828   1.1  christos    }
    829   1.1  christos 
    830  1.10  christos    for (i=0; i < length && GET_U_1(data); i++, data++)
    831  1.10  christos        ND_PRINT("%c", ND_ASCII_ISPRINT(GET_U_1(data)) ? GET_U_1(data) : '.');
    832   1.1  christos 
    833   1.1  christos    return;
    834   1.1  christos 
    835   1.1  christos    trunc:
    836  1.10  christos       nd_print_trunc(ndo);
    837   1.1  christos }
    838   1.1  christos 
    839   1.1  christos /*
    840   1.1  christos  * print vendor specific attributes
    841   1.1  christos  */
    842   1.1  christos static void
    843   1.5  christos print_vendor_attr(netdissect_options *ndo,
    844  1.10  christos                   const u_char *data, u_int length, u_short attr_code _U_)
    845   1.1  christos {
    846   1.1  christos     u_int idx;
    847   1.1  christos     u_int vendor_id;
    848   1.1  christos     u_int vendor_type;
    849   1.1  christos     u_int vendor_length;
    850   1.1  christos 
    851   1.1  christos     if (length < 4)
    852   1.1  christos         goto trunc;
    853  1.10  christos     vendor_id = GET_BE_U_4(data);
    854   1.1  christos     data+=4;
    855   1.1  christos     length-=4;
    856   1.1  christos 
    857  1.10  christos     ND_PRINT("Vendor: %s (%u)",
    858   1.1  christos            tok2str(smi_values,"Unknown",vendor_id),
    859  1.10  christos            vendor_id);
    860   1.1  christos 
    861   1.1  christos     while (length >= 2) {
    862  1.10  christos         vendor_type = GET_U_1(data);
    863  1.10  christos         vendor_length = GET_U_1(data + 1);
    864   1.1  christos 
    865   1.1  christos         if (vendor_length < 2)
    866   1.1  christos         {
    867  1.10  christos             ND_PRINT("\n\t    Vendor Attribute: %u, Length: %u (bogus, must be >= 2)",
    868   1.1  christos                    vendor_type,
    869  1.10  christos                    vendor_length);
    870   1.1  christos             return;
    871   1.1  christos         }
    872   1.1  christos         if (vendor_length > length)
    873   1.1  christos         {
    874  1.10  christos             ND_PRINT("\n\t    Vendor Attribute: %u, Length: %u (bogus, goes past end of vendor-specific attribute)",
    875   1.1  christos                    vendor_type,
    876  1.10  christos                    vendor_length);
    877   1.1  christos             return;
    878   1.1  christos         }
    879   1.1  christos         data+=2;
    880   1.1  christos         vendor_length-=2;
    881   1.1  christos         length-=2;
    882  1.10  christos 	ND_TCHECK_LEN(data, vendor_length);
    883   1.1  christos 
    884  1.10  christos         ND_PRINT("\n\t    Vendor Attribute: %u, Length: %u, Value: ",
    885   1.1  christos                vendor_type,
    886  1.10  christos                vendor_length);
    887   1.1  christos         for (idx = 0; idx < vendor_length ; idx++, data++)
    888  1.10  christos             ND_PRINT("%c", ND_ASCII_ISPRINT(GET_U_1(data)) ? GET_U_1(data) : '.');
    889   1.1  christos         length-=vendor_length;
    890   1.1  christos     }
    891   1.1  christos     return;
    892   1.1  christos 
    893   1.1  christos    trunc:
    894  1.10  christos      nd_print_trunc(ndo);
    895   1.1  christos }
    896   1.1  christos 
    897   1.1  christos /******************************/
    898   1.1  christos /* Print an attribute numeric */
    899   1.1  christos /* value pointed by 'data'    */
    900   1.1  christos /* and 'length' size.         */
    901   1.1  christos /******************************/
    902   1.1  christos /* Returns nothing.           */
    903   1.1  christos /******************************/
    904   1.1  christos static void
    905   1.5  christos print_attr_num(netdissect_options *ndo,
    906  1.10  christos                const u_char *data, u_int length, u_short attr_code)
    907   1.1  christos {
    908   1.5  christos    uint32_t timeout;
    909   1.1  christos 
    910   1.1  christos    if (length != 4)
    911   1.1  christos    {
    912  1.10  christos        ND_PRINT("ERROR: length %u != 4", length);
    913   1.1  christos        return;
    914   1.1  christos    }
    915   1.1  christos 
    916   1.1  christos                           /* This attribute has standard values */
    917   1.1  christos    if (attr_type[attr_code].siz_subtypes)
    918   1.1  christos    {
    919   1.1  christos       static const char **table;
    920   1.5  christos       uint32_t data_value;
    921   1.1  christos       table = attr_type[attr_code].subtypes;
    922   1.1  christos 
    923   1.1  christos       if ( (attr_code == TUNNEL_TYPE) || (attr_code == TUNNEL_MEDIUM) )
    924   1.1  christos       {
    925  1.10  christos          if (!GET_U_1(data))
    926  1.10  christos             ND_PRINT("Tag[Unused] ");
    927   1.1  christos          else
    928  1.10  christos             ND_PRINT("Tag[%u] ", GET_U_1(data));
    929   1.1  christos          data++;
    930  1.10  christos          data_value = GET_BE_U_3(data);
    931   1.1  christos       }
    932   1.1  christos       else
    933   1.1  christos       {
    934  1.10  christos          data_value = GET_BE_U_4(data);
    935   1.1  christos       }
    936   1.5  christos       if ( data_value <= (uint32_t)(attr_type[attr_code].siz_subtypes - 1 +
    937   1.1  christos             attr_type[attr_code].first_subtype) &&
    938   1.1  christos 	   data_value >= attr_type[attr_code].first_subtype )
    939  1.10  christos          ND_PRINT("%s", table[data_value]);
    940   1.1  christos       else
    941  1.10  christos          ND_PRINT("#%u", data_value);
    942   1.1  christos    }
    943   1.1  christos    else
    944   1.1  christos    {
    945   1.1  christos       switch(attr_code) /* Be aware of special cases... */
    946   1.1  christos       {
    947   1.1  christos         case FRM_IPX:
    948  1.10  christos              if (GET_BE_U_4(data) == 0xFFFFFFFE )
    949  1.10  christos                 ND_PRINT("NAS Select");
    950   1.1  christos              else
    951  1.10  christos                 ND_PRINT("%u", GET_BE_U_4(data));
    952   1.1  christos           break;
    953   1.1  christos 
    954   1.1  christos         case SESSION_TIMEOUT:
    955   1.1  christos         case IDLE_TIMEOUT:
    956   1.1  christos         case ACCT_DELAY:
    957   1.1  christos         case ACCT_SESSION_TIME:
    958   1.1  christos         case ACCT_INT_INTERVAL:
    959  1.10  christos              timeout = GET_BE_U_4(data);
    960   1.1  christos              if ( timeout < 60 )
    961  1.10  christos                 ND_PRINT("%02d secs", timeout);
    962   1.1  christos              else
    963   1.1  christos              {
    964   1.1  christos                 if ( timeout < 3600 )
    965  1.10  christos                    ND_PRINT("%02d:%02d min",
    966  1.10  christos                           timeout / 60, timeout % 60);
    967   1.1  christos                 else
    968  1.10  christos                    ND_PRINT("%02d:%02d:%02d hours",
    969   1.1  christos                           timeout / 3600, (timeout % 3600) / 60,
    970  1.10  christos                           timeout % 60);
    971   1.1  christos              }
    972   1.1  christos           break;
    973   1.1  christos 
    974   1.1  christos         case FRM_ATALK_LINK:
    975  1.10  christos              if (GET_BE_U_4(data))
    976  1.10  christos                 ND_PRINT("%u", GET_BE_U_4(data));
    977   1.1  christos              else
    978  1.10  christos                 ND_PRINT("Unnumbered");
    979   1.1  christos           break;
    980   1.1  christos 
    981   1.1  christos         case FRM_ATALK_NETWORK:
    982  1.10  christos              if (GET_BE_U_4(data))
    983  1.10  christos                 ND_PRINT("%u", GET_BE_U_4(data));
    984   1.1  christos              else
    985  1.10  christos                 ND_PRINT("NAS assigned");
    986   1.1  christos           break;
    987   1.1  christos 
    988   1.1  christos         case TUNNEL_PREFERENCE:
    989  1.10  christos             if (GET_U_1(data))
    990  1.10  christos                ND_PRINT("Tag[%u] ", GET_U_1(data));
    991   1.6  christos             else
    992  1.10  christos                ND_PRINT("Tag[Unused] ");
    993   1.1  christos             data++;
    994  1.10  christos             ND_PRINT("%u", GET_BE_U_3(data));
    995   1.6  christos           break;
    996   1.6  christos 
    997   1.6  christos         case EGRESS_VLAN_ID:
    998  1.10  christos             ND_PRINT("%s (0x%02x) ",
    999  1.10  christos                    tok2str(rfc4675_tagged,"Unknown tag",GET_U_1(data)),
   1000  1.10  christos                    GET_U_1(data));
   1001   1.6  christos             data++;
   1002  1.10  christos             ND_PRINT("%u", GET_BE_U_3(data));
   1003   1.1  christos           break;
   1004   1.1  christos 
   1005   1.1  christos         default:
   1006  1.10  christos              ND_PRINT("%u", GET_BE_U_4(data));
   1007   1.1  christos           break;
   1008   1.1  christos 
   1009   1.1  christos       } /* switch */
   1010   1.1  christos 
   1011   1.1  christos    } /* if-else */
   1012   1.1  christos }
   1013   1.1  christos 
   1014   1.1  christos /*****************************/
   1015   1.1  christos /* Print an attribute IPv4   */
   1016   1.1  christos /* address value pointed by  */
   1017   1.1  christos /* 'data' and 'length' size. */
   1018   1.1  christos /*****************************/
   1019   1.1  christos /* Returns nothing.          */
   1020   1.1  christos /*****************************/
   1021   1.1  christos static void
   1022   1.5  christos print_attr_address(netdissect_options *ndo,
   1023  1.10  christos                    const u_char *data, u_int length, u_short attr_code)
   1024   1.1  christos {
   1025   1.1  christos    if (length != 4)
   1026   1.1  christos    {
   1027  1.10  christos        ND_PRINT("ERROR: length %u != 4", length);
   1028   1.1  christos        return;
   1029   1.1  christos    }
   1030   1.1  christos 
   1031   1.1  christos    switch(attr_code)
   1032   1.1  christos    {
   1033   1.1  christos       case FRM_IPADDR:
   1034   1.1  christos       case LOG_IPHOST:
   1035  1.10  christos            if (GET_BE_U_4(data) == 0xFFFFFFFF )
   1036  1.10  christos               ND_PRINT("User Selected");
   1037   1.1  christos            else
   1038  1.10  christos               if (GET_BE_U_4(data) == 0xFFFFFFFE )
   1039  1.10  christos                  ND_PRINT("NAS Select");
   1040   1.1  christos               else
   1041  1.10  christos                  ND_PRINT("%s",GET_IPADDR_STRING(data));
   1042   1.1  christos       break;
   1043   1.1  christos 
   1044   1.1  christos       default:
   1045  1.10  christos           ND_PRINT("%s", GET_IPADDR_STRING(data));
   1046   1.1  christos       break;
   1047   1.1  christos    }
   1048  1.10  christos }
   1049  1.10  christos 
   1050  1.10  christos /*****************************/
   1051  1.10  christos /* Print an attribute IPv6   */
   1052  1.10  christos /* address value pointed by  */
   1053  1.10  christos /* 'data' and 'length' size. */
   1054  1.10  christos /*****************************/
   1055  1.10  christos /* Returns nothing.          */
   1056  1.10  christos /*****************************/
   1057  1.10  christos static void
   1058  1.10  christos print_attr_address6(netdissect_options *ndo,
   1059  1.10  christos                    const u_char *data, u_int length, u_short attr_code _U_)
   1060  1.10  christos {
   1061  1.10  christos    if (length != 16)
   1062  1.10  christos    {
   1063  1.10  christos        ND_PRINT("ERROR: length %u != 16", length);
   1064  1.10  christos        return;
   1065  1.10  christos    }
   1066  1.10  christos 
   1067  1.10  christos    ND_PRINT("%s", GET_IP6ADDR_STRING(data));
   1068  1.10  christos }
   1069  1.10  christos 
   1070  1.10  christos static void
   1071  1.10  christos print_attr_netmask6(netdissect_options *ndo,
   1072  1.10  christos                     const u_char *data, u_int length, u_short attr_code _U_)
   1073  1.10  christos {
   1074  1.10  christos    u_char data2[16];
   1075  1.10  christos 
   1076  1.10  christos    if (length < 2 || length > 18)
   1077  1.10  christos    {
   1078  1.10  christos        ND_PRINT("ERROR: length %u not in range (2..18)", length);
   1079  1.10  christos        return;
   1080  1.10  christos    }
   1081  1.10  christos    ND_TCHECK_LEN(data, length);
   1082  1.10  christos    if (GET_U_1(data + 1) > 128)
   1083  1.10  christos    {
   1084  1.10  christos       ND_PRINT("ERROR: netmask %u not in range (0..128)", GET_U_1(data + 1));
   1085  1.10  christos       return;
   1086  1.10  christos    }
   1087  1.10  christos 
   1088  1.10  christos    memset(data2, 0, sizeof(data2));
   1089  1.10  christos    if (length > 2)
   1090  1.10  christos       memcpy(data2, data+2, length-2);
   1091  1.10  christos 
   1092  1.10  christos    ND_PRINT("%s/%u", ip6addr_string(ndo, data2), GET_U_1(data + 1)); /* local buffer, not packet data; don't use GET_IP6ADDR_STRING() */
   1093  1.10  christos 
   1094  1.10  christos    if (GET_U_1(data + 1) > 8 * (length - 2))
   1095  1.10  christos       ND_PRINT(" (inconsistent prefix length)");
   1096   1.1  christos 
   1097   1.1  christos    return;
   1098   1.1  christos 
   1099   1.1  christos    trunc:
   1100  1.10  christos      nd_print_trunc(ndo);
   1101   1.1  christos }
   1102   1.1  christos 
   1103  1.10  christos static void
   1104  1.10  christos print_attr_mip6_home_link_prefix(netdissect_options *ndo,
   1105  1.10  christos                     const u_char *data, u_int length, u_short attr_code _U_)
   1106  1.10  christos {
   1107  1.10  christos    if (length != 17)
   1108  1.10  christos    {
   1109  1.10  christos       ND_PRINT("ERROR: length %u != 17", length);
   1110  1.10  christos       return;
   1111  1.10  christos    }
   1112  1.10  christos    ND_TCHECK_LEN(data, length);
   1113  1.10  christos    if (GET_U_1(data) > 128)
   1114  1.10  christos    {
   1115  1.10  christos       ND_PRINT("ERROR: netmask %u not in range (0..128)", GET_U_1(data));
   1116  1.10  christos       return;
   1117  1.10  christos    }
   1118  1.10  christos 
   1119  1.10  christos    ND_PRINT("%s/%u", GET_IP6ADDR_STRING(data + 1), GET_U_1(data));
   1120  1.10  christos 
   1121  1.10  christos    return;
   1122  1.10  christos 
   1123  1.10  christos    trunc:
   1124  1.10  christos      nd_print_trunc(ndo);
   1125  1.10  christos }
   1126  1.10  christos 
   1127  1.10  christos static void
   1128  1.10  christos print_attr_operator_name(netdissect_options *ndo,
   1129  1.10  christos                     const u_char *data, u_int length, u_short attr_code _U_)
   1130  1.10  christos {
   1131  1.10  christos    u_int namespace_value;
   1132  1.10  christos 
   1133  1.10  christos    ND_TCHECK_LEN(data, length);
   1134  1.10  christos    if (length < 2)
   1135  1.10  christos    {
   1136  1.10  christos       ND_PRINT("ERROR: length %u < 2", length);
   1137  1.10  christos       return;
   1138  1.10  christos    }
   1139  1.10  christos    namespace_value = GET_U_1(data);
   1140  1.10  christos    data++;
   1141  1.10  christos    ND_PRINT("[%s] ", tok2str(operator_name_vector, "unknown namespace %u", namespace_value));
   1142  1.10  christos 
   1143  1.10  christos    (void)nd_printn(ndo, data, length - 1, NULL);
   1144  1.10  christos 
   1145  1.10  christos    return;
   1146  1.10  christos 
   1147  1.10  christos    trunc:
   1148  1.10  christos       nd_print_trunc(ndo);
   1149  1.10  christos }
   1150  1.10  christos 
   1151  1.10  christos static void
   1152  1.10  christos print_attr_location_information(netdissect_options *ndo,
   1153  1.10  christos                     const u_char *data, u_int length, u_short attr_code _U_)
   1154  1.10  christos {
   1155  1.10  christos    uint16_t index;
   1156  1.10  christos    uint8_t code, entity;
   1157  1.10  christos 
   1158  1.10  christos    ND_TCHECK_LEN(data, length);
   1159  1.10  christos    if (length < 21)
   1160  1.10  christos    {
   1161  1.10  christos      ND_PRINT("ERROR: length %u < 21", length);
   1162  1.10  christos       return;
   1163  1.10  christos    }
   1164  1.10  christos 
   1165  1.10  christos    index = GET_BE_U_2(data);
   1166  1.10  christos    data += 2;
   1167  1.10  christos 
   1168  1.10  christos    code = GET_U_1(data);
   1169  1.10  christos    data++;
   1170  1.10  christos 
   1171  1.10  christos    entity = GET_U_1(data);
   1172  1.10  christos    data++;
   1173  1.10  christos 
   1174  1.10  christos    ND_PRINT("index %u, code %s, entity %s, ",
   1175  1.10  christos        index,
   1176  1.10  christos        tok2str(location_information_code_vector, "Unknown (%u)", code),
   1177  1.10  christos        tok2str(location_information_entity_vector, "Unknown (%u)", entity)
   1178  1.10  christos    );
   1179  1.10  christos 
   1180  1.10  christos    ND_PRINT("sighting time ");
   1181  1.10  christos    p_ntp_time(ndo, (const struct l_fixedpt *)data);
   1182  1.10  christos    ND_PRINT(", ");
   1183  1.10  christos    data += 8;
   1184  1.10  christos 
   1185  1.10  christos    ND_PRINT("time to live ");
   1186  1.10  christos    p_ntp_time(ndo, (const struct l_fixedpt *)data);
   1187  1.10  christos    ND_PRINT(", ");
   1188  1.10  christos    data += 8;
   1189  1.10  christos 
   1190  1.10  christos    ND_PRINT("method \"");
   1191  1.10  christos    (void)nd_printn(ndo, data, length - 20, NULL);
   1192  1.10  christos    ND_PRINT("\"");
   1193  1.10  christos 
   1194  1.10  christos    return;
   1195  1.10  christos 
   1196  1.10  christos    trunc:
   1197  1.10  christos       nd_print_trunc(ndo);
   1198  1.10  christos }
   1199  1.10  christos 
   1200  1.10  christos static void
   1201  1.10  christos print_attr_location_data(netdissect_options *ndo,
   1202  1.10  christos                     const u_char *data, u_int length, u_short attr_code _U_)
   1203  1.10  christos {
   1204  1.10  christos    uint16_t index;
   1205  1.10  christos 
   1206  1.10  christos    ND_TCHECK_LEN(data, length);
   1207  1.10  christos    if (length < 3)
   1208  1.10  christos    {
   1209  1.10  christos      ND_PRINT("ERROR: length %u < 3", length);
   1210  1.10  christos       return;
   1211  1.10  christos    }
   1212  1.10  christos 
   1213  1.10  christos    index = GET_BE_U_2(data);
   1214  1.10  christos    data += 2;
   1215  1.10  christos    ND_PRINT("index %u, location", index);
   1216  1.10  christos 
   1217  1.10  christos    /* The Location field of the String field of the Location-Data attribute
   1218  1.10  christos     * can have two completely different structures depending on the value of
   1219  1.10  christos     * the Code field of a Location-Info attribute, which supposedly precedes
   1220  1.10  christos     * the current attribute. Unfortunately, this choice of encoding makes it
   1221  1.10  christos     * non-trivial to decode the Location field without preserving some state
   1222  1.10  christos     * between the attributes.
   1223  1.10  christos     */
   1224  1.10  christos    hex_and_ascii_print(ndo, "\n\t    ", data, length - 2);
   1225  1.10  christos 
   1226  1.10  christos    return;
   1227  1.10  christos 
   1228  1.10  christos    trunc:
   1229  1.10  christos       nd_print_trunc(ndo);
   1230  1.10  christos }
   1231  1.10  christos 
   1232  1.10  christos static void
   1233  1.10  christos print_basic_location_policy_rules(netdissect_options *ndo,
   1234  1.10  christos                     const u_char *data, u_int length, u_short attr_code _U_)
   1235  1.10  christos {
   1236  1.10  christos    uint16_t flags;
   1237  1.10  christos 
   1238  1.10  christos    ND_TCHECK_LEN(data, length);
   1239  1.10  christos    if (length < 10)
   1240  1.10  christos    {
   1241  1.10  christos      ND_PRINT("ERROR: length %u < 10", length);
   1242  1.10  christos       return;
   1243  1.10  christos    }
   1244  1.10  christos 
   1245  1.10  christos    flags = GET_BE_U_2(data);
   1246  1.10  christos    data += 2;
   1247  1.10  christos    ND_PRINT("flags [%s], ", bittok2str(blpr_bm, "none", flags));
   1248  1.10  christos 
   1249  1.10  christos    ND_PRINT("retention expires ");
   1250  1.10  christos    p_ntp_time(ndo, (const struct l_fixedpt *)data);
   1251  1.10  christos    data += 8;
   1252  1.10  christos 
   1253  1.10  christos    if (length > 10) {
   1254  1.10  christos       ND_PRINT(", note well \"");
   1255  1.10  christos       (void)nd_printn(ndo, data, length - 10, NULL);
   1256  1.10  christos       ND_PRINT("\"");
   1257  1.10  christos    }
   1258  1.10  christos 
   1259  1.10  christos    return;
   1260  1.10  christos 
   1261  1.10  christos    trunc:
   1262  1.10  christos       nd_print_trunc(ndo);
   1263  1.10  christos }
   1264  1.10  christos 
   1265  1.10  christos 
   1266   1.1  christos /*************************************/
   1267   1.1  christos /* Print an attribute of 'secs since */
   1268   1.1  christos /* January 1, 1970 00:00 UTC' value  */
   1269   1.1  christos /* pointed by 'data' and 'length'    */
   1270   1.1  christos /* size.                             */
   1271   1.1  christos /*************************************/
   1272   1.1  christos /* Returns nothing.                  */
   1273   1.1  christos /*************************************/
   1274   1.5  christos static void
   1275   1.5  christos print_attr_time(netdissect_options *ndo,
   1276  1.10  christos                 const u_char *data, u_int length, u_short attr_code _U_)
   1277   1.1  christos {
   1278   1.1  christos    time_t attr_time;
   1279   1.1  christos    char string[26];
   1280   1.1  christos 
   1281   1.1  christos    if (length != 4)
   1282   1.1  christos    {
   1283  1.10  christos        ND_PRINT("ERROR: length %u != 4", length);
   1284   1.1  christos        return;
   1285   1.1  christos    }
   1286   1.1  christos 
   1287  1.10  christos    attr_time = GET_BE_U_4(data);
   1288  1.10  christos    strlcpy(string, ctime(&attr_time), sizeof(string));
   1289   1.1  christos    /* Get rid of the newline */
   1290   1.1  christos    string[24] = '\0';
   1291  1.10  christos    ND_PRINT("%.24s", string);
   1292  1.10  christos }
   1293  1.10  christos 
   1294  1.10  christos static void
   1295  1.10  christos print_attr_vector64(netdissect_options *ndo,
   1296  1.10  christos                  register const u_char *data, u_int length, u_short attr_code _U_)
   1297  1.10  christos {
   1298  1.10  christos    uint64_t data_value, i;
   1299  1.10  christos    const char *sep = "";
   1300  1.10  christos 
   1301  1.10  christos    if (length != 8)
   1302  1.10  christos    {
   1303  1.10  christos        ND_PRINT("ERROR: length %u != 8", length);
   1304  1.10  christos        return;
   1305  1.10  christos    }
   1306  1.10  christos 
   1307  1.10  christos    ND_PRINT("[");
   1308  1.10  christos 
   1309  1.10  christos    data_value = GET_BE_U_8(data);
   1310  1.10  christos    /* Print the 64-bit field in a format similar to bittok2str(), less
   1311  1.10  christos     * flagging any unknown bits. This way it should be easier to replace
   1312  1.10  christos     * the custom code with a library function later.
   1313  1.10  christos     */
   1314  1.10  christos    for (i = 0; i < TAM_SIZE(mip6_feature_vector); i++) {
   1315  1.10  christos        if (data_value & mip6_feature_vector[i].v) {
   1316  1.10  christos            ND_PRINT("%s%s", sep, mip6_feature_vector[i].s);
   1317  1.10  christos            sep = ", ";
   1318  1.10  christos        }
   1319  1.10  christos    }
   1320   1.1  christos 
   1321  1.10  christos    ND_PRINT("]");
   1322   1.1  christos }
   1323   1.1  christos 
   1324   1.1  christos /***********************************/
   1325   1.1  christos /* Print an attribute of 'strange' */
   1326   1.1  christos /* data format pointed by 'data'   */
   1327   1.1  christos /* and 'length' size.              */
   1328   1.1  christos /***********************************/
   1329   1.1  christos /* Returns nothing.                */
   1330   1.1  christos /***********************************/
   1331   1.5  christos static void
   1332   1.5  christos print_attr_strange(netdissect_options *ndo,
   1333  1.10  christos                    const u_char *data, u_int length, u_short attr_code)
   1334   1.1  christos {
   1335   1.1  christos    u_short len_data;
   1336  1.10  christos    u_int error_cause_value;
   1337   1.1  christos 
   1338   1.1  christos    switch(attr_code)
   1339   1.1  christos    {
   1340   1.1  christos       case ARAP_PASS:
   1341   1.1  christos            if (length != 16)
   1342   1.1  christos            {
   1343  1.10  christos                ND_PRINT("ERROR: length %u != 16", length);
   1344   1.1  christos                return;
   1345   1.1  christos            }
   1346  1.10  christos            ND_PRINT("User_challenge (");
   1347   1.1  christos            len_data = 8;
   1348   1.1  christos            PRINT_HEX(len_data, data);
   1349  1.10  christos            ND_PRINT(") User_resp(");
   1350   1.1  christos            len_data = 8;
   1351   1.1  christos            PRINT_HEX(len_data, data);
   1352  1.10  christos            ND_PRINT(")");
   1353   1.1  christos         break;
   1354   1.1  christos 
   1355   1.1  christos       case ARAP_FEATURES:
   1356   1.1  christos            if (length != 14)
   1357   1.1  christos            {
   1358  1.10  christos                ND_PRINT("ERROR: length %u != 14", length);
   1359   1.1  christos                return;
   1360   1.1  christos            }
   1361  1.10  christos            if (GET_U_1(data))
   1362  1.10  christos               ND_PRINT("User can change password");
   1363   1.1  christos            else
   1364  1.10  christos               ND_PRINT("User cannot change password");
   1365   1.1  christos            data++;
   1366  1.10  christos            ND_PRINT(", Min password length: %u", GET_U_1(data));
   1367   1.1  christos            data++;
   1368  1.10  christos            ND_PRINT(", created at: ");
   1369   1.1  christos            len_data = 4;
   1370   1.1  christos            PRINT_HEX(len_data, data);
   1371  1.10  christos            ND_PRINT(", expires in: ");
   1372   1.1  christos            len_data = 4;
   1373   1.1  christos            PRINT_HEX(len_data, data);
   1374  1.10  christos            ND_PRINT(", Current Time: ");
   1375   1.1  christos            len_data = 4;
   1376   1.1  christos            PRINT_HEX(len_data, data);
   1377   1.1  christos         break;
   1378   1.1  christos 
   1379   1.1  christos       case ARAP_CHALLENGE_RESP:
   1380   1.1  christos            if (length < 8)
   1381   1.1  christos            {
   1382  1.10  christos                ND_PRINT("ERROR: length %u != 8", length);
   1383   1.1  christos                return;
   1384   1.1  christos            }
   1385   1.1  christos            len_data = 8;
   1386   1.1  christos            PRINT_HEX(len_data, data);
   1387   1.1  christos         break;
   1388  1.10  christos 
   1389  1.10  christos       case ERROR_CAUSE:
   1390  1.10  christos            if (length != 4)
   1391  1.10  christos            {
   1392  1.10  christos                ND_PRINT("Error: length %u != 4", length);
   1393  1.10  christos                return;
   1394  1.10  christos            }
   1395  1.10  christos 
   1396  1.10  christos            error_cause_value = GET_BE_U_4(data);
   1397  1.10  christos            ND_PRINT("Error cause %u: %s", error_cause_value, tok2str(errorcausetype, "Error-Cause %u not known", error_cause_value));
   1398  1.10  christos         break;
   1399   1.1  christos    }
   1400   1.1  christos    return;
   1401   1.1  christos }
   1402   1.1  christos 
   1403   1.1  christos static void
   1404   1.5  christos radius_attrs_print(netdissect_options *ndo,
   1405  1.10  christos                    const u_char *attr, u_int length)
   1406   1.1  christos {
   1407  1.10  christos    const struct radius_attr *rad_attr = (const struct radius_attr *)attr;
   1408   1.1  christos    const char *attr_string;
   1409  1.10  christos    uint8_t type, len;
   1410   1.1  christos 
   1411   1.1  christos    while (length > 0)
   1412   1.1  christos    {
   1413   1.1  christos      if (length < 2)
   1414   1.1  christos         goto trunc;
   1415  1.10  christos      ND_TCHECK_SIZE(rad_attr);
   1416   1.5  christos 
   1417  1.10  christos      type = GET_U_1(rad_attr->type);
   1418  1.10  christos      len = GET_U_1(rad_attr->len);
   1419  1.10  christos      if (type != 0 && type < TAM_SIZE(attr_type))
   1420  1.10  christos 	attr_string = attr_type[type].name;
   1421   1.1  christos      else
   1422   1.1  christos 	attr_string = "Unknown";
   1423  1.10  christos 
   1424  1.10  christos      ND_PRINT("\n\t  %s Attribute (%u), length: %u",
   1425  1.10  christos                attr_string,
   1426  1.10  christos                type,
   1427  1.10  christos                len);
   1428  1.10  christos      if (len < 2)
   1429   1.1  christos      {
   1430  1.10  christos        ND_PRINT(" (bogus, must be >= 2)");
   1431  1.10  christos        return;
   1432   1.1  christos      }
   1433  1.10  christos      if (len > length)
   1434   1.1  christos      {
   1435  1.10  christos         ND_PRINT(" (bogus, goes past end of packet)");
   1436   1.1  christos         return;
   1437   1.1  christos      }
   1438  1.10  christos      ND_PRINT(", Value: ");
   1439   1.1  christos 
   1440  1.10  christos      if (type < TAM_SIZE(attr_type))
   1441   1.1  christos      {
   1442  1.10  christos          if (len > 2)
   1443   1.1  christos          {
   1444  1.10  christos              if ( attr_type[type].print_func )
   1445  1.10  christos                  (*attr_type[type].print_func)(
   1446   1.7  christos                      ndo, ((const u_char *)(rad_attr+1)),
   1447  1.10  christos                      len - 2, type);
   1448   1.1  christos          }
   1449   1.1  christos      }
   1450   1.1  christos      /* do we also want to see a hex dump ? */
   1451   1.5  christos      if (ndo->ndo_vflag> 1)
   1452  1.10  christos          print_unknown_data(ndo, (const u_char *)rad_attr+2, "\n\t    ", (len)-2);
   1453   1.1  christos 
   1454  1.10  christos      length-=(len);
   1455  1.10  christos      rad_attr = (const struct radius_attr *)( ((const char *)(rad_attr))+len);
   1456   1.1  christos    }
   1457   1.1  christos    return;
   1458   1.1  christos 
   1459   1.1  christos trunc:
   1460  1.10  christos    nd_print_trunc(ndo);
   1461   1.1  christos }
   1462   1.1  christos 
   1463   1.1  christos void
   1464   1.5  christos radius_print(netdissect_options *ndo,
   1465   1.5  christos              const u_char *dat, u_int length)
   1466   1.1  christos {
   1467  1.10  christos    const struct radius_hdr *rad;
   1468   1.1  christos    u_int len, auth_idx;
   1469   1.1  christos 
   1470  1.10  christos    ndo->ndo_protocol = "radius";
   1471  1.10  christos    ND_TCHECK_LEN(dat, MIN_RADIUS_LEN);
   1472   1.7  christos    rad = (const struct radius_hdr *)dat;
   1473  1.10  christos    len = GET_BE_U_2(rad->len);
   1474   1.1  christos 
   1475   1.1  christos    if (len < MIN_RADIUS_LEN)
   1476   1.1  christos    {
   1477  1.10  christos 	  nd_print_trunc(ndo);
   1478   1.1  christos 	  return;
   1479   1.1  christos    }
   1480   1.1  christos 
   1481   1.1  christos    if (len > length)
   1482   1.1  christos 	  len = length;
   1483   1.1  christos 
   1484   1.5  christos    if (ndo->ndo_vflag < 1) {
   1485  1.10  christos        ND_PRINT("RADIUS, %s (%u), id: 0x%02x length: %u",
   1486  1.10  christos               tok2str(radius_command_values,"Unknown Command",GET_U_1(rad->code)),
   1487  1.10  christos               GET_U_1(rad->code),
   1488  1.10  christos               GET_U_1(rad->id),
   1489  1.10  christos               len);
   1490   1.1  christos        return;
   1491   1.1  christos    }
   1492   1.1  christos    else {
   1493  1.10  christos        ND_PRINT("RADIUS, length: %u\n\t%s (%u), id: 0x%02x, Authenticator: ",
   1494   1.1  christos               len,
   1495  1.10  christos               tok2str(radius_command_values,"Unknown Command",GET_U_1(rad->code)),
   1496  1.10  christos               GET_U_1(rad->code),
   1497  1.10  christos               GET_U_1(rad->id));
   1498   1.1  christos 
   1499   1.1  christos        for(auth_idx=0; auth_idx < 16; auth_idx++)
   1500  1.10  christos             ND_PRINT("%02x", rad->auth[auth_idx]);
   1501   1.1  christos    }
   1502   1.1  christos 
   1503   1.1  christos    if (len > MIN_RADIUS_LEN)
   1504   1.5  christos       radius_attrs_print(ndo, dat + MIN_RADIUS_LEN, len - MIN_RADIUS_LEN);
   1505   1.1  christos    return;
   1506   1.1  christos 
   1507   1.1  christos trunc:
   1508  1.10  christos    nd_print_trunc(ndo);
   1509   1.1  christos }
   1510