net: mqtt: Add SOCKS5 proxy support

This commits adds a new MQTT transport. The purpose is to be able to
connect to a MQTT broker through a SOCKS5 proxy.

Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
This commit is contained in:
Tomasz Gorochowik 2019-02-04 16:11:46 +01:00 committed by Jukka Rissanen
commit df0d7652df
5 changed files with 88 additions and 1 deletions

View file

@ -348,6 +348,11 @@ enum mqtt_transport_type {
MQTT_TRANSPORT_SECURE,
#endif /* CONFIG_MQTT_LIB_TLS */
#if defined(CONFIG_MQTT_LIB_SOCKS)
/** Use SOCKS5 proxy for MQTT connection. */
MQTT_TRANSPORT_SOCKS,
#endif /* CONFIG_MQTT_LIB_SOCKS */
/** Shall not be used as a transport type.
* Indicator of maximum transport types possible.
*/
@ -381,6 +386,18 @@ struct mqtt_transport {
struct mqtt_sec_config config;
} tls;
#endif /* CONFIG_MQTT_LIB_TLS */
#if defined(CONFIG_MQTT_LIB_SOCKS)
/* SOCKS5 proxy transport for MQTT */
struct {
/** Socket descriptor. */
int sock;
/** SOCKS5 proxy address. */
struct sockaddr_storage *proxy;
} socks5;
#endif /* CONFIG_MQTT_LIB_SOCKS */
};
};