
Sample Programs
Connection Mode
/**************************************************************************
put a message consisting of only a control part on a stream
**************************************************************************/
void |
|
|
put_ctrl(fd, length, pri) |
| |
int | fd; | /* file descriptor */ |
int | length; | /* length of control message */ |
int | pri; | /* priority of message: either 0 or RS_HIPRI */ |
{ |
|
|
/* set the len field in the strbuf structure */ ctrl_buf.len = length;
/* call putmsg and check for an error */ if(putmsg(fd, &ctrl_buf, 0, pri) < 0) {
printf(”error: put_ctrl putmsg failed, errno = %d\n”, errno); exit(1);
}
}
/************************************************************************** put a message consisting of both a control part and a control part on a stream
**************************************************************************/
void
put_both(fd, ctrl_length, data_length, pri)
int | fd; | /* file descriptor */ |
int | ctrl_length; /* length of control part */ | |
int | data_length; /* length of data part */ | |
int | pri; | /* priority of message: either 0 or RS_HIPRI */ |
{
/* set the len fields in the strbuf structures */ ctrl_buf.len = ctrl_length;
data_buf.len = data_length;
/* call putmsg and check for an error */ if(putmsg(fd, &ctrl_buf, &data_buf, pri) < 0) {
printf(”error: put_both putmsg failed, errno = %d\n”, errno); exit(1);
}
}
/************************************************************************** print a string followed by a DLSAP
**************************************************************************/
void
print_dlsap(string, dlsap, dlsap_len)
char | *string; | /* | label */ |
u_char | *dlsap; | /* | the DLSAP */ |
Appendix A | 147 |