include only source NATD payloads really needed
authorMartin Willi <martin@strongswan.org>
Fri, 27 Oct 2006 10:46:35 +0000 (10:46 -0000)
committerMartin Willi <martin@strongswan.org>
Fri, 27 Oct 2006 10:46:35 +0000 (10:46 -0000)
src/charon/sa/transactions/ike_sa_init.c

index 89d0c33..34e7f70 100644 (file)
@@ -369,17 +369,27 @@ static status_t get_request(private_ike_sa_init_t *this, message_t **result)
                linked_list_t *list;
                host_t *host;
                
                linked_list_t *list;
                host_t *host;
                
-               /* N(NAT_DETECTION_SOURCE_IP)+ */
-               list = charon->socket->create_local_address_list(charon->socket);
-               while (list->remove_first(list, (void**)&host) == SUCCESS)
+               /* N(NAT_DETECTION_SOURCE_IP)+
+                * we include only one notify if our address is defined, but all
+                * possible if not */
+               host = this->connection->get_my_host(this->connection);
+               if (host->is_anyaddr(host))
+               {
+                       /* TODO: we could get the src address from netlink */
+                       list = charon->socket->create_local_address_list(charon->socket);
+                       while (list->remove_first(list, (void**)&host) == SUCCESS)
+                       {
+                               notify = build_natd_payload(this, NAT_DETECTION_SOURCE_IP, host);
+                               host->destroy(host);
+                               request->add_payload(request, (payload_t*)notify);
+                       }
+                       list->destroy(list);
+               }
+               else
                {
                {
-                       /* TODO: should we only include NAT payloads for addresses
-                        * of used address family? */
                        notify = build_natd_payload(this, NAT_DETECTION_SOURCE_IP, host);
                        notify = build_natd_payload(this, NAT_DETECTION_SOURCE_IP, host);
-                       host->destroy(host);
                        request->add_payload(request, (payload_t*)notify);
                }
                        request->add_payload(request, (payload_t*)notify);
                }
-               list->destroy(list);
                
                /* N(NAT_DETECTION_DESTINATION_IP) */
                notify = build_natd_payload(this, NAT_DETECTION_DESTINATION_IP, other);
                
                /* N(NAT_DETECTION_DESTINATION_IP) */
                notify = build_natd_payload(this, NAT_DETECTION_DESTINATION_IP, other);