
Sample Programs
Connection Mode
int | dlsap_len; | /* length of dlsap */ |
{
int i;
printf(”%s0x”, string);
for(i = 0; i < dlsap_len; i++) { printf(”%02x”, dlsap[i]);
}
printf(”\n”);
}
/************************************************************************** open the DLPI cloneable device file, get a list of available PPAs, and attach to the first PPA; returns a file descriptor for the stream
**************************************************************************/
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)) ==
}
/*
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 */
/* make sure we found at least one PPA */
printf(”error: no PPAs available\n”); exit(1);
}
/* examine the first PPA */
ppa_info = (dl_hp_ppa_info_t *)((u_char *)ctrl_area +
ppa =
case DL_CSMACD: case DL_ETHER:
mac_name = ”Ethernet”; break;
case DL_TPR:
mac_name = ”Token Ring”; break;
148 | Appendix A |