1fcf3ce44SJohn Forte /*
2fcf3ce44SJohn Forte  * CDDL HEADER START
3fcf3ce44SJohn Forte  *
4fcf3ce44SJohn Forte  * The contents of this file are subject to the terms of the
5fcf3ce44SJohn Forte  * Common Development and Distribution License (the "License").
6fcf3ce44SJohn Forte  * You may not use this file except in compliance with the License.
7fcf3ce44SJohn Forte  *
8fcf3ce44SJohn Forte  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fcf3ce44SJohn Forte  * or http://www.opensolaris.org/os/licensing.
10fcf3ce44SJohn Forte  * See the License for the specific language governing permissions
11fcf3ce44SJohn Forte  * and limitations under the License.
12fcf3ce44SJohn Forte  *
13fcf3ce44SJohn Forte  * When distributing Covered Code, include this CDDL HEADER in each
14fcf3ce44SJohn Forte  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fcf3ce44SJohn Forte  * If applicable, add the following below this CDDL HEADER, with the
16fcf3ce44SJohn Forte  * fields enclosed by brackets "[]" replaced with your own identifying
17fcf3ce44SJohn Forte  * information: Portions Copyright [yyyy] [name of copyright owner]
18fcf3ce44SJohn Forte  *
19fcf3ce44SJohn Forte  * CDDL HEADER END
20fcf3ce44SJohn Forte  */
21fcf3ce44SJohn Forte /*
22*4246c8e9SJack Meng  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23fcf3ce44SJohn Forte  * Use is subject to license terms.
24fcf3ce44SJohn Forte  */
25fcf3ce44SJohn Forte 
26fcf3ce44SJohn Forte #ifndef	_ISCSI_DOOR_H
27fcf3ce44SJohn Forte #define	_ISCSI_DOOR_H
28fcf3ce44SJohn Forte 
29fcf3ce44SJohn Forte #ifdef __cplusplus
30fcf3ce44SJohn Forte extern "C" {
31fcf3ce44SJohn Forte #endif
32fcf3ce44SJohn Forte 
33fcf3ce44SJohn Forte #define	ISCSI_DOOR_REQ_SIGNATURE	0x53435349
34fcf3ce44SJohn Forte #define	ISCSI_DOOR_REQ_VERSION_1	1
35fcf3ce44SJohn Forte #define	ISCSI_DOOR_MAX_DATA_SIZE	8192
36fcf3ce44SJohn Forte 
37fcf3ce44SJohn Forte 
38fcf3ce44SJohn Forte #define	ISCSI_DOOR_GETIPNODEBYNAME_REQ	0x0000
39fcf3ce44SJohn Forte #define	ISCSI_DOOR_GETIPNODEBYNAME_CNF	0x4000
40fcf3ce44SJohn Forte #define	ISCSI_DOOR_ERROR_IND		0x8000
41fcf3ce44SJohn Forte 
42fcf3ce44SJohn Forte #define	ISCSI_DOOR_STATUS_SUCCESS	0x00000000
43fcf3ce44SJohn Forte #define	ISCSI_DOOR_STATUS_REQ_LENGTH	0x00000001
44fcf3ce44SJohn Forte #define	ISCSI_DOOR_STATUS_REQ_FORMAT	0x00000002
45fcf3ce44SJohn Forte #define	ISCSI_DOOR_STATUS_REQ_INVALID	0x00000003
46fcf3ce44SJohn Forte #define	ISCSI_DOOR_STATUS_REQ_VERSION	0x00000004
47fcf3ce44SJohn Forte #define	ISCSI_DOOR_STATUS_MORE		0x00000005
48fcf3ce44SJohn Forte 
49fcf3ce44SJohn Forte typedef struct _iscsi_door_msg_hdr {
50fcf3ce44SJohn Forte 	uint32_t		signature;
51fcf3ce44SJohn Forte 	uint32_t		version;
52fcf3ce44SJohn Forte 	uint32_t		opcode;
53fcf3ce44SJohn Forte 	uint32_t		status;
54fcf3ce44SJohn Forte } iscsi_door_msg_hdr_t;
55fcf3ce44SJohn Forte 
56fcf3ce44SJohn Forte typedef struct _getipnodebyname_req {
57fcf3ce44SJohn Forte 	iscsi_door_msg_hdr_t	hdr;
58fcf3ce44SJohn Forte 	uint32_t		name_offset;
59fcf3ce44SJohn Forte 	uint32_t		name_length;
60fcf3ce44SJohn Forte 	uint32_t		af;
61fcf3ce44SJohn Forte 	uint32_t		flags;
62fcf3ce44SJohn Forte } getipnodebyname_req_t;
63fcf3ce44SJohn Forte 
64fcf3ce44SJohn Forte typedef struct _getipnodebyname_cnf {
65fcf3ce44SJohn Forte 	iscsi_door_msg_hdr_t	hdr;
66fcf3ce44SJohn Forte 	uint32_t		h_size_needed;
67fcf3ce44SJohn Forte 	uint32_t		h_addr_list_offset;
68fcf3ce44SJohn Forte 	uint32_t		h_addr_list_length;
69fcf3ce44SJohn Forte 	uint32_t		h_addrtype;
70fcf3ce44SJohn Forte 	uint32_t		h_addrlen;
71fcf3ce44SJohn Forte 	uint32_t		h_name_offset;
72fcf3ce44SJohn Forte 	uint32_t		h_name_len;
73fcf3ce44SJohn Forte 	uint32_t		h_alias_list_offset;
74fcf3ce44SJohn Forte 	uint32_t		h_alias_list_length;
75fcf3ce44SJohn Forte 	int32_t			error_num;
76fcf3ce44SJohn Forte } getipnodebyname_cnf_t;
77fcf3ce44SJohn Forte 
78fcf3ce44SJohn Forte typedef union _iscsi_door_req {
79fcf3ce44SJohn Forte 	iscsi_door_msg_hdr_t	hdr;
80fcf3ce44SJohn Forte 	getipnodebyname_req_t	ginbn_req;
81fcf3ce44SJohn Forte } iscsi_door_req_t;
82fcf3ce44SJohn Forte 
83fcf3ce44SJohn Forte typedef union _iscsi_door_cnf {
84fcf3ce44SJohn Forte 	iscsi_door_msg_hdr_t	hdr;
85fcf3ce44SJohn Forte 	getipnodebyname_cnf_t	ginbn_cnf;
86fcf3ce44SJohn Forte } iscsi_door_cnf_t;
87fcf3ce44SJohn Forte 
88fcf3ce44SJohn Forte typedef union _iscsi_door_ind {
89fcf3ce44SJohn Forte 	iscsi_door_msg_hdr_t	hdr;
90fcf3ce44SJohn Forte 	iscsi_door_msg_hdr_t	error_ind;
91fcf3ce44SJohn Forte } iscsi_door_ind_t;
92fcf3ce44SJohn Forte 
93fcf3ce44SJohn Forte typedef union _iscsi_door_msg {
94fcf3ce44SJohn Forte 	iscsi_door_msg_hdr_t	hdr;
95fcf3ce44SJohn Forte 	iscsi_door_req_t	req;
96fcf3ce44SJohn Forte 	iscsi_door_cnf_t	cnf;
97fcf3ce44SJohn Forte 	iscsi_door_ind_t	ind;
98fcf3ce44SJohn Forte } iscsi_door_msg_t;
99fcf3ce44SJohn Forte 
100fcf3ce44SJohn Forte #ifdef _KERNEL
101fcf3ce44SJohn Forte 
102fcf3ce44SJohn Forte /* Defines copied from netdb.h */
103fcf3ce44SJohn Forte #define	HOST_NOT_FOUND	1 /* Authoritive Answer Host not found */
104fcf3ce44SJohn Forte #define	TRY_AGAIN	2 /* Non-Authoritive Host not found, or SERVERFAIL */
105fcf3ce44SJohn Forte #define	NO_RECOVERY	3 /* Non recoverable errors,FORMERR,REFUSED,NOTIMP */
106fcf3ce44SJohn Forte #define	NO_DATA		4 /* Valid name, no data record of requested type */
107fcf3ce44SJohn Forte #define	NO_ADDRESS	NO_DATA	/* no address, look for MX record */
108fcf3ce44SJohn Forte 
109fcf3ce44SJohn Forte #define	AI_V4MAPPED	0x0001 /* IPv4 mapped addresses if no IPv6 */
110fcf3ce44SJohn Forte #define	AI_ALL		0x0002 /* IPv6 and IPv4 mapped addresses */
111fcf3ce44SJohn Forte #define	AI_ADDRCONFIG	0x0004 /* AAAA or A records only if IPv6/IPv4 cnfgd */
112fcf3ce44SJohn Forte 
113fcf3ce44SJohn Forte struct  hostent {
114fcf3ce44SJohn Forte 	char	*h_name;	/* official name of host */
115fcf3ce44SJohn Forte 	char	**h_aliases;	/* alias list */
116fcf3ce44SJohn Forte 	int	h_addrtype;	/* host address type */
117fcf3ce44SJohn Forte 	int	h_length;	/* length of address */
118fcf3ce44SJohn Forte 	char	**h_addr_list;	/* list of addresses from name server */
119fcf3ce44SJohn Forte };
120fcf3ce44SJohn Forte 
121fcf3ce44SJohn Forte boolean_t
122fcf3ce44SJohn Forte iscsi_door_ini(void);
123fcf3ce44SJohn Forte 
124fcf3ce44SJohn Forte boolean_t
125fcf3ce44SJohn Forte iscsi_door_term(void);
126fcf3ce44SJohn Forte 
127fcf3ce44SJohn Forte boolean_t
128fcf3ce44SJohn Forte iscsi_door_bind(
129fcf3ce44SJohn Forte 	int		did
130fcf3ce44SJohn Forte );
131fcf3ce44SJohn Forte 
132*4246c8e9SJack Meng void
133*4246c8e9SJack Meng iscsi_door_unbind(void);
134*4246c8e9SJack Meng 
135fcf3ce44SJohn Forte void
136fcf3ce44SJohn Forte kfreehostent(
137fcf3ce44SJohn Forte 	struct hostent	*hptr
138fcf3ce44SJohn Forte );
139fcf3ce44SJohn Forte 
140fcf3ce44SJohn Forte struct hostent *
141fcf3ce44SJohn Forte kgetipnodebyname(
142fcf3ce44SJohn Forte 	const char	*name,
143fcf3ce44SJohn Forte 	int		af,
144fcf3ce44SJohn Forte 	int		flags,
145fcf3ce44SJohn Forte 	int		*error_num
146fcf3ce44SJohn Forte );
147fcf3ce44SJohn Forte 
148fcf3ce44SJohn Forte #else	/* !_KERNEL */
149fcf3ce44SJohn Forte 
150fcf3ce44SJohn Forte #define	kfreehostent		freehostent
151fcf3ce44SJohn Forte #define	kgetipnodebyname	getipnodebyname
152fcf3ce44SJohn Forte 
153fcf3ce44SJohn Forte #endif	/* _KERNEL */
154fcf3ce44SJohn Forte 
155*4246c8e9SJack Meng /*
156*4246c8e9SJack Meng  * iSCSI initiator SMF service status in kernel
157*4246c8e9SJack Meng  */
158*4246c8e9SJack Meng #define	ISCSI_SERVICE_ENABLED		0x0
159*4246c8e9SJack Meng #define	ISCSI_SERVICE_DISABLED		0x1
160*4246c8e9SJack Meng #define	ISCSI_SERVICE_TRANSITION	0x2
161*4246c8e9SJack Meng 
162fcf3ce44SJohn Forte #ifdef __cplusplus
163fcf3ce44SJohn Forte }
164fcf3ce44SJohn Forte #endif
165fcf3ce44SJohn Forte 
166fcf3ce44SJohn Forte #endif /* _ISCSI_DOOR_H */