Sample Programs

Connectionless Mode

{

dl_unitdata_ind_t *data_ind = (dl_unitdata_ind_t *)ctrl_area;

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 */

data_req->dl_primitive = DL_UNITDATA_REQ; data_req->dl_dest_addr_length = rdlsap_len; data_req->dl_dest_addr_offset = sizeof(dl_unitdata_req_t); /* copy dlsap */

data_req->dl_priority.dl_min = 0; data_req->dl_priority.dl_max = 0;

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”);

}

Appendix A

163

Page 163
Image 163
HP UX 11i v2 Networking Software manual Appendix a 163