ports/145198: [patch] add verbose option to net-mgmt/choparp
Gleb Kurtsou
gk at FreeBSD.org
Tue Mar 30 09:40:09 UTC 2010
>Number: 145198
>Category: ports
>Synopsis: [patch] add verbose option to net-mgmt/choparp
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Tue Mar 30 09:40:08 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator: Gleb Kurtsou
>Release:
>Organization:
>Environment:
FreeBSD tops 9.0-CURRENT FreeBSD 9.0-CURRENT #19 r205158+38fe7c2-dirty: Thu Mar 18 15:48:13 EET 2010 root at tops:/usr/obj/freebsd-src/local/sys/TOPS amd64
>Description:
By default choparp prints warning on gratuitous ARP packets.
Print warning only if -v option given
Add another type gratuitous ARP used by windows: packet containing zero sender ip
>How-To-Repeat:
>Fix:
Copy attached patch to /usr/ports/net-mgmt/choparp/files
Rebuild, install
Patch attached with submission follows:
--- choparp.c.orig 2010-03-17 21:22:44.000000000 +0200
+++ choparp.c 2010-03-17 21:20:52.421965709 +0200
@@ -76,6 +76,7 @@
struct cidr *targets = NULL, *excludes = NULL;
u_char target_mac[ETHER_ADDR_LEN]; /* target MAC address */
+int verbose = 0;
/*
ARP filter program
@@ -241,7 +242,13 @@
return(0);
}
if (ntohl(*(u_int32_t *)(arp->arp_tpa)) == ntohl(*(u_int32_t *)(arp->arp_spa))) {
- fprintf(stderr,"checkarp: WARNING: sender equal dest.\n");
+ if (verbose != 0)
+ fprintf(stderr,"checkarp: WARNING: sender equal dest.\n");
+ return(0);
+ }
+ if (0 == ntohl(*(u_int32_t *)(arp->arp_spa))) {
+ if (verbose != 0)
+ fprintf(stderr,"checkarp: WARNING: zero sender address.\n");
return(0);
}
target_ip = ntohl(*(u_int32_t *)(arp->arp_tpa));
@@ -376,13 +383,13 @@
void
usage(void){
- fprintf(stderr,"usage: choparp if_name mac_addr [-]addr/mask...\n");
+ fprintf(stderr,"usage: choparp [-v] if_name mac_addr [-]addr/mask...\n");
exit(-1);
}
int
main(int argc, char **argv){
- int fd;
+ int ch, fd;
char *buf, *ifname;
struct cidr **targets_tail = &targets, **excludes_tail = &excludes;
#define APPEND(LIST,ADDR,MASK) \
@@ -395,13 +402,24 @@
} while (0)
size_t buflen;
- if (argc < 4)
+ while ((ch = getopt(argc, argv, "v")) != -1)
+ switch (ch) {
+ case 'v':
+ verbose++;
+ break;
+ default:
+ usage();
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (argc < 3)
usage();
- ifname = argv[1];
- if (setmac(argv[2], ifname))
+ ifname = argv[0];
+ if (setmac(argv[1], ifname))
usage();
- argv += 3; argc -= 3;
+ argv += 2; argc -= 2;
while (argc > 0) {
u_int32_t addr, mask = ~0;
--- choparp.8.orig 2010-03-17 21:22:44.000000000 +0200
+++ choparp.8 2010-03-17 21:20:05.461772794 +0200
@@ -35,6 +35,7 @@
.Nd cheap and omitted proxy ARP
.Sh SYNOPSIS
.Nm choparp
+.Op Fl v
.Ar if_name mac_addr
.Oo Fl Oc Ns Ar net_addr Ns
.Op / Ns Ar net_mask
@@ -90,6 +91,9 @@
by preceding them with
.Fl
.Pp
+.Fl v
+option enables verbose mode, showing warning for invalid ARP packets.
+.Pp
.Nm choparp
uses the Berkeley Packet Filter
.Nm bpf(4)
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list