From cfa665e9b60dbdcdca7fb2615ffac3937891f360 Mon Sep 17 00:00:00 2001 From: huangxin Date: Mon, 13 Jun 2022 11:09:36 +0800 Subject: [PATCH] =?UTF-8?q?OCT=20REM:=201.=20=E6=B6=88=E6=81=AF=E9=98=9F?= =?UTF-8?q?=E5=88=97=E4=BF=AE=E6=94=B9=E4=B8=BA=E5=8F=8C=E5=90=91IPC?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=202.=20pcap=E9=A9=B1=E5=8A=A8=E6=94=AF?= =?UTF-8?q?=E6=8C=81vxLan=E6=95=B0=E6=8D=AE=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- srcs/libs/config/agent.cfg | 21 +- srcs/libs/configure/config.c | 6 +- srcs/libs/configure/config_help.c | 4 +- srcs/libs/include/config.h | 5 +- srcs/libs/mq/mq_data.c | 6 +- srcs/lwip/src/arch_linux/Filelists.cmake | 1 - .../src/arch_linux/include/netif/pcapif.h | 2 +- srcs/lwip/src/arch_linux/netif/pcapif.c | 204 ++++++++++-------- srcs/lwip/src/arch_linux/netif/rawif.c | 7 +- srcs/pppoe/vcpe_pppoe.c | 2 +- srcs/user/user_info.c | 6 +- srcs/vcpe_agent.c | 6 +- 12 files changed, 151 insertions(+), 119 deletions(-) diff --git a/srcs/libs/config/agent.cfg b/srcs/libs/config/agent.cfg index dee39fb..7dbb989 100644 --- a/srcs/libs/config/agent.cfg +++ b/srcs/libs/config/agent.cfg @@ -44,24 +44,25 @@ application: # MQ 相关配置 zero_mq: { - svr_port = 6278; # ZeroMQ 服务器端口 - agent_port = 6279; # Agetn 通信端口 + svr_port = 6278; # ZeroMQ 服务器端口 + agent_addr = "ipc:///tmp/msg_fifo0"; # 消息通道路径 }; # vxlan 相关 - vxlan: + vxlan_wan: { - vxlan_enable = true; # 是否启动vxLan隧道封装 - vxlan_nic = "ens36"; # vxlan 物理网卡名称 - vxlan_peer_ip = "192.168.20.112"; # vxlan 对端IP - vxlan_peer_mac = "00:0C:29:49:CB:27"; # vxlan 对端 MAC 地址 + enable = true; # 是否启动vxLan隧道封装 + nic = "ens36"; # vxlan 物理网卡名称 + peer_ip = "192.168.20.112"; # vxlan 对端IP + peer_mac = "00:0C:29:49:CB:27"; # vxlan 对端 MAC 地址 + pkg_filter = "udp port 4789 and ether src not 00:0c:29:07:cb:55"; # 包过滤器 }; # vcpe 本地服务网络接口配置 local_eth: { - local_ip = "192.168.100.1"; - local_netmast = "255.255.0.0"; - local_gw = "192.168.100.1"; + ip = "192.168.100.1"; + netmast = "255.255.0.0"; + gw = "192.168.100.1"; } } \ No newline at end of file diff --git a/srcs/libs/configure/config.c b/srcs/libs/configure/config.c index 13bed9e..d52fffd 100644 --- a/srcs/libs/configure/config.c +++ b/srcs/libs/configure/config.c @@ -344,11 +344,11 @@ const char *config_item_dump_fmt(const char *titleMessage) { case VALUE_TYPE_STRING: tmp = sdsempty(); tmp = sdscatprintf(tmp, "\"%s\"", CFG_STRING_VALUE(pItem)); - if(sdslen(tmp) > 43) { + if (sdslen(tmp) > 43) { sdsrange(tmp, 0, 39); sdscat(tmp, "...\""); } - s = sdscatprintf(s, "|%4d | %-25s | %-45s | %-44s |\n", pItem->cfgId, tmp2, pItem->pcfgKey, tmp); + s = sdscatprintf(s, "|%4d | %-25s | %-45s | %-44s |\n", pItem->cfgId, tmp2, pItem->pcfgKey, tmp); sdsfree(tmp); break; default: @@ -484,7 +484,7 @@ do { /* 消息队列相配置 */ \ /* ZeroMq配置 */ \ ADD_CFG_ITEM(CFG_MQ_SVR_PORT, "application.zero_mq.svr_port", VALUE_TYPE_INTEGRAL, "6278", "ZeroMQ server port"); \ - ADD_CFG_ITEM(CFG_MQ_DATA_CH, "application.zero_mq.agent_port", VALUE_TYPE_INTEGRAL, "6279", "ZeroMQ Agent server port"); \ + ADD_CFG_ITEM(CFG_MQ_DATA_PATH, "application.zero_mq.agent_addr", VALUE_TYPE_STRING, "ipc:///tmp/msg_fifo0", "ZeroMQ Agent data path"); \ /* vxLan 隧道配置 */ \ ADD_CFG_ITEM(CFG_VXLAN_NIC_NAME, "application.vxlan_wan.nic", VALUE_TYPE_STRING, "", "Network card name to send data"); \ ADD_CFG_ITEM(CFG_VXLAN_SUPPORT, "application.vxlan_wan.enable", VALUE_TYPE_BOOL, "1", "Is support vxLan tune"); \ diff --git a/srcs/libs/configure/config_help.c b/srcs/libs/configure/config_help.c index 12c7e4c..ddc3bb7 100644 --- a/srcs/libs/configure/config_help.c +++ b/srcs/libs/configure/config_help.c @@ -111,6 +111,6 @@ int cfg_get_zero_mq_port() { return (unsigned short)cfg_get_integral_value(CFG_MQ_SVR_PORT); } -int cfg_get_zero_mq_data_channel() { - return (unsigned short)cfg_get_integral_value(CFG_MQ_DATA_CH); +const char *cfg_get_zero_mq_data_path() { + return cfg_get_string_value(CFG_MQ_DATA_PATH); } \ No newline at end of file diff --git a/srcs/libs/include/config.h b/srcs/libs/include/config.h index b14b06a..4e69b67 100644 --- a/srcs/libs/include/config.h +++ b/srcs/libs/include/config.h @@ -41,7 +41,7 @@ typedef enum { CFG_DB_MYSQL_PASSWD = 19, CFG_DB_MYSQL_DB_NAME = 20, CFG_MQ_SVR_PORT = 21, - CFG_MQ_DATA_CH = 22, + CFG_MQ_DATA_PATH = 22, CFG_VXLAN_NIC_NAME = 23, CFG_VXLAN_SUPPORT = 24, CFG_VXLAN_PEER_IP = 25, @@ -74,7 +74,7 @@ const char *cfg_get_mysql_user(); const char *cfg_get_mysql_passwd(); const char *cfg_get_mysql_database(); int cfg_get_zero_mq_port(); -int cfg_get_zero_mq_data_channel(); +const char *cfg_get_zero_mq_data_path(); const char *cfg_get_string_value(CONFIG_ITEM_ID id); long double cfg_get_float_value(CONFIG_ITEM_ID id); @@ -90,6 +90,7 @@ const char *config_get_vxlan_nic_name(); const char *config_get_vxlan_peer_mac(); const char *config_get_vxlan_peer_ip(); const char *config_get_vxlan_pkg_filter(); + #ifdef __cplusplus } #endif diff --git a/srcs/libs/mq/mq_data.c b/srcs/libs/mq/mq_data.c index 32eecdd..320e4fc 100644 --- a/srcs/libs/mq/mq_data.c +++ b/srcs/libs/mq/mq_data.c @@ -82,7 +82,7 @@ int mq_data_init(DATACHNNELCB dataCb) { g_pDataChCb = dataCb; - g_pDataCh = zmq_socket(pContext, ZMQ_REQ); + g_pDataCh = zmq_socket(pContext, ZMQ_PAIR); if (g_pDataCh == NULL) { zmq_ctx_destroy(g_pDataCh); @@ -91,8 +91,8 @@ int mq_data_init(DATACHNNELCB dataCb) { memset(buf, 0, 1024); - sprintf(buf, "tcp://127.0.0.1:%d", cfg_get_zero_mq_data_channel()); - dzlog_info("Start message queue connect: tcp://127.0.0.1:%d\n", cfg_get_zero_mq_data_channel()); + sprintf(buf, "%s", cfg_get_zero_mq_data_path()); + dzlog_info("Start message queue connect: %s\n", cfg_get_zero_mq_data_path()); if (zmq_connect(g_pDataCh, buf) != 0) { zmq_close(g_pDataCh); diff --git a/srcs/lwip/src/arch_linux/Filelists.cmake b/srcs/lwip/src/arch_linux/Filelists.cmake index 679345a..ec6be0d 100644 --- a/srcs/lwip/src/arch_linux/Filelists.cmake +++ b/srcs/lwip/src/arch_linux/Filelists.cmake @@ -15,7 +15,6 @@ set(lwipcontribportunix_SRCS ) set(lwipcontribportunixnetifs_SRCS - ${LWIP_DIR}/src/arch_linux/netif/rawif.c ${LWIP_DIR}/src/arch_linux/netif/sio.c ${LWIP_DIR}/src/arch_linux/netif/pppoe_if.c ${LWIP_DIR}/src/arch_linux/netif/pcapif.c diff --git a/srcs/lwip/src/arch_linux/include/netif/pcapif.h b/srcs/lwip/src/arch_linux/include/netif/pcapif.h index 5748a31..63299a2 100644 --- a/srcs/lwip/src/arch_linux/include/netif/pcapif.h +++ b/srcs/lwip/src/arch_linux/include/netif/pcapif.h @@ -39,7 +39,7 @@ extern "C" { err_t pcapif_init(struct netif *netif); void pcapif_poll(struct netif *netif); err_t pcapif_output(struct netif *netif, struct pbuf *p); -struct netif *bind_pcap_if(const char *eth_name, const char *pkg_filter); +struct netif *bind_pcap_if(const char *eth_name, const char *pkg_filter, int vxlan_support); #ifdef __cplusplus } #endif diff --git a/srcs/lwip/src/arch_linux/netif/pcapif.c b/srcs/lwip/src/arch_linux/netif/pcapif.c index 3684afa..d19afb8 100644 --- a/srcs/lwip/src/arch_linux/netif/pcapif.c +++ b/srcs/lwip/src/arch_linux/netif/pcapif.c @@ -47,10 +47,18 @@ #include "netif/etharp.h" #include "netif/pcapif.h" +#include "vxlan_pkg.h" +#include "lwip/vxlan.h" +#include "user_info.h" +#include "lwip/tcpip.h" +#include "netif/pppoeif.h" +#include "misc.h" #if defined(LWIP_UNIX_LINUX) #include #include +#include +#include /* Define those to better describe your network interface. */ #define IFNAME0 'p' @@ -68,9 +76,12 @@ struct pcapif { pcap_t *pcap; const char *eth_name; unsigned char mac_addr[6]; - const char *pkg_filter; - void *msg_input; - void *msg_output; + + const char *pkg_filter; + void *msg_input; + void *msg_output; + + int vxlan_support; }; #if !NO_SYS @@ -107,6 +118,7 @@ static void pcapif_msg_thread(void *arg) { } } + zmq_msg_close(&msg); usleep(10); } } @@ -131,31 +143,8 @@ static void pcap_pkg_cb(unsigned char *args, const struct pcap_pkthdr *pkthdr, c } /*-----------------------------------------------------------------------------------*/ static void low_level_init(struct netif *netif) { - char buf[2048]; - bpf_u_int32 netaddr = 0, mask = 0; - pcap_t *pPcap = NULL; - struct bpf_program filter; - char errBuf[PCAP_ERRBUF_SIZE]; struct pcapif *pcapif = (struct pcapif *)netif->state; - memset(errBuf, 0, PCAP_ERRBUF_SIZE); - memset(buf, 0, 2048); - - pPcap = pcap_open_live(pcapif->eth_name, MAX_BYTES_PACKAGE, 1, -1, errBuf); - pcap_lookupnet(pcapif->eth_name, &netaddr, &mask, errBuf); - - snprintf(buf, 2048, "(%s) and (inbound)", pcapif->pkg_filter); - - dzlog_debug("Pcap netif used filter: \"%s\"\n", buf); - if (pcap_compile(pPcap, &filter, buf, 1, mask) == -1) { - dzlog_error("Set package fileter[%s] error: %s\n", buf, pcap_geterr(pPcap)); - } - if (pcap_setfilter(pPcap, &filter) == -1) { - dzlog_error("Set package fileter[%s] error: %s\n", buf, pcap_geterr(pPcap)); - } - - pcapif->pcap = pPcap; - /* Obtain MAC address from network interface. */ netif->hwaddr[0] = pcapif->mac_addr[0]; @@ -188,9 +177,10 @@ static void low_level_init(struct netif *netif) { /*-----------------------------------------------------------------------------------*/ static err_t low_level_output(struct netif *netif, struct pbuf *p) { - char buf[1518]; /* max packet size including VLAN excluding CRC */ - ssize_t written; - struct pcapif *pcapif = (struct pcapif *)netif->state; + unsigned char buf[1518]; /* max packet size including VLAN excluding CRC */ + ssize_t written = 0; + struct pcapif *pcapif = (struct pcapif *)netif->state; + PUSER_INFO_CONTEXT pUser = (PUSER_INFO_CONTEXT)p->extra; if (p->tot_len > sizeof(buf)) { MIB2_STATS_NETIF_INC(netif, ifoutdiscards); @@ -201,22 +191,20 @@ static err_t low_level_output(struct netif *netif, struct pbuf *p) { /* initiate transfer(); */ pbuf_copy_partial(p, buf, p->tot_len, 0); - /* signal that packet should be sent(); */ - written = pcap_inject(pcapif->pcap, buf, p->tot_len); + if (pcapif->vxlan_support) { + unsigned int outSize = 0; + unsigned char *pBuf = vxlan_pkg_encode(buf, p->tot_len, &pUser->vxlan, &outSize); -#if 0 - dzlog_info("\n Send: \n"); - hdzlog_info(buf, p->tot_len); - dzlog_info("\n"); -#endif + if (pBuf && outSize != 0) { + written = pcap_inject(pcapif->pcap, pBuf, outSize); + } - if (written < p->tot_len) { - MIB2_STATS_NETIF_INC(netif, ifoutdiscards); - perror("pcapif: write"); - return ERR_IF; + free(pBuf); + + return written == (outSize) ? ERR_OK : ERR_IF; } else { - MIB2_STATS_NETIF_ADD(netif, ifoutoctets, (u32_t)written); - return ERR_OK; + written = pcap_inject(pcapif->pcap, buf, p->tot_len); + return (written == p->tot_len) ? ERR_OK : ERR_IF; } } @@ -321,30 +309,66 @@ static void link_callback(struct netif *state_netif) { #endif /* LWIP_NETIF_LINK_CALLBACK */ static err_t netif_input_data(struct pbuf *p, struct netif *inp) { - err_t err = ERR_OK; - struct netif *netif; - LWIP_UNUSED_ARG(inp); + err_t err = ERR_OK; + struct pcapif *pcapif = (struct pcapif *)inp->state; + const unsigned char *pBuf = (const unsigned char *)p->payload; - NETIF_FOREACH(netif) { - if (netif->hwaddr_len == 6 && memcmp(p->payload, netif->hwaddr, netif->hwaddr_len) == 0) { + if (pcapif->vxlan_support) { + const struct vxlan_package *pkg = (const struct vxlan_package *)pBuf; + VXLAN_TAG tag; + struct pbuf *ebuf = NULL; + PUSER_INFO_CONTEXT pContext; - if ((err = netif->input(p, netif)) != ERR_OK) { - LWIP_DEBUGF(NETIF_DEBUG, ("pppoeif_input: netif input error\n")); - pbuf_free(p); + tag.vni = VXLAN_VIN_ID(lwip_htonl(pkg->vxlan_head.vni_reserved)); + tag.q1 = lwip_ntohs(pkg->qinq_head.out_priority_cfi_and_id); + tag.q2 = lwip_ntohs(pkg->qinq_head.in_priority_cfi_and_id); + + HASH_FIND(hh_vxlan, get_all_user_by_tag(), &tag, sizeof(VXLAN_TAG), pContext); + + if (pContext && pContext->session.pppif) { + vxlan_pkg_decode(p, &ebuf, &tag); + + if (ebuf == NULL) { + return ERR_IF; } + if ((err = pContext->session.nicif->input(ebuf, pContext->session.nicif)) != ERR_OK) { + LWIP_DEBUGF(NETIF_DEBUG, ("pppoeif_input: netif input error\n")); + } + + pbuf_free(p); return err; } + } else { + struct netif *netif; + NETIF_FOREACH(netif) { + if (netif->hwaddr_len == 6 && memcmp(p->payload, netif->hwaddr, netif->hwaddr_len) == 0) { + + if ((err = netif->input(p, netif)) != ERR_OK) { + LWIP_DEBUGF(NETIF_DEBUG, ("pppoeif_input: netif input error\n")); + pbuf_free(p); + } + + return err; + } + } } - return err; + return tcpip_input(p, inp); } -struct netif *bind_pcap_if(const char *eth_name, const char *pkg_filter) { - void *msg_context = zmq_ctx_new(); - struct netif *netif; - struct ifreq ifr; - ip4_addr_t ipaddr, netmask, gw; +struct netif *bind_pcap_if(const char *eth_name, const char *pkg_filter, int vxlan_support) { + void *msg_context = zmq_ctx_new(); + pcap_t *pPcap = NULL; + struct netif *netif; + struct ifreq ifr; + struct bpf_program filter; + unsigned char mac[6]; + ip4_addr_t ipaddr_t, netmask_t, gw_t; + char errBuf[PCAP_ERRBUF_SIZE]; + char buf[2048]; + unsigned int ipaddr = 0, gw = 0, netmask = 0; + struct pcapif *pcapif = (struct pcapif *)mem_malloc(sizeof(struct pcapif)); if (pcapif == NULL) { @@ -354,46 +378,48 @@ struct netif *bind_pcap_if(const char *eth_name, const char *pkg_filter) { memset(pcapif, 0, sizeof(struct pcapif)); + if (vxlan_support) { + + if (vxlan_link_init(eth_name) != ERR_OK) { + dzlog_error("bind_pcapsocket_if: Get local nic info failed\n"); + free(pcapif); + return NULL; + } + + pcapif->vxlan_support = vxlan_support; + } + if (eth_name && strlen(eth_name) > 0) { pcapif->eth_name = eth_name; } - pcapif->pkg_filter = pkg_filter; -#if 0 - if (vxlan_link_init(eth_name) != ERR_OK) { - dzlog_error("bind_pcapsocket_if: Get local nic info failed\n"); - return NULL; + pcapif->pkg_filter = strdup(pkg_filter); + + memset(errBuf, 0, PCAP_ERRBUF_SIZE); + memset(buf, 0, 2048); + + pPcap = pcap_open_live(pcapif->eth_name, MAX_BYTES_PACKAGE, 1, -1, errBuf); + + if (get_nic_info(eth_name, &ipaddr, &netmask, &gw, mac) != ERR_OK) { + dzlog_error("Get NIC %s information error\n", eth_name); } -#endif - ip4_addr_set_zero(&gw); - ip4_addr_set_zero(&ipaddr); - ip4_addr_set_zero(&netmask); - IP4_ADDR(&netmask, 255, 255, 255, 0); - IP4_ADDR(&ipaddr, 192, 168, 100, 32); - IP4_ADDR(&gw, 192, 168, 100, 250); -#if 0 - IP4_ADDR(&gw, - (DEFAULT_GW_IPADDR & 0xFF000000), - (DEFAULT_GW_IPADDR & 0xFF0000), - (DEFAULT_GW_IPADDR & 0xFF00), - (DEFAULT_GW_IPADDR & 0xFF)); + dzlog_debug("Pcap netif used filter: \"%s\"\n", pcapif->pkg_filter); + if (pcap_compile(pPcap, &filter, buf, 1, netmask) == -1) { + dzlog_error("Set package fileter[%s] error: %s\n", buf, pcap_geterr(pPcap)); + } + if (pcap_setfilter(pPcap, &filter) == -1) { + dzlog_error("Set package fileter[%s] error: %s\n", buf, pcap_geterr(pPcap)); + } - IP4_ADDR(&ipaddr, - (g_localIpAddrBegin & 0xFF000000), - (g_localIpAddrBegin & 0xFF0000), - (g_localIpAddrBegin & 0xFF00), - (g_localIpAddrBegin & 0xFF)); + pcapif->pcap = pPcap; + + ipaddr_t.addr = ipaddr; + netmask_t.addr = netmask; + gw_t.addr = gw; + + memcpy(pcapif->mac_addr, mac, 6); - pcapif->vxlan_support = cfg_get_support_vxlan(); - pcapif->pvxLan = g_pvxLanBuf; -#endif - pcapif->mac_addr[0] = 0x00; - pcapif->mac_addr[1] = 0x0C; - pcapif->mac_addr[2] = 0x01; - pcapif->mac_addr[3] = 0x02; - pcapif->mac_addr[4] = 0x00; - pcapif->mac_addr[5] = 0x0a; memset(&ifr, 0, sizeof(ifr)); strcpy(ifr.ifr_name, pcapif->eth_name); @@ -413,7 +439,7 @@ struct netif *bind_pcap_if(const char *eth_name, const char *pkg_filter) { return NULL; } - netif_add(netif, &ipaddr, &netmask, &gw, pcapif, pcapif_init, netif_input_data); + netif_add(netif, &ipaddr_t, &netmask_t, &gw_t, pcapif, pcapif_init, netif_input_data); #if LWIP_NETIF_STATUS_CALLBACK netif_set_status_callback(netif, status_callback); diff --git a/srcs/lwip/src/arch_linux/netif/rawif.c b/srcs/lwip/src/arch_linux/netif/rawif.c index 10f4bd2..03bb1ea 100644 --- a/srcs/lwip/src/arch_linux/netif/rawif.c +++ b/srcs/lwip/src/arch_linux/netif/rawif.c @@ -95,6 +95,7 @@ struct sockaddr_ll { unsigned char sll_addr[8]; }; + typedef struct { unsigned int vni; unsigned char *output_head; @@ -218,6 +219,7 @@ static void low_level_init(struct netif *netif) { * */ /*-----------------------------------------------------------------------------------*/ +#if 0 static unsigned short udp_checksum(unsigned char *pNetPacket, unsigned int uLen) { unsigned int iLen = uLen - sizeof(struct eth_hdr) - sizeof(struct ip_hdr) + 12; unsigned short sum = 0; @@ -245,9 +247,10 @@ static unsigned short udp_checksum(unsigned char *pNetPacket, unsigned int uLen) } return sum; } +#endif static err_t low_level_output(struct netif *netif, struct pbuf *p) { - unsigned char sndBuf[1518]; +// unsigned char sndBuf[1518]; unsigned char buf[1518]; /* max packet size including VLAN excluding CRC */ ssize_t written = 0; struct sockaddr_ll dstAddr; @@ -536,6 +539,7 @@ static void link_callback(struct netif *state_netif) { } #endif /* LWIP_NETIF_LINK_CALLBACK */ +#if 0 static struct pbuf *vxlan_unpackag(const unsigned char *pBuf, int size) { struct pbuf *q; unsigned char buf[1500]; @@ -559,6 +563,7 @@ static struct pbuf *vxlan_unpackag(const unsigned char *pBuf, int size) { } return q; } +#endif static err_t netif_input_data(struct pbuf *p, struct netif *inp) { err_t err; diff --git a/srcs/pppoe/vcpe_pppoe.c b/srcs/pppoe/vcpe_pppoe.c index 80de872..3d6325f 100644 --- a/srcs/pppoe/vcpe_pppoe.c +++ b/srcs/pppoe/vcpe_pppoe.c @@ -260,7 +260,7 @@ int pppoe_session_init() { static uv_thread_t uvThread, cacheThread; uv_rwlock_init(&g_cacheLock); - g_rawSocketIf = bind_pcap_if(config_get_vxlan_nic_name(), config_get_vxlan_pkg_filter()); + g_rawSocketIf = bind_pcap_if(config_get_vxlan_nic_name(), config_get_vxlan_pkg_filter(), cfg_get_support_vxlan()); if (g_rawSocketIf) { dzlog_info("Create Raw Socket netif: <%p>\n", (void *)g_rawSocketIf); diff --git a/srcs/user/user_info.c b/srcs/user/user_info.c index 2b51b5b..3a2b606 100644 --- a/srcs/user/user_info.c +++ b/srcs/user/user_info.c @@ -19,10 +19,10 @@ static USER_PARAMS g_userInfo[] = { void user_info_init() { uv_rwlock_init(&g_userLock); - //user_info_add(0, &g_userInfo[0]); - //user_info_add(1, &g_userInfo[1]); + user_info_add(0, &g_userInfo[0]); + user_info_add(1, &g_userInfo[1]); //user_info_add(2, &g_userInfo[2]); - user_info_add(3, &g_userInfo[3]); + //user_info_add(3, &g_userInfo[3]); } void user_info_change_status(PUSER_INFO_CONTEXT pInfo, USER_STATUS status) { diff --git a/srcs/vcpe_agent.c b/srcs/vcpe_agent.c index cd04fe5..80d5dea 100644 --- a/srcs/vcpe_agent.c +++ b/srcs/vcpe_agent.c @@ -48,7 +48,7 @@ static int data_mq_init(void) { return -ERR_MQ_CREATE_MQ; } - g_pResponse = zmq_socket(g_pContext, ZMQ_REP); + g_pResponse = zmq_socket(g_pContext, ZMQ_PAIR); if (g_pResponse == NULL) { zmq_ctx_destroy(g_pContext); @@ -57,8 +57,8 @@ static int data_mq_init(void) { memset(buf, 0, 1024); - sprintf(buf, "tcp://*:6279"); - printf("Start message data channel server: tcp://*:6279\n"); + sprintf(buf, "ipc:///tmp/msg_fifo0"); + printf("Start message data channel server: ipc:///tmp/msg_fifo0\n"); if (zmq_bind(g_pResponse, buf) != 0) {