1e5b75505Sopenharmony_ci/* 2e5b75505Sopenharmony_ci * RADIUS message processing 3e5b75505Sopenharmony_ci * Copyright (c) 2002-2009, 2012, 2014-2015, Jouni Malinen <j@w1.fi> 4e5b75505Sopenharmony_ci * 5e5b75505Sopenharmony_ci * This software may be distributed under the terms of the BSD license. 6e5b75505Sopenharmony_ci * See README for more details. 7e5b75505Sopenharmony_ci */ 8e5b75505Sopenharmony_ci 9e5b75505Sopenharmony_ci#ifndef RADIUS_H 10e5b75505Sopenharmony_ci#define RADIUS_H 11e5b75505Sopenharmony_ci 12e5b75505Sopenharmony_ci/* RFC 2865 - RADIUS */ 13e5b75505Sopenharmony_ci 14e5b75505Sopenharmony_ci#ifdef _MSC_VER 15e5b75505Sopenharmony_ci#pragma pack(push, 1) 16e5b75505Sopenharmony_ci#endif /* _MSC_VER */ 17e5b75505Sopenharmony_ci 18e5b75505Sopenharmony_cistruct radius_hdr { 19e5b75505Sopenharmony_ci u8 code; 20e5b75505Sopenharmony_ci u8 identifier; 21e5b75505Sopenharmony_ci be16 length; /* including this header */ 22e5b75505Sopenharmony_ci u8 authenticator[16]; 23e5b75505Sopenharmony_ci /* followed by length-20 octets of attributes */ 24e5b75505Sopenharmony_ci} STRUCT_PACKED; 25e5b75505Sopenharmony_ci 26e5b75505Sopenharmony_cienum { RADIUS_CODE_ACCESS_REQUEST = 1, 27e5b75505Sopenharmony_ci RADIUS_CODE_ACCESS_ACCEPT = 2, 28e5b75505Sopenharmony_ci RADIUS_CODE_ACCESS_REJECT = 3, 29e5b75505Sopenharmony_ci RADIUS_CODE_ACCOUNTING_REQUEST = 4, 30e5b75505Sopenharmony_ci RADIUS_CODE_ACCOUNTING_RESPONSE = 5, 31e5b75505Sopenharmony_ci RADIUS_CODE_ACCESS_CHALLENGE = 11, 32e5b75505Sopenharmony_ci RADIUS_CODE_STATUS_SERVER = 12, 33e5b75505Sopenharmony_ci RADIUS_CODE_STATUS_CLIENT = 13, 34e5b75505Sopenharmony_ci RADIUS_CODE_DISCONNECT_REQUEST = 40, 35e5b75505Sopenharmony_ci RADIUS_CODE_DISCONNECT_ACK = 41, 36e5b75505Sopenharmony_ci RADIUS_CODE_DISCONNECT_NAK = 42, 37e5b75505Sopenharmony_ci RADIUS_CODE_COA_REQUEST = 43, 38e5b75505Sopenharmony_ci RADIUS_CODE_COA_ACK = 44, 39e5b75505Sopenharmony_ci RADIUS_CODE_COA_NAK = 45, 40e5b75505Sopenharmony_ci RADIUS_CODE_RESERVED = 255 41e5b75505Sopenharmony_ci}; 42e5b75505Sopenharmony_ci 43e5b75505Sopenharmony_cistruct radius_attr_hdr { 44e5b75505Sopenharmony_ci u8 type; 45e5b75505Sopenharmony_ci u8 length; /* including this header */ 46e5b75505Sopenharmony_ci /* followed by length-2 octets of attribute value */ 47e5b75505Sopenharmony_ci} STRUCT_PACKED; 48e5b75505Sopenharmony_ci 49e5b75505Sopenharmony_ci#define RADIUS_MAX_ATTR_LEN (255 - sizeof(struct radius_attr_hdr)) 50e5b75505Sopenharmony_ci 51e5b75505Sopenharmony_cienum { RADIUS_ATTR_USER_NAME = 1, 52e5b75505Sopenharmony_ci RADIUS_ATTR_USER_PASSWORD = 2, 53e5b75505Sopenharmony_ci RADIUS_ATTR_NAS_IP_ADDRESS = 4, 54e5b75505Sopenharmony_ci RADIUS_ATTR_NAS_PORT = 5, 55e5b75505Sopenharmony_ci RADIUS_ATTR_SERVICE_TYPE = 6, 56e5b75505Sopenharmony_ci RADIUS_ATTR_FRAMED_IP_ADDRESS = 8, 57e5b75505Sopenharmony_ci RADIUS_ATTR_FRAMED_MTU = 12, 58e5b75505Sopenharmony_ci RADIUS_ATTR_REPLY_MESSAGE = 18, 59e5b75505Sopenharmony_ci RADIUS_ATTR_STATE = 24, 60e5b75505Sopenharmony_ci RADIUS_ATTR_CLASS = 25, 61e5b75505Sopenharmony_ci RADIUS_ATTR_VENDOR_SPECIFIC = 26, 62e5b75505Sopenharmony_ci RADIUS_ATTR_SESSION_TIMEOUT = 27, 63e5b75505Sopenharmony_ci RADIUS_ATTR_IDLE_TIMEOUT = 28, 64e5b75505Sopenharmony_ci RADIUS_ATTR_TERMINATION_ACTION = 29, 65e5b75505Sopenharmony_ci RADIUS_ATTR_CALLED_STATION_ID = 30, 66e5b75505Sopenharmony_ci RADIUS_ATTR_CALLING_STATION_ID = 31, 67e5b75505Sopenharmony_ci RADIUS_ATTR_NAS_IDENTIFIER = 32, 68e5b75505Sopenharmony_ci RADIUS_ATTR_PROXY_STATE = 33, 69e5b75505Sopenharmony_ci RADIUS_ATTR_ACCT_STATUS_TYPE = 40, 70e5b75505Sopenharmony_ci RADIUS_ATTR_ACCT_DELAY_TIME = 41, 71e5b75505Sopenharmony_ci RADIUS_ATTR_ACCT_INPUT_OCTETS = 42, 72e5b75505Sopenharmony_ci RADIUS_ATTR_ACCT_OUTPUT_OCTETS = 43, 73e5b75505Sopenharmony_ci RADIUS_ATTR_ACCT_SESSION_ID = 44, 74e5b75505Sopenharmony_ci RADIUS_ATTR_ACCT_AUTHENTIC = 45, 75e5b75505Sopenharmony_ci RADIUS_ATTR_ACCT_SESSION_TIME = 46, 76e5b75505Sopenharmony_ci RADIUS_ATTR_ACCT_INPUT_PACKETS = 47, 77e5b75505Sopenharmony_ci RADIUS_ATTR_ACCT_OUTPUT_PACKETS = 48, 78e5b75505Sopenharmony_ci RADIUS_ATTR_ACCT_TERMINATE_CAUSE = 49, 79e5b75505Sopenharmony_ci RADIUS_ATTR_ACCT_MULTI_SESSION_ID = 50, 80e5b75505Sopenharmony_ci RADIUS_ATTR_ACCT_LINK_COUNT = 51, 81e5b75505Sopenharmony_ci RADIUS_ATTR_ACCT_INPUT_GIGAWORDS = 52, 82e5b75505Sopenharmony_ci RADIUS_ATTR_ACCT_OUTPUT_GIGAWORDS = 53, 83e5b75505Sopenharmony_ci RADIUS_ATTR_EVENT_TIMESTAMP = 55, 84e5b75505Sopenharmony_ci RADIUS_ATTR_EGRESS_VLANID = 56, 85e5b75505Sopenharmony_ci RADIUS_ATTR_NAS_PORT_TYPE = 61, 86e5b75505Sopenharmony_ci RADIUS_ATTR_TUNNEL_TYPE = 64, 87e5b75505Sopenharmony_ci RADIUS_ATTR_TUNNEL_MEDIUM_TYPE = 65, 88e5b75505Sopenharmony_ci RADIUS_ATTR_TUNNEL_PASSWORD = 69, 89e5b75505Sopenharmony_ci RADIUS_ATTR_CONNECT_INFO = 77, 90e5b75505Sopenharmony_ci RADIUS_ATTR_EAP_MESSAGE = 79, 91e5b75505Sopenharmony_ci RADIUS_ATTR_MESSAGE_AUTHENTICATOR = 80, 92e5b75505Sopenharmony_ci RADIUS_ATTR_TUNNEL_PRIVATE_GROUP_ID = 81, 93e5b75505Sopenharmony_ci RADIUS_ATTR_ACCT_INTERIM_INTERVAL = 85, 94e5b75505Sopenharmony_ci RADIUS_ATTR_CHARGEABLE_USER_IDENTITY = 89, 95e5b75505Sopenharmony_ci RADIUS_ATTR_NAS_IPV6_ADDRESS = 95, 96e5b75505Sopenharmony_ci RADIUS_ATTR_ERROR_CAUSE = 101, 97e5b75505Sopenharmony_ci RADIUS_ATTR_EAP_KEY_NAME = 102, 98e5b75505Sopenharmony_ci RADIUS_ATTR_OPERATOR_NAME = 126, 99e5b75505Sopenharmony_ci RADIUS_ATTR_LOCATION_INFO = 127, 100e5b75505Sopenharmony_ci RADIUS_ATTR_LOCATION_DATA = 128, 101e5b75505Sopenharmony_ci RADIUS_ATTR_BASIC_LOCATION_POLICY_RULES = 129, 102e5b75505Sopenharmony_ci RADIUS_ATTR_EXTENDED_LOCATION_POLICY_RULES = 130, 103e5b75505Sopenharmony_ci RADIUS_ATTR_LOCATION_CAPABLE = 131, 104e5b75505Sopenharmony_ci RADIUS_ATTR_REQUESTED_LOCATION_INFO = 132, 105e5b75505Sopenharmony_ci RADIUS_ATTR_GSS_ACCEPTOR_SERVICE_NAME = 164, 106e5b75505Sopenharmony_ci RADIUS_ATTR_GSS_ACCEPTOR_HOST_NAME = 165, 107e5b75505Sopenharmony_ci RADIUS_ATTR_GSS_ACCEPTOR_SERVICE_SPECIFICS = 166, 108e5b75505Sopenharmony_ci RADIUS_ATTR_GSS_ACCEPTOR_REALM_NAME = 167, 109e5b75505Sopenharmony_ci RADIUS_ATTR_MOBILITY_DOMAIN_ID = 177, 110e5b75505Sopenharmony_ci RADIUS_ATTR_WLAN_HESSID = 181, 111e5b75505Sopenharmony_ci RADIUS_ATTR_WLAN_REASON_CODE = 185, 112e5b75505Sopenharmony_ci RADIUS_ATTR_WLAN_PAIRWISE_CIPHER = 186, 113e5b75505Sopenharmony_ci RADIUS_ATTR_WLAN_GROUP_CIPHER = 187, 114e5b75505Sopenharmony_ci RADIUS_ATTR_WLAN_AKM_SUITE = 188, 115e5b75505Sopenharmony_ci RADIUS_ATTR_WLAN_GROUP_MGMT_CIPHER = 189, 116e5b75505Sopenharmony_ci}; 117e5b75505Sopenharmony_ci 118e5b75505Sopenharmony_ci 119e5b75505Sopenharmony_ci/* Service-Type values (RFC 2865, 5.6) */ 120e5b75505Sopenharmony_ci#define RADIUS_SERVICE_TYPE_FRAMED 2 121e5b75505Sopenharmony_ci 122e5b75505Sopenharmony_ci/* Termination-Action */ 123e5b75505Sopenharmony_ci#define RADIUS_TERMINATION_ACTION_DEFAULT 0 124e5b75505Sopenharmony_ci#define RADIUS_TERMINATION_ACTION_RADIUS_REQUEST 1 125e5b75505Sopenharmony_ci 126e5b75505Sopenharmony_ci/* NAS-Port-Type */ 127e5b75505Sopenharmony_ci#define RADIUS_NAS_PORT_TYPE_IEEE_802_11 19 128e5b75505Sopenharmony_ci 129e5b75505Sopenharmony_ci/* Acct-Status-Type */ 130e5b75505Sopenharmony_ci#define RADIUS_ACCT_STATUS_TYPE_START 1 131e5b75505Sopenharmony_ci#define RADIUS_ACCT_STATUS_TYPE_STOP 2 132e5b75505Sopenharmony_ci#define RADIUS_ACCT_STATUS_TYPE_INTERIM_UPDATE 3 133e5b75505Sopenharmony_ci#define RADIUS_ACCT_STATUS_TYPE_ACCOUNTING_ON 7 134e5b75505Sopenharmony_ci#define RADIUS_ACCT_STATUS_TYPE_ACCOUNTING_OFF 8 135e5b75505Sopenharmony_ci 136e5b75505Sopenharmony_ci/* Acct-Authentic */ 137e5b75505Sopenharmony_ci#define RADIUS_ACCT_AUTHENTIC_RADIUS 1 138e5b75505Sopenharmony_ci#define RADIUS_ACCT_AUTHENTIC_LOCAL 2 139e5b75505Sopenharmony_ci#define RADIUS_ACCT_AUTHENTIC_REMOTE 3 140e5b75505Sopenharmony_ci 141e5b75505Sopenharmony_ci/* Acct-Terminate-Cause */ 142e5b75505Sopenharmony_ci#define RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST 1 143e5b75505Sopenharmony_ci#define RADIUS_ACCT_TERMINATE_CAUSE_LOST_CARRIER 2 144e5b75505Sopenharmony_ci#define RADIUS_ACCT_TERMINATE_CAUSE_LOST_SERVICE 3 145e5b75505Sopenharmony_ci#define RADIUS_ACCT_TERMINATE_CAUSE_IDLE_TIMEOUT 4 146e5b75505Sopenharmony_ci#define RADIUS_ACCT_TERMINATE_CAUSE_SESSION_TIMEOUT 5 147e5b75505Sopenharmony_ci#define RADIUS_ACCT_TERMINATE_CAUSE_ADMIN_RESET 6 148e5b75505Sopenharmony_ci#define RADIUS_ACCT_TERMINATE_CAUSE_ADMIN_REBOOT 7 149e5b75505Sopenharmony_ci#define RADIUS_ACCT_TERMINATE_CAUSE_PORT_ERROR 8 150e5b75505Sopenharmony_ci#define RADIUS_ACCT_TERMINATE_CAUSE_NAS_ERROR 9 151e5b75505Sopenharmony_ci#define RADIUS_ACCT_TERMINATE_CAUSE_NAS_REQUEST 10 152e5b75505Sopenharmony_ci#define RADIUS_ACCT_TERMINATE_CAUSE_NAS_REBOOT 11 153e5b75505Sopenharmony_ci#define RADIUS_ACCT_TERMINATE_CAUSE_PORT_UNNEEDED 12 154e5b75505Sopenharmony_ci#define RADIUS_ACCT_TERMINATE_CAUSE_PORT_PREEMPTED 13 155e5b75505Sopenharmony_ci#define RADIUS_ACCT_TERMINATE_CAUSE_PORT_SUSPENDED 14 156e5b75505Sopenharmony_ci#define RADIUS_ACCT_TERMINATE_CAUSE_SERVICE_UNAVAILABLE 15 157e5b75505Sopenharmony_ci#define RADIUS_ACCT_TERMINATE_CAUSE_CALLBACK 16 158e5b75505Sopenharmony_ci#define RADIUS_ACCT_TERMINATE_CAUSE_USER_ERROR 17 159e5b75505Sopenharmony_ci#define RADIUS_ACCT_TERMINATE_CAUSE_HOST_REQUEST 18 160e5b75505Sopenharmony_ci 161e5b75505Sopenharmony_ci#define RADIUS_TUNNEL_TAGS 32 162e5b75505Sopenharmony_ci 163e5b75505Sopenharmony_ci/* Tunnel-Type */ 164e5b75505Sopenharmony_ci#define RADIUS_TUNNEL_TYPE_PPTP 1 165e5b75505Sopenharmony_ci#define RADIUS_TUNNEL_TYPE_L2TP 3 166e5b75505Sopenharmony_ci#define RADIUS_TUNNEL_TYPE_IPIP 7 167e5b75505Sopenharmony_ci#define RADIUS_TUNNEL_TYPE_GRE 10 168e5b75505Sopenharmony_ci#define RADIUS_TUNNEL_TYPE_VLAN 13 169e5b75505Sopenharmony_ci 170e5b75505Sopenharmony_ci/* Tunnel-Medium-Type */ 171e5b75505Sopenharmony_ci#define RADIUS_TUNNEL_MEDIUM_TYPE_IPV4 1 172e5b75505Sopenharmony_ci#define RADIUS_TUNNEL_MEDIUM_TYPE_IPV6 2 173e5b75505Sopenharmony_ci#define RADIUS_TUNNEL_MEDIUM_TYPE_802 6 174e5b75505Sopenharmony_ci 175e5b75505Sopenharmony_ci 176e5b75505Sopenharmony_cistruct radius_attr_vendor { 177e5b75505Sopenharmony_ci u8 vendor_type; 178e5b75505Sopenharmony_ci u8 vendor_length; 179e5b75505Sopenharmony_ci} STRUCT_PACKED; 180e5b75505Sopenharmony_ci 181e5b75505Sopenharmony_ci#define RADIUS_VENDOR_ID_CISCO 9 182e5b75505Sopenharmony_ci#define RADIUS_CISCO_AV_PAIR 1 183e5b75505Sopenharmony_ci 184e5b75505Sopenharmony_ci/* RFC 2548 - Microsoft Vendor-specific RADIUS Attributes */ 185e5b75505Sopenharmony_ci#define RADIUS_VENDOR_ID_MICROSOFT 311 186e5b75505Sopenharmony_ci 187e5b75505Sopenharmony_cienum { RADIUS_VENDOR_ATTR_MS_MPPE_SEND_KEY = 16, 188e5b75505Sopenharmony_ci RADIUS_VENDOR_ATTR_MS_MPPE_RECV_KEY = 17 189e5b75505Sopenharmony_ci}; 190e5b75505Sopenharmony_ci 191e5b75505Sopenharmony_ci 192e5b75505Sopenharmony_ci/* Hotspot 2.0 - WFA Vendor-specific RADIUS Attributes */ 193e5b75505Sopenharmony_ci#define RADIUS_VENDOR_ID_WFA 40808 194e5b75505Sopenharmony_ci 195e5b75505Sopenharmony_cienum { 196e5b75505Sopenharmony_ci RADIUS_VENDOR_ATTR_WFA_HS20_SUBSCR_REMEDIATION = 1, 197e5b75505Sopenharmony_ci RADIUS_VENDOR_ATTR_WFA_HS20_AP_VERSION = 2, 198e5b75505Sopenharmony_ci RADIUS_VENDOR_ATTR_WFA_HS20_STA_VERSION = 3, 199e5b75505Sopenharmony_ci RADIUS_VENDOR_ATTR_WFA_HS20_DEAUTH_REQ = 4, 200e5b75505Sopenharmony_ci RADIUS_VENDOR_ATTR_WFA_HS20_SESSION_INFO_URL = 5, 201e5b75505Sopenharmony_ci RADIUS_VENDOR_ATTR_WFA_HS20_ROAMING_CONSORTIUM = 6, 202e5b75505Sopenharmony_ci RADIUS_VENDOR_ATTR_WFA_HS20_T_C_FILENAME = 7, 203e5b75505Sopenharmony_ci RADIUS_VENDOR_ATTR_WFA_HS20_TIMESTAMP = 8, 204e5b75505Sopenharmony_ci RADIUS_VENDOR_ATTR_WFA_HS20_T_C_FILTERING = 9, 205e5b75505Sopenharmony_ci RADIUS_VENDOR_ATTR_WFA_HS20_T_C_URL = 10, 206e5b75505Sopenharmony_ci}; 207e5b75505Sopenharmony_ci 208e5b75505Sopenharmony_ci#ifdef _MSC_VER 209e5b75505Sopenharmony_ci#pragma pack(pop) 210e5b75505Sopenharmony_ci#endif /* _MSC_VER */ 211e5b75505Sopenharmony_ci 212e5b75505Sopenharmony_cistruct radius_ms_mppe_keys { 213e5b75505Sopenharmony_ci u8 *send; 214e5b75505Sopenharmony_ci size_t send_len; 215e5b75505Sopenharmony_ci u8 *recv; 216e5b75505Sopenharmony_ci size_t recv_len; 217e5b75505Sopenharmony_ci}; 218e5b75505Sopenharmony_ci 219e5b75505Sopenharmony_ci 220e5b75505Sopenharmony_cistruct radius_msg; 221e5b75505Sopenharmony_ci 222e5b75505Sopenharmony_ci/* Default size to be allocated for new RADIUS messages */ 223e5b75505Sopenharmony_ci#define RADIUS_DEFAULT_MSG_SIZE 1024 224e5b75505Sopenharmony_ci 225e5b75505Sopenharmony_ci/* Default size to be allocated for attribute array */ 226e5b75505Sopenharmony_ci#define RADIUS_DEFAULT_ATTR_COUNT 16 227e5b75505Sopenharmony_ci 228e5b75505Sopenharmony_ci/* Maximum message length for incoming RADIUS messages, as stated in RFC 2865 229e5b75505Sopenharmony_ci * Section 3 ("Packet Format").*/ 230e5b75505Sopenharmony_ci#define RADIUS_MAX_MSG_LEN 4096 231e5b75505Sopenharmony_ci 232e5b75505Sopenharmony_ci/* MAC address ASCII format for IEEE 802.1X use 233e5b75505Sopenharmony_ci * (draft-congdon-radius-8021x-20.txt) */ 234e5b75505Sopenharmony_ci#define RADIUS_802_1X_ADDR_FORMAT "%02X-%02X-%02X-%02X-%02X-%02X" 235e5b75505Sopenharmony_ci/* MAC address ASCII format for non-802.1X use */ 236e5b75505Sopenharmony_ci#define RADIUS_ADDR_FORMAT "%02x%02x%02x%02x%02x%02x" 237e5b75505Sopenharmony_ci 238e5b75505Sopenharmony_cistruct radius_hdr * radius_msg_get_hdr(struct radius_msg *msg); 239e5b75505Sopenharmony_cistruct wpabuf * radius_msg_get_buf(struct radius_msg *msg); 240e5b75505Sopenharmony_cistruct radius_msg * radius_msg_new(u8 code, u8 identifier); 241e5b75505Sopenharmony_civoid radius_msg_free(struct radius_msg *msg); 242e5b75505Sopenharmony_civoid radius_msg_dump(struct radius_msg *msg); 243e5b75505Sopenharmony_ciint radius_msg_finish(struct radius_msg *msg, const u8 *secret, 244e5b75505Sopenharmony_ci size_t secret_len); 245e5b75505Sopenharmony_ciint radius_msg_finish_srv(struct radius_msg *msg, const u8 *secret, 246e5b75505Sopenharmony_ci size_t secret_len, const u8 *req_authenticator); 247e5b75505Sopenharmony_ciint radius_msg_finish_das_resp(struct radius_msg *msg, const u8 *secret, 248e5b75505Sopenharmony_ci size_t secret_len, 249e5b75505Sopenharmony_ci const struct radius_hdr *req_hdr); 250e5b75505Sopenharmony_civoid radius_msg_finish_acct(struct radius_msg *msg, const u8 *secret, 251e5b75505Sopenharmony_ci size_t secret_len); 252e5b75505Sopenharmony_civoid radius_msg_finish_acct_resp(struct radius_msg *msg, const u8 *secret, 253e5b75505Sopenharmony_ci size_t secret_len, 254e5b75505Sopenharmony_ci const u8 *req_authenticator); 255e5b75505Sopenharmony_ciint radius_msg_verify_acct_req(struct radius_msg *msg, const u8 *secret, 256e5b75505Sopenharmony_ci size_t secret_len); 257e5b75505Sopenharmony_ciint radius_msg_verify_das_req(struct radius_msg *msg, const u8 *secret, 258e5b75505Sopenharmony_ci size_t secret_len, 259e5b75505Sopenharmony_ci int require_message_authenticator); 260e5b75505Sopenharmony_cistruct radius_attr_hdr * radius_msg_add_attr(struct radius_msg *msg, u8 type, 261e5b75505Sopenharmony_ci const u8 *data, size_t data_len); 262e5b75505Sopenharmony_cistruct radius_msg * radius_msg_parse(const u8 *data, size_t len); 263e5b75505Sopenharmony_ciint radius_msg_add_eap(struct radius_msg *msg, const u8 *data, 264e5b75505Sopenharmony_ci size_t data_len); 265e5b75505Sopenharmony_cistruct wpabuf * radius_msg_get_eap(struct radius_msg *msg); 266e5b75505Sopenharmony_ciint radius_msg_verify(struct radius_msg *msg, const u8 *secret, 267e5b75505Sopenharmony_ci size_t secret_len, struct radius_msg *sent_msg, 268e5b75505Sopenharmony_ci int auth); 269e5b75505Sopenharmony_ciint radius_msg_verify_msg_auth(struct radius_msg *msg, const u8 *secret, 270e5b75505Sopenharmony_ci size_t secret_len, const u8 *req_auth); 271e5b75505Sopenharmony_ciint radius_msg_copy_attr(struct radius_msg *dst, struct radius_msg *src, 272e5b75505Sopenharmony_ci u8 type); 273e5b75505Sopenharmony_ciint radius_msg_make_authenticator(struct radius_msg *msg); 274e5b75505Sopenharmony_cistruct radius_ms_mppe_keys * 275e5b75505Sopenharmony_ciradius_msg_get_ms_keys(struct radius_msg *msg, struct radius_msg *sent_msg, 276e5b75505Sopenharmony_ci const u8 *secret, size_t secret_len); 277e5b75505Sopenharmony_cistruct radius_ms_mppe_keys * 278e5b75505Sopenharmony_ciradius_msg_get_cisco_keys(struct radius_msg *msg, struct radius_msg *sent_msg, 279e5b75505Sopenharmony_ci const u8 *secret, size_t secret_len); 280e5b75505Sopenharmony_ciint radius_msg_add_mppe_keys(struct radius_msg *msg, 281e5b75505Sopenharmony_ci const u8 *req_authenticator, 282e5b75505Sopenharmony_ci const u8 *secret, size_t secret_len, 283e5b75505Sopenharmony_ci const u8 *send_key, size_t send_key_len, 284e5b75505Sopenharmony_ci const u8 *recv_key, size_t recv_key_len); 285e5b75505Sopenharmony_ciint radius_msg_add_wfa(struct radius_msg *msg, u8 subtype, const u8 *data, 286e5b75505Sopenharmony_ci size_t len); 287e5b75505Sopenharmony_ciint radius_user_password_hide(struct radius_msg *msg, 288e5b75505Sopenharmony_ci const u8 *data, size_t data_len, 289e5b75505Sopenharmony_ci const u8 *secret, size_t secret_len, 290e5b75505Sopenharmony_ci u8 *buf, size_t buf_len); 291e5b75505Sopenharmony_cistruct radius_attr_hdr * 292e5b75505Sopenharmony_ciradius_msg_add_attr_user_password(struct radius_msg *msg, 293e5b75505Sopenharmony_ci const u8 *data, size_t data_len, 294e5b75505Sopenharmony_ci const u8 *secret, size_t secret_len); 295e5b75505Sopenharmony_ciint radius_msg_get_attr(struct radius_msg *msg, u8 type, u8 *buf, size_t len); 296e5b75505Sopenharmony_ciint radius_msg_get_vlanid(struct radius_msg *msg, int *untagged, int numtagged, 297e5b75505Sopenharmony_ci int *tagged); 298e5b75505Sopenharmony_cichar * radius_msg_get_tunnel_password(struct radius_msg *msg, int *keylen, 299e5b75505Sopenharmony_ci const u8 *secret, size_t secret_len, 300e5b75505Sopenharmony_ci struct radius_msg *sent_msg, size_t n); 301e5b75505Sopenharmony_ci 302e5b75505Sopenharmony_cistatic inline int radius_msg_add_attr_int32(struct radius_msg *msg, u8 type, 303e5b75505Sopenharmony_ci u32 value) 304e5b75505Sopenharmony_ci{ 305e5b75505Sopenharmony_ci u32 val = htonl(value); 306e5b75505Sopenharmony_ci return radius_msg_add_attr(msg, type, (u8 *) &val, 4) != NULL; 307e5b75505Sopenharmony_ci} 308e5b75505Sopenharmony_ci 309e5b75505Sopenharmony_cistatic inline int radius_msg_get_attr_int32(struct radius_msg *msg, u8 type, 310e5b75505Sopenharmony_ci u32 *value) 311e5b75505Sopenharmony_ci{ 312e5b75505Sopenharmony_ci u32 val; 313e5b75505Sopenharmony_ci int res; 314e5b75505Sopenharmony_ci res = radius_msg_get_attr(msg, type, (u8 *) &val, 4); 315e5b75505Sopenharmony_ci if (res != 4) 316e5b75505Sopenharmony_ci return -1; 317e5b75505Sopenharmony_ci 318e5b75505Sopenharmony_ci *value = ntohl(val); 319e5b75505Sopenharmony_ci return 0; 320e5b75505Sopenharmony_ci} 321e5b75505Sopenharmony_ciint radius_msg_get_attr_ptr(struct radius_msg *msg, u8 type, u8 **buf, 322e5b75505Sopenharmony_ci size_t *len, const u8 *start); 323e5b75505Sopenharmony_ciint radius_msg_count_attr(struct radius_msg *msg, u8 type, int min_len); 324e5b75505Sopenharmony_ci 325e5b75505Sopenharmony_ci 326e5b75505Sopenharmony_cistruct radius_attr_data { 327e5b75505Sopenharmony_ci u8 *data; 328e5b75505Sopenharmony_ci size_t len; 329e5b75505Sopenharmony_ci}; 330e5b75505Sopenharmony_ci 331e5b75505Sopenharmony_cistruct radius_class_data { 332e5b75505Sopenharmony_ci struct radius_attr_data *attr; 333e5b75505Sopenharmony_ci size_t count; 334e5b75505Sopenharmony_ci}; 335e5b75505Sopenharmony_ci 336e5b75505Sopenharmony_civoid radius_free_class(struct radius_class_data *c); 337e5b75505Sopenharmony_ciint radius_copy_class(struct radius_class_data *dst, 338e5b75505Sopenharmony_ci const struct radius_class_data *src); 339e5b75505Sopenharmony_ci 340e5b75505Sopenharmony_ciu8 radius_msg_find_unlisted_attr(struct radius_msg *msg, u8 *attrs); 341e5b75505Sopenharmony_ci 342e5b75505Sopenharmony_ciint radius_gen_session_id(u8 *id, size_t len); 343e5b75505Sopenharmony_ci 344e5b75505Sopenharmony_ci#endif /* RADIUS_H */ 345