-/* $OpenBSD: route.c,v 1.216 2018/07/01 08:53:03 mpi Exp $ */
+/* $OpenBSD: route.c,v 1.217 2018/07/10 13:11:38 kn Exp $ */
/* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */
/*
int key;
uint8_t prio = 0;
struct hostent *hp = NULL;
+ int sawdest = 0;
if (uid)
errx(1, "must be root to alter routing table");
usage(1+*argv);
ishost = getaddr(RTA_DST, af, *++argv, &hp);
dest = *argv;
+ sawdest = 1;
break;
case K_LABEL:
if (!--argc)
getlabel(*++argv);
break;
case K_NETMASK:
+ if (!sawdest)
+ errx(1, "-netmask must follow "
+ "destination parameter");
if (!--argc)
usage(1+*argv);
getaddr(RTA_NETMASK, af, *++argv, NULL);
forcenet++;
break;
case K_PREFIXLEN:
+ if (!sawdest)
+ errx(1, "-prefixlen must follow "
+ "destination parameter");
if (!--argc)
usage(1+*argv);
ishost = prefixlen(af, *++argv);
} else {
if ((rtm_addrs & RTA_DST) == 0) {
dest = *argv;
+ sawdest = 1;
ishost = getaddr(RTA_DST, af, *argv, &hp);
} else if ((rtm_addrs & RTA_GATEWAY) == 0) {
gateway = *argv;