--- mqtt/src/daemon.c 2011/12/01 14:41:11 1.1.2.6 +++ mqtt/src/daemon.c 2011/12/05 08:15:50 1.1.2.7 @@ -1,12 +1,17 @@ #include "global.h" +extern char cliCmd[], *cliStr[]; + + static void * startSession(sched_task_t *task) { mqtt_msg_t *buf; mqtt_cb_t cbs[MQTT_TYPE_MAX + 1] = { 0 }; + struct mqtthdr *hdr; int ret = 0; + register int i; FTRACE(4); @@ -22,6 +27,15 @@ startSession(sched_task_t *task) errno, strerror(errno)); mqtt_msgFree(&buf, 42); goto end; + } else { + hdr = (struct mqtthdr*) buf->msg_base; + for (ret = i = 0; cliCmd[i] && !(ret = (hdr->mqtt_msg.type == cliCmd[i])); i++); + if (!ret) { + syslog(LOG_ERR, "Error:: wrong command type #%d %s", + hdr->mqtt_msg.type, cliStr[i]); + mqtt_msgFree(&buf, 42); + goto end; + } } ret = mqttDispatcher(cbs, buf);