diff options
author | charnier <charnier@FreeBSD.org> | 1997-10-01 06:27:34 +0000 |
---|---|---|
committer | charnier <charnier@FreeBSD.org> | 1997-10-01 06:27:34 +0000 |
commit | 9e9c06cc6a32be0e300ed8612438b503e0b8998e (patch) | |
tree | 8e151bdb7514865fe3110d1333885e42d7eba49c /usr.sbin/mtest | |
parent | c1e15eaeace209f91bade884a0d522702bc52ad5 (diff) | |
download | FreeBSD-src-9e9c06cc6a32be0e300ed8612438b503e0b8998e.zip FreeBSD-src-9e9c06cc6a32be0e300ed8612438b503e0b8998e.tar.gz |
Use err(3). -Wall cleaning.
Diffstat (limited to 'usr.sbin/mtest')
-rw-r--r-- | usr.sbin/mtest/mtest.8 | 2 | ||||
-rw-r--r-- | usr.sbin/mtest/mtest.c | 28 |
2 files changed, 15 insertions, 15 deletions
diff --git a/usr.sbin/mtest/mtest.8 b/usr.sbin/mtest/mtest.8 index a28943e..bdb4aec 100644 --- a/usr.sbin/mtest/mtest.8 +++ b/usr.sbin/mtest/mtest.8 @@ -47,6 +47,6 @@ Quit the program. .El .\" .Sh SEE ALSO .Sh AUTHORS -Steve Deering +.An Steve Deering .Sh BUGS The command parser is not very flexible. diff --git a/usr.sbin/mtest/mtest.c b/usr.sbin/mtest/mtest.c index 13d305f..a43dd2b 100644 --- a/usr.sbin/mtest/mtest.c +++ b/usr.sbin/mtest/mtest.c @@ -5,6 +5,7 @@ * Written by Steve Deering, Stanford University, February 1989. */ +#include <err.h> #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> @@ -13,6 +14,7 @@ #include <sys/ioctl.h> #include <netinet/in.h> +int main( argc, argv ) int argc; char **argv; @@ -27,10 +29,7 @@ main( argc, argv ) unsigned e1, e2, e3, e4, e5, e6; if( (so = socket( AF_INET, SOCK_DGRAM, 0 )) == -1) - { - perror( "can't open socket" ); - exit( 1 ); - } + err( 1, "can't open socket" ); printf( "multicast membership test program; " ); printf( "enter ? for list of commands\n" ); @@ -58,7 +57,7 @@ main( argc, argv ) { ++lineptr; while( *lineptr == ' ' || *lineptr == '\t' ) ++lineptr; - if( (n = sscanf( lineptr, "%u.%u.%u.%u %u.%u.%u.%u %u", + if( (n = sscanf( lineptr, "%u.%u.%u.%u %u.%u.%u.%u", &g1, &g2, &g3, &g4, &i1, &i2, &i3, &i4 )) != 8 ) { printf( "bad args\n" ); @@ -70,7 +69,7 @@ main( argc, argv ) imr.imr_interface.s_addr = htonl(imr.imr_interface.s_addr); if( setsockopt( so, IPPROTO_IP, IP_ADD_MEMBERSHIP, &imr, sizeof(struct ip_mreq) ) == -1 ) - perror( "can't join group" ); + warn( "can't join group" ); else printf( "group joined\n" ); break; } @@ -79,7 +78,7 @@ main( argc, argv ) { ++lineptr; while( *lineptr == ' ' || *lineptr == '\t' ) ++lineptr; - if( (n = sscanf( lineptr, "%u.%u.%u.%u %u.%u.%u.%u %u", + if( (n = sscanf( lineptr, "%u.%u.%u.%u %u.%u.%u.%u", &g1, &g2, &g3, &g4, &i1, &i2, &i3, &i4 )) != 8 ) { printf( "bad args\n" ); @@ -91,7 +90,7 @@ main( argc, argv ) imr.imr_interface.s_addr = htonl(imr.imr_interface.s_addr); if( setsockopt( so, IPPROTO_IP, IP_DROP_MEMBERSHIP, &imr, sizeof(struct ip_mreq) ) == -1 ) - perror( "can't leave group" ); + warn( "can't leave group" ); else printf( "group left\n" ); break; } @@ -114,7 +113,7 @@ main( argc, argv ) ifr.ifr_addr.sa_data[4] = e5; ifr.ifr_addr.sa_data[5] = e6; if( ioctl( so, SIOCADDMULTI, &ifr ) == -1 ) - perror( "can't add ether adress" ); + warn( "can't add ether address" ); else printf( "ether address added\n" ); break; } @@ -137,7 +136,7 @@ main( argc, argv ) ifr.ifr_addr.sa_data[4] = e5; ifr.ifr_addr.sa_data[5] = e6; if( ioctl( so, SIOCDELMULTI, &ifr ) == -1 ) - perror( "can't delete ether adress" ); + warn( "can't delete ether address" ); else printf( "ether address deleted\n" ); break; } @@ -153,7 +152,7 @@ main( argc, argv ) } if( ioctl( so, SIOCGIFFLAGS, &ifr ) == -1 ) { - perror( "can't get interface flags" ); + warn( "can't get interface flags" ); break; } printf( "interface flags %x, ", ifr.ifr_flags ); @@ -161,7 +160,7 @@ main( argc, argv ) if( f ) ifr.ifr_flags |= IFF_ALLMULTI; else ifr.ifr_flags &= ~IFF_ALLMULTI; if( ioctl( so, SIOCSIFFLAGS, &ifr ) == -1 ) - perror( "can't set" ); + warn( "can't set" ); else printf( "changed to %x\n", ifr.ifr_flags ); break; } @@ -177,7 +176,7 @@ main( argc, argv ) } if( ioctl( so, SIOCGIFFLAGS, &ifr ) == -1 ) { - perror( "can't get interface flags" ); + warn( "can't get interface flags" ); break; } printf( "interface flags %x, ", ifr.ifr_flags ); @@ -185,7 +184,7 @@ main( argc, argv ) if( f ) ifr.ifr_flags |= IFF_PROMISC; else ifr.ifr_flags &= ~IFF_PROMISC; if( ioctl( so, SIOCSIFFLAGS, &ifr ) == -1 ) - perror( "can't set" ); + warn( "can't set" ); else printf( "changed to %x\n", ifr.ifr_flags ); break; } @@ -202,4 +201,5 @@ main( argc, argv ) } } } + return(0); } |