- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How do I programmatically get the hardware address...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2004 02:30 PM
01-15-2004 02:30 PM
Thanks in advance to all that reply.
Philip A. Reyniers
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2004 07:44 PM
01-15-2004 07:44 PM
Re: How do I programmatically get the hardware address for a SCSI device?
tools like ioscan use the config driver (/dev/config) to obtain that kind of information. I'm afraid this API is not disclosed for general use.
Sorry...
Dietmar.
PS.: Maybe you should open a support call to get confirmation for this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2004 10:46 PM
01-15-2004 10:46 PM
Re: How do I programmatically get the hardware address for a SCSI device?
The best way to do it is a
#define BUFSZ 1024
int p[2];
char command[256];
char buf[BUFSZ];
int res;
FILE *f;
sprintf(command,"/usr/sbin/lssf %s 2>/dev/null",devfile);
f=popen(command,"r");
if (!f)
{
perror("popen");
}
if(fgets(buf,BUFSZ,f)!=0)
{
char *p,*q;
p=strstr(buf,"address");
if(p) p=strchr(p,' ');
if(p) q=strchr(++p,' ');
if(q) *q=0;
printf("%s\n",p);
} else
{
buf[0]=0;
if(ferror(f)) perror("fread");
else printf("nosuchdev?\n");
return -1
}
pclose(f);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2004 11:00 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2004 02:11 AM
01-16-2004 02:11 AM
Re: How do I programmatically get the hardware address for a SCSI device?
Looking at souce you listed, I see that ioparmams.h has the following structure listed as such:
****************CODE LISTING****************
typedef struct ioconfig {
char name[MAX_NAME_LEN];
char class[MAX_NAME_LEN];
hw_path_t hw_path;
int instance;
} ioconfig_t;
***********STOP CODE LISTING****************
However, class is trated as a C++ keyword and thus will not compile. So, if I modify the source to the following:
****************CODE LISTING****************
typedef struct ioconfig {
char name[MAX_NAME_LEN];
char dclass[MAX_NAME_LEN];
hw_path_t hw_path;
int instance;
} ioconfig_t;
***********STOP CODE LISTING****************
The following compiles but cores when trying to create the union ioconfig_record rec:
****************CODE LISTING****************
#include
#include
#include
#include
#include
#include "ioparams.h"
int main( void ) {
FILE *fp;
union ioconfig_record rec;
unsigned long magic;
struct hw_path last_path;
char hw_path[14], *p;
int bytes, x;
cout << "DEBUG" << endl;
fp = fopen(IOCONFIG_FILE,"rb");
if ( !fp ) {
perror( "fopen" );
exit(0);
}
fclose(fp);
}
***********STOP CODE LISTING****************
Can you or anyone else provide some additional insight?
As always, Thanks In Advance.
Phil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2004 03:02 AM
01-16-2004 03:02 AM
Re: How do I programmatically get the hardware address for a SCSI device?
lssf /dev/dsk/c6t4d0
sdisk card instance 6 SCSI target 4 SCSI LUN 0 section 0 at address 0/8/0/0.1.27.0.0.4.0 /dev/dsk/c6t4d0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2004 03:29 AM
01-16-2004 03:29 AM
Re: How do I programmatically get the hardware address for a SCSI device?
I hope you've seen the comment in ioparams.h... :)
NOTE:
This header file contains information specific to the internals of the HP-UX implementation. The contents of this header file are subject to change without notice. Such changes may affect source code, object code, or binary compatibility between releases of HP-UX. Code which uses the symbols contained within this header file is inherently non-portable (even between HP-UX implementations).
Best regards...
Dietmar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2004 12:35 PM
01-16-2004 12:35 PM
Re: How do I programmatically get the hardware address for a SCSI device?
Just enclose your include for ioparms as an extern "C". This seems to work fine:
#ifdef __cplusplus
#define class ioclass
extern "C" {
#endif
#include "/usr/conf/io/ioparams.h"
#ifdef __cplusplus
};
#endif
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2004 03:52 AM
01-17-2004 03:52 AM
Re: How do I programmatically get the hardware address for a SCSI device?
I would like to start out by thanking you and the others that have replied to this question. All have provided solid direction and great snips of code.
There is a lot of information to gleem from these examples. However, unless I am not seeing the entire picture, it only appears to traverse the very top-level of hardware addresses. With this said, I think I have just few more questions on the subject that I hope that you might be able to shed some light on.
The ioparams.h include file procides some external (extern) functions:
*****************CODE SNIP******************
void *io_search __(( void *token, int type, int qual, ...));
void *io_search_array __(( void *token, int type, int qual, char *key[], void *dat[] ));
int io_query __(( void *token, int type, char *key, void *ptr ));
int io_get_key_info __(( int type, char *key, char *type_name, int *size ));
************STOP CODE SNIP******************
Do you know how these functions are used and can you provide an example?
I have included the external functions into my source but have not figured out how they should be called.
Thanks In Advance For Any All Assistance,
Phil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2004 09:23 AM
01-17-2004 09:23 AM
Re: How do I programmatically get the hardware address for a SCSI device?
Those functions are defined in an internal lib
libIO.a which is not delivered.
really the only supportable way to do it is still to use lssf
In ioparms.h there is a
#ifdef _KERNEL
around the function proto. Which means those functions there a prototyped for kernel functions.