--- mqtt/src/daemon.c 2011/12/05 14:11:47 1.1.2.9 +++ mqtt/src/daemon.c 2011/12/08 14:52:47 1.1.2.10 @@ -9,8 +9,11 @@ startSession(sched_task_t *task) { static u_char basebuf[USHRT_MAX]; mqtt_cb_t cbs[MQTT_TYPE_MAX + 1] = { 0 }; - mqtt_msg_t *buf; + mqtt_msg_t *buf = { basebuf, sizeof basebuf }; + mqtthdr_connflgs_t flg; int ret = 0; + struct timeval tv = { 0 }; + u_short ka; FTRACE(4); @@ -29,6 +32,13 @@ startSession(sched_task_t *task) goto end; } + flg = mqtt_readCONNECT(buf, &ka, ); + if (flg.reserved) { + VERB(3) syslog(LOG_ERR, "Error:: in MQTT protocol #%d - %s", + mqtt_GetErrno(), mqtt_GetError()); + goto end; + } + /* for (ret = i = 0; cliCmd[i] && !(ret = (hdr->mqtt_msg.type == cliCmd[i])); i++); if (!ret) { @@ -41,9 +51,10 @@ startSession(sched_task_t *task) /* check online table for user */ // ChkSessPUB(&cfg, ); - ret = mqttDispatcher(cbs, buf); +// ret = mqttDispatcher(cbs, buf); // mqtt_msgFree(&buf, 42); + /* switch (ret) { case -1: syslog(LOG_ERR, "Error:: in MQTT protocol #%d - %s", mqtt_GetErrno(), mqtt_GetError()); @@ -51,6 +62,7 @@ startSession(sched_task_t *task) default: return NULL; } + */ end: /* close client connection */ close(TASK_FD(task)); VERB(1) syslog(LOG_DEBUG, "Close client %s with socket=%d",