HP B2355-90138 manual LLA Example Program

Models: B2355-90138

1 41
Download 41 pages 55.62 Kb
Page 34
Image 34

 

LLA and DLPI Example Programs

 

LLA Example Program

intfd;

/* file descriptor */

char *mac_name;

/* open the device file */

if((fd = open(”/dev/lan0”, O_RDWR)) == -1) { printf(”error: open failed, errno = %d\n”, errno); exit(1);

}

/* return the file descriptor for the LLA device to the caller */ return(fd);

}

/**************************************************************************** Bind to a sap. LLA does not automatically return the local MAC address and local sap information when binding a protocol value.

You must explicitly request the local MAC address via the LOCAL_ADDRESS control request.

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

void

 

 

bind(fd, sap)

 

 

int

fd;

/* file descriptor */

int

sap;

/* 802.2 SAP to bind on */

{

 

 

ctrl_buf.reqtype = LOG_SSAP; ctrl_buf.vtype = INTEGERTYPE; ctrl_buf.value.i = sap;

/* send the LOG_SSAP request. LLA will return success or failure when the ioctl completes, so there is no need to wait for an acknowledgement.

*/

put_ctrl(fd, NETCTRL);

}

/**************************************************************************** Get the local MAC address.

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

void

 

 

get_local_address(fd, ret_addr)

 

int

fd;

/* file descriptor */

caddr_tret_addr;/* return local address here */

{

ctrl_buf.reqtype = LOCAL_ADDRESS;

/* send the LOCAL_ADDRESS request. LLA will return success or

failure when the ioctl completes, so there is no need to wait for an acknowledgement.

*/

put_ctrl(fd, NETSTAT);

34

Chapter 2

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