| 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)) ==
}
/* 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 |