LLA and DLPI Example Programs
DLPI Example Program
char *rdlsap;
int msg_res;
msg_res = get_msg(fd); check_ctrl(DL_UNITDATA_IND); if(msg_res != GOT_BOTH) {
printf(”error: did not receive data part of message\n”); exit(1);
}
return(data_buf.len);
}
/********************************************************************* send a data packet; assumes data_area has already been filled in
*********************************************************************/
void
send_data(fd, rdlsap, rdlsap_len, len)
int | fd; | /* file descriptor */ | |
u_char* | rdlsap;/* remote dlsap */ | ||
int | rdlsap_len;/* length | of rdlsap */ | |
int | len;/* length of the | packet to send */ | |
{ |
|
|
|
dl_unitdata_req_t *data_req = | (dl_unitdata_req_t *)ctrl_area; | ||
u_char*out_dlsap; |
|
|
/* fill in data_req */
out_dlsap = (u_char *)ctrl_area + sizeof(dl_unitdata_req_t); memcpy(out_dlsap, rdlsap, rdlsap_len);
put_both(fd, sizeof(dl_unitdata_req_t) + rdlsap_len, len, 0);
}
/********************************************************************* print a string followed by a DLSAP
*********************************************************************/
void
print_dlsap(string, dlsap, dlsap_len)
char | *string; | /* label */ |
u_char | *dlsap; | /* the DLSAP */ |
int | dlsap_len; | /* length of dlsap */ |
{ |
|
|
int | i; |
|
printf(”%s”, string);
for(i = 0; i < dlsap_len; i++) { printf(”%02x”, dlsap[i]);
}
printf(”\n”);
}
28 | Chapter 2 |