static void
procargs(int argc, char **argv)
{
- char *p, *loc6;
+ char *ipstr, *maskstr;
if (argc < 3)
usage();
-
- loc6 = *argv++;
- argc--;
-
- /* local v6 address (mask defaults to /128) */
- memcpy(localmask, IPallbits, sizeof localmask);
- p = strchr(loc6, '/');
- if (p != nil) {
- parseipmask(localmask, p);
- *p = 0;
- }
- if (parseip(local6, loc6) == -1)
- sysfatal("bad local v6 address %s", loc6);
- if (isv4(local6))
- usage();
- if (argc >= 1 && argv[0][0] == '/') {
- parseipmask(localmask, *argv++);
- argc--;
- }
+ ipstr = *argv++, argc--;
+ maskstr = strchr(ipstr, '/');
+ if (maskstr == nil && **argv == '/')
+ maskstr = *argv++, argc--;
+ if (parseipandmask(local6, localmask, ipstr, maskstr) == -1 || isv4(local6))
+ sysfatal("bad local v6 address/mask: %s", ipstr);
if (debug)
fprint(2, "local6 %I %M\n", local6, localmask);
-
- outside = netmkaddr(*argv++, "udp", "5072");
argc--;
+ outside = netmkaddr(*argv++, "udp", "5072");
if(outside == nil)
usage();
outside = strdup(outside);
exits(0);
}
-/*
- * based on libthread's threadsetname, but drags in less library code.
- * actually just sets the arguments displayed.
- */
-void
-procsetname(char *fmt, ...)
-{
- int fd;
- char *cmdname;
- char buf[128];
- va_list arg;
-
- va_start(arg, fmt);
- cmdname = vsmprint(fmt, arg);
- va_end(arg);
- if (cmdname == nil)
- return;
- snprint(buf, sizeof buf, "#p/%d/args", getpid());
- if((fd = open(buf, OWRITE)) >= 0){
- write(fd, cmdname, strlen(cmdname)+1);
- close(fd);
- }
- free(cmdname);
-}
-
static int alarmed;
static void
ip->src, ip->dst);
continue;
}
- if ((!equivip6(ip->dst, remote6) && badipv6(ip->dst))) {
+ if ((ipcmp(ip->dst, remote6) != 0 && badipv6(ip->dst))) {
syslog(0, "ayiya", "egress filtered %I -> %I; "
"bad dst not remote", ip->src, ip->dst);
continue;
* (this blocks link-local and multicast addresses as well)
*/
maskip(op->dst, localmask, a);
- if (!equivip6(a, localnet)) {
+ if (ipcmp(a, localnet) != 0) {
syslog(0, "ayiya", "ingress filtered %I -> %I; "
"dst not on local net", op->src, op->dst);
break;