Add basic change for v1453

Change-Id: I9497a61bbc3717f66413794a4e7dee0347c0bc33
diff --git a/mbtk/include/mqtt/MQTTClient.h b/mbtk/include/mqtt/MQTTClient.h
new file mode 100755
index 0000000..890a11b
--- /dev/null
+++ b/mbtk/include/mqtt/MQTTClient.h
@@ -0,0 +1,100 @@
+/*******************************************************************************

+ * Copyright (c) 2014 IBM Corp.

+ *

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * and Eclipse Distribution License v1.0 which accompany this distribution.

+ *

+ * The Eclipse Public License is available at

+ *    http://www.eclipse.org/legal/epl-v10.html

+ * and the Eclipse Distribution License is available at

+ *   http://www.eclipse.org/org/documents/edl-v10.php.

+ *

+ * Contributors:

+ *    Allan Stockdill-Mander/Ian Craggs - initial API and implementation and/or initial documentation

+ *******************************************************************************/

+

+#ifndef __MQTT_CLIENT_C_

+#define __MQTT_CLIENT_C_

+

+#include "MQTTPacket.h"

+#include "stdio.h"

+#include "MQTTLinux.h" 

+

+#define MAX_PACKET_ID 65535

+#define MAX_MESSAGE_HANDLERS 5

+#define MAX_FAIL_ALLOWED  2

+

+enum QoS { QOS0, QOS1, QOS2 };

+

+// all failure return codes must be negative

+enum returnCode {DISCONNECTED = -3,  BUFFER_OVERFLOW = -2, FAILURE = -1, SUCCESS = 0 };

+

+void NewTimer(Timer*);

+

+typedef struct MQTTMessage MQTTMessage;

+

+typedef struct MessageData MessageData;

+

+struct MQTTMessage

+{

+    enum QoS qos;

+    char retained;

+    char dup;

+    unsigned short id;

+    void *payload;

+    size_t payloadlen;

+};

+

+struct MessageData

+{

+    MQTTMessage* message;

+    MQTTString* topicName;

+};

+

+typedef struct {

+    char clientId[255];

+    char deviceToken[255];

+} regnwl_info_t;

+

+typedef void (*messageHandler)(MessageData*);

+

+typedef struct Client Client;

+

+int MQTTConnect (Client*, MQTTPacket_connectData*);

+int MQTTPublish (Client*, const char*, MQTTMessage*);

+int MQTTSubscribe (Client*, const char*, enum QoS, messageHandler);

+int MQTTUnsubscribe (Client*, const char*);

+int MQTTDisconnect (Client*,Network*);

+int MQTTYield (Client*, int);

+

+void setDefaultMessageHandler(Client*, messageHandler);

+

+void MQTTClient(Client*, Network*, unsigned int, unsigned char*, size_t, unsigned char*, size_t);

+

+struct Client {

+    unsigned int next_packetid;

+    unsigned int command_timeout_ms;

+    size_t buf_size, readbuf_size;

+    unsigned char *buf;  

+    unsigned char *readbuf; 

+    unsigned int keepAliveInterval;

+    char ping_outstanding;

+    int fail_count;

+    int isconnected;

+

+    struct MessageHandlers

+    {

+        const char* topicFilter;

+        void (*fp) (MessageData*);

+    } messageHandlers[MAX_MESSAGE_HANDLERS];      // Message handlers are indexed by subscription topic

+    

+    void (*defaultMessageHandler) (MessageData*);

+    

+    Network* ipstack;

+    Timer ping_timer;

+};

+

+#define DefaultClient {0, 0, 0, 0, NULL, NULL, 0, 0, 0}

+

+#endif

diff --git a/mbtk/include/mqtt/MQTTConnect.h b/mbtk/include/mqtt/MQTTConnect.h
new file mode 100755
index 0000000..d77f18c
--- /dev/null
+++ b/mbtk/include/mqtt/MQTTConnect.h
@@ -0,0 +1,136 @@
+/*******************************************************************************

+ * Copyright (c) 2014 IBM Corp.

+ *

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * and Eclipse Distribution License v1.0 which accompany this distribution.

+ *

+ * The Eclipse Public License is available at

+ *    http://www.eclipse.org/legal/epl-v10.html

+ * and the Eclipse Distribution License is available at

+ *   http://www.eclipse.org/org/documents/edl-v10.php.

+ *

+ * Contributors:

+ *    Ian Craggs - initial API and implementation and/or initial documentation

+ *    Xiang Rong - 442039 Add makefile to Embedded C client

+ *******************************************************************************/

+

+#ifndef MQTTCONNECT_H_

+#define MQTTCONNECT_H_

+

+#if !defined(DLLImport)

+  #define DLLImport 

+#endif

+#if !defined(DLLExport)

+  #define DLLExport

+#endif

+

+

+typedef union

+{

+	unsigned char all;	/**< all connect flags */

+#if defined(REVERSED)

+	struct

+	{

+		unsigned int username : 1;			/**< 3.1 user name */

+		unsigned int password : 1; 			/**< 3.1 password */

+		unsigned int willRetain : 1;		/**< will retain setting */

+		unsigned int willQoS : 2;				/**< will QoS value */

+		unsigned int will : 1;			    /**< will flag */

+		unsigned int cleansession : 1;	  /**< clean session flag */

+		unsigned int : 1;	  	          /**< unused */

+	} bits;

+#else

+	struct

+	{

+		unsigned int : 1;	     					/**< unused */

+		unsigned int cleansession : 1;	  /**< cleansession flag */

+		unsigned int will : 1;			    /**< will flag */

+		unsigned int willQoS : 2;				/**< will QoS value */

+		unsigned int willRetain : 1;		/**< will retain setting */

+		unsigned int password : 1; 			/**< 3.1 password */

+		unsigned int username : 1;			/**< 3.1 user name */

+	} bits;

+#endif

+} MQTTConnectFlags;	/**< connect flags byte */

+

+

+

+/**

+ * Defines the MQTT "Last Will and Testament" (LWT) settings for

+ * the connect packet.

+ */

+typedef struct

+{

+	/** The eyecatcher for this structure.  must be MQTW. */

+	char struct_id[4];

+	/** The version number of this structure.  Must be 0 */

+	int struct_version;

+	/** The LWT topic to which the LWT message will be published. */

+	MQTTString topicName;

+	/** The LWT payload. */

+	MQTTString message;

+	/**

+      * The retained flag for the LWT message (see MQTTAsync_message.retained).

+      */

+	unsigned char retained;

+	/**

+      * The quality of service setting for the LWT message (see

+      * MQTTAsync_message.qos and @ref qos).

+      */

+	char qos;

+} MQTTPacket_willOptions;

+

+

+#define MQTTPacket_willOptions_initializer { {'M', 'Q', 'T', 'W'}, 0, {NULL, {0, NULL}}, {NULL, {0, NULL}}, 0, 0 }

+

+

+typedef struct

+{

+	/** The eyecatcher for this structure.  must be MQTC. */

+	char struct_id[4];

+	/** The version number of this structure.  Must be 0 */

+	int struct_version;

+	/** Version of MQTT to be used.  3 = 3.1 4 = 3.1.1

+	  */

+	unsigned char MQTTVersion;

+	MQTTString clientID;

+	unsigned short keepAliveInterval;

+	unsigned char cleansession;

+	unsigned char willFlag;

+	MQTTPacket_willOptions will;

+	MQTTString username;

+	MQTTString password;

+} MQTTPacket_connectData;

+

+typedef union

+{

+	unsigned char all;	/**< all connack flags */

+#if defined(REVERSED)

+	struct

+	{

+		unsigned int sessionpresent : 1;    /**< session present flag */

+		unsigned int : 7;	  	          /**< unused */

+	} bits;

+#else

+	struct

+	{

+		unsigned int : 7;	     			/**< unused */

+		unsigned int sessionpresent : 1;    /**< session present flag */

+	} bits;

+#endif

+} MQTTConnackFlags;	/**< connack flags byte */

+

+#define MQTTPacket_connectData_initializer { {'M', 'Q', 'T', 'C'}, 0, 4, {NULL, {0, NULL}}, 60, 1, 0, \

+		MQTTPacket_willOptions_initializer, {NULL, {0, NULL}}, {NULL, {0, NULL}} }

+

+DLLExport int MQTTSerialize_connect(unsigned char* buf, int buflen, MQTTPacket_connectData* options);

+DLLExport int MQTTDeserialize_connect(MQTTPacket_connectData* data, unsigned char* buf, int len);

+

+DLLExport int MQTTSerialize_connack(unsigned char* buf, int buflen, unsigned char connack_rc, unsigned char sessionPresent);

+DLLExport int MQTTDeserialize_connack(unsigned char* sessionPresent, unsigned char* connack_rc, unsigned char* buf, int buflen);

+

+DLLExport int MQTTSerialize_disconnect(unsigned char* buf, int buflen);

+DLLExport int MQTTSerialize_pingreq(unsigned char* buf, int buflen);

+

+#endif /* MQTTCONNECT_H_ */

diff --git a/mbtk/include/mqtt/MQTTFormat.h b/mbtk/include/mqtt/MQTTFormat.h
new file mode 100755
index 0000000..f7bd0d1
--- /dev/null
+++ b/mbtk/include/mqtt/MQTTFormat.h
@@ -0,0 +1,37 @@
+/*******************************************************************************

+ * Copyright (c) 2014 IBM Corp.

+ *

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * and Eclipse Distribution License v1.0 which accompany this distribution.

+ *

+ * The Eclipse Public License is available at

+ *    http://www.eclipse.org/legal/epl-v10.html

+ * and the Eclipse Distribution License is available at

+ *   http://www.eclipse.org/org/documents/edl-v10.php.

+ *

+ * Contributors:

+ *    Ian Craggs - initial API and implementation and/or initial documentation

+ *******************************************************************************/

+

+#if !defined(MQTTFORMAT_H)

+#define MQTTFORMAT_H

+

+#include "StackTrace.h"

+#include "MQTTPacket.h"

+

+const char* MQTTPacket_getName(unsigned short packetid);

+int MQTTStringFormat_connect(char* strbuf, int strbuflen, MQTTPacket_connectData* data);

+int MQTTStringFormat_connack(char* strbuf, int strbuflen, unsigned char connack_rc, unsigned char sessionPresent);

+int MQTTStringFormat_publish(char* strbuf, int strbuflen, unsigned char dup, int qos, unsigned char retained,

+		unsigned short packetid, MQTTString topicName, unsigned char* payload, int payloadlen);

+int MQTTStringFormat_ack(char* strbuf, int strbuflen, unsigned char packettype, unsigned char dup, unsigned short packetid);

+int MQTTStringFormat_subscribe(char* strbuf, int strbuflen, unsigned char dup, unsigned short packetid, int count,

+		MQTTString topicFilters[], int requestedQoSs[]);

+int MQTTStringFormat_suback(char* strbuf, int strbuflen, unsigned short packetid, int count, int* grantedQoSs);

+int MQTTStringFormat_unsubscribe(char* strbuf, int strbuflen, unsigned char dup, unsigned short packetid,

+		int count, MQTTString topicFilters[]);

+char* MQTTFormat_toClientString(char* strbuf, int strbuflen, unsigned char* buf, int buflen);

+char* MQTTFormat_toServerString(char* strbuf, int strbuflen, unsigned char* buf, int buflen);

+

+#endif

diff --git a/mbtk/include/mqtt/MQTTLinux.h b/mbtk/include/mqtt/MQTTLinux.h
new file mode 100755
index 0000000..6ca888a
--- /dev/null
+++ b/mbtk/include/mqtt/MQTTLinux.h
@@ -0,0 +1,74 @@
+/*******************************************************************************

+ * Copyright (c) 2014 IBM Corp.

+ *

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * and Eclipse Distribution License v1.0 which accompany this distribution.

+ *

+ * The Eclipse Public License is available at

+ *    http://www.eclipse.org/legal/epl-v10.html

+ * and the Eclipse Distribution License is available at

+ *   http://www.eclipse.org/org/documents/edl-v10.php.

+ *

+ * Contributors:

+ *    Allan Stockdill-Mander - initial API and implementation and/or initial documentation

+ *******************************************************************************/

+

+#ifndef __MQTT_LINUX_

+#define __MQTT_LINUX_

+

+#include <sys/types.h>

+#include <sys/socket.h>

+#include <sys/param.h>

+#include <sys/time.h>

+#include <sys/select.h>

+#include <netinet/in.h>

+#include <netinet/tcp.h>

+#include <arpa/inet.h>

+#include <netdb.h>

+#include <stdio.h>

+#include <unistd.h>

+#include <errno.h>

+#include <fcntl.h>

+#include <stdbool.h>

+#include <stdlib.h>

+#include <string.h>

+#include <signal.h>

+

+// #include <openssl/ssl.h>

+// #include <openssl/err.h>

+//#include "DC_iot_port.h"

+

+typedef struct Timer Timer;

+

+struct Timer {

+	struct timeval end_time;

+};

+

+typedef struct Network Network;

+struct Network

+{

+	int my_socket;

+    bool is_support_ssl;

+    bool ingnore_cert;

+    int handle;

+	int (*mqttread) (Network*, unsigned char*, int, int);

+	int (*mqttwrite) (Network*, unsigned char*, int, int);

+	void (*disconnect) (Network*);

+};

+

+char expired(Timer*);

+void countdown_ms(Timer*, unsigned int);

+void countdown(Timer*, unsigned int);

+int left_ms(Timer*);

+

+void InitTimer(Timer*);

+

+int linux_read(Network*, unsigned char*, int, int);

+int linux_write(Network*, unsigned char*, int, int);

+void linux_disconnect(Network*);

+void NewNetwork(Network*);

+

+int ConnectNetwork(Network*, char*, int, bool ,bool );

+

+#endif
\ No newline at end of file
diff --git a/mbtk/include/mqtt/MQTTPacket.h b/mbtk/include/mqtt/MQTTPacket.h
new file mode 100755
index 0000000..f417929
--- /dev/null
+++ b/mbtk/include/mqtt/MQTTPacket.h
@@ -0,0 +1,133 @@
+/*******************************************************************************

+ * Copyright (c) 2014 IBM Corp.

+ *

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * and Eclipse Distribution License v1.0 which accompany this distribution.

+ *

+ * The Eclipse Public License is available at

+ *    http://www.eclipse.org/legal/epl-v10.html

+ * and the Eclipse Distribution License is available at

+ *   http://www.eclipse.org/org/documents/edl-v10.php.

+ *

+ * Contributors:

+ *    Ian Craggs - initial API and implementation and/or initial documentation

+ *    Xiang Rong - 442039 Add makefile to Embedded C client

+ *******************************************************************************/

+

+#ifndef MQTTPACKET_H_

+#define MQTTPACKET_H_

+

+#if defined(__cplusplus) /* If this is a C++ compiler, use C linkage */

+extern "C" {

+#endif

+

+#if defined(WIN32_DLL) || defined(WIN64_DLL)

+  #define DLLImport __declspec(dllimport)

+  #define DLLExport __declspec(dllexport)

+#elif defined(LINUX_SO)

+  #define DLLImport extern

+  #define DLLExport  __attribute__ ((visibility ("default")))

+#else

+  #define DLLImport

+  #define DLLExport  

+#endif

+

+enum errors

+{

+	MQTTPACKET_BUFFER_TOO_SHORT = -2,

+	MQTTPACKET_READ_ERROR = -1,

+	MQTTPACKET_READ_COMPLETE

+};

+

+enum msgTypes

+{

+	CONNECT = 1, CONNACK, PUBLISH, PUBACK, PUBREC, PUBREL,

+	PUBCOMP, SUBSCRIBE, SUBACK, UNSUBSCRIBE, UNSUBACK,

+	PINGREQ, PINGRESP, DISCONNECT

+};

+

+/**

+ * Bitfields for the MQTT header byte.

+ */

+typedef union

+{

+	unsigned char byte;	                /**< the whole byte */

+#if defined(REVERSED)

+	struct

+	{

+		unsigned int type : 4;			/**< message type nibble */

+		unsigned int dup : 1;				/**< DUP flag bit */

+		unsigned int qos : 2;				/**< QoS value, 0, 1 or 2 */

+		unsigned int retain : 1;		/**< retained flag bit */

+	} bits;

+#else

+	struct

+	{

+		unsigned int retain : 1;		/**< retained flag bit */

+		unsigned int qos : 2;				/**< QoS value, 0, 1 or 2 */

+		unsigned int dup : 1;				/**< DUP flag bit */

+		unsigned int type : 4;			/**< message type nibble */

+	} bits;

+#endif

+} MQTTHeader;

+

+typedef struct

+{

+	int len;

+	char* data;

+} MQTTLenString;

+

+typedef struct

+{

+	char* cstring;

+	MQTTLenString lenstring;

+} MQTTString;

+

+#define MQTTString_initializer {NULL, {0, NULL}}

+

+int MQTTstrlen(MQTTString mqttstring);

+

+#include "MQTTConnect.h"

+#include "MQTTPublish.h"

+#include "MQTTSubscribe.h"

+#include "MQTTUnsubscribe.h"

+#include "MQTTFormat.h"

+

+int MQTTSerialize_ack(unsigned char* buf, int buflen, unsigned char type, unsigned char dup, unsigned short packetid);

+int MQTTDeserialize_ack(unsigned char* packettype, unsigned char* dup, unsigned short* packetid, unsigned char* buf, int buflen);

+

+int MQTTPacket_len(int rem_len);

+int MQTTPacket_equals(MQTTString* a, char* b);

+

+int MQTTPacket_encode(unsigned char* buf, int length);

+int MQTTPacket_decode(int (*getcharfn)(unsigned char*, int), int* value);

+int MQTTPacket_decodeBuf(unsigned char* buf, int* value);

+

+int readInt(unsigned char** pptr);

+char readChar(unsigned char** pptr);

+void writeChar(unsigned char** pptr, char c);

+void writeInt(unsigned char** pptr, int anInt);

+int readMQTTLenString(MQTTString* mqttstring, unsigned char** pptr, unsigned char* enddata);

+void writeCString(unsigned char** pptr, const char* string);

+void writeMQTTString(unsigned char** pptr, MQTTString mqttstring);

+

+DLLExport int MQTTPacket_read(unsigned char* buf, int buflen, int (*getfn)(unsigned char*, int));

+

+typedef struct {

+	int (*getfn)(void *, unsigned char*, int); /* must return -1 for error, 0 for call again, or the number of bytes read */

+	void *sck;	/* pointer to whatever the system may use to identify the transport */

+	int multiplier;

+	int rem_len;

+	int len;

+	char state;

+}MQTTTransport;

+

+int MQTTPacket_readnb(unsigned char* buf, int buflen, MQTTTransport *trp);

+

+#ifdef __cplusplus /* If this is a C++ compiler, use C linkage */

+}

+#endif

+

+

+#endif /* MQTTPACKET_H_ */

diff --git a/mbtk/include/mqtt/MQTTPublish.h b/mbtk/include/mqtt/MQTTPublish.h
new file mode 100755
index 0000000..d62dddb
--- /dev/null
+++ b/mbtk/include/mqtt/MQTTPublish.h
@@ -0,0 +1,38 @@
+/*******************************************************************************

+ * Copyright (c) 2014 IBM Corp.

+ *

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * and Eclipse Distribution License v1.0 which accompany this distribution.

+ *

+ * The Eclipse Public License is available at

+ *    http://www.eclipse.org/legal/epl-v10.html

+ * and the Eclipse Distribution License is available at

+ *   http://www.eclipse.org/org/documents/edl-v10.php.

+ *

+ * Contributors:

+ *    Ian Craggs - initial API and implementation and/or initial documentation

+ *    Xiang Rong - 442039 Add makefile to Embedded C client

+ *******************************************************************************/

+

+#ifndef MQTTPUBLISH_H_

+#define MQTTPUBLISH_H_

+

+#if !defined(DLLImport)

+  #define DLLImport 

+#endif

+#if !defined(DLLExport)

+  #define DLLExport

+#endif

+

+DLLExport int MQTTSerialize_publish(unsigned char* buf, int buflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid,

+		MQTTString topicName, unsigned char* payload, int payloadlen);

+

+DLLExport int MQTTDeserialize_publish(unsigned char* dup, int* qos, unsigned char* retained, unsigned short* packetid, MQTTString* topicName,

+		unsigned char** payload, int* payloadlen, unsigned char* buf, int len);

+

+DLLExport int MQTTSerialize_puback(unsigned char* buf, int buflen, unsigned short packetid);

+DLLExport int MQTTSerialize_pubrel(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid);

+DLLExport int MQTTSerialize_pubcomp(unsigned char* buf, int buflen, unsigned short packetid);

+

+#endif /* MQTTPUBLISH_H_ */

diff --git a/mbtk/include/mqtt/MQTTSubscribe.h b/mbtk/include/mqtt/MQTTSubscribe.h
new file mode 100755
index 0000000..383ca0d
--- /dev/null
+++ b/mbtk/include/mqtt/MQTTSubscribe.h
@@ -0,0 +1,39 @@
+/*******************************************************************************

+ * Copyright (c) 2014 IBM Corp.

+ *

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * and Eclipse Distribution License v1.0 which accompany this distribution.

+ *

+ * The Eclipse Public License is available at

+ *    http://www.eclipse.org/legal/epl-v10.html

+ * and the Eclipse Distribution License is available at

+ *   http://www.eclipse.org/org/documents/edl-v10.php.

+ *

+ * Contributors:

+ *    Ian Craggs - initial API and implementation and/or initial documentation

+ *    Xiang Rong - 442039 Add makefile to Embedded C client

+ *******************************************************************************/

+

+#ifndef MQTTSUBSCRIBE_H_

+#define MQTTSUBSCRIBE_H_

+

+#if !defined(DLLImport)

+  #define DLLImport 

+#endif

+#if !defined(DLLExport)

+  #define DLLExport

+#endif

+

+DLLExport int MQTTSerialize_subscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid,

+		int count, MQTTString topicFilters[], int requestedQoSs[]);

+

+DLLExport int MQTTDeserialize_subscribe(unsigned char* dup, unsigned short* packetid,

+		int maxcount, int* count, MQTTString topicFilters[], int requestedQoSs[], unsigned char* buf, int len);

+

+DLLExport int MQTTSerialize_suback(unsigned char* buf, int buflen, unsigned short packetid, int count, int* grantedQoSs);

+

+DLLExport int MQTTDeserialize_suback(unsigned short* packetid, int maxcount, int* count, int grantedQoSs[], unsigned char* buf, int len);

+

+

+#endif /* MQTTSUBSCRIBE_H_ */

diff --git a/mbtk/include/mqtt/MQTTUnsubscribe.h b/mbtk/include/mqtt/MQTTUnsubscribe.h
new file mode 100755
index 0000000..1644ae5
--- /dev/null
+++ b/mbtk/include/mqtt/MQTTUnsubscribe.h
@@ -0,0 +1,38 @@
+/*******************************************************************************

+ * Copyright (c) 2014 IBM Corp.

+ *

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * and Eclipse Distribution License v1.0 which accompany this distribution.

+ *

+ * The Eclipse Public License is available at

+ *    http://www.eclipse.org/legal/epl-v10.html

+ * and the Eclipse Distribution License is available at

+ *   http://www.eclipse.org/org/documents/edl-v10.php.

+ *

+ * Contributors:

+ *    Ian Craggs - initial API and implementation and/or initial documentation

+ *    Xiang Rong - 442039 Add makefile to Embedded C client

+ *******************************************************************************/

+

+#ifndef MQTTUNSUBSCRIBE_H_

+#define MQTTUNSUBSCRIBE_H_

+

+#if !defined(DLLImport)

+  #define DLLImport 

+#endif

+#if !defined(DLLExport)

+  #define DLLExport

+#endif

+

+DLLExport int MQTTSerialize_unsubscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid,

+		int count, MQTTString topicFilters[]);

+

+DLLExport int MQTTDeserialize_unsubscribe(unsigned char* dup, unsigned short* packetid, int max_count, int* count, MQTTString topicFilters[],

+		unsigned char* buf, int len);

+

+DLLExport int MQTTSerialize_unsuback(unsigned char* buf, int buflen, unsigned short packetid);

+

+DLLExport int MQTTDeserialize_unsuback(unsigned short* packetid, unsigned char* buf, int len);

+

+#endif /* MQTTUNSUBSCRIBE_H_ */

diff --git a/mbtk/include/mqtt/StackTrace.h b/mbtk/include/mqtt/StackTrace.h
new file mode 100755
index 0000000..c65a2ef
--- /dev/null
+++ b/mbtk/include/mqtt/StackTrace.h
@@ -0,0 +1,78 @@
+/*******************************************************************************

+ * Copyright (c) 2014 IBM Corp.

+ *

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * and Eclipse Distribution License v1.0 which accompany this distribution.

+ *

+ * The Eclipse Public License is available at

+ *    http://www.eclipse.org/legal/epl-v10.html

+ * and the Eclipse Distribution License is available at

+ *   http://www.eclipse.org/org/documents/edl-v10.php.

+ *

+ * Contributors:

+ *    Ian Craggs - initial API and implementation and/or initial documentation

+ *    Ian Craggs - fix for bug #434081

+ *******************************************************************************/

+

+#ifndef STACKTRACE_H_

+#define STACKTRACE_H_

+

+#include <stdio.h>

+#define NOSTACKTRACE 1

+

+#if defined(NOSTACKTRACE)

+#define FUNC_ENTRY

+#define FUNC_ENTRY_NOLOG

+#define FUNC_ENTRY_MED

+#define FUNC_ENTRY_MAX

+#define FUNC_EXIT

+#define FUNC_EXIT_NOLOG

+#define FUNC_EXIT_MED

+#define FUNC_EXIT_MAX

+#define FUNC_EXIT_RC(x)

+#define FUNC_EXIT_MED_RC(x)

+#define FUNC_EXIT_MAX_RC(x)

+

+#else

+

+#if defined(WIN32)

+#define inline __inline

+#define FUNC_ENTRY StackTrace_entry(__FUNCTION__, __LINE__, TRACE_MINIMUM)

+#define FUNC_ENTRY_NOLOG StackTrace_entry(__FUNCTION__, __LINE__, -1)

+#define FUNC_ENTRY_MED StackTrace_entry(__FUNCTION__, __LINE__, TRACE_MEDIUM)

+#define FUNC_ENTRY_MAX StackTrace_entry(__FUNCTION__, __LINE__, TRACE_MAXIMUM)

+#define FUNC_EXIT StackTrace_exit(__FUNCTION__, __LINE__, NULL, TRACE_MINIMUM)

+#define FUNC_EXIT_NOLOG StackTrace_exit(__FUNCTION__, __LINE__, -1)

+#define FUNC_EXIT_MED StackTrace_exit(__FUNCTION__, __LINE__, NULL, TRACE_MEDIUM)

+#define FUNC_EXIT_MAX StackTrace_exit(__FUNCTION__, __LINE__, NULL, TRACE_MAXIMUM)

+#define FUNC_EXIT_RC(x) StackTrace_exit(__FUNCTION__, __LINE__, &x, TRACE_MINIMUM)

+#define FUNC_EXIT_MED_RC(x) StackTrace_exit(__FUNCTION__, __LINE__, &x, TRACE_MEDIUM)

+#define FUNC_EXIT_MAX_RC(x) StackTrace_exit(__FUNCTION__, __LINE__, &x, TRACE_MAXIMUM)

+#else

+#define FUNC_ENTRY StackTrace_entry(__func__, __LINE__, TRACE_MINIMUM)

+#define FUNC_ENTRY_NOLOG StackTrace_entry(__func__, __LINE__, -1)

+#define FUNC_ENTRY_MED StackTrace_entry(__func__, __LINE__, TRACE_MEDIUM)

+#define FUNC_ENTRY_MAX StackTrace_entry(__func__, __LINE__, TRACE_MAXIMUM)

+#define FUNC_EXIT StackTrace_exit(__func__, __LINE__, NULL, TRACE_MINIMUM)

+#define FUNC_EXIT_NOLOG StackTrace_exit(__func__, __LINE__, NULL, -1)

+#define FUNC_EXIT_MED StackTrace_exit(__func__, __LINE__, NULL, TRACE_MEDIUM)

+#define FUNC_EXIT_MAX StackTrace_exit(__func__, __LINE__, NULL, TRACE_MAXIMUM)

+#define FUNC_EXIT_RC(x) StackTrace_exit(__func__, __LINE__, &x, TRACE_MINIMUM)

+#define FUNC_EXIT_MED_RC(x) StackTrace_exit(__func__, __LINE__, &x, TRACE_MEDIUM)

+#define FUNC_EXIT_MAX_RC(x) StackTrace_exit(__func__, __LINE__, &x, TRACE_MAXIMUM)

+

+void StackTrace_entry(const char* name, int line, int trace);

+void StackTrace_exit(const char* name, int line, void* return_value, int trace);

+

+void StackTrace_printStack(FILE* dest);

+char* StackTrace_get(unsigned long);

+

+#endif

+

+#endif

+

+

+

+

+#endif /* STACKTRACE_H_ */