keepalive
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "hard_keepalive.h"
|
||||
|
||||
int udp_socket_recv(int sockfd, uint32_t *src_ip, uint8_t *buf, uint32_t buf_size)
|
||||
int udp_socket_recv(int sockfd, uint32_t *src_ip, uint16_t *src_port, uint8_t *buf, uint32_t buf_size)
|
||||
{
|
||||
if (NULL == buf) return -1;
|
||||
|
||||
@@ -32,7 +32,8 @@ int udp_socket_recv(int sockfd, uint32_t *src_ip, uint8_t *buf, uint32_t buf_siz
|
||||
perror("recvfrom");
|
||||
return -1;
|
||||
}
|
||||
*src_ip = ((struct sockaddr_in *)&their_addr)->sin_addr.s_addr;
|
||||
*src_ip = ((struct sockaddr_in *)&their_addr)->sin_addr.s_addr;
|
||||
*src_port = ((struct sockaddr_in *)&their_addr)->sin_port;
|
||||
return numbytes;
|
||||
}
|
||||
|
||||
@@ -92,17 +93,6 @@ int create_recv_udp_socket(uint16_t port)
|
||||
return sockfd;
|
||||
}
|
||||
|
||||
|
||||
int create_send_udp_socket()
|
||||
{
|
||||
int sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (-1 == sockfd)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return sockfd;
|
||||
}
|
||||
|
||||
void* thread_hard_keepalive(void *param)
|
||||
{
|
||||
char buf[1500] = {0};
|
||||
@@ -110,12 +100,12 @@ void* thread_hard_keepalive(void *param)
|
||||
bfd_port_t* bfd_port = (bfd_port_t*)param;
|
||||
int size = 0;
|
||||
uint32_t src_ip = 0;
|
||||
uint16_t src_port = 0;
|
||||
int send_rec = 0;
|
||||
fd_set rset;
|
||||
int recv_pkt_sd = create_recv_udp_socket(htons(bfd_port->recv_port));
|
||||
int send_pkt_sd = create_send_udp_socket();
|
||||
|
||||
if(-1==recv_pkt_sd || -1==send_pkt_sd)
|
||||
if(-1==recv_pkt_sd)
|
||||
{
|
||||
printf("hard_keepalive create socket error.\n");
|
||||
return NULL;
|
||||
@@ -131,16 +121,16 @@ void* thread_hard_keepalive(void *param)
|
||||
}
|
||||
if(FD_ISSET(recv_pkt_sd, &rset))
|
||||
{
|
||||
size = udp_socket_recv(recv_pkt_sd, &src_ip, (unsigned char*)buf, sizeof(buf));
|
||||
size = udp_socket_recv(recv_pkt_sd, &src_ip, &src_port, (unsigned char*)buf, sizeof(buf));
|
||||
if(size>0)
|
||||
{
|
||||
/*<2A><><EFBFBD><EFBFBD>discriminator*/
|
||||
memcpy(discriminator_temp, buf+MY_ID_OFFSET, ID_SIZE);
|
||||
memcpy(buf+MY_ID_OFFSET, buf+YOUR_ID_OFFSET, ID_SIZE);
|
||||
memcpy(buf+YOUR_ID_OFFSET, discriminator_temp, ID_SIZE);
|
||||
send_rec = udp_socket_send(send_pkt_sd,
|
||||
send_rec = udp_socket_send(recv_pkt_sd,
|
||||
src_ip,
|
||||
htons(bfd_port->send_port),
|
||||
src_port,
|
||||
(char*)buf,size);
|
||||
if(-1==send_rec)
|
||||
{
|
||||
|
||||
@@ -42,8 +42,8 @@ const char* frag_rssb_version = "2018-08-13T09:00:00";
|
||||
const char* frag_rssb_version_time = "2018-08-13T09:00:00";
|
||||
const char* frag_rssb_version_des = "MESA@iie rssb_maskey";
|
||||
|
||||
int FRAG_RSSB_VERSION_1_0_20180927 = 0;
|
||||
const char* frag_rssb_version_time_in = "2018-09-27";
|
||||
int FRAG_RSSB_VERSION_1_0_20181008 = 0;
|
||||
const char* frag_rssb_version_time_in = "2018-10-08";
|
||||
const char* frag_rssb_version_des_in = "hard balance";
|
||||
void frag_rssb_history()
|
||||
{
|
||||
@@ -741,7 +741,6 @@ int read_conf_and_init(const char* filename)
|
||||
MESA_load_profile_uint_def(filename, "WLB", "wlb_report_interval", (unsigned int*)&g_frag_cfg.wlb_report_interval,10);
|
||||
MESA_load_profile_uint_def(filename, "WLB", "enable_override", (unsigned int*)&g_frag_cfg.enable_override,0);
|
||||
MESA_load_profile_uint_def(filename, "WLB", "bfd_recv_port", (unsigned int*)&g_frag_cfg.bfd_recv_port,0);
|
||||
MESA_load_profile_uint_def(filename, "WLB", "bfd_send_port", (unsigned int*)&g_frag_cfg.bfd_send_port,0);
|
||||
|
||||
/*send bizman :<3A><>ƴװ<C6B4><D7B0>ǰ<EFBFBD>˷<EFBFBD><CBB7><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>˿<EFBFBD>*/
|
||||
MESA_load_profile_short_def(filename, "NETWORK", "BizmanAckPort", (short*)&g_frag_cfg.bizman_ack_port,22084);
|
||||
@@ -1282,11 +1281,10 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if(g_frag_cfg.bfd_recv_port>0 && g_frag_cfg.bfd_send_port>0)
|
||||
if(g_frag_cfg.bfd_recv_port>0)
|
||||
{
|
||||
bfd_port_t bfd_port;
|
||||
bfd_port.recv_port = g_frag_cfg.bfd_recv_port;
|
||||
bfd_port.send_port = g_frag_cfg.bfd_send_port;
|
||||
hard_keepalive_run(&bfd_port);
|
||||
}
|
||||
|
||||
|
||||
@@ -242,7 +242,6 @@ typedef struct frag_rssb_configure_s
|
||||
int16_t save_media;
|
||||
|
||||
uint32_t bfd_recv_port;
|
||||
uint32_t bfd_send_port;
|
||||
}frag_rssb_configure_t;
|
||||
|
||||
typedef struct frag_rssb_status_s
|
||||
|
||||
Reference in New Issue
Block a user