Sample Programs
Connection Mode
/* copy in the dlsap */
tdlsap = (u_char *)ctrl_area +
/* send the connect request */
print_dlsap(”sending CONNECT_REQ to DLSAP ”, dlsap, dlsap_len); put_ctrl(fd, sizeof(dl_connect_req_t) + dlsap_len, 0);
}
/************************************************************************* get a connection response token for a stream; returns the token
*************************************************************************/
u_long |
|
|
get_token(fd) |
|
|
int | fd; | /* file descriptor */ |
{ |
|
|
dl_token_req_t | *tok_req = (dl_token_req_t *)ctrl_area; | |
dl_token_ack_t | *tok_ack = (dl_token_ack_t *)ctrl_area; |
/*
Send down a token request. Note that unlike most of the other messages this one is a PCPROTO message so we call put_ctrl with RS_HIPRI instead of zero.
*/
put_ctrl(fd, sizeof(dl_token_req_t), RS_HIPRI);
/* wait for the token ack */ get_msg(fd); check_ctrl(DL_TOKEN_ACK);
/* return the token */
}
/************************************************************************* get a connect indication from a stream; returns the correlation number
*************************************************************************/
u_long |
|
|
connect_ind(fd) |
|
|
int | fd; | /* file descriptor */ |
{ |
|
|
dl_connect_ind_t | *con_ind = (dl_connect_ind_t *)ctrl_area; | |
u_char | *dlsap; |
|
int | dlsap_len; |
|
/* wait for the connect indication */ get_msg(fd); check_ctrl(DL_CONNECT_IND);
/* print the calling DLSAP */
dlsap = (u_char *)ctrl_area +
Appendix A | 151 |