LLA to DLPI Migration Guide, April 1997

30 Chapter 2
LLA and DLPI Example Programs
DLPI Example Program
}
/*
We're finished with PART 1. Now call cleanup to unbind, then
detach, then close the device file.
*/
cleanup(send_fd);
cleanup(recv_fd);
/*
PART 2 of program. Demonstrate connectionless data transfer
with LLC SNAP SAP header.
*/
/*
As demonstrated in the first part of this program we must first
open the DLPI device file, /dev/dlpi, and attach to a PPA.
*/
send_fd = attach();
recv_fd = attach();
/*
The first method for binding a SNAP protocol value (which is
demonstrated below) requires the user to first bind the SNAP
SAP 0xAA, then issue a subsequent bind with class
DL_HIERARCHICAL_BIND with the 5 bytes of SNAP information.
The second method (which is not demonstrated in this program) is
to bind any supported protocol value (see section 5) and then
issue a subsequent bind with class DL_PEER_BIND. The data area
area of the subsequent bind should include 6 bytes of data, the
first byte being the SNAP SAP 0xAA followed by 5 bytes of SNAP
information.
*/
bind(send_fd, SNAP_SAP, 0, DL_CLDLS, sdlsap, &sdlsap_len);
bind(recv_fd, SNAP_SAP, 0, DL_CLDLS, rdlsap, &rdlsap_len);
/*
Now we must complete the binding of the SNAP protocol value
with the subsequent bind request and a subsequent bind class
of DL_HIERARCHICAL_BIND.
*/
subs_bind(send_fd, SEND_SNAP_SAP, 5, DL_HIERARCHICAL_BIND,
sdlsap,&sdlsap_len);
subs_bind(recv_fd, RECV_SNAP_SAP, 5, DL_HIERARCHICAL_BIND,
rdlsap,&rdlsap_len);
/* print the DLSAPs we got back from the binds */
print_dlsap(”sending DLSAP = ”, sdlsap, sdlsap_len);
print_dlsap(”receiving DLSAP = ”, rdlsap, rdlsap_len);
/*
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 */