summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHakan Olsson <ho@cvs.openbsd.org>2003-12-14 14:50:24 +0000
committerHakan Olsson <ho@cvs.openbsd.org>2003-12-14 14:50:24 +0000
commita2fd51fdea85e149c489dbc46f2b8c2249cdf33a (patch)
tree8068c5f99c6a32e13e7881762cb217528690c233
parent87cfb42d6fc7165c848ef61cac3f360abfc00c5e (diff)
Log the actual port for src and dst, don't assume it's always 500.
-rw-r--r--sbin/isakmpd/log.c6
-rw-r--r--sbin/isakmpd/util.c18
-rw-r--r--sbin/isakmpd/util.h3
3 files changed, 23 insertions, 4 deletions
diff --git a/sbin/isakmpd/log.c b/sbin/isakmpd/log.c
index 7c656f489d7..98fa5b57e61 100644
--- a/sbin/isakmpd/log.c
+++ b/sbin/isakmpd/log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.c,v 1.36 2003/11/06 16:12:07 ho Exp $ */
+/* $OpenBSD: log.c,v 1.37 2003/12/14 14:50:23 ho Exp $ */
/* $EOM: log.c,v 1.30 2000/09/29 08:19:23 niklas Exp $ */
/*
@@ -63,6 +63,7 @@
#include "isakmp_num.h"
#include "log.h"
#include "monitor.h"
+#include "util.h"
static void _log_print (int, int, const char *, va_list, int, int);
@@ -469,7 +470,8 @@ log_packet_iov (struct sockaddr *src, struct sockaddr *dst, struct iovec *iov,
isakmphdr->flags &= ~(ISAKMP_FLAGS_ENC);
/* udp */
- udp.uh_sport = udp.uh_dport = htons (500);
+ udp.uh_sport = sockaddr_port (src);
+ udp.uh_dport = sockaddr_port (dst);
datalen += sizeof udp;
udp.uh_ulen = htons (datalen);
diff --git a/sbin/isakmpd/util.c b/sbin/isakmpd/util.c
index 7984ea027df..c5748a5c9bc 100644
--- a/sbin/isakmpd/util.c
+++ b/sbin/isakmpd/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.34 2003/06/03 14:28:16 ho Exp $ */
+/* $OpenBSD: util.c,v 1.35 2003/12/14 14:50:23 ho Exp $ */
/* $EOM: util.c,v 1.23 2000/11/23 12:22:08 niklas Exp $ */
/*
@@ -451,6 +451,22 @@ sockaddr_addrdata (struct sockaddr *sa)
}
}
+in_port_t
+sockaddr_port (struct sockaddr *sa)
+{
+ switch (sa->sa_family)
+ {
+ case AF_INET6:
+ return ((struct sockaddr_in6 *)sa)->sin6_port;
+ case AF_INET:
+ return ((struct sockaddr_in *)sa)->sin_port;
+ default:
+ log_print ("sockaddr_port: unsupported protocol family %d",
+ sa->sa_family);
+ return 0;
+ }
+}
+
/*
* Convert network address to text. The network address does not need
* to be properly aligned.
diff --git a/sbin/isakmpd/util.h b/sbin/isakmpd/util.h
index b5884f7bfd4..7c5547c0d35 100644
--- a/sbin/isakmpd/util.h
+++ b/sbin/isakmpd/util.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.h,v 1.15 2003/06/03 14:28:16 ho Exp $ */
+/* $OpenBSD: util.h,v 1.16 2003/12/14 14:50:23 ho Exp $ */
/* $EOM: util.h,v 1.10 2000/10/24 13:33:39 niklas Exp $ */
/*
@@ -63,6 +63,7 @@ extern int ones_test (const u_int8_t *, size_t);
extern int sockaddr2text (struct sockaddr *, char **, int);
extern u_int8_t *sockaddr_addrdata (struct sockaddr *);
extern int sockaddr_addrlen (struct sockaddr *);
+extern in_port_t sockaddr_port (struct sockaddr *);
extern int text2sockaddr (char *, char *, struct sockaddr **);
extern void util_ntoa (char **, int, u_int8_t *);
extern int zero_test (const u_int8_t *, size_t);