REM:
1. 可以根据下发的配置增加vxLan信息
2. vxLan用户信息为空时,网卡走普通数据包模式
This commit is contained in:
huangxin 2022-06-14 09:14:03 +08:00
parent f6b5fe515c
commit 6ee38533ed
4 changed files with 22 additions and 24 deletions

View File

@ -45,7 +45,7 @@ application:
zero_mq: zero_mq:
{ {
svr_port = 6278; # ZeroMQ 服务器端口 svr_port = 6278; # ZeroMQ 服务器端口
agent_addr = "ipc:///tmp/msg_fifo0"; # 消息通道路径 agent_addr = "ipc:///tmp/msg_fifo1"; # 消息通道路径
}; };
# vxlan 相关 # vxlan 相关

View File

@ -14,6 +14,7 @@
#include "pppoe_info.h" #include "pppoe_info.h"
#include "user_errno.h" #include "user_errno.h"
#include "user_info.h" #include "user_info.h"
#include "vxlan_pkg.h"
#define AGENT_CMD_ADDUSER ("add-ywg-pppoe-vcpe") #define AGENT_CMD_ADDUSER ("add-ywg-pppoe-vcpe")
@ -247,7 +248,6 @@ static void process_data_msg(void *UNUSED(pDataCh), zmq_msg_t *pMsg) {
PADD_INFO pInfo = &(p->pInfo[m]); PADD_INFO pInfo = &(p->pInfo[m]);
for (n = 0; n < pInfo->userCount; n++) { for (n = 0; n < pInfo->userCount; n++) {
PADD_USER_USER pUser = &(pInfo->pUser[n]); PADD_USER_USER pUser = &(pInfo->pUser[n]);
#if 1
USER_PARAMS userInfo; USER_PARAMS userInfo;
memset(&userInfo, 0, sizeof(USER_PARAMS)); memset(&userInfo, 0, sizeof(USER_PARAMS));
@ -259,8 +259,8 @@ static void process_data_msg(void *UNUSED(pDataCh), zmq_msg_t *pMsg) {
userInfo.q1 = pUser->c_tag_in; userInfo.q1 = pUser->c_tag_in;
userInfo.q2 = pUser->s_tag_in; userInfo.q2 = pUser->s_tag_in;
str_to_mac(pUser->clientMac, userInfo.mac_addr); str_to_mac(pUser->clientMac, userInfo.mac_addr);
vxlan_peer_add(pUser->vni, pInfo->vxlan.vsvxlanIP, pInfo->vxlan.vsvxlanMac);
user_info_add(userInfo.userid, &userInfo); user_info_add(userInfo.userid, &userInfo);
#endif
} }
} }
free_add_user(p); free_add_user(p);

View File

@ -197,15 +197,14 @@ static err_t low_level_output(struct netif *netif, struct pbuf *p) {
if (pBuf && outSize != 0) { if (pBuf && outSize != 0) {
written = pcap_inject(pcapif->pcap, pBuf, outSize); written = pcap_inject(pcapif->pcap, pBuf, outSize);
}
free(pBuf); free(pBuf);
return written == (outSize) ? ERR_OK : ERR_IF; return written == (outSize) ? ERR_OK : ERR_IF;
} else { }
}
written = pcap_inject(pcapif->pcap, buf, p->tot_len); written = pcap_inject(pcapif->pcap, buf, p->tot_len);
return (written == p->tot_len) ? ERR_OK : ERR_IF; return (written == p->tot_len) ? ERR_OK : ERR_IF;
}
} }
err_t pcapif_output(struct netif *netif, struct pbuf *p) { err_t pcapif_output(struct netif *netif, struct pbuf *p) {
@ -310,6 +309,7 @@ static void link_callback(struct netif *state_netif) {
static err_t netif_input_data(struct pbuf *p, struct netif *inp) { static err_t netif_input_data(struct pbuf *p, struct netif *inp) {
err_t err = ERR_OK; err_t err = ERR_OK;
struct netif *netif;
struct pcapif *pcapif = (struct pcapif *)inp->state; struct pcapif *pcapif = (struct pcapif *)inp->state;
const unsigned char *pBuf = (const unsigned char *)p->payload; const unsigned char *pBuf = (const unsigned char *)p->payload;
@ -331,9 +331,9 @@ static err_t netif_input_data(struct pbuf *p, struct netif *inp) {
if (ebuf == NULL) { if (ebuf == NULL) {
return ERR_IF; return ERR_IF;
} else { } else {
struct eth_hdr* eth = (struct eth_hdr*)ebuf->payload; struct eth_hdr *eth = (struct eth_hdr *)ebuf->payload;
if(strlen(pContext->session.data.svrBaseMac) == 0) { if (strlen(pContext->session.data.svrBaseMac) == 0) {
if (strlen(pContext->session.data.svrBaseMac) == 0) { if (strlen(pContext->session.data.svrBaseMac) == 0) {
sprintf(pContext->session.data.svrBaseMac, sprintf(pContext->session.data.svrBaseMac,
"%02X:%02X:%02X:%02X:%02X:%02X", "%02X:%02X:%02X:%02X:%02X:%02X",
@ -354,8 +354,8 @@ static err_t netif_input_data(struct pbuf *p, struct netif *inp) {
pbuf_free(p); pbuf_free(p);
return err; return err;
} }
} else { }
struct netif *netif;
NETIF_FOREACH(netif) { NETIF_FOREACH(netif) {
if (netif->hwaddr_len == 6 && memcmp(p->payload, netif->hwaddr, netif->hwaddr_len) == 0) { if (netif->hwaddr_len == 6 && memcmp(p->payload, netif->hwaddr, netif->hwaddr_len) == 0) {
@ -367,7 +367,6 @@ static err_t netif_input_data(struct pbuf *p, struct netif *inp) {
return err; return err;
} }
} }
}
return tcpip_input(p, inp); return tcpip_input(p, inp);
} }

View File

@ -145,7 +145,6 @@ _Noreturn void sessionCalcCb(void *UNUSED(pArg)) {
case STATUS_TASK_INIT: case STATUS_TASK_INIT:
if (pppoe_session_create(pUser) == ERR_SUCCESS) { if (pppoe_session_create(pUser) == ERR_SUCCESS) {
dzlog_debug("User(%05d:%s) init pppoe session\n", pUser->userid, pUser->user_info.pppoe_user); dzlog_debug("User(%05d:%s) init pppoe session\n", pUser->userid, pUser->user_info.pppoe_user);
vxlan_peer_add(pUser->vxlan.vni, config_get_vxlan_peer_ip(), config_get_vxlan_peer_mac());
pSession->status = STATUS_TASK_DIAL; pSession->status = STATUS_TASK_DIAL;
} }
break; break;