HP (Hewlett-Packard) B2355-90138 Network Card User Manual


 
Chapter 2 39
LLA and DLPI Example Programs
LLA Example Program
/*
The following bind is not needed because we are running in loopback
mode with only one LAN interface. Since the sending LLA device
will use the same SNAP address for sending and receiving we'll
just loopback on the same LLA file descriptor.
bind_snap(recv_fd, RECV_SNAP_SAP);
*/
get_local_address(send_fd, local_addr);
/*
Set the destination MAC and SAP address to the local address.
This will allow us to send loopback packets. As mention above,
the SNAP address does not need to be logged, it is used here
only to distinguish SAPs and SNAP values.
*/
set_dst_address(send_fd, local_addr, RECV_SNAP_SAP, 6);
/* print the MAC and SAP addresses we are sending and receiving on */
memcpy((caddr_t)&local_addr[6], SEND_SNAP_SAP, 5);
print_dlsap(”sending too = ”, local_addr, 11);
print_dlsap(”receiving on = ”, local_addr, 11);
/*
Time to send some data. We'll send 5 data packets in sequence.
*/
for(i = 0; i < 5; i++) {
/* send (i+1)*10 data bytes with the first byte = i */
data_area[0] = i;
/* Initialize data area */
for (j = 1; j < (i+1)*10; j++)
data_area[j] = ”a”;
print_dlsap(”sending data to ”,local_addr, 11);
send_data(send_fd, (i + 1) * 10);
/* receive the data packet. Since we are sending
to the SNAP address we enabled on the send_fd we
must also receive on this file descriptor.
*/
recv_len = recv_data(send_fd);
printf(”received %d bytes, first word = %d\n”, recv_len,
data_area[0]);
}
/*
We're finished. Now call cleanup to then close the device file.
*/
cleanup(send_fd);
cleanup(recv_fd);
}