#ifndef __MQTTD_H
#define __MQTTD_H
#define API_SERVER_SIDE
#include <mqttapi.h>
struct tagStore {
char st_qos;
u_short st_msgid;
mqtt_subscr_t st_subscr;
SLIST_ENTRY(tagStore) st_node;
};
struct tagSession {
/* client session thread id */
pthread_t sess_tid;
pthread_mutex_t sess_mtx;
/* server dispatcher */
mqtt_srv_t *sess_srv;
/* client network settings */
int sess_sock;
u_short sess_ka;
/* client send retry in miliseconds, if client not receive message */
u_int sess_retry;
/* message work buffer */
mqtt_msg_t *sess_buf;
/* authentication user info */
char sess_cid[MAX_CONNID];
char sess_user[MAX_CRED];
char sess_pass[MAX_CRED];
char sess_addr[64];
/* connect flags */
char sess_clean;
struct {
char flag;
char qos;
char retain;
char *topic;
char *msg;
} sess_will;
/* session subscriptions */
SLIST_HEAD(tStore, tagStore) sess_subscr;
TAILQ_ENTRY(tagSession) sess_node;
};
typedef TAILQ_HEAD(, tagSession) sessions_t;
#define SESS_ELEM_LOCK(x) pthread_mutex_lock(&(x)->sess_mtx)
#define SESS_ELEM_UNLOCK(x) pthread_mutex_unlock(&(x)->sess_mtx)
#define SESS_LOCK pthread_mutex_lock(&mtx_sess)
#define SESS_UNLOCK pthread_mutex_unlock(&mtx_sess)
struct tagPub {
ait_val_t pub_name;
mqtt_msg_t pub_packet;
TAILQ_ENTRY(tagPub) pub_node;
};
typedef TAILQ_HEAD(, tagPub) pubs_t;
#define PUBS_LOCK pthread_mutex_lock(&mtx_pub)
#define PUBS_UNLOCK pthread_mutex_unlock(&mtx_pub)
extern sessions_t Sessions;
extern pubs_t Pubs;
extern sched_root_task_t *root;
extern cfg_root_t cfg;
extern pthread_mutex_t mtx_sess, mtx_pub;
#endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>