📄 localmodule.c
字号:
#include "localmodule.h"#include "dealpacket.h"//初始化共享库int Init_Local_Module(void){#ifdef _FUNCTION_FLOW_ doLog(0, "%s: Init_Local_Module() in ...\n", SO_NAME);#endif#ifdef _TEST_DEBUG_ doLog(0, "<--- Begin initialization module --- \n");#endif if (create_pop3_thread(&pid)==FAIL) return FAIL;/* if (dao_mysql_init(NULL, 0, DB_USER_NAME, DB_USER_PWD, DB_DBAS_NAME)) { #ifdef _TEST_DEBUG_ doLog(0, "Database Config Error.\n"); #endif close_pop3_thread(pid); return FAIL; }*/#ifdef _TEST_DEBUG_ doLog(0, " --- End initialization module --->\n"); doLog(0, " \n");#endif#ifdef _FUNCTION_FLOW_ doLog(0, "%s: Init_Sub_Module() return SUCCESS ...\n", SO_NAME);#endif return SUCCESS;}//处理数据包int Local_Module_Deal(const char *packet, int len){ int ret = ACCEPT;#ifdef _FUNCTION_FLOW_ doLog(0, "%s: Local_Module_Deal() in ...\n", SO_NAME);#endif struct tcphdr *ptcp = NULL; ptcp = (struct tcphdr *)(packet+sizeof(struct ether_header) + sizeof(struct iphdr)); //doLog(0, "ptcp->source = %d, ptcp->dest = %d\n", ntohs(ptcp->source), ntohs(ptcp->dest)); if (ntohs(ptcp->source)!=110 && ntohs(ptcp->dest)!=110) { return ACCEPT; }#ifdef _TEST_DEBUG_ doLog(0, " 检测到192.168.2.35通过POP3协议发送数据\n"); doLog(0, "<--- Begin deal packet --- \n");#endif ret = deal_packet(packet, len);#ifdef _TEST_DEBUG_ doLog(0, " --- End deal packet --->\n"); doLog(0, " \n");#endif#ifdef _FUNCTION_FLOW_ doLog(0, "%s: Local_Module_Deal() return ACCEPT ...\n", SO_NAME);#endif return ACCEPT;}//释放本共享库int Close_Local_Module(void){#ifdef _FUNCTION_FLOW_ doLog(0, "%s: Close_Local_Module() in ...\n", SO_NAME);#endif #ifdef _TEST_DEBUG_ doLog(0, "<--- Begin Uninitialization Module --- \n");#endif close_pop3_thread(pid);// dao_mysql_release();#ifdef _TEST_DEBUG_ doLog(0, " --- End Uninitialization Module --->\n"); doLog(0, " \n");#endif#ifdef _FUNCTION_FLOW_ doLog(0, "%s: Close_Local_Module() return SUCCESS ...\n", SO_NAME);#endif return SUCCESS;}//处理共享库消息int Local_Module_Message(unsigned int cmd){#ifdef _FUNCTION_FLOW_ doLog(0, "%s: Local_Module_Message() in ...\n", SO_NAME);#endif #ifdef _TEST_DEBUG_ doLog(0, "<--- Begin deal message [0x%02x] --- \n", cmd);#endif#ifdef _TEST_DEBUG_ doLog(0, " --- End deal message [0x%02x] --->\n", cmd); doLog(0, " \n");#endif#ifdef _FUNCTION_FLOW_ doLog(0, "%s: Local_Module_Message() return SUCCESS ...\n", SO_NAME);#endif return SUCCESS;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -