llcsetup.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <poll.h>
#include <sys/ethernet.h>
#include <dirent.h>
#include "rpld.h"
#include "dluser.h"
#define BUFSIZE 10000
static char *llcdev;
extern int if_fd;
extern char ifName[];
extern int debugLevel;
extern char debugmsg[];
extern int ifUnit;
extern int ppanum;
extern int need_llc;
struct ether_addr myNodeAddr;
/*
* Next lines makes enabmulti, and thus its fields, 32 bit aligned. This is
* necessary on sparc. Space allocated must be rounded up to the next highest
* number of words.
*/
DL_ENABMULTI_REQ_SIZE /* Basic size */
+ 10 /* Address */
sizeof (uint32_t)]; /* Convert to 32 bit */
char *enabmulti = (char *)enabmulti_aligned;
int
llcsetup(void)
{
/* struct size */
int flags = 0;
int muxid;
char myname[64];
struct ether_addr eas;
int use_llc1;
unsigned char *multAddrp;
/*
* Open a stream to the Ethernet driver.
*/
if (debugLevel >= MSG_INFO_2) {
}
if (debugLevel >= MSG_FATAL) {
}
return (-1);
}
if (debugLevel >= MSG_FATAL) {
ifName);
}
return (-1);
}
/*
* Attach the Ethernet stream to PPA specified by ifUnit.
*/
if (debugLevel >= MSG_INFO_2) {
}
if (debugLevel >= MSG_FATAL) {
}
return (-1);
}
/*
* Get the node address
*/
if (debugLevel >= MSG_INFO_1) {
ether_ntoa(&myNodeAddr));
}
} else {
if (debugLevel >= MSG_FATAL) {
}
return (-1);
}
/*
* Bind the Ethernet stream to SAP 0xfc.
*/
if (debugLevel >= MSG_INFO_2) {
}
if (debugLevel >= MSG_FATAL) {
}
return (-1);
}
if (debugLevel >= MSG_INFO_1) {
if (need_llc)
ifName);
else
ifName);
}
/*
* Token ring (IEEE 802.5) has the multicast address bytes
* bit-reversed (but not byte-reserved)
*/
else
if (need_llc) {
/*
* Open a stream to the LLC driver.
* At this point it is certain that an llc device is needed
* So we try only llc1.
*/
if (debugLevel >= MSG_INFO_2) {
llcdev);
}
/*
* llc1 doesnt work barf and quit.
*/
if (debugLevel >= MSG_FATAL) {
"Failed to open device %s\n",
llcdev);
}
return (-1);
}
/*
*/
if (debugLevel >= MSG_INFO_2) {
}
if (debugLevel >= MSG_FATAL) {
"Failed to I_LINK %s under %s\n",
}
return (-1);
}
/*
* Set the PPA of the Ethernet driver to ppanum.
* (This is the PPA that LLC clients need to specify when they
* attach to LLC.)
*/
if (debugLevel >= MSG_INFO_2) {
}
if (debugLevel >= MSG_FATAL) {
"Failed to set PPA %d to device %s\n",
}
return (-1);
}
/*
* Attach the LLC stream to PPA ppanum.
*/
if (debugLevel >= MSG_INFO_2) {
"Sending DL_ATTACH_REQ to %s FC\n", llcdev);
}
if (debugLevel >= MSG_FATAL) {
"Failed to attach to device %s\n",
llcdev);
}
return (-1);
}
/*
* Bind the LLC stream to SAP 0xfc.
*/
if (debugLevel >= MSG_INFO_2) {
"Sending DL_BIND_REQ to %s FC\n", llcdev);
}
< 0) {
if (debugLevel >= MSG_FATAL) {
"Failed to bind to device %s\n",
llcdev);
}
return (-1);
}
} else {
/* All subsequent I/O done using llc_fd.fd */
}
/*
* Set the RPL multicast address
*/
if (debugLevel >= MSG_INFO_2) {
}
if (debugLevel >= MSG_FATAL) {
"Failed to enable RPL required multicast address\n");
}
return (-1);
}
/*
* Read the acknowledgement message (will be DL_OK_ACK if
* it was successful).
*/
if (debugLevel >= MSG_FATAL) {
"Failed in getmsg() to receive ack for multicast enable operation\n");
}
return (-1);
}
if (debugLevel >= MSG_FATAL) {
}
return (-1);
}
return (0);
}
int
{
union DL_primitives *dlp;
char *buf;
int flags;
int tmp;
/* Allocate required buffers */
if (debugLevel >= MSG_FATAL) {
}
return (-1);
}
/* Issue DL_PHYS_ADDR_REQ */
if (debugLevel >= MSG_FATAL) {
"Failed in putmsg() for DL_PHYS_ADDR_REQ\n");
}
return (-1);
}
/* read reply */
flags = 0;
if (debugLevel >= MSG_FATAL) {
"Failed in getmsg() for DL_PHYS_ADDR_REQ\n");
}
return (-1);
}
if (debugLevel >= MSG_ALWAYS) {
"phys_addr_ack: ret[%d] ctl.len[%d] flags[%d]\n",
}
/* Validate DL_PHYS_ADDR_ACK reply */
if (debugLevel >= MSG_FATAL) {
"phys_addr failed: short reply to phys_addr request\n");
}
return (-1);
}
/*
* Do not print errors for DL_UNSUPPORTED and DL_NOTSUPPORTED
*/
if (debugLevel >= MSG_FATAL) {
"phys_addr failed: dl_errno %d unix_errno %d\n",
}
}
return (-1);
}
if (debugLevel >= MSG_FATAL) {
"phys_addr failed: unrecognizable dl_primitive %d received\n",
dlp->dl_primitive);
}
return (-1);
}
if (debugLevel >= MSG_FATAL) {
"phys_addr failed: short phys_addr acknowledgement received\n");
}
return (-1);
}
/* Check length of address. */
return (-1);
/*
* copy ethernet address
*/
return (0);
}