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); this->logger->log(this->logger, ERROR, "unable to setup send socket on port %d!", this->natt_port);
return FAILED; return FAILED;
} else { }
else
{
int type = UDP_ENCAP_ESPINUDP; int type = UDP_ENCAP_ESPINUDP;
if (setsockopt(this->natt_fd, SOL_UDP, UDP_ENCAP, &type, sizeof(type)) < 0 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!"); this->logger->log(this->logger, ERROR,
close(this->natt_fd); "unable to set UDP_ENCAP on natt send socket! NAT-T may fail! error: %s",
close(this->send_fd); strerror(errno));
close(this->raw_fd);
return FAILED;
} }
} }