HP B2355-90138 manual Struct strbuf databuf =

Page 22

LLA and DLPI Example Programs

DLPI Example Program

struct strbuf data_buf = {

 

 

 

AREA_SIZE,

/* maxlen =

AREA_SIZE */

0,

 

/* len gets

filled in for each message */

data_area

/* buf = data area */

};

 

 

 

 

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

get the next message from a

stream; get_msg() returns one of the

following defines

 

 

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

#define GOT_CTRL

 

1

/*

message has only a control part */

#define GOT_DATA

 

2

/*

message has only a data part */

#define GOT_BOTH

 

3

/*

message has control and data parts */

int

 

 

 

 

get_msg(fd)

 

 

 

 

int

fd;

 

/*

file descriptor */

{

 

 

 

 

int

flags = 0;

/*

0 ---> get any available message */

int

result = 0;

/*

return value */

/*

 

 

 

 

zero first byte of control area so the caller can call check_ctrl

without checking the get_msg return value; if only data was

in the message and the user

was expecting control or control +

data, then when he calls check_ctrl it will compare the expected primitive zero and print information about the primitive

that it got. */ ctrl_area[0] = 0;

/* call getmsg and check for an error */ if(getmsg(fd, &ctrl_buf, &data_buf, &flags) < 0) {

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

}

if(ctrl_buf.len > 0) { result = GOT_CTRL;

}

if(data_buf.len > 0) { result = GOT_DATA;

}

return(result);

}

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

check that control message is the expected message

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

void

check_ctrl(ex_prim)

int

ex_prim; /* the expected primitive */

{

dl_error_ack_t*err_ack = (dl_error_ack_t *)ctrl_area;

/* did we get the expected primitive? */ if(err_ack->dl_primitive != ex_prim) {

22

Chapter 2

Image 22
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 Ioctl Requests LLA ioctl req type Dlpi PrimitiveLogreadtimeout Transmitting Data Receiving Data Receiving Data LLA and Dlpi Example LLA and Dlpi Example Programs Dlpi Example Program Snap SAPStruct 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