/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2000 by Cisco Systems, Inc. All rights reserved.
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
/*
* iSCSI Software Initiator
*/
#include <sys/pathname.h>
#include "iscsi.h"
typedef struct _mybuffer {
} mybuffer_t;
/*
* iscsi_door_ini
*
* This function initializes the variables needed to handle the door upcall.
*/
iscsi_door_ini(void)
{
if (!iscsi_door_init) {
NULL,
NULL);
NULL,
NULL);
return (B_TRUE);
}
return (B_FALSE);
}
/*
* iscsi_door_term
*
* This function releases the resources allocated to handle the door
* upcall. It disconnects from the door if currently connected.
*/
iscsi_door_term(void)
{
if (iscsi_door_init) {
return (B_TRUE);
}
return (B_FALSE);
}
/*
* iscsi_door_bind
*
* This function tries to connect the iscsi_door. If it succeeds
* it keeps the vnode.
*/
int did
)
{
if (new_handle == NULL) {
/* The lookup failed. */
return (B_FALSE);
}
/* The new handle is stored. If we had one, it is released. */
if (iscsi_door_handle != NULL) {
}
return (B_TRUE);
}
/*
* iscsi_door_unbind
*
* This function releases the current door handle.
*/
void
iscsi_door_unbind(void)
{
if (iscsi_door_handle != NULL) {
}
}
/*
* iscsi_door_upcall
*
* This function tries to call the iscsi_door.
*/
static
{
int error;
/*
* This semaphore limits the number of simultaneous calls
* to the door.
*/
/*
* The mutex protecting the iscsi_door_handle is entered.
*/
if (iscsi_door_handle == NULL) {
/* There's no door handle. */
return (B_FALSE);
}
if (error != 0) {
return (B_FALSE);
} else {
return (B_TRUE);
}
}
/*
* kfreehostent
*
* This function frees the memory returned by kgetipnodebyname.
*/
void
)
{
if (hptr) {
return;
}
}
/* A message should be logged here. */
}
/*
* kgetipnodebyname
*
* This function builds a request that will be sent to the iscsi_door.
* The iSCSI door after receiving the request calls getipnodebyaddr().
* for more information on the input, output parameter and return value,
* consult the man page for getipnodebyname().
*
* Before calling the iscsi door this function tries to do the conversion
* locally. If a name resolution is needed the iscsi door is called.
*
* There's some limitations to the information returned by this function.
* Only one address of the address list returned by getipnodebyname() is
* returned. The other parameters of the structure should be ignored.
*/
struct hostent *
const char *name,
int af,
int flags,
int *error_num
)
{
if (buffer) {
/*
* The buffer was successfully allocated.
*
* Buffer
*
* +--------------------+ <--- buffer
* | mybuffer_t |
* +--------------------+ <--- hptr
* | |
* | |
* | hostent_size |
* | |
* | |
* | |
* +--------------------+ <--- req, cnf
* | |
* | |
* | |
* | msg_size |
* | |
* | |
* | |
* +--------------------+
*/
hostent_size -= sizeof (struct hostent);
/*
* We try first locally. If the conversion cannot be done
* by inet_pton the door is called.
* The cnf address is used as output buffer.
* inet_pton returns '1' if the conversion was successful.
*/
switch (af) {
case AF_INET:
break;
case AF_INET6:
break;
default:
*error_num = NO_RECOVERY;
return (NULL);
}
(hostent_size < sizeof (char *))) {
*error_num = NO_RECOVERY;
return (NULL);
}
/*
* inet_pton converted the string successfully.
*/
sizeof (struct hostent));
return (hptr);
}
/*
* The name couldn't ne converted by inet_pton. The door is
* called.
*/
/* Header initialization. */
/* Body initialization. */
if (req->name_length >
*error_num = NO_RECOVERY;
return (NULL);
}
name,
req->name_length);
/* Door argument initialization. */
/* The door call failed */
*error_num = NO_RECOVERY;
return (NULL);
}
/*
* The door call itself was successful. The value returned
* in arg.rbuf should be cnf, but we never know.
*/
/* The door didn't like the request */
*error_num = NO_RECOVERY;
return (NULL);
}
if (cnf->h_addr_list_length == 0) {
return (NULL);
}
sizeof (struct hostent));
return (hptr);
} else {
*error_num = NO_RECOVERY;
return (NULL);
}
}