net: socks: Make SOCKS5 implementation transparent
Current SOCKS5 implementation is above socket level and every higher layer protocol or application level needs to have SOCKS5 related changes. This solution is based on socket setsockopt(). Application caller has to set proxy details through setsockopt() and socket:connect() will take care creating connection. Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
This commit is contained in:
parent
c8fa169294
commit
39ed77e438
3 changed files with 135 additions and 80 deletions
|
@ -1,6 +1,8 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Antmicro Ltd
|
||||
*
|
||||
* Copyright (c) 2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
@ -11,23 +13,26 @@
|
|||
|
||||
/**@brief Connects to destination through a SOCKS5 proxy server.
|
||||
*
|
||||
* @param[in] proxy Address of the proxy server.
|
||||
* @param[in] destination Address of the destination server.
|
||||
* @param[in] ctx Network context.
|
||||
* @param[in] dest Address of the destination server.
|
||||
* @param[in] dest_len Address length of the destination server.
|
||||
*
|
||||
* @retval File descriptor of the opened connection or an error code if it was
|
||||
* unsuccessful.
|
||||
* @retval 0 or an error code if it was unsuccessful.
|
||||
*/
|
||||
#if defined(CONFIG_SOCKS)
|
||||
int socks5_client_tcp_connect(const struct sockaddr *proxy,
|
||||
const struct sockaddr *destination);
|
||||
int net_socks5_connect(struct net_context *ctx,
|
||||
const struct sockaddr *dest,
|
||||
socklen_t dest_len);
|
||||
#else
|
||||
inline int socks5_client_tcp_connect(const struct sockaddr *proxy,
|
||||
const struct sockaddr *destination)
|
||||
inline int net_socks5_connect(struct net_context *ctx,
|
||||
const struct sockaddr *dest,
|
||||
socklen_t dest_len)
|
||||
{
|
||||
ARG_UNUSED(proxy);
|
||||
ARG_UNUSED(destination);
|
||||
ARG_UNUSED(ctx);
|
||||
ARG_UNUSED(dest);
|
||||
ARG_UNUSED(dest_len);
|
||||
|
||||
return 0;
|
||||
return -ENOTSUP;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue