summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHakan Olsson <ho@cvs.openbsd.org>2004-06-21 18:40:02 +0000
committerHakan Olsson <ho@cvs.openbsd.org>2004-06-21 18:40:02 +0000
commit0239e4cfebc1ebf30d110ddb12e4c01e9548e77c (patch)
treeed16ca3b276605d136eb7b76bff2fae2e04b749b
parent2cad447880285e7c39e4688f6f6f37e7d644aeb8 (diff)
When switching from main to encap transport, copy dst port if
translated (NAT).
-rw-r--r--sbin/isakmpd/virtual.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/sbin/isakmpd/virtual.c b/sbin/isakmpd/virtual.c
index 00a44ad81fd..629d50119af 100644
--- a/sbin/isakmpd/virtual.c
+++ b/sbin/isakmpd/virtual.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: virtual.c,v 1.2 2004/06/21 13:09:01 ho Exp $ */
+/* $OpenBSD: virtual.c,v 1.3 2004/06/21 18:40:01 ho Exp $ */
/*
* Copyright (c) 2004 Håkan Olsson. All rights reserved.
@@ -614,13 +614,10 @@ virtual_send_message(struct message *msg, struct transport *t)
{
struct virtual_transport *v =
(struct virtual_transport *)msg->transport;
-
- /* XXX Debug */
- if (t)
- log_print("virtual_send_message: called with "
- "transport %p != NULL", t);
-
#if defined (USE_NAT_TRAVERSAL)
+ struct sockaddr *sa;
+ in_port_t port;
+
/*
* Activate NAT-T Encapsulation if
* - the exchange says we can, and
@@ -635,8 +632,16 @@ virtual_send_message(struct message *msg, struct transport *t)
LOG_DBG((LOG_MESSAGE, 10, "virtual_send_message: "
"enabling NAT-T encapsulation for this exchange"));
v->encap_is_active++;
+
+ /* Copy destination port if it is translated (NAT). */
+ v->main->vtbl->get_dst(v->main, &sa);
+ port = ntohs(sockaddr_port(sa));
+ if (port != UDP_DEFAULT_PORT) {
+ v->main->vtbl->get_dst(v->encap, &sa);
+ sockaddr_set_port(sa, port);
+ }
}
-#endif
+#endif /* USE_NAT_TRAVERSAL */
if (v->encap_is_active)
return v->encap->vtbl->send_message(msg, v->encap);