1 /******************************************************************************* 2 * Copyright (c) 2009, 2022 IBM Corp., Ian Craggs, and others 3 * 4 * All rights reserved. This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License v2.0 6 * and Eclipse Distribution License v1.0 which accompany this distribution. 7 * 8 * The Eclipse Public License is available at 9 * https://www.eclipse.org/legal/epl-2.0/ 10 * and the Eclipse Distribution License is available at 11 * http://www.eclipse.org/org/documents/edl-v10.php. 12 * 13 * Contributors: 14 * Ian Craggs - initial API and implementation and/or initial documentation 15 * Ian Craggs, Allan Stockdill-Mander - SSL updates 16 * Ian Craggs - MQTT 3.1.1 support 17 * Ian Craggs - SNI support 18 * Ian Craggs - MQTT 5.0 support 19 * Sven Gambel - add generic proxy support 20 *******************************************************************************/ 21 22 #if !defined(MQTTPROTOCOLOUT_H) 23 #define MQTTPROTOCOLOUT_H 24 25 #include "LinkedList.h" 26 #include "MQTTPacket.h" 27 #include "Clients.h" 28 #include "Log.h" 29 #include "Messages.h" 30 #include "MQTTProtocol.h" 31 #include "MQTTProtocolClient.h" 32 33 #define MQTT_DEFAULT_PORT 1883 34 #define SECURE_MQTT_DEFAULT_PORT 8883 35 #define WS_DEFAULT_PORT 80 36 #define WSS_DEFAULT_PORT 443 37 #define PROXY_DEFAULT_PORT 8080 38 39 size_t MQTTProtocol_addressPort(const char* uri, int* port, const char **topic, int default_port); 40 void MQTTProtocol_reconnect(const char* ip_address, Clients* client); 41 #if defined(OPENSSL) || defined(MBEDTLS) 42 #if defined(__GNUC__) && defined(__linux__) && !defined(__LITEOS__) 43 int MQTTProtocol_connect(const char* ip_address, Clients* acClients, int ssl, int websocket, int MQTTVersion, 44 MQTTProperties* connectProperties, MQTTProperties* willProperties, long timeout); 45 #else 46 int MQTTProtocol_connect(const char* ip_address, Clients* acClients, int ssl, int websocket, int MQTTVersion, 47 MQTTProperties* connectProperties, MQTTProperties* willProperties); 48 #endif 49 #else 50 #if defined(__GNUC__) && defined(__linux__) && !defined(__LITEOS__) 51 int MQTTProtocol_connect(const char* ip_address, Clients* acClients, int websocket, int MQTTVersion, 52 MQTTProperties* connectProperties, MQTTProperties* willProperties, long timeout); 53 #else 54 int MQTTProtocol_connect(const char* ip_address, Clients* acClients, int websocket, int MQTTVersion, 55 MQTTProperties* connectProperties, MQTTProperties* willProperties); 56 #endif 57 #endif 58 int MQTTProtocol_handlePingresps(void* pack, SOCKET sock); 59 int MQTTProtocol_subscribe(Clients* client, List* topics, List* qoss, int msgID, 60 MQTTSubscribe_options* opts, MQTTProperties* props); 61 int MQTTProtocol_handleSubacks(void* pack, SOCKET sock); 62 int MQTTProtocol_unsubscribe(Clients* client, List* topics, int msgID, MQTTProperties* props); 63 int MQTTProtocol_handleUnsubacks(void* pack, SOCKET sock); 64 int MQTTProtocol_handleDisconnects(void* pack, SOCKET sock); 65 66 #endif 67