summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>1998-05-28 07:31:30 +0000
committerjulian <julian@FreeBSD.org>1998-05-28 07:31:30 +0000
commit3654f28d394a609d42e7000c62963c45e3bba3db (patch)
treea0c4a75b9d449d35688f210d464d3eb6236d22d7
parenta9535209980b33d1252f13b48710b5f4642dccea (diff)
downloadFreeBSD-src-3654f28d394a609d42e7000c62963c45e3bba3db.zip
FreeBSD-src-3654f28d394a609d42e7000c62963c45e3bba3db.tar.gz
Use AF_LINK rather than AF_UNSPEC to set an ethernet multicast address.
This is obviously not a terribly used function as it's apparently been broken forever. It IS possible that this fix is wrong and that the KERNEL is wrong (in which case you should fix if_ethersubr.c) either way it certainly has more hope of working now than before. I'd take it to 2.2 except that obviously no-one cares :-)
-rw-r--r--usr.sbin/mtest/mtest.c47
1 files changed, 33 insertions, 14 deletions
diff --git a/usr.sbin/mtest/mtest.c b/usr.sbin/mtest/mtest.c
index a43dd2b..1e2e373 100644
--- a/usr.sbin/mtest/mtest.c
+++ b/usr.sbin/mtest/mtest.c
@@ -11,6 +11,7 @@
#include <sys/socket.h>
#include <sys/time.h>
#include <net/if.h>
+#include <net/if_dl.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
@@ -97,6 +98,8 @@ main( argc, argv )
case 'a':
{
+ struct sockaddr_dl *dlp;
+ unsigned char *bp;
++lineptr;
while( *lineptr == ' ' || *lineptr == '\t' ) ++lineptr;
if( (n = sscanf( lineptr, "%s %x.%x.%x.%x.%x.%x",
@@ -105,13 +108,20 @@ main( argc, argv )
printf( "bad args\n" );
break;
}
- ifr.ifr_addr.sa_family = AF_UNSPEC;
- ifr.ifr_addr.sa_data[0] = e1;
- ifr.ifr_addr.sa_data[1] = e2;
- ifr.ifr_addr.sa_data[2] = e3;
- ifr.ifr_addr.sa_data[3] = e4;
- ifr.ifr_addr.sa_data[4] = e5;
- ifr.ifr_addr.sa_data[5] = e6;
+ dlp = (struct sockaddr_dl *)&ifr.ifr_addr;
+ dlp->sdl_len = sizeof(struct sockaddr_dl);
+ dlp->sdl_family = AF_LINK;
+ dlp->sdl_index = 0;
+ dlp->sdl_nlen = 0;
+ dlp->sdl_alen = 6;
+ dlp->sdl_slen = 0;
+ bp = LLADDR(dlp);
+ bp[0] = e1;
+ bp[1] = e2;
+ bp[2] = e3;
+ bp[3] = e4;
+ bp[4] = e5;
+ bp[5] = e6;
if( ioctl( so, SIOCADDMULTI, &ifr ) == -1 )
warn( "can't add ether address" );
else printf( "ether address added\n" );
@@ -120,6 +130,8 @@ main( argc, argv )
case 'd':
{
+ struct sockaddr_dl *dlp;
+ unsigned char *bp;
++lineptr;
while( *lineptr == ' ' || *lineptr == '\t' ) ++lineptr;
if( (n = sscanf( lineptr, "%s %x.%x.%x.%x.%x.%x",
@@ -128,13 +140,20 @@ main( argc, argv )
printf( "bad args\n" );
break;
}
- ifr.ifr_addr.sa_family = AF_UNSPEC;
- ifr.ifr_addr.sa_data[0] = e1;
- ifr.ifr_addr.sa_data[1] = e2;
- ifr.ifr_addr.sa_data[2] = e3;
- ifr.ifr_addr.sa_data[3] = e4;
- ifr.ifr_addr.sa_data[4] = e5;
- ifr.ifr_addr.sa_data[5] = e6;
+ dlp = (struct sockaddr_dl *)&ifr.ifr_addr;
+ dlp->sdl_len = sizeof(struct sockaddr_dl);
+ dlp->sdl_family = AF_LINK;
+ dlp->sdl_index = 0;
+ dlp->sdl_nlen = 0;
+ dlp->sdl_alen = 6;
+ dlp->sdl_slen = 0;
+ bp = LLADDR(dlp);
+ bp[0] = e1;
+ bp[1] = e2;
+ bp[2] = e3;
+ bp[3] = e4;
+ bp[4] = e5;
+ bp[5] = e6;
if( ioctl( so, SIOCDELMULTI, &ifr ) == -1 )
warn( "can't delete ether address" );
else printf( "ether address deleted\n" );
OpenPOWER on IntegriCloud