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
1 changed files with 7 additions and 8 deletions

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);
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));
}
}