Sent via Deja.com http://www.deja.com/
Before you buy.
There's probably a number of ways to do it. One way is to examine the
sysBootLine string. Here's a shell example:
-> printf sysBootLine
cpm(0,0)jway:vxWorks e=172.16.18.23:ffff0000 h=172.16.16.166
g=172.16.16.1 u=remoteftp pw=
tomahawk f=0x8 tn=rot21value = 113 = 0x71 = 'q'
The e= value is the target ip and mask; the h= value is the host.
In code, this snippet seems to work ok:
extern char *sysBootLine;
BOOT_PARAMS BootParams;
if (*bootStringToStruct (sysBootLine, &BootParams) == 0)
{
// Get my IP address. (see documentation for field name
associated with host IP address).
sscanf (BootParams.ead, "%d.%d.%d.%d", &l1, &l2, &l3, &l4);
}
Hope this helps.
Jim
> Newsgroups: comp.os.vxworks
> Subject: which function can I use to get host ipaddr?
> Date: Thu, 10 Aug 2000 20:40:24 GMT
> From: lx1...@my-deja.com
> Organization: Deja.com - Before you buy.
> Message-ID: <8mv3vn$7ai$1...@nnrp1.deja.com>
-----------------------------------------
Jim Way, Software Engineer
Datum Austin (Austron Inc.)
voice: 512.721.4170
fax : 512.990.9712
email: jwayATdatumDOTcom (no spam please)
-----------------------------------------
If you know the interface name just call ifAddrGet().
Getting the list of interface names may be more difficult.
The vxWorks ifShow() routines checks each entry in the ifnet table.
David
----------------------------------------------------------------
David Laight email: d...@tadpole.co.uk
Tadpole Technology plc phone: +44 1223 428 232
Cambridge, UK fax: +44 1223 428 201