1: #ifndef __MQTTD_H
2: #define __MQTTD_H
3:
4:
5: struct tagStore {
6: char st_qos;
7: u_short st_msgid;
8:
9: mqtt_subscr_t st_subscr;
10:
11: SLIST_ENTRY(tagStore) st_node;
12: };
13:
14: struct tagSession {
15: /* client session thread id */
16: pthread_t sess_tid;
17: pthread_mutex_t sess_mtx;
18: /* server dispatcher */
19: mqtt_srv_t *sess_srv;
20:
21: /* client network settings */
22: int sess_sock;
23: u_short sess_ka;
24: /* client send retry in miliseconds, if client not receive message */
25: u_int sess_retry;
26: /* message work buffer */
27: mqtt_msg_t *sess_buf;
28:
29: /* authentication user info */
30: char sess_cid[MAX_CONNID];
31: char sess_user[MAX_CRED];
32: char sess_pass[MAX_CRED];
33: char sess_addr[64];
34:
35: /* connect flags */
36: char sess_clean;
37: struct {
38: char flag;
39: char qos;
40: char retain;
41: char *topic;
42: char *msg;
43: } sess_will;
44:
45: /* Data Storage by QoS class */
46: SLIST_HEAD(tStore, tagStore) sess_txque[3];
47: TAILQ_ENTRY(tagSession) sess_node;
48: };
49: typedef TAILQ_HEAD(, tagSession) sessions_t;
50: #define SESS_ELEM_LOCK(x) pthread_mutex_lock(&(x)->sess_mtx)
51: #define SESS_ELEM_UNLOCK(x) pthread_mutex_unlock(&(x)->sess_mtx)
52:
53:
54: extern sessions_t Sessions;
55: extern sched_root_task_t *root;
56: extern cfg_root_t cfg;
57: extern pthread_mutex_t mtx_sess, mtx_pub;
58: #define SESS_LOCK pthread_mutex_lock(&mtx_sess)
59: #define SESS_UNLOCK pthread_mutex_unlock(&mtx_sess)
60: #define PUB_LOCK pthread_mutex_lock(&mtx_pub)
61: #define PUB_UNLOCK pthread_mutex_unlock(&mtx_pub)
62:
63:
64: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>