Set UDP encapsulation option on all sockets
This commit is contained in:
@@ -345,7 +345,7 @@ METHOD(socket_t, receiver, status_t,
|
|||||||
* open a socket to send and receive packets
|
* open a socket to send and receive packets
|
||||||
*/
|
*/
|
||||||
static int open_socket(private_socket_dynamic_socket_t *this,
|
static int open_socket(private_socket_dynamic_socket_t *this,
|
||||||
int family, u_int16_t port, bool first)
|
int family, u_int16_t port)
|
||||||
{
|
{
|
||||||
int on = TRUE, type = UDP_ENCAP_ESPINUDP;
|
int on = TRUE, type = UDP_ENCAP_ESPINUDP;
|
||||||
struct sockaddr_storage addr;
|
struct sockaddr_storage addr;
|
||||||
@@ -418,8 +418,8 @@ static int open_socket(private_socket_dynamic_socket_t *this,
|
|||||||
DBG1(DBG_NET, "installing IKE bypass policy failed");
|
DBG1(DBG_NET, "installing IKE bypass policy failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* enable UDP decapsulation globally, only for one socket needed */
|
/* enable UDP decapsulation on each socket */
|
||||||
if (first && setsockopt(fd, SOL_UDP, UDP_ENCAP, &type, sizeof(type)) < 0)
|
if (setsockopt(fd, SOL_UDP, UDP_ENCAP, &type, sizeof(type)) < 0)
|
||||||
{
|
{
|
||||||
DBG1(DBG_NET, "unable to set UDP_ENCAP: %s", strerror(errno));
|
DBG1(DBG_NET, "unable to set UDP_ENCAP: %s", strerror(errno));
|
||||||
}
|
}
|
||||||
@@ -446,8 +446,7 @@ static dynsock_t *find_socket(private_socket_dynamic_socket_t *this,
|
|||||||
{
|
{
|
||||||
return skt;
|
return skt;
|
||||||
}
|
}
|
||||||
fd = open_socket(this, family, port,
|
fd = open_socket(this, family, port);
|
||||||
this->sockets->get_count(this->sockets));
|
|
||||||
if (!fd)
|
if (!fd)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user