Clients.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright (c) 2009, 2020 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 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 - add SSL support
16  * Ian Craggs - fix for bug 413429 - connectionLost not called
17  * Ian Craggs - change will payload to binary
18  * Ian Craggs - password to binary
19  * Ian Craggs - MQTT 5 support
20  *******************************************************************************/
21 
22 #if !defined(CLIENTS_H)
23 #define CLIENTS_H
24 
25 #include <stdint.h>
26 #include "MQTTTime.h"
27 #if defined(OPENSSL)
28 #if defined(_WIN32) || defined(_WIN64)
29 #include <winsock2.h>
30 #endif
31 #include <openssl/ssl.h>
32 #endif
33 #include "MQTTClient.h"
34 #include "LinkedList.h"
35 #include "MQTTClientPersistence.h"
36 
40 typedef struct
41 {
42  char *topic;
43  int topiclen;
44  char* payload;
46  int refcount;
47  uint8_t mask[4];
48 } Publications;
49 
53 typedef struct
54 {
55  int qos;
56  int retain;
57  int msgid;
63  int len;
64 } Messages;
65 
69 typedef struct
70 {
71  char *topic;
73  void *payload;
74  int retained;
75  int qos;
76 } willMessages;
77 
78 typedef struct
79 {
80  int socket;
84 #if defined(OPENSSL)
85  SSL* ssl;
86  SSL_CTX* ctx;
87  char *https_proxy;
88  char *https_proxy_auth;
89 #endif
90  char *http_proxy;
92  int websocket;
96 
97 
98 /* connection states */
100 #define NOT_IN_PROGRESS 0x0
101 
102 #define TCP_IN_PROGRESS 0x1
103 
104 #define SSL_IN_PROGRESS 0x2
105 
106 #define WEBSOCKET_IN_PROGRESS 0x3
107 
108 #define WAIT_FOR_CONNACK 0x4
109 
110 #define PROXY_CONNECT_IN_PROGRESS 0x5
111 
112 #define DISCONNECTING -2
113 
117 typedef struct
118 {
119  char* clientID;
120  const char* username;
122  const void* password;
123  unsigned int cleansession : 1;
124  unsigned int cleanstart : 1;
125  unsigned int connected : 1;
126  unsigned int good : 1;
127  unsigned int ping_outstanding : 1;
128  signed int connect_state : 4;
130  int msgID;
138  unsigned int qentry_seqno;
139  void* phandle;
145  void* context;
148 #if defined(OPENSSL)
149  MQTTClient_SSLOptions *sslopts;
150  SSL_SESSION* session;
151 #endif
152 } Clients;
153 
154 int clientIDCompare(void* a, void* b);
155 int clientSocketCompare(void* a, void* b);
156 
160 typedef struct
161 {
162  const char* version;
164 } ClientStates;
165 
166 #endif
List * messageQueue
Definition: Clients.h:137
char * websocket_key
Definition: Clients.h:93
int qos
Definition: Clients.h:55
START_TIME_TYPE lastPing
Definition: Clients.h:83
MQTTPersistence_beforeWrite * beforeWrite
Definition: Clients.h:141
int clientIDCompare(void *a, void *b)
Definition: Clients.c:36
int MQTTVersion
Definition: Clients.h:146
int sessionExpiry
Definition: Clients.h:147
int websocket
Definition: Clients.h:92
int msgID
Definition: Clients.h:130
const MQTTClient_nameValue * httpHeaders
Definition: Clients.h:94
MQTTProperties properties
Definition: Clients.h:59
List * outboundMsgs
Definition: Clients.h:136
void * context
Definition: Clients.h:145
int len
Definition: Clients.h:63
int clientSocketCompare(void *a, void *b)
Definition: Clients.c:50
START_TIME_TYPE lastTouch
Definition: Clients.h:61
int passwordlen
Definition: Clients.h:121
networkHandles net
Definition: Clients.h:129
void * beforeWrite_context
Definition: Clients.h:143
List * clients
Definition: Clients.h:163
int keepAliveInterval
Definition: Clients.h:131
This structure represents a persistent data store, used to store outbound and inbound messages...
MQTTClient_persistence * persistence
Definition: Clients.h:140
START_TIME_TYPE lastReceived
Definition: Clients.h:82
int payloadlen
Definition: Clients.h:72
int msgid
Definition: Clients.h:57
int payloadlen
Definition: Clients.h:45
void * payload
Definition: Clients.h:73
#define START_TIME_TYPE
Definition: MQTTTime.h:36
int refcount
Definition: Clients.h:46
int retained
Definition: Clients.h:74
char nextMessageType
Definition: Clients.h:62
unsigned int qentry_seqno
Definition: Clients.h:138
int maxInflightMessages
Definition: Clients.h:133
START_TIME_TYPE lastSent
Definition: Clients.h:81
char * payload
Definition: Clients.h:44
void * afterRead_context
Definition: Clients.h:144
int topiclen
Definition: Clients.h:43
const void * password
Definition: Clients.h:122
char * topic
Definition: Clients.h:42
char * topic
Definition: Clients.h:71
void * phandle
Definition: Clients.h:139
int retain
Definition: Clients.h:56
int MQTTVersion
Definition: Clients.h:58
const char * version
Definition: Clients.h:162
char * clientID
Definition: Clients.h:119
char * http_proxy_auth
Definition: Clients.h:91
A structure containing the function pointers to a persistence implementation and the context or state...
MQTTPersistence_afterRead * afterRead
Definition: Clients.h:142
volatile int connected
List * inboundMsgs
Definition: Clients.h:135
int retryInterval
Definition: Clients.h:132
Publications * publish
Definition: Clients.h:60
int MQTTPersistence_afterRead(void *context, char **buffer, int *buflen)
const char * username
Definition: Clients.h:120
char * http_proxy
Definition: Clients.h:90
int MQTTPersistence_beforeWrite(void *context, int bufcount, char *buffers[], int buflens[])
willMessages * will
Definition: Clients.h:134


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 03:47:33