Commit 0db490ba authored by whmaizmy's avatar whmaizmy

【修改内容】增加无效topic的过滤

【提交人】陈伟灿
parent 1761e6e5
......@@ -11,7 +11,7 @@ CFLAGS += -I$(TOP_DIR)/common/json
CFLAGS += -I$(TOP_DIR)/common/nanomsg/include
CFLAGS += -I$(TOP_DIR)/common/ev/include
CFLAGS += -I$(TOP_DIR)/common/sqlite
LDFLAGS += -lapi_com
LDFLAGS += -lapi_com -lkk_tsl
LDFLAGS += -L$(TOP_DIR)/common/nanomsg -static -lnanomsg
LDFLAGS += -L$(TOP_DIR)/common/ev -static -lev
LDFLAGS += -L$(TOP_DIR)/output/release/lib -static -lapi_com
......
......@@ -43,9 +43,41 @@ void KK_Sendto_CloudData(void *data,int len)
printf("[%s][%d] payload:%s\n",__FUNCTION__,__LINE__,pData->valuestring);
KK_MQTT_SendMsg(pTopic->valuestring,(const char*)pData->valuestring);
}
#define KK_FILTER_ADD_TOPIC "/thing/topo/add"
#define KK_FILTER_ADD_TOPIC_REPLY "/thing/topo/add_reply"
#define KK_FILTER_DELETE_TOPIC "/thing/topo/delete"
#define KK_FILTER_DELETE_TOPIC_REPLY "/thing/topo/delete_reply"
#define KK_FILTER_REGISTER_TOPIC "/thing/sub/register"
#define KK_FILTER_REGISTER_TOPIC_REPLY "/thing/sub/register_reply"
#define KK_FILTER_LOGIN_TOPIC "/thing/combine/login"
#define KK_FILTER_LOGIN_TOPIC_REPLY "/thing/combine/login_reply"
static int _check_invalid_topic(char* topic)
{
if(strstr(topic, KK_FILTER_ADD_TOPIC) != NULL && \
strstr(topic,KK_FILTER_ADD_TOPIC_REPLY) == NULL){
return 1;
}
else if(strstr(topic, KK_FILTER_DELETE_TOPIC) != NULL && \
strstr(topic,KK_FILTER_DELETE_TOPIC_REPLY) == NULL){
return 1;
}
else if(strstr(topic, KK_FILTER_REGISTER_TOPIC) != NULL && \
strstr(topic,KK_FILTER_REGISTER_TOPIC_REPLY) == NULL){
return 1;
}
else if(strstr(topic, KK_FILTER_LOGIN_TOPIC) != NULL && \
strstr(topic,KK_FILTER_LOGIN_TOPIC_REPLY) == NULL){
return 1;
}
return 0;
}
void KK_Sendto_DevData(const char *topic,const char *data)
{
if(_check_invalid_topic())
{
return;//ingore the message
}
char *send_data = _kk_data_create(topic,data);
kk_ipc_send(IPC_APP2MID, send_data, strlen(send_data)+1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment