/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/bootprops.h>
#include <sys/bootconf.h>
#include <sys/iscsi_protocol.h>
#define OBP_GET_KEY_STATUS_OK 0
extern ib_boot_prop_t *iscsiboot_prop;
static void generate_iscsi_initiator_id(void);
static int
{
}
static boolean_t
iscsiboot_tgt_prop_read(void)
{
int proplen;
long iscsi_tpgtl;
long port;
int ret = 0;
int status = 0;
int chap_user_len = 0;
int chap_pwd_len = 0;
/* Get iscsi target IP address */
if (proplen > 0) {
iscsi_target_ip) > 0) {
if (inet_aton(iscsi_target_ip,
0) {
}
}
}
return (B_FALSE);
}
/* Get iscsi target port number */
if (proplen > 0) {
iscsi_port) > 0) {
10, &port) == 0) {
(unsigned int)port;
}
}
}
}
/* Get iscsi target LUN number */
if (proplen > 0) {
iscsi_lun) > 0) {
if (parse_lun_num(iscsi_lun,
(uchar_t *)
== B_TRUE) {
}
}
}
}
/* Get iscsi target portal group tag */
if (proplen > 0) {
iscsi_tpgt) > 0) {
&iscsi_tpgtl) == 0) {
}
}
}
}
/* Get iscsi target node name */
if (proplen > 0) {
iscsi_target_name) > 0) {
}
}
}
return (B_FALSE);
}
/* Get iscsi target boot partition */
if (proplen > 0) {
(void) snprintf(
}
}
}
/* Get CHAP name and secret */
if (ret != 0) {
return (B_FALSE);
}
if (status == OBP_GET_KEY_STATUS_NOT_EXIST) {
/* No chap name */
return (B_TRUE);
}
if (status != OBP_GET_KEY_STATUS_OK ||
chap_user_len <= 0) {
return (B_FALSE);
}
if (ret != 0) {
return (B_FALSE);
}
if (status == OBP_GET_KEY_STATUS_NOT_EXIST) {
/* No chap secret */
return (B_TRUE);
}
if (status != OBP_GET_KEY_STATUS_OK ||
chap_pwd_len <= 0) {
return (B_FALSE);
}
return (B_TRUE);
}
static boolean_t
iscsiboot_init_prop_read(void)
{
int proplen;
/* Get initiator node name */
if (proplen > 0) {
iscsi_initiator_id) > 0) {
(void) snprintf(
}
}
}
return (B_TRUE);
}
static boolean_t
iscsiboot_nic_prop_read(void)
{
int proplen;
/* Get host IP address */
if (proplen > 0) {
host_ip) > 0) {
0) {
}
}
}
return (B_FALSE);
}
/* Get router IP address */
if (proplen > 0) {
router_ip) > 0) {
}
}
/* Get host netmask */
if (proplen > 0) {
subnet_mask) > 0) {
int i = 0;
while (tmp) {
i ++;
}
}
}
}
}
/* Get iscsi boot NIC path in OBP */
if (proplen > 0) {
iscsi_network_path) > 0) {
if (proplen > 0) {
host_mac) > 0) {
(void) memcpy(
host_mac, 6);
}
}
}
}
return (B_FALSE);
}
return (B_TRUE);
}
/*
* Manully construct iscsiboot_prop table based on
* OBP '/chosen' properties related to iscsi boot
*/
void
{
if (iscsiboot_prop != NULL)
return;
if ((iscsiboot_tgt_prop_read() == B_TRUE) &&
(iscsiboot_init_prop_read() == B_TRUE) &&
(iscsiboot_nic_prop_read() == B_TRUE)) {
} else {
}
}
static boolean_t
{
char *p, *buf;
long tmp;
int i = 0;
return (B_FALSE);
}
for (i = 0; i < 4; i++) {
p = NULL;
if (p != NULL) {
*p = '\0';
}
return (B_FALSE);
}
if (p != NULL) {
buf = p + 1;
} else {
break;
}
}
return (B_TRUE);
}
static void
{
KM_SLEEP);
38, "iqn.1986-03.com.sun:boot.%02x%02x%02x%02x%02x%02x",
}
/* We only deal with a.b.c.d decimal format. ip points to 4 byte storage */
static int
{
int i = 0;
char c = *ipstr;
for (;;) {
if (!isdigit(c))
return (-1);
for (;;) {
if (!isdigit(c))
break;
c = *++ipstr;
}
i++;
if (i == 4)
break;
if (c != '.')
return (-1);
c = *++ipstr;
}
if (c != 0)
return (-1);
return (0);
}