cleaner error handling on UDP encapsultion sockopt failure
authorMartin Willi <martin@strongswan.org>
Thu, 22 Jun 2006 13:05:15 +0000 (13:05 -0000)
committerMartin Willi <martin@strongswan.org>
Thu, 22 Jun 2006 13:05:15 +0000 (13:05 -0000)
src/charon/network/socket.c

index 0cd57aa..eb61c83 100644 (file)
@@ -389,16 +389,15 @@ static status_t initialize(private_socket_t *this)
        {
                this->logger->log(this->logger, ERROR, "unable to setup send socket on port %d!", this->natt_port);
                return FAILED;
-       } else {
+       }
+       else
+       {
                int type = UDP_ENCAP_ESPINUDP;
-               if (setsockopt(this->natt_fd, SOL_UDP, UDP_ENCAP, &type, sizeof(type)) < 0 
-                   && errno == ENOPROTOOPT)
+               if (setsockopt(this->natt_fd, SOL_UDP, UDP_ENCAP, &type, sizeof(type)) < 0)
                {
-                       this->logger->log(this->logger, ERROR, "unable to set UDP_ENCAP on natt send socket!");
-                       close(this->natt_fd);
-                       close(this->send_fd);
-                       close(this->raw_fd);
-                       return FAILED;
+                       this->logger->log(this->logger, ERROR, 
+                                                         "unable to set UDP_ENCAP on natt send socket! NAT-T may fail! error: %s",
+                                                         strerror(errno)); 
                }
        }