diff options
author | Max Khon <fjoe@FreeBSD.org> | 2013-09-18 06:21:10 +0000 |
---|---|---|
committer | Max Khon <fjoe@FreeBSD.org> | 2013-09-18 06:21:10 +0000 |
commit | 7cf536db202f746baf7dc23e946b8a39c93e723f (patch) | |
tree | a65db96e320dac75b7d0b7cca5779d68c23ac51e /sysutils/sbniconfig | |
parent | 19bd1f550fe0f901bc37101ef12fff83036e5bdc (diff) |
Notes
Diffstat (limited to 'sysutils/sbniconfig')
-rw-r--r-- | sysutils/sbniconfig/Makefile | 8 | ||||
-rw-r--r-- | sysutils/sbniconfig/distinfo | 2 | ||||
-rw-r--r-- | sysutils/sbniconfig/files/sbniconfig.c | 176 |
3 files changed, 178 insertions, 8 deletions
diff --git a/sysutils/sbniconfig/Makefile b/sysutils/sbniconfig/Makefile index 645a5bf07c0a..f3515359fe24 100644 --- a/sysutils/sbniconfig/Makefile +++ b/sysutils/sbniconfig/Makefile @@ -8,10 +8,7 @@ PORTNAME= sbniconfig PORTVERSION= 1.0 CATEGORIES= sysutils -MASTER_SITES= ftp://ftp.granch.ru/pub/drivers/sbni12/FREEBSD/sbniconfig/ -DISTNAME= sbniconfig.c -EXTRACT_SUFX= .gz -EXTRACT_ONLY= +DISTFILES= # none MAINTAINER= fjoe@FreeBSD.org COMMENT= Configurator for Granch SBNI12-xx adapters @@ -22,7 +19,6 @@ ONLY_FOR_ARCHS= i386 PLIST_FILES= bin/sbniconfig post-extract: - @${GZCAT} ${DISTDIR}/${DISTFILES} > ${WRKDIR}/sbniconfig.c - @${CP} ${FILESDIR}/Makefile ${WRKDIR} + @${CP} ${FILESDIR}/Makefile ${FILESDIR}/sbniconfig.c ${WRKDIR} .include <bsd.port.mk> diff --git a/sysutils/sbniconfig/distinfo b/sysutils/sbniconfig/distinfo deleted file mode 100644 index 1fa303e114c1..000000000000 --- a/sysutils/sbniconfig/distinfo +++ /dev/null @@ -1,2 +0,0 @@ -SHA256 (sbniconfig.c.gz) = fd78a0f42a4faabc9e6b0b400e939a7ce8856a76c6c9df0152ecec5d39013274 -SIZE (sbniconfig.c.gz) = 1623 diff --git a/sysutils/sbniconfig/files/sbniconfig.c b/sysutils/sbniconfig/files/sbniconfig.c new file mode 100644 index 000000000000..587267433b95 --- /dev/null +++ b/sysutils/sbniconfig/files/sbniconfig.c @@ -0,0 +1,176 @@ +/* + * Copyright (c) 1997 + * Granch ltd. + * + * Redistribution and use in source forms, with and without modification, + * are permitted provided that this entire comment appear intact. + * + * THIS SOURCE CODE IS PROVIDED ``AS IS'' WITHOUT ANY WARRANTIES OF ANY KIND. + * + * sbniconfig.c,v 2.0.0 97/08/06 + */ + +/* + * SBNI adapter configuration utility + * + * Revision 2.0.0 97/08/06 + * Initial revision + * + * Revision 2.0.1 97/08/11 + * Additional internal statistics support (tx statistics) + * + * Revisuion 2.1 Jul 7 2000 + * Added feature to specify baud rate and rxl instead of flags + * + * + */ + +#include <sys/types.h> +#include <sys/param.h> +#include <sys/socket.h> +#include <sys/sockio.h> +#include <net/if.h> +#include <netinet/in.h> +#include <netinet/if_ether.h> +#include <errno.h> +#include <stdio.h> +#include <string.h> + +#include "if_sbnivar.h" + +char* rate_tab[] = { + "0", + "1", + "2", + "3" +}; + +int main(argc, argv) +int argc; +char *argv[]; +{ + char *if_name; + int s; + struct ifreq ifr; + struct sbni_in_stats in_stats; + + struct sbni_flags flags; + + int rxl=-1,baud=-1; + int rxlfix=1<<6; + + + if(argc < 2 || argc > 4){ + fprintf(stderr, "usage:\tsbniconfig if_name [flags]\n"); + fprintf(stderr, "\tsbniconfig if_name baud rxl\n"); + fprintf(stderr, "e.g.: \tsbniconfig sbni0 0xdeadbeef or \n\tsbniconfig sbni0 2 15\n\tsbniconfig sbni0 0 auto\n"); + + exit(1); + } + if_name = argv[1]; + if(argc == 3 || argc == 4){ + char* endptr; + if(argc == 3){ + *(u_int32_t*)&flags = strtoul(argv[2], &endptr, 0); + if(*endptr){ + fprintf(stderr, + "sbniconfig: invalid flags specified\n"); + exit(1); + } + + }else{ + baud=atoi(argv[2]); + if(strcasecmp(argv[3],"auto")){ + /* NON auto */ + rxl=atoi(argv[3]); + rxlfix=1<<6; + }else{ + rxl=0; + rxlfix=0; + } + + if((baud < 0) || (baud > 3) || (rxl < 0) || (rxl > 15)){ + printf("incorrect params.\n"); + exit(1); + } + + printf("baud rate = %d\n",baud); + + if(!rxlfix) + printf("rxl = auto\n"); + else{ + printf("rxl = %d\n",rxl); + } + + srandom(time(NULL)); + + *(u_int32_t*)&flags = random(); + *((u_char*) &flags + 3) = rxl | rxlfix | (baud<<4) | (1<<7); + printf("new flags = 0x%x\n",flags); + } + + flags.mac_addr = htonl(flags.mac_addr) >> 8; + } + + s = socket(AF_INET, SOCK_DGRAM, 0); + if(s < 0){ + perror("sbniconfig: socket"); + exit (1); + } + + strncpy(ifr.ifr_name, if_name, sizeof (ifr.ifr_name)); + ifr.ifr_addr.sa_family = AF_INET; + + if(argc == 2){ + if(ioctl(s, SIOCGHWFLAGS, (caddr_t)&ifr) < 0){ + perror("sbniconfig: SIOCGHWFLAGS"); + exit(1); + } + flags = *(struct sbni_flags*)&ifr.ifr_data; + + ifr.ifr_data = (caddr_t)&in_stats; + if(ioctl(s, SIOCGINSTATS, (caddr_t)&ifr) < 0){ + perror("sbniconfig: SIOCGINSTATS"); + exit(1); + } + + printf("%s:\tMAC addr: 00:ff:01:%02x:%02x:%02x\n" + "\treceive level: 0x%x (%s)\n" + "\tbaud rate: %s (%s)\n" + "\tTotal rx=%u\tBad rx=%u\tGood rx=%u\tTimeouts=%u\n" + "\tError frame ratio %6.2f%%\n" + "\tTotal tx=%u\tResend tx=%u\tImmediate tx=%u\n", + if_name, + *(u_char*) &flags, + *(((u_char*) &flags)+1), + *(((u_char*) &flags)+2), + (unsigned) flags.rxl, + flags.fixed_rxl ? "fixed" : "autodetected", + rate_tab[flags.rate], + flags.fixed_rate ? "fixed" : "autodetected", + in_stats.all_rx_number, + in_stats.bad_rx_number, + in_stats.all_rx_number - in_stats.bad_rx_number, + in_stats.timeout_number, + (float)(in_stats.bad_rx_number*100./(in_stats.all_rx_number+0.01)), + in_stats.all_tx_number, + in_stats.resend_tx_number, + in_stats.all_tx_number - in_stats.resend_tx_number); + } + else if((argc == 3) || (argc ==4 )){ + if(*(caddr_t*)&flags != 0){ + ifr.ifr_data = *(caddr_t*)&flags; + if(ioctl(s, SIOCSHWFLAGS, (caddr_t)&ifr) < 0){ + perror("sbniconfig: SIOCSHWFLAGS"); + exit(1); + } + } + if(ioctl(s, SIOCRINSTATS, (caddr_t)&ifr) < 0){ + perror("sbniconfig: SIOCRINSTATS"); + exit(1); + } + } + + close (s); + return 0; +} |