1 ///
2 module mosquittod.types;
3 
4 ///
5 enum MOSQ_LOG
6 {
7     NONE        = 0, ///
8     INFO        = 1<<0, ///
9     NOTICE      = 1<<1, ///
10     WARNING     = 1<<2, ///
11     ERR         = 1<<3, ///
12     DEBUG       = 1<<4, ///
13     SUBSCRIBE   = 1<<5, ///
14     UNSUBSCRIBE = 1<<6, ///
15     WEBSOCKETS  = 1<<7, ///
16     INTERNAL    = 0x80000000U, ///
17     ALL         = 0xFFFFFFFFU, ///
18 }
19 
20 ///
21 enum MOSQ_ERR 
22 {
23     AUTH_CONTINUE = -4, ///
24     NO_SUBSCRIBERS = -3, ///
25     SUB_EXISTS = -2, ///
26     CONN_PENDING = -1, ///
27     SUCCESS = 0, ///
28     NOMEM = 1, ///
29     PROTOCOL = 2, ///
30     INVAL = 3, ///
31     NO_CONN = 4, ///
32     CONN_REFUSED = 5, ///
33     NOT_FOUND = 6, ///
34     CONN_LOST = 7, ///
35     TLS = 8, ///
36     PAYLOAD_SIZE = 9, ///
37     NOT_SUPPORTED = 10, ///
38     AUTH = 11, ///
39     ACL_DENIED = 12, ///
40     UNKNOWN = 13, ///
41     ERRNO = 14, ///
42     EAI = 15, ///
43     PROXY = 16, ///
44     PLUGIN_DEFER = 17, ///
45     MALFORMED_UTF8 = 18, ///
46     KEEPALIVE = 19, ///
47     LOOKUP = 20, ///
48     MALFORMED_PACKET = 21, ///
49     DUPLICATE_PROPERTY = 22, ///
50     TLS_HANDSHAKE = 23, ///
51     QOS_NOT_SUPPORTED = 24, ///
52     OVERSIZE_PACKET = 25, ///
53     OCSP = 26, ///
54 }
55 
56 ///
57 enum MOSQ_OPT
58 {
59     PROTOCOL_VERSION = 1, ///
60     SSL_CTX = 2, ///
61     SSL_CTX_WITH_DEFAULTS = 3, ///
62     RECEIVE_MAXIMUM = 4, ///
63     SEND_MAXIMUM = 5, ///
64     TLS_KEYFORM = 6, ///
65     TLS_ENGINE = 7, ///
66     TLS_ENGINE_KPASS_SHA1 = 8, ///
67     TLS_OCSP_REQUIRED = 9, ///
68     TLS_ALPN = 10, ///
69 }
70 
71 ///
72 enum MQTT_PROTOCOL
73 {
74     V31  = 3, ///
75     V311 = 4, ///
76     V5   = 5, ///
77 }
78 
79 ///
80 struct mosquitto_message
81 {
82     ///
83     int mid;
84     ///
85     char* topic;
86     ///
87     void* payload;
88     ///
89     int payloadlen;
90     ///
91     int qos;
92     ///
93     bool retain;
94 }
95 
96 ///
97 alias mosquitto = void;
98 
99 ///
100 alias mosquitto_property = void;
101 
102 ///
103 struct libmosquitto_will
104 {
105     ///
106     char *topic;
107     ///
108     void *payload;
109     ///
110     int payloadlen;
111     ///
112     int qos;
113     ///
114     bool retain;
115 }
116 
117     ///
118 struct libmosquitto_auth
119 {
120     ///
121     char *username;
122     ///
123     char *password;
124 }
125 
126 ///
127 alias mosq_tls_callback = extern(C) int function(char*, int, int, void*);
128 
129 ///
130 struct libmosquitto_tls
131 {
132     ///
133     char *cafile;
134     ///
135     char *capath;
136     ///
137     char *certfile;
138     ///
139     char *keyfile;
140     ///
141     char *ciphers;
142     ///
143     char *tls_version;
144     ///
145     mosq_tls_callback pw_callback;
146     ///
147     int cert_reqs;
148 }
149 
150 extern(C)
151 {
152     alias mosq_base_callback = void function(mosquitto*, void*, int);
153     alias mosq_wf_callback   = void function(mosquitto*, void*, int, int);
154     alias mosq_msg_callback  = void function(mosquitto*, void*, const mosquitto_message*);
155     alias mosq_sub_callback  = void function(mosquitto*, void*, int, int, const int*);
156     alias mosq_log_callback  = void function(mosquitto*, void*, int, const(char)*);
157 
158     alias mosq_v5_base1_callback = void function(mosquitto*, void*, int, const mosquitto_property*);
159     alias mosq_v5_base2_callback = void function(mosquitto*, void*, int, int, const mosquitto_property*);
160     alias mosq_v5_msg_callback  = void function(mosquitto*, void*, const mosquitto_message*, const mosquitto_property*);
161     alias mosq_v5_sub_callback  = void function(mosquitto*, void*, int, int, const int*, const mosquitto_property*);
162 }