DLPI Programmer's Guide

152 Appendix A
Sample Programs
Connection Mode
/* return the correlation number */
return(con_ind->dl_correlation);
}
/**************************************************************************
send a connect response with a specified correlation and token;
wait for the OK_ACK
**************************************************************************/
void
connect_res(fd, correlation, token)
int fd; /* file descriptor */
u_long correlation; /* correlation number of CONNECT_IND */
/* being responded to */
u_long token; /* token of stream to pass connection to */
{
dl_connect_res_t *con_res = (dl_connect_res_t *)ctrl_area;
/* fill in the connect response */
con_res->dl_primitive = DL_CONNECT_RES;
con_res->dl_correlation = correlation;
con_res->dl_resp_token = token;
/* QOS is not supported; these fields must be set to zero */
con_res->dl_qos_length = 0;
con_res->dl_qos_offset = 0;
con_res->dl_growth = 0;
put_ctrl(fd, sizeof(dl_connect_res_t), 0);
get_msg(fd);
check_ctrl(DL_OK_ACK);
}
/**************************************************************************
send a DISCONNECT_REQ and wait for the OK_ACK
**************************************************************************/
void
disconnect_req(fd)
int fd; /* file descriptor */
{
dl_disconnect_req_t *disc_req = (dl_disconnect_req_t *)ctrl_area;
/* fill in the disconnect request */
disc_req->dl_primitive = DL_DISCONNECT_REQ;
/* this is a normal disconnect */
disc_req->dl_reason = DL_DISC_NORMAL_CONDITION;
/*
Since we are not rejecting a CONNECT_IND, we set the correlation
to zero.