Marc Lupien <marclupien@hotmail.com> wrote:
Is there a way of doing this under QNX 4 ?
#include <stdio.h>
#include <malloc.h>
#include <sys/kernel.h>
#include <sys/net_nq.h>
#include <sys/net41msg.h>
#include <sys/net_drvr.h>
#include <errno.h>
void main()
{
int ctr;
int pid;
struct _net_rnodemap rnodemap;
char data[1024];
struct _net_rnodemap_reply *rnodemap_reply;
int nids[20];
if ((pid=qnx_vc_name_attach(0, 64, “qnx/net”))==-1) {
printf (“Could not attach to Net (%d)\n”, errno);
exit(0);
}
memset(&rnodemap, 0, sizeof(rnodemap));
rnodemap.type=_NET_RNODEMAP;
rnodemap.log_nid=getnid();
rnodemap_reply=(struct _net_rnodemap_reply *) data;
if ((Send(pid, &rnodemap, rnodemap_reply, sizeof(rnodemap),
1000))==-1) {
printf (“Send error\n” );
exit(0);
}
printf (“MAC: “); // If you have multiple cards you will need a loop here
for (ctr=0; ctr<6; ctr++)
printf (”%02X”, rnodemap_reply->card[0].phys_addr[ctr]);
printf ("\n");
}
The sys/net* headers are in the netraw package on /usr/free.
I think all the relevant bits are:
#define _NET_RNODEMAP 0x421
struct _net_rnodemap {
short unsigned int type;
short unsigned int subtype;
nid_t log_nid;
short unsigned int zero1;
short unsigned int zero2;
};
struct _card_info {
short unsigned int lan_addr;
unsigned char phys_addr[6];
time_t last_tx_fail;
};
struct _net_rnodemap_reply {
short unsigned int status;
short unsigned int zero1;
short unsigned int num_card;
short unsigned int zero2;
struct _card_info card[];
};
-David
–
QNX Training Services
dagibbs@qnx.com