HP B2355-90138 manual Dlpi Example Program

Page 28

LLA and DLPI Example Programs

DLPI Example Program

char *rdlsap;

int msg_res;

msg_res = get_msg(fd); check_ctrl(DL_UNITDATA_IND); if(msg_res != GOT_BOTH) {

printf(”error: did not receive data part of message\n”); exit(1);

}

return(data_buf.len);

}

/********************************************************************* send a data packet; assumes data_area has already been filled in

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

void

send_data(fd, rdlsap, rdlsap_len, len)

int

fd;

/* file descriptor */

u_char*

rdlsap;/* remote dlsap */

int

rdlsap_len;/* length

of rdlsap */

int

len;/* length of the

packet to send */

{

 

 

 

dl_unitdata_req_t *data_req =

(dl_unitdata_req_t *)ctrl_area;

u_char*out_dlsap;

 

 

/* fill in data_req */

data_req->dl_primitive = DL_UNITDATA_REQ; data_req->dl_dest_addr_length = rdlsap_len; data_req->dl_dest_addr_offset = sizeof(dl_unitdata_req_t); /* copy dlsap */

out_dlsap = (u_char *)ctrl_area + sizeof(dl_unitdata_req_t); memcpy(out_dlsap, rdlsap, rdlsap_len);

put_both(fd, sizeof(dl_unitdata_req_t) + rdlsap_len, len, 0);

}

/********************************************************************* print a string followed by a DLSAP

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

void

print_dlsap(string, dlsap, dlsap_len)

char

*string;

/* label */

u_char

*dlsap;

/* the DLSAP */

int

dlsap_len;

/* length of dlsap */

{

 

 

int

i;

 

printf(”%s”, string);

for(i = 0; i < dlsap_len; i++) { printf(”%02x”, dlsap[i]);

}

printf(”\n”);

}

28

Chapter 2

Image 28
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