version 1.1.2.7, 2011/12/05 08:15:50
|
version 1.1.2.8, 2011/12/05 10:37:17
|
Line 7 extern char cliCmd[], *cliStr[];
|
Line 7 extern char cliCmd[], *cliStr[];
|
static void * |
static void * |
startSession(sched_task_t *task) |
startSession(sched_task_t *task) |
{ |
{ |
|
static u_char basebuf[USHRT_MAX]; |
mqtt_msg_t *buf; |
mqtt_msg_t *buf; |
mqtt_cb_t cbs[MQTT_TYPE_MAX + 1] = { 0 }; |
mqtt_cb_t cbs[MQTT_TYPE_MAX + 1] = { 0 }; |
struct mqtthdr *hdr; |
struct mqtthdr *hdr; |
int ret = 0; | int len, ret = 0; |
register int i; | |
|
|
FTRACE(4); |
FTRACE(4); |
|
|
|
/* |
buf = mqtt_msgAlloc(USHRT_MAX); |
buf = mqtt_msgAlloc(USHRT_MAX); |
if (!buf) { |
if (!buf) { |
syslog(LOG_ERR, "Error:: allocate message buf (%d) #%d - %s", (int) TASK_FD(task), |
syslog(LOG_ERR, "Error:: allocate message buf (%d) #%d - %s", (int) TASK_FD(task), |
mqtt_GetErrno(), mqtt_GetError()); |
mqtt_GetErrno(), mqtt_GetError()); |
goto end; |
goto end; |
} |
} |
|
*/ |
|
|
if (recv(TASK_FD(task), buf->msg_base, buf->msg_len, 0) == -1) { | if (recv(TASK_FD(task), basebuf, sizeof basebuf, 0) == -1) { |
syslog(LOG_ERR, "Error:: recv(%d) #%d - %s", (int) TASK_FD(task), | VERB(3) syslog(LOG_ERR, "Error:: recv(%d) #%d - %s", (int) TASK_FD(task), |
errno, strerror(errno)); |
errno, strerror(errno)); |
mqtt_msgFree(&buf, 42); |
|
goto end; |
goto end; |
} else { | } else |
hdr = (struct mqtthdr*) buf->msg_base; | hdr = (struct mqtthdr*) basebuf; |
| if (hdr->mqtt_msg.type != MQTT_TYPE_CONNECT) { |
| VERB(2) syslog(LOG_ERR, "Error:: wrong command type for 1st command #%d", |
| hdr->mqtt_msg.type); |
| goto end; |
| } else |
| len = mqtt_decodeLen(hdr->mqtt_len, &ret); |
| |
| /* |
for (ret = i = 0; cliCmd[i] && !(ret = (hdr->mqtt_msg.type == cliCmd[i])); i++); |
for (ret = i = 0; cliCmd[i] && !(ret = (hdr->mqtt_msg.type == cliCmd[i])); i++); |
if (!ret) { |
if (!ret) { |
syslog(LOG_ERR, "Error:: wrong command type #%d %s", | VERB(2) syslog(LOG_ERR, "Error:: wrong command type #%d %s", |
hdr->mqtt_msg.type, cliStr[i]); |
hdr->mqtt_msg.type, cliStr[i]); |
mqtt_msgFree(&buf, 42); |
|
goto end; |
goto end; |
} |
} |
} | */ |
|
|
ret = mqttDispatcher(cbs, buf); | /* check online table for user */ |
| // ChkSessPUB(&cfg, ); |
|
|
|
ret = mqttDispatcher(cbs, buf); |
mqtt_msgFree(&buf, 42); |
mqtt_msgFree(&buf, 42); |
|
|
switch (ret) { |
switch (ret) { |