Fibre Channel SNIA HBA API Programmer's Guide

HBA_STATUS_ERROR_UNAVAILABLE
Returned when the
adapter to which the
handle corresponds is not
available.
HBA_STATUS_ERROR_MORE_DATA
Returned when the
allocated buffer is
insufficient.
Call order sequence: See Appendix A.
Example Code:
HBA_STATUS status;
HBA_HANDLE adapterhandle;
HBA_FCPTARGETMAPPING single_mapping;
PHBA_FCPTARGETMAPPING map_list;
memset(&single_mapping, 0, sizeof(single_mapping));
single_mapping.NumberOfEntries = 1;
printf("Calling HBA_GetFcpTargetMapping() first time"
"with single entry buffer\n");
if ((status = HBA_GetFcpTargetMapping(adapterhandle,
&single_mapping)) == HBA_STATUS_ERROR_MORE_DATA
{
if (single_mapping.NumberOfEntries > 0)
{
map_list = (PHBA_FCPTARGETMAPPING) malloc
((single_mapping.NumberOfEntries) *
sizeof(HBA_FCPTARGETMAPPING) );
if(map_list)
{
map_list->NumberOfEntries =
single_mapping.NumberOfEntries;
printf ("Calling HBA_GetFcpTargetMapping\n");
if ((status =
HBA_GetFcpTargetMapping(adapterhandle,
map_list)) != HBA_STATUS_OK)
{
printf ("HBA_GetFcpTargetMapping error %d\n",
status);
}
printf("HBA_GetFcpTargetMapping %u targets during
second call with sufficient buffer\n",
map_list->NumberOfEntries);
} else
{
printf ("malloc failed\n");
}
}
} else
{
if (status != HBA_STATUS_OK)
{
printf("HBA_GetFcpTargetMapping error %d\n",
status);
}
}
28 HBA Common Library APIs