/*
* Copyright Fen Systems Ltd. 2007. Portions of this code are derived
* from IBM Corporation Sample Programs. Copyright IBM Corporation
* 2004, 2007. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/netdevice.h>
#include <ipxe/ethernet.h>
/** @file
*
* iSCSI boot firmware table
*
* The information in this file is derived from the document "iSCSI
* Boot Firmware Table (iBFT)" as published by IBM at
*
*
*/
/**
* An iBFT created by iPXE
*
*/
struct ipxe_ibft {
/** The fixed section */
/** The Initiator section */
/** The NIC section */
/** The Target section */
/** Strings block */
char strings[0];
/**
* iSCSI string block descriptor
*
* This is an internal structure that we use to keep track of the
* allocation of string data.
*/
struct ibft_strings {
/** The iBFT containing these strings */
/** Offset of first free byte within iBFT */
/** Total length of the iBFT */
};
/**
* Fill in an IP address field within iBFT
*
* @v ipaddr IP address field
* @v in IPv4 address
*/
}
}
/**
* Fill in an IP address within iBFT from configuration setting
*
* @v ipaddr IP address field
* @v setting Configuration setting
* @v count Maximum number of IP addresses
*/
unsigned int count ) {
unsigned int i;
for ( i = 0 ; i < count ; i++ ) {
}
}
/**
* Read IP address from iBFT (for debugging)
*
* @v strings iBFT string block descriptor
* @v string String field
* @ret ipaddr IP address string
*/
}
/**
* Allocate a string within iBFT
*
* @v strings iBFT string block descriptor
* @v string String field to fill in
* @v len Length of string to allocate (excluding NUL)
* @ret dest String destination, or NULL
*/
return NULL;
}
/**
* Fill in a string field within iBFT
*
* @v strings iBFT string block descriptor
* @v string String field
* @v data String to fill in, or NULL
* @ret rc Return status code
*/
char *dest;
if ( ! data )
return 0;
if ( ! dest )
return -ENOBUFS;
return 0;
}
/**
* Fill in a string field within iBFT from configuration setting
*
* @v strings iBFT string block descriptor
* @v string String field
* @v setting Configuration setting
* @ret rc Return status code
*/
struct ibft_string *string,
int len;
char *dest;
if ( len < 0 ) {
return 0;
}
if ( ! dest )
return -ENOBUFS;
return 0;
}
/**
* Read string from iBFT (for debugging)
*
* @v strings iBFT string block descriptor
* @v string String field
* @ret data String content (or "<empty>")
*/
struct ibft_string *string ) {
}
/**
* Fill in NIC portion of iBFT
*
* @v nic NIC portion of iBFT
* @v strings iBFT string block descriptor
* @v netdev Network device
* @ret rc Return status code
*/
struct ibft_strings *strings,
struct net_device *netdev ) {
unsigned int netmask_count = 0;
int rc;
/* Fill in common header */
/* Extract values from configuration settings */
&hostname_setting ) ) != 0 )
return rc;
DBG ( "iBFT NIC hostname = %s\n",
/* Derive subnet mask prefix from subnet mask */
while ( netmask_addr.s_addr ) {
}
/* Extract values from net-device configuration */
nic->mac_address ) ) != 0 ) {
return rc;
}
return 0;
}
/**
* Fill in Initiator portion of iBFT
*
* @v initiator Initiator portion of iBFT
* @v strings iBFT string block descriptor
* @v iscsi iSCSI session
* @ret rc Return status code
*/
struct ibft_strings *strings,
struct iscsi_session *iscsi ) {
int rc;
/* Fill in common header */
/* Fill in hostname */
iscsi->initiator_iqn ) ) != 0 )
return rc;
DBG ( "iBFT initiator hostname = %s\n",
return 0;
}
/**
* Fill in Target CHAP portion of iBFT
*
* @v target Target portion of iBFT
* @v strings iBFT string block descriptor
* @v iscsi iSCSI session
* @ret rc Return status code
*/
struct ibft_strings *strings,
struct iscsi_session *iscsi ) {
int rc;
return 0;
iscsi->initiator_username ) ) != 0 )
return rc;
DBG ( "iBFT target username = %s\n",
iscsi->initiator_password ) ) != 0 )
return rc;
DBG ( "iBFT target password = <redacted>\n" );
return 0;
}
/**
* Fill in Target Reverse CHAP portion of iBFT
*
* @v target Target portion of iBFT
* @v strings iBFT string block descriptor
* @v iscsi iSCSI session
* @ret rc Return status code
*/
struct ibft_strings *strings,
struct iscsi_session *iscsi ) {
int rc;
return 0;
iscsi->target_username ) ) != 0 )
return rc;
DBG ( "iBFT target reverse username = %s\n",
iscsi->target_password ) ) != 0 )
return rc;
DBG ( "iBFT target reverse password = <redacted>\n" );
return 0;
}
/**
* Fill in Target portion of iBFT
*
* @v target Target portion of iBFT
* @v strings iBFT string block descriptor
* @v iscsi iSCSI session
* @ret rc Return status code
*/
struct ibft_strings *strings,
struct iscsi_session *iscsi ) {
int rc;
/* Fill in common header */
/* Fill in Target values */
iscsi->target_iqn ) ) != 0 )
return rc;
DBG ( "iBFT target name = %s\n",
return rc;
iscsi ) ) != 0 )
return rc;
return 0;
}
/**
* Fill in iBFT
*
* @v iscsi iSCSI session
* @v acpi ACPI table
* @v len Length of ACPI table
* @ret rc Return status code
*/
struct acpi_description_header *acpi,
};
int rc;
/* Ugly hack. Now that we have a generic interface mechanism
* that can support ioctls, we can potentially eliminate this.
*/
netdev = last_opened_netdev();
if ( ! netdev ) {
iscsi );
return -ENODEV;
}
/* Fill in ACPI header */
/* Fill in Control block */
/* Fill in NIC, Initiator and Target blocks */
return rc;
iscsi ) ) != 0 )
return rc;
iscsi ) ) != 0 )
return rc;
return 0;
}