beautypg.com

DSS Networks C5468 User Manual

Page 38

background image

GigMAC-CPCI-3U Network Interface Cards
Gig-CPCI-3U Gigabit Ethernet Switches

Board and Driver Users Manual

DSS NETWORKS, INC. DocVersion: 1.2

Page: 38

A. Opening a socket for management API

int

s;

s = socket (PF_INET, SOCK_STREAM, 0);


B. Create request block for driver ioctl

struct ifreq ifr;
int subCmd;
NpkUserCtl myIoc;

char myDataBuf[MAX_LINES * MAX_LINE_LEN];


/* set interface name */

strcpy (ifr.ifr_name, “eth1”);

/* set ioctl sub-type */

subCmd = DM_IOCTL_GET_STATS;

/* set command argument */
myIoc.arg1 = 0;

myIoc.dataItm = (u_int) myDataBuf;
ifr.ifr_data = (char *) &myIoc;


C. Issue ioctl command


/* issue ioctl to network driver */

err = ioctl (s, SIOCDEVPRIVATE + subCmd, &ifr);

D. Check and print results


if (err < 0)
{
/* perror (errno); */
usage ();
exit (1);
}
if (subCmd == DM_IOCTL_GET_TRC)
{
print_trace();
}
else
{
if ((subCmd != DM_IOCTL_SET_LOOP_MODE) &&
(subCmd != DM_IOCTL_PROG_EEPROM))
printf ("\n%s\n", myDataBuf);
}

IOCTL COMMAND SUB-TYPES

This manual is related to the following products: