Reputation: 55
I am trying to verify the Ethernet devices on a device are working correctly. I'm running the command:
ifconfig("interfaceName dhcp")
for each ethernet interface.
What I would also like to do is verify that each device got an ip address as well. I know I can just run 'ifconfig' by itself and look at the output, but I'm writing automated test code. So is there a function that can return the ip address of a specific interface in VxWorks?
Upvotes: 4
Views: 7933
Reputation: 309
I believe ifAddrGet() in ifLib.h may be what you're looking for. The first argument takes an interface name and the second argument takes a buffer, into which the address will be returned.
I haven't tested the following on an actual target, but it should be a start toward what you need:
#include <stdlib.h>
#include <stdio.h>
#include "inetLib.h"
#include "ifLib.h"
void print_if_address (void);
void print_if_address ()
{
char if_name[] = "dhcp";
char ip_address[INET_ADDR_LEN] = {0};
ifAddrGet (if_name, ip_address);
printf ("%s\n", ip_address);
}
Upvotes: 3