summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sbin/ipsec/ipsecadm/ipsecadm.c30
-rw-r--r--sbin/ipsec/ipsecadm/xf_flow.c14
2 files changed, 22 insertions, 22 deletions
diff --git a/sbin/ipsec/ipsecadm/ipsecadm.c b/sbin/ipsec/ipsecadm/ipsecadm.c
index 9c387ae088e..9ef7569bc6a 100644
--- a/sbin/ipsec/ipsecadm/ipsecadm.c
+++ b/sbin/ipsec/ipsecadm/ipsecadm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipsecadm.c,v 1.15 1998/05/24 13:29:01 provos Exp $ */
+/* $OpenBSD: ipsecadm.c,v 1.16 1998/06/08 17:42:33 provos Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
@@ -173,7 +173,7 @@ main(argc, argv)
int auth = 0, enc = 0, ivlen = 0, klen = 0, alen = 0;
int proto = IPPROTO_ESP, proto2 = IPPROTO_AH;
int dport = -1, sport = -1, tproto = -1;
- int delete = 0, local = 0;
+ int delete = 0, local = 0, result;
int chain = 0;
u_int32_t spi = 0, spi2 = 0;
struct in_addr src, dst, dst2, osrc, odst, osmask, odmask;
@@ -374,8 +374,8 @@ main(argc, argv)
argv[0]);
exit(1);
} else if (iscmd(mode, FLOW) &&
- (((odst.s_addr & odmask.s_addr) == 0) ||
- ((osrc.s_addr & osmask.s_addr) == 0))) {
+ (odst.s_addr == 0 && odmask.s_addr == 0 &&
+ osrc.s_addr == 0 && osmask.s_addr == 0)) {
fprintf(stderr, "%s: No subnets for flow specified\n",
argv[0]);
exit(1);
@@ -388,36 +388,36 @@ main(argc, argv)
if (isencauth(mode)) {
switch(mode) {
case ESP_NEW:
- xf_esp_new(src, dst, spi, enc, auth, ivp, keyp, authp,
- osrc, odst, newpadding);
+ result = xf_esp_new(src, dst, spi, enc, auth, ivp, keyp,
+ authp, osrc, odst, newpadding);
break;
case ESP_OLD:
- xf_esp_old(src, dst, spi, enc, ivp, keyp, osrc, odst);
+ result = xf_esp_old(src, dst, spi, enc, ivp, keyp, osrc, odst);
break;
case AH_NEW:
- xf_ah_new(src, dst, spi, auth, keyp, osrc, odst);
+ result = xf_ah_new(src, dst, spi, auth, keyp, osrc, odst);
break;
case AH_OLD:
- xf_ah_old(src, dst, spi, auth, keyp, osrc, odst);
+ result = xf_ah_old(src, dst, spi, auth, keyp, osrc, odst);
break;
}
} else {
switch(mode & CMD_MASK) {
case GRP_SPI:
- xf_grp(dst, spi, proto, dst2, spi2, proto2);
+ result = xf_grp(dst, spi, proto, dst2, spi2, proto2);
break;
case DEL_SPI:
- xf_delspi(dst, spi, proto, chain);
+ result = xf_delspi(dst, spi, proto, chain);
break;
case ENC_IP:
- xf_ip4(src, dst, spi, osrc, odst);
+ result = xf_ip4(src, dst, spi, osrc, odst);
break;
case FLOW:
- xf_flow(dst, spi, proto, osrc, osmask, odst, odmask, tproto,
- sport, dport, delete, local);
+ result = xf_flow(dst, spi, proto, osrc, osmask, odst, odmask,
+ tproto, sport, dport, delete, local);
break;
}
}
- return 1;
+ exit (result ? 0 : 1);
}
diff --git a/sbin/ipsec/ipsecadm/xf_flow.c b/sbin/ipsec/ipsecadm/xf_flow.c
index b91a1b5134b..7e97ee55feb 100644
--- a/sbin/ipsec/ipsecadm/xf_flow.c
+++ b/sbin/ipsec/ipsecadm/xf_flow.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xf_flow.c,v 1.3 1998/06/01 10:51:40 provos Exp $ */
+/* $OpenBSD: xf_flow.c,v 1.4 1998/06/08 17:42:34 provos Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
@@ -69,7 +69,7 @@ xf_flow(struct in_addr dst, u_int32_t spi, int proto,
{
struct sockaddr_encap *ddst, *msk, *gw;
struct rt_msghdr *rtm;
- int sd, off;
+ int sd, off, error = 0;
sd = socket(PF_ROUTE, SOCK_RAW, AF_UNSPEC);
if (sd < 0) {
@@ -137,19 +137,19 @@ xf_flow(struct in_addr dst, u_int32_t spi, int proto,
rtm->rtm_msglen = sizeof(*rtm) + ddst->sen_len +
(delete ? 0 : gw->sen_len) + msk->sen_len;
- if (write(sd, (caddr_t) buf, rtm->rtm_msglen) < 0) {
+ if (write(sd, (caddr_t) buf, rtm->rtm_msglen) == -1) {
perror("write");
- return 0;
+ error = 1;
}
/* Additionally create/delete a flow for local packets */
if (local) {
ddst->sen_ip_src.s_addr = INADDR_ANY;
msk->sen_ip_src.s_addr = INADDR_BROADCAST;
- if (write(sd, (caddr_t) buf, rtm->rtm_msglen) < 0) {
+ if (write(sd, (caddr_t) buf, rtm->rtm_msglen) == -1) {
perror("write");
- return 0;
+ error = 1;
}
}
- return 1;
+ return (error ? 0 : 1);
}