LLA and DLPI Example Programs

LLA Example Program

/*

Set the destination MAC and SAP address to the local address. This will allow us to send loopback packets.

*/

set_dst_address(send_fd, local_addr, RECV_SAP, INTEGERTYPE);

/* print the MAC and SAP addresses we are sending and receiving on */ local_addr[6] = SEND_SAP;

print_dest_addr(”sending too = ”, local_addr, 7); local_addr[6] = RECV_SAP; print_dest_addr(”receiving on = ”, local_addr, 7);

/*

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_dest_addr(”sending data to ”,local_addr, 7); send_data(send_fd, (i + 1) * 10);

/* receive the data packet */ recv_len = recv_data(recv_fd);

printf(”received %d bytes, first word = %d\n”, recv_len, (u_int)data_area[0]);

}

/*

We're finished with PART 1. Now call cleanup to 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();

/*

Bind the send and recv SNAP protocols. When binding SNAP over

LLA the SNAP address will be used as both the sending and receiving protocol address. Therefore, there is no need to issue a seperate request to log the destination SNAP protocol. However, we still need to set the destination MAC address.

*/

bind_snap(send_fd, SEND_SNAP_SAP);

38

Chapter 2

Page 38
Image 38
HP B2355-90138 manual LLA Example Program