diff options
| author | Arne Schwabe <arne@rfc2549.org> | 2013-01-04 22:14:40 +0100 | 
|---|---|---|
| committer | Arne Schwabe <arne@rfc2549.org> | 2013-01-04 22:14:40 +0100 | 
| commit | 23f4d798440207c00407cc7cb0c6493a7cf01d4e (patch) | |
| tree | 581c62477fca922f88c182ebf77d009cb9e4815e /openvpn | |
| parent | 5350c37c79e7fc3561c0bda068565ef19630131a (diff) | |
Fetch current translation from crowd.in
--HG--
extra : rebase_source : 44d6489286ed63d24bb099ee9cd04aadb58e81f5
Diffstat (limited to 'openvpn')
| -rw-r--r-- | openvpn/src/openvpn/socket.c | 19 | ||||
| -rw-r--r-- | openvpn/src/openvpn/socket.h | 17 | 
2 files changed, 33 insertions, 3 deletions
| diff --git a/openvpn/src/openvpn/socket.c b/openvpn/src/openvpn/socket.c index 47329ddf..e3e93525 100644 --- a/openvpn/src/openvpn/socket.c +++ b/openvpn/src/openvpn/socket.c @@ -686,22 +686,32 @@ create_socket (struct link_socket *sock)      {        ASSERT (0);      } +      /* set socket buffers based on --sndbuf and --rcvbuf options */      socket_set_buffers (sock->sd, &sock->socket_buffer_sizes);      /* set socket to --mark packets with given value */      socket_set_mark (sock->sd, sock->mark); +} +  #ifdef TARGET_ANDROID +static void protect_fd_nonlocal (int fd, struct sockaddr* addr) +{ +    if (addr_local (addr)) { +        msg(M_DEBUG, "Address is local, not protecting socket fd %d", fd); +        return; +    } +          struct user_pass up;      strcpy(up.username ,__func__); -    management->connection.fdtosend = sock->sd; -    msg(M_DEBUG, "Protecting socket fd %d", sock->sd); +    management->connection.fdtosend = fd; +    msg(M_DEBUG, "Protecting socket fd %d", fd);      management_query_user_pass(management, &up , "PROTECTFD", GET_USER_PASS_NEED_OK,(void*) 0); +}  #endif -}  /*   * Functions used for establishing a TCP stream connection. @@ -926,7 +936,10 @@ openvpn_connect (socket_descriptor_t sd,  #ifdef CONNECT_NONBLOCK    set_nonblock (sd); + +  protect_fd_nonlocal(sd, remote);    status = connect (sd, remote, af_addr_size(remote->sa_family)); +    if (status)      status = openvpn_errno ();    if ( diff --git a/openvpn/src/openvpn/socket.h b/openvpn/src/openvpn/socket.h index 1a6d7c32..5b7a26a9 100644 --- a/openvpn/src/openvpn/socket.h +++ b/openvpn/src/openvpn/socket.h @@ -595,6 +595,23 @@ addr_defined (const struct openvpn_sockaddr *addr)      default: return 0;    }  } + +static inline bool +addr_local (const struct sockaddr *addr) +{ +    if (!addr) +        return false; +    switch (addr->sa_family) { +        case AF_INET: +            return ((const struct sockaddr_in*)addr)->sin_addr.s_addr == htonl(INADDR_LOOPBACK); +        case AF_INET6: +            return  IN6_IS_ADDR_LOOPBACK(&((const struct sockaddr_in6*)addr)->sin6_addr); +        default: +            return false; +    } +} + +  static inline bool  addr_defined_ipi (const struct link_socket_actual *lsa)  { | 
