17978SPeter.Dunlap@Sun.COM /* 27978SPeter.Dunlap@Sun.COM * CDDL HEADER START 37978SPeter.Dunlap@Sun.COM * 47978SPeter.Dunlap@Sun.COM * The contents of this file are subject to the terms of the 57978SPeter.Dunlap@Sun.COM * Common Development and Distribution License (the "License"). 67978SPeter.Dunlap@Sun.COM * You may not use this file except in compliance with the License. 77978SPeter.Dunlap@Sun.COM * 87978SPeter.Dunlap@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97978SPeter.Dunlap@Sun.COM * or http://www.opensolaris.org/os/licensing. 107978SPeter.Dunlap@Sun.COM * See the License for the specific language governing permissions 117978SPeter.Dunlap@Sun.COM * and limitations under the License. 127978SPeter.Dunlap@Sun.COM * 137978SPeter.Dunlap@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 147978SPeter.Dunlap@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157978SPeter.Dunlap@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 167978SPeter.Dunlap@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 177978SPeter.Dunlap@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 187978SPeter.Dunlap@Sun.COM * 197978SPeter.Dunlap@Sun.COM * CDDL HEADER END 207978SPeter.Dunlap@Sun.COM */ 217978SPeter.Dunlap@Sun.COM /* 227978SPeter.Dunlap@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 237978SPeter.Dunlap@Sun.COM * Use is subject to license terms. 247978SPeter.Dunlap@Sun.COM */ 257978SPeter.Dunlap@Sun.COM 267978SPeter.Dunlap@Sun.COM #ifndef _RADIUS_PACKET_H 277978SPeter.Dunlap@Sun.COM #define _RADIUS_PACKET_H 287978SPeter.Dunlap@Sun.COM 297978SPeter.Dunlap@Sun.COM #ifdef __cplusplus 307978SPeter.Dunlap@Sun.COM extern "C" { 317978SPeter.Dunlap@Sun.COM #endif 327978SPeter.Dunlap@Sun.COM 337978SPeter.Dunlap@Sun.COM #include <netinet/in.h> 347978SPeter.Dunlap@Sun.COM #include <sys/types.h> 35*8348SEric.Yu@Sun.COM #include <sys/ksocket.h> 367978SPeter.Dunlap@Sun.COM #include <sys/iscsit/radius_protocol.h> 377978SPeter.Dunlap@Sun.COM 387978SPeter.Dunlap@Sun.COM /* A total of RAD_RCV_TIMEOUT * RAD_RETRY_MAX seconds timeout. */ 397978SPeter.Dunlap@Sun.COM #define RAD_RCV_TIMEOUT 5 /* Timeout for receiving RADIUS packet in */ 407978SPeter.Dunlap@Sun.COM /* sec. */ 417978SPeter.Dunlap@Sun.COM #define RAD_RETRY_MAX 2 /* Max. # of times to retry receiving */ 427978SPeter.Dunlap@Sun.COM /* packet. */ 437978SPeter.Dunlap@Sun.COM 447978SPeter.Dunlap@Sun.COM /* Describes a RADIUS attribute */ 457978SPeter.Dunlap@Sun.COM typedef struct radius_attr { 467978SPeter.Dunlap@Sun.COM int attr_type_code; /* RADIUS attribute type code, */ 477978SPeter.Dunlap@Sun.COM /* e.g. RAD_USER_PASSWORD, etc. */ 487978SPeter.Dunlap@Sun.COM int attr_value_len; 497978SPeter.Dunlap@Sun.COM uint8_t attr_value[MAX_RAD_ATTR_VALUE_LEN]; 507978SPeter.Dunlap@Sun.COM } radius_attr_t; 517978SPeter.Dunlap@Sun.COM 527978SPeter.Dunlap@Sun.COM /* Describes data fields of a RADIUS packet. */ 537978SPeter.Dunlap@Sun.COM typedef struct radius_packet_data { 547978SPeter.Dunlap@Sun.COM uint8_t code; /* RADIUS code, section 3, RFC 2865. */ 557978SPeter.Dunlap@Sun.COM uint8_t identifier; 567978SPeter.Dunlap@Sun.COM uint8_t authenticator[RAD_AUTHENTICATOR_LEN]; 577978SPeter.Dunlap@Sun.COM int num_of_attrs; 587978SPeter.Dunlap@Sun.COM radius_attr_t attrs[4]; /* For this implementation each */ 597978SPeter.Dunlap@Sun.COM /* outbound RADIUS packet will only */ 607978SPeter.Dunlap@Sun.COM /* have 3 attributes associated with */ 617978SPeter.Dunlap@Sun.COM /* it thus the chosen size should be */ 627978SPeter.Dunlap@Sun.COM /* good enough. */ 637978SPeter.Dunlap@Sun.COM } radius_packet_data_t; 647978SPeter.Dunlap@Sun.COM 657978SPeter.Dunlap@Sun.COM /* 667978SPeter.Dunlap@Sun.COM * Send a request to a RADIUS server. 677978SPeter.Dunlap@Sun.COM * 687978SPeter.Dunlap@Sun.COM * Returns > 0 on success, <= 0 on failure . 697978SPeter.Dunlap@Sun.COM * 707978SPeter.Dunlap@Sun.COM */ 717978SPeter.Dunlap@Sun.COM int 72*8348SEric.Yu@Sun.COM iscsit_snd_radius_request(ksocket_t socket, 737978SPeter.Dunlap@Sun.COM iscsi_ipaddr_t rsvr_ip_addr, 747978SPeter.Dunlap@Sun.COM uint32_t rsvr_port, 757978SPeter.Dunlap@Sun.COM radius_packet_data_t *packet_data); 767978SPeter.Dunlap@Sun.COM 777978SPeter.Dunlap@Sun.COM #define RAD_RSP_RCVD_SUCCESS 0 787978SPeter.Dunlap@Sun.COM #define RAD_RSP_RCVD_NO_DATA 1 797978SPeter.Dunlap@Sun.COM #define RAD_RSP_RCVD_TIMEOUT 2 807978SPeter.Dunlap@Sun.COM #define RAD_RSP_RCVD_PROTOCOL_ERR 3 817978SPeter.Dunlap@Sun.COM #define RAD_RSP_RCVD_AUTH_FAILED 4 827978SPeter.Dunlap@Sun.COM /* 837978SPeter.Dunlap@Sun.COM * Receives a response from a RADIUS server. 847978SPeter.Dunlap@Sun.COM * 857978SPeter.Dunlap@Sun.COM * Return receive status. 867978SPeter.Dunlap@Sun.COM */ 877978SPeter.Dunlap@Sun.COM int 88*8348SEric.Yu@Sun.COM iscsit_rcv_radius_response(ksocket_t socket, 897978SPeter.Dunlap@Sun.COM uint8_t *shared_secret, 907978SPeter.Dunlap@Sun.COM uint32_t shared_secret_len, 917978SPeter.Dunlap@Sun.COM uint8_t *req_authenticator, 927978SPeter.Dunlap@Sun.COM radius_packet_data_t *resp_data); 937978SPeter.Dunlap@Sun.COM 947978SPeter.Dunlap@Sun.COM #ifdef __cplusplus 957978SPeter.Dunlap@Sun.COM } 967978SPeter.Dunlap@Sun.COM #endif 977978SPeter.Dunlap@Sun.COM 987978SPeter.Dunlap@Sun.COM #endif /* _RADIUS_PACKET_H */ 99