HP B2355-90138 manual Dlpi Example Program

Page 25

 

 

LLA and DLPI Example Programs

 

 

DLPI Example Program

int

 

 

attach() {

 

 

int

fd;

/* file descriptor */

int

ppa;

/* PPA to attach to */

dl_hp_ppa_req_t

*ppa_req = (dl_attach_req_t *)ctrl_area;

dl_hp_ppa_ack_t *ppa_ack = (dl_hp_ppa_ack_t *)ctrl_area; dl_hp_ppa_info_t *ppa_info;

dl_attach_req_t *attach_req = (dl_attach_req_t *)ctrl_area; char *mac_name;

/* open the device file */

if((fd = open(”/dev/dlpi”, O_RDWR)) == -1) { printf(”error: open failed, errno = %d\n”, errno); exit(1);

}

/*

find a PPA to attach to; we assume that the first PPA on the remote is on the same media as the first local PPA

*/

/* send a PPA_REQ and wait for the PPA_ACK */ ppa_req->dl_primitive = DL_HP_PPA_REQ; put_ctrl(fd, sizeof(dl_hp_ppa_req_t), 0); get_msg(fd); check_ctrl(DL_HP_PPA_ACK);

/* make sure we found at least one PPA */ if(ppa_ack->dl_length == 0) {

printf(”error: no PPAs available\n”); exit(1);

}

/* examine the first PPA */

ppa_info = (dl_hp_ppa_info_t *)((u_char *)ctrl_area + ppa_ack->dl_offset);

ppa = ppa_info->dl_ppa; switch(ppa_info->dl_mac_type) {

case DL_CSMACD: case DL_ETHER:

mac_name = ”Ethernet”; break;

case DL_TPR:

mac_name = ”Token Ring”; break;

case DL_FDDI:

mac_name = ”FDDI”; break;

default:

printf(”error: unknown MAC type in ppa_info\n”); exit(1);

}

printf(”attaching to %s media on PPA %d\n”, mac_name, ppa);

/*

fill in ATTACH_REQ with the PPA we found, send the ATTACH_REQ, and wait for the OK_ACK

*/

attach_req->dl_primitive = DL_ATTACH_REQ;

Chapter 2

25

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