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