1a6d42e7dSPeter Dunlap /* 2a6d42e7dSPeter Dunlap * CDDL HEADER START 3a6d42e7dSPeter Dunlap * 4a6d42e7dSPeter Dunlap * The contents of this file are subject to the terms of the 5a6d42e7dSPeter Dunlap * Common Development and Distribution License (the "License"). 6a6d42e7dSPeter Dunlap * You may not use this file except in compliance with the License. 7a6d42e7dSPeter Dunlap * 8a6d42e7dSPeter Dunlap * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9a6d42e7dSPeter Dunlap * or http://www.opensolaris.org/os/licensing. 10a6d42e7dSPeter Dunlap * See the License for the specific language governing permissions 11a6d42e7dSPeter Dunlap * and limitations under the License. 12a6d42e7dSPeter Dunlap * 13a6d42e7dSPeter Dunlap * When distributing Covered Code, include this CDDL HEADER in each 14a6d42e7dSPeter Dunlap * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15a6d42e7dSPeter Dunlap * If applicable, add the following below this CDDL HEADER, with the 16a6d42e7dSPeter Dunlap * fields enclosed by brackets "[]" replaced with your own identifying 17a6d42e7dSPeter Dunlap * information: Portions Copyright [yyyy] [name of copyright owner] 18a6d42e7dSPeter Dunlap * 19a6d42e7dSPeter Dunlap * CDDL HEADER END 20a6d42e7dSPeter Dunlap */ 21a6d42e7dSPeter Dunlap /* 22a6d42e7dSPeter Dunlap * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23a6d42e7dSPeter Dunlap * Use is subject to license terms. 24a6d42e7dSPeter Dunlap */ 25a6d42e7dSPeter Dunlap 26a6d42e7dSPeter Dunlap #ifndef _RADIUS_PACKET_H 27a6d42e7dSPeter Dunlap #define _RADIUS_PACKET_H 28a6d42e7dSPeter Dunlap 29a6d42e7dSPeter Dunlap #ifdef __cplusplus 30a6d42e7dSPeter Dunlap extern "C" { 31a6d42e7dSPeter Dunlap #endif 32a6d42e7dSPeter Dunlap 33a6d42e7dSPeter Dunlap #include <netinet/in.h> 34a6d42e7dSPeter Dunlap #include <sys/types.h> 35*0f1702c5SYu Xiangning #include <sys/ksocket.h> 36a6d42e7dSPeter Dunlap #include <sys/iscsit/radius_protocol.h> 37a6d42e7dSPeter Dunlap 38a6d42e7dSPeter Dunlap /* A total of RAD_RCV_TIMEOUT * RAD_RETRY_MAX seconds timeout. */ 39a6d42e7dSPeter Dunlap #define RAD_RCV_TIMEOUT 5 /* Timeout for receiving RADIUS packet in */ 40a6d42e7dSPeter Dunlap /* sec. */ 41a6d42e7dSPeter Dunlap #define RAD_RETRY_MAX 2 /* Max. # of times to retry receiving */ 42a6d42e7dSPeter Dunlap /* packet. */ 43a6d42e7dSPeter Dunlap 44a6d42e7dSPeter Dunlap /* Describes a RADIUS attribute */ 45a6d42e7dSPeter Dunlap typedef struct radius_attr { 46a6d42e7dSPeter Dunlap int attr_type_code; /* RADIUS attribute type code, */ 47a6d42e7dSPeter Dunlap /* e.g. RAD_USER_PASSWORD, etc. */ 48a6d42e7dSPeter Dunlap int attr_value_len; 49a6d42e7dSPeter Dunlap uint8_t attr_value[MAX_RAD_ATTR_VALUE_LEN]; 50a6d42e7dSPeter Dunlap } radius_attr_t; 51a6d42e7dSPeter Dunlap 52a6d42e7dSPeter Dunlap /* Describes data fields of a RADIUS packet. */ 53a6d42e7dSPeter Dunlap typedef struct radius_packet_data { 54a6d42e7dSPeter Dunlap uint8_t code; /* RADIUS code, section 3, RFC 2865. */ 55a6d42e7dSPeter Dunlap uint8_t identifier; 56a6d42e7dSPeter Dunlap uint8_t authenticator[RAD_AUTHENTICATOR_LEN]; 57a6d42e7dSPeter Dunlap int num_of_attrs; 58a6d42e7dSPeter Dunlap radius_attr_t attrs[4]; /* For this implementation each */ 59a6d42e7dSPeter Dunlap /* outbound RADIUS packet will only */ 60a6d42e7dSPeter Dunlap /* have 3 attributes associated with */ 61a6d42e7dSPeter Dunlap /* it thus the chosen size should be */ 62a6d42e7dSPeter Dunlap /* good enough. */ 63a6d42e7dSPeter Dunlap } radius_packet_data_t; 64a6d42e7dSPeter Dunlap 65a6d42e7dSPeter Dunlap /* 66a6d42e7dSPeter Dunlap * Send a request to a RADIUS server. 67a6d42e7dSPeter Dunlap * 68a6d42e7dSPeter Dunlap * Returns > 0 on success, <= 0 on failure . 69a6d42e7dSPeter Dunlap * 70a6d42e7dSPeter Dunlap */ 71a6d42e7dSPeter Dunlap int 72*0f1702c5SYu Xiangning iscsit_snd_radius_request(ksocket_t socket, 73a6d42e7dSPeter Dunlap iscsi_ipaddr_t rsvr_ip_addr, 74a6d42e7dSPeter Dunlap uint32_t rsvr_port, 75a6d42e7dSPeter Dunlap radius_packet_data_t *packet_data); 76a6d42e7dSPeter Dunlap 77a6d42e7dSPeter Dunlap #define RAD_RSP_RCVD_SUCCESS 0 78a6d42e7dSPeter Dunlap #define RAD_RSP_RCVD_NO_DATA 1 79a6d42e7dSPeter Dunlap #define RAD_RSP_RCVD_TIMEOUT 2 80a6d42e7dSPeter Dunlap #define RAD_RSP_RCVD_PROTOCOL_ERR 3 81a6d42e7dSPeter Dunlap #define RAD_RSP_RCVD_AUTH_FAILED 4 82a6d42e7dSPeter Dunlap /* 83a6d42e7dSPeter Dunlap * Receives a response from a RADIUS server. 84a6d42e7dSPeter Dunlap * 85a6d42e7dSPeter Dunlap * Return receive status. 86a6d42e7dSPeter Dunlap */ 87a6d42e7dSPeter Dunlap int 88*0f1702c5SYu Xiangning iscsit_rcv_radius_response(ksocket_t socket, 89a6d42e7dSPeter Dunlap uint8_t *shared_secret, 90a6d42e7dSPeter Dunlap uint32_t shared_secret_len, 91a6d42e7dSPeter Dunlap uint8_t *req_authenticator, 92a6d42e7dSPeter Dunlap radius_packet_data_t *resp_data); 93a6d42e7dSPeter Dunlap 94a6d42e7dSPeter Dunlap #ifdef __cplusplus 95a6d42e7dSPeter Dunlap } 96a6d42e7dSPeter Dunlap #endif 97a6d42e7dSPeter Dunlap 98a6d42e7dSPeter Dunlap #endif /* _RADIUS_PACKET_H */ 99