HP B2355-90138 manual LLA Example Program

Page 33

LLA and DLPI Example Programs

LLA Example Program

/*

*Read a packet from the device.

*/

/* call read and check for an error */

if((recv_cnt = read(fd, data_area, MAX_PKT_SIZE)) < 0) { printf(”error: read failed, errno = %d\n”, errno); exit(1);

}

return(recv_cnt);

}

/************************************************************************** Send a packet over LLA

***************************************************************************/

void

 

 

put_data(fd, length)

 

int

fd;

/* file descriptor */

int

length;

/* length of data message */

{

 

 

/* call putmsg and check for an error */ if(write(fd, data_area, length) < 0) {

printf(”error: put_data putmsg failed, errno = %d\n”, errno); exit(1);

}

}

/*************************************************************************** Send a control request to the driver.

****************************************************************************/

void

 

 

put_ctrl(fd, cmd)

 

 

int

fd;

/* file descriptor */

int

cmd;

/* NETCTRL or NETSTAT */

{

 

 

/* Send control request to driver */ if(ioctl(fd, cmd, &ctrl_buf) < 0) {

printf(”error: put_ctrl putmsg failed, errno = %d\n”, errno); exit(1);

}

}

/**************************************************************************** Open an LLA device. The device file specifies which device you attaching to. There is no need to issue a seperate attach control request to designate which device you are using. In this example

we will default to /dev/lan0.

*****************************************************************************

*/ int attach() {

Chapter 2

33

Image 33
Contents LLA to Dlpi Migration Guide Legal Notices Page Page Contents Contents Printing History Page Preface Page LLA to Dlpi Migration LLA to Dlpi Migration Device Files LLA ioctl req type Dlpi Primitive Ioctl RequestsLogreadtimeout Transmitting Data Receiving Data Receiving Data LLA and Dlpi Example LLA and Dlpi Example Programs Snap SAP Dlpi Example ProgramStruct strbuf databuf = Dlpi Example Program Dlpi Example Program Dlpi Example Program Dlpi Example Program Dlpi Example Program Dlpi Example Program Dlpi Example Program Dlpi Example Program Dlpi Example Program LLA Example Program LLA Example Program LLA Example Program LLA Example Program LLA Example Program LLA Example Program LLA Example Program LLA Example Program LLA Example Program Index