version 1.1.2.6, 2011/12/01 14:41:11
|
version 1.1.2.11, 2011/12/08 17:02:25
|
Line 1
|
Line 1
|
#include "global.h" |
#include "global.h" |
|
#include "mqttd.h" |
|
|
|
|
|
extern char cliCmd[], *cliStr[]; |
|
|
|
|
static void * |
static void * |
startSession(sched_task_t *task) |
startSession(sched_task_t *task) |
{ |
{ |
mqtt_msg_t *buf; | u_char basebuf[USHRT_MAX]; |
mqtt_cb_t cbs[MQTT_TYPE_MAX + 1] = { 0 }; |
mqtt_cb_t cbs[MQTT_TYPE_MAX + 1] = { 0 }; |
|
// mqtt_msg_t *buf = { basebuf, sizeof basebuf }; |
|
mqtthdr_connflgs_t flg; |
int ret = 0; |
int ret = 0; |
|
struct timeval tv = { 0 }; |
|
u_short ka; |
|
|
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; |
} |
} |
|
|
ret = mqttDispatcher(cbs, buf); | /* |
| 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; |
| } */ |
|
|
mqtt_msgFree(&buf, 42); | /* |
| for (ret = i = 0; cliCmd[i] && !(ret = (hdr->mqtt_msg.type == cliCmd[i])); i++); |
| if (!ret) { |
| VERB(2) syslog(LOG_ERR, "Error:: wrong command type #%d %s", |
| hdr->mqtt_msg.type, cliStr[i]); |
| goto end; |
| } |
| */ |
|
|
|
/* check online table for user */ |
|
// ChkSessPUB(&cfg, ); |
|
|
|
// ret = mqttDispatcher(cbs, buf); |
|
// mqtt_msgFree(&buf, 42); |
|
|
|
/* |
switch (ret) { |
switch (ret) { |
case -1: |
case -1: |
syslog(LOG_ERR, "Error:: in MQTT protocol #%d - %s", mqtt_GetErrno(), mqtt_GetError()); |
syslog(LOG_ERR, "Error:: in MQTT protocol #%d - %s", mqtt_GetErrno(), mqtt_GetError()); |
Line 35 startSession(sched_task_t *task)
|
Line 64 startSession(sched_task_t *task)
|
default: |
default: |
return NULL; |
return NULL; |
} |
} |
|
*/ |
end: /* close client connection */ |
end: /* close client connection */ |
close(TASK_FD(task)); |
close(TASK_FD(task)); |
VERB(1) syslog(LOG_DEBUG, "Close client %s with socket=%d", |
VERB(1) syslog(LOG_DEBUG, "Close client %s with socket=%d", |