LLA and DLPI Example Programs

LLA Example Program

int

dest_addr_len; /* length of dest_addr */

{

int i;

printf(”%s”, string);

for(i = 0; i < dest_addr_len; i++) { printf(”%02x”, dest_addr[i]);

}

printf(”\n”);

}

/**************************************************************************** main

****************************************************************************/

main() {

 

 

int

send_fd, recv_fd;

/* file descriptors */

u_char

local_addr[20];

/* local MAC address */

int

i, j, recv_len;

 

/*

PART 1 of program. Demonstrate connectionless data transfer with LLC SAP header.

*/

/*

First, we must open the LLA device file, /dev/lan0. LLA does not require a seperate control request to specify which device you want to use, it is explicit in the open request (via the device file minor number).

*/

send_fd = attach(); recv_fd = attach();

/*

Now we have to bind to a IEEESAP. Since LLA only supports connectionless services there is no need to specify a specific service mode. LLA also does not return the local MAC address automatically when binding, so we need to issue a seperate control request (LOCAL_ADDRESS)to get this information (see below).

*/

bind(send_fd, SEND_SAP); bind(recv_fd, RECV_SAP);

/*

The following calls to get_local_address and set_dst_address

are required for LLA because of one primary difference in sending data over LLA and DLPI. The difference is that DLPI

requires you to specify the destination address as part of the data request and LLA requires the destination address to be logged prior to the data request.

Get the local MAC address so that we can send loopback packets. */

get_local_address(send_fd, local_addr);

Chapter 2

37