summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorAngelos D. Keromytis <angelos@cvs.openbsd.org>2001-06-29 20:45:40 +0000
committerAngelos D. Keromytis <angelos@cvs.openbsd.org>2001-06-29 20:45:40 +0000
commite4fc2085e569fcdd453f419d76a2aee5f81d6291 (patch)
tree5f0cab0606a2388f0d7463aa66bae0ab97b2ec25 /sbin
parenta5bb99d71a2a1d57ec865f82145578beb96e713b (diff)
Set the port *before* the comparison.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/isakmpd/udp.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/sbin/isakmpd/udp.c b/sbin/isakmpd/udp.c
index a253df7c2f2..0cee10a81c4 100644
--- a/sbin/isakmpd/udp.c
+++ b/sbin/isakmpd/udp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udp.c,v 1.34 2001/06/29 20:38:16 angelos Exp $ */
+/* $OpenBSD: udp.c,v 1.35 2001/06/29 20:45:39 angelos Exp $ */
/* $EOM: udp.c,v 1.57 2001/01/26 10:09:57 niklas Exp $ */
/*
@@ -331,6 +331,23 @@ udp_bind_if (struct ifreq *ifrp, void *arg)
if (!(flags_ifr.ifr_flags & IFF_UP))
return;
+ /* Set port */
+ switch (if_addr->sa_family)
+ {
+ case AF_INET:
+ ((struct sockaddr_in *)if_addr)->sin_port =
+ htons((in_port_t)strtol (port, NULL, 10));
+ break;
+ case AF_INET6:
+ ((struct sockaddr_in6 *)if_addr)->sin6_port =
+ htons((in_port_t)strtol (port, NULL, 10));
+ break;
+ default:
+ log_print ("udp_bind_if: unsupported protocol family %d",
+ if_addr->sa_family);
+ break;
+ }
+
/*
* If we are explicit about what addresses we can listen to, be sure
* to respect that option.
@@ -350,7 +367,7 @@ udp_bind_if (struct ifreq *ifrp, void *arg)
continue;
}
- /* If found, take the easy way out. */
+ /* If found, take the easy way out. */
if (memcmp (addr, if_addr, addr->sa_len) == 0)
{
free (addr);
@@ -370,22 +387,6 @@ udp_bind_if (struct ifreq *ifrp, void *arg)
return;
}
- /* Set port */
- switch (if_addr->sa_family)
- {
- case AF_INET:
- ((struct sockaddr_in *)if_addr)->sin_port =
- htons((in_port_t)strtol (port, NULL, 10));
- break;
- case AF_INET6:
- ((struct sockaddr_in6 *)if_addr)->sin6_port =
- htons((in_port_t)strtol (port, NULL, 10));
- break;
- default:
- log_print ("udp_bind_if: unsupported protocol family %d",
- if_addr->sa_family);
- break;
- }
t = udp_bind (if_addr);
if (!t)
{