#include <sys/types.h>
#include <stdio.h>
#include <sys/socket.h>
#include <sys/sockio.h>
#include <svr3/bsd/net/if.h>
#include <sys/stropts.h>
#include <sys/sockio.h>

#define SIOCSLAF        _IOW('i',25, struct ifreq)        /* set Logical Address Filter */

struct ifreq ifr;
int cmd;
int fd;
int len;
caddr_t dat;

unsigned char laf[8];
unsigned char LAF[] = {
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};

main(ac,av)
	int ac;
	char **av;
{
	int c;
	extern int optind;
	extern char *optarg;

	if (ac < 2 ) {
	    usage();
	    exit(1);
	}
	while ((c = getopt(ac, av, "a:d:hs:")) != EOF)
	    switch (c) {
		case 'a':
		    cmd = SIOCADDMULTI;
		    dat = (caddr_t) &ifr;
		    len = sizeof(ifr);
		    dlpi_getenet(optarg, ifr.ifr_addr.sa_data);
		    break;

		case 'd':
		    cmd = SIOCDELMULTI;
		    dat = (caddr_t) &ifr;
		    len = sizeof(ifr);
		    dlpi_getenet(optarg, ifr.ifr_addr.sa_data);
		    break;

		case 's':
		    cmd = SIOCSLAF;
		    dat = (caddr_t) LAF;
		    len = 8;
		    break;

		case 'h':
		case '?':
		    usage();
		    exit(1);
	    }
	for (; optind < ac; optind++) {
	    fd = dlpi_open (av[optind]);
	    dlpi_strioctl(fd, cmd, 2, dat, len);
	    close (fd);
	}
	
}

usage()
{
	fprintf(stderr, "Usage: -a (or) -d ethernet.adrs  device\n");
}
