cleaner error handling on UDP encapsultion sockopt failure

This commit is contained in:
Martin Willi
2006-06-22 13:05:15 +00:00
parent 6f51c9f184
commit 4b24dd2d7d
+8 -9
View 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); this->logger->log(this->logger, ERROR, "unable to setup send socket on port %d!", this->natt_port);
return FAILED; return FAILED;
} else { }
int type = UDP_ENCAP_ESPINUDP; else
if (setsockopt(this->natt_fd, SOL_UDP, UDP_ENCAP, &type, sizeof(type)) < 0
&& errno == ENOPROTOOPT)
{ {
this->logger->log(this->logger, ERROR, "unable to set UDP_ENCAP on natt send socket!"); int type = UDP_ENCAP_ESPINUDP;
close(this->natt_fd); if (setsockopt(this->natt_fd, SOL_UDP, UDP_ENCAP, &type, sizeof(type)) < 0)
close(this->send_fd); {
close(this->raw_fd); this->logger->log(this->logger, ERROR,
return FAILED; "unable to set UDP_ENCAP on natt send socket! NAT-T may fail! error: %s",
strerror(errno));
} }
} }