aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorJulian Elischer <julian@FreeBSD.org>1998-05-28 07:31:30 +0000
committerJulian Elischer <julian@FreeBSD.org>1998-05-28 07:31:30 +0000
commit4a71a2e71bdc472ecfe5390957894b3e6427fc93 (patch)
treead0f7ba6f343f1c6861615e7cb7f5db97b73f2a1 /usr.sbin
parentc17155d44b4c765ec40b85ca5f3d130d3c0e601e (diff)
downloadsrc-4a71a2e71bdc472ecfe5390957894b3e6427fc93.tar.gz
src-4a71a2e71bdc472ecfe5390957894b3e6427fc93.zip
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 :-)
Notes
Notes: svn path=/head/; revision=36440
Diffstat (limited to 'usr.sbin')
-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 a43dd2bc514e..1e2e37347e5e 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" );