56 char* colon_pos = strrchr(uri,
':');
57 char* buf = (
char*)uri;
63 if (colon_pos < strrchr(uri,
']'))
69 len = colon_pos - uri;
70 *port = atoi(colon_pos + 1);
81 const char* addr_start = uri;
83 addr_start = colon_pos;
84 *topic = strchr( addr_start,
'/' );
87 if (buf[len - 1] ==
']')
111 else if (isxdigit(*(p1 + 1)) && isxdigit(*(p1 + 2))) {
118 *p0++ = (char)strtol(hex, 0, 16);
120 *basic_auth_in_len -= 2;
137 #if defined(__GNUC__) && defined(__linux__) 145 #if defined(__GNUC__) && defined(__linux__) 157 b64_size_t basic_auth_in_len, basic_auth_out_len;
165 if ((p0 = getenv(
"http_proxy")))
167 p1 = strchr(p0,
'@');
171 p1 = strchr(p0,
':') + 3;
180 p0 = (
char *)basic_auth;
193 p1 = strchr(p0,
':');
200 aClient->
net.https_proxy = NULL;
201 aClient->
net.https_proxy_auth = NULL;
202 if ((p0 = getenv(
"https_proxy"))) {
203 p1 = strchr(p0,
'@');
205 aClient->
net.https_proxy = p1 + 1;
206 p1 = strchr(p0,
':') + 3;
207 basic_auth_in_len = (
b64_size_t)(aClient->
net.https_proxy - p1);
215 p0 = (
char *)basic_auth;
218 if ((aClient->
net.https_proxy_auth = (
char *)
malloc(
sizeof(
char) * basic_auth_out_len)) == NULL)
224 Base64_encode(aClient->
net.https_proxy_auth, basic_auth_out_len, basic_auth, basic_auth_in_len);
228 p1 = strchr(p0,
':');
230 aClient->
net.https_proxy = p1 + 3;
239 #if defined(__GNUC__) && defined(__linux__) 249 else if (ssl && websocket && aClient->
net.https_proxy) {
251 #if defined(__GNUC__) && defined(__linux__) 267 #if defined(__GNUC__) && defined(__linux__) 276 if (rc == EINPROGRESS || rc == EWOULDBLOCK)
283 if (websocket && aClient->
net.https_proxy) {
289 rc = aClient->sslopts->struct_version >= 3 ?
291 aClient->sslopts->verify, aClient->sslopts->ssl_error_cb, aClient->sslopts->ssl_error_context) :
293 aClient->sslopts->verify, NULL, NULL);
int WebSocket_proxy_connect(networkHandles *net, int ssl, const char *hostname)
void MQTTPacket_freeSuback(Suback *pack)
#define PROXY_CONNECT_IN_PROGRESS
#define MQTT_DEFAULT_PORT
int Socket_new(const char *addr, size_t addr_len, int port, int *sock)
int SSLSocket_setSocketForSSL(networkHandles *net, MQTTClient_SSLOptions *opts, const char *hostname, size_t hostname_len)
int MQTTProtocol_connect(const char *ip_address, Clients *aClient, int websocket, int MQTTVersion, MQTTProperties *connectProperties, MQTTProperties *willProperties)
#define PAHO_MEMORY_ERROR
int MQTTPacket_send_connect(Clients *client, int MQTTVersion, MQTTProperties *connectProperties, MQTTProperties *willProperties)
int SSLSocket_connect(SSL *ssl, int sock, const char *hostname, int verify, int(*cb)(const char *str, size_t len, void *u), void *u)
int clientSocketCompare(void *a, void *b)
b64_size_t Base64_encodeLength(const b64_data_t *in, b64_size_t in_len)
void MQTTProtocol_specialChars(char *p0, char *p1, b64_size_t *basic_auth_in_len)
int MQTTProtocol_handleUnsubacks(void *pack, int sock)
b64_size_t Base64_encode(char *out, b64_size_t out_len, const b64_data_t *in, b64_size_t in_len)
int MQTTPacket_send_subscribe(List *topics, List *qoss, MQTTSubscribe_options *opts, MQTTProperties *props, int msgid, int dup, Clients *client)
void MQTTPacket_freeUnsuback(Unsuback *pack)
void Log(enum LOG_LEVELS log_level, int msgno, const char *format,...)
int MQTTProtocol_unsubscribe(Clients *client, List *topics, int msgID, MQTTProperties *props)
int MQTTPacket_send_unsubscribe(List *topics, MQTTProperties *props, int msgid, int dup, Clients *client)
#define WEBSOCKET_IN_PROGRESS
unsigned int ping_outstanding
#define SECURE_MQTT_DEFAULT_PORT
int MQTTProtocol_handlePingresps(void *pack, int sock)
int MQTTProtocol_subscribe(Clients *client, List *topics, List *qoss, int msgID, MQTTSubscribe_options *opts, MQTTProperties *props)
int WebSocket_connect(networkHandles *net, const char *uri)
int MQTTProtocol_handleSubacks(void *pack, int sock)
size_t MQTTProtocol_addressPort(const char *uri, int *port, const char **topic, int default_port)
#define TCPSOCKET_COMPLETE
ListElement * ListFindItem(List *aList, void *content, int(*callback)(void *, void *))
#define TCPSOCKET_INTERRUPTED