• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*******************************************************************************
2  * Copyright (c) 2009, 2017 IBM Corp.
3  *
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * and Eclipse Distribution License v1.0 which accompany this distribution.
7  *
8  * The Eclipse Public License is available at
9  *    http://www.eclipse.org/legal/epl-v10.html
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 updates
17  *    Rong Xiang, Ian Craggs - C++ compatibility
18  *    Ian Craggs - add debug definition of MQTTStrdup for when needed
19  *******************************************************************************/
20 
21 #if !defined(MQTTPROTOCOLCLIENT_H)
22 #define MQTTPROTOCOLCLIENT_H
23 
24 #include "LinkedList.h"
25 #include "MQTTPacket.h"
26 #include "Log.h"
27 #include "MQTTProtocol.h"
28 #include "Messages.h"
29 #include "MQTTProperties.h"
30 
31 #define MAX_MSG_ID 65535
32 #define MAX_CLIENTID_LEN 65535
33 
34 int MQTTProtocol_startPublish(Clients* pubclient, Publish* publish, int qos, int retained, Messages** m);
35 Messages* MQTTProtocol_createMessage(Publish* publish, Messages** mm, int qos, int retained);
36 Publications* MQTTProtocol_storePublication(Publish* publish, int* len);
37 int messageIDCompare(void* a, void* b);
38 int MQTTProtocol_assignMsgId(Clients* client);
39 void MQTTProtocol_removePublication(Publications* p);
40 void Protocol_processPublication(Publish* publish, Clients* client);
41 
42 int MQTTProtocol_handlePublishes(void* pack, int sock);
43 int MQTTProtocol_handlePubacks(void* pack, int sock);
44 int MQTTProtocol_handlePubrecs(void* pack, int sock);
45 int MQTTProtocol_handlePubrels(void* pack, int sock);
46 int MQTTProtocol_handlePubcomps(void* pack, int sock);
47 
48 void MQTTProtocol_closeSession(Clients* c, int sendwill);
49 void MQTTProtocol_keepalive(time_t);
50 void MQTTProtocol_retry(time_t, int, int);
51 void MQTTProtocol_freeClient(Clients* client);
52 void MQTTProtocol_emptyMessageList(List* msgList);
53 void MQTTProtocol_freeMessageList(List* msgList);
54 
55 char* MQTTStrncpy(char *dest, const char* src, size_t num);
56 char* MQTTStrdup(const char* src);
57 
58 //#define MQTTStrdup(src) MQTTStrncpy(malloc(strlen(src)+1), src, strlen(src)+1)
59 
60 #endif
61