--- pluto/connections.c.org 2003-10-01 23:53:37.000000000 +0200 +++ pluto/connections.c 2003-11-15 18:31:16.000000000 +0100 @@ -2278,10 +2278,10 @@ continue; /* compare protocol and ports */ - if (d->this.protocol != our_protocol - || d->this.port != our_port - || d->that.protocol != peer_protocol - || d->that.port != peer_port) + if ((d->this.protocol != our_protocol) + || (d->this.port && (d->this.port != our_port)) + || (d->that.protocol != peer_protocol) + || (d->that.port && (d->that.port != peer_port))) continue; if (oppo) @@ -2372,9 +2372,9 @@ if (samesubnet(&c->this.client, our_net) && samesubnet(&c->that.client, peer_net) && (c->this.protocol == our_protocol) - && (c->this.port == our_port) + && (!c->this.port || (c->this.port == our_port)) && (c->that.protocol == peer_protocol) - && (c->that.port == peer_port)) + && (!c->that.port || (c->that.port == peer_port))) { passert(oriented(*c)); if (routed(c->routing))