summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwangmenglan <[email protected]>2023-12-22 17:08:25 +0800
committerwangmenglan <[email protected]>2023-12-22 18:00:03 +0800
commitcb33c3d5a10db8cb3dcdb83b9375c7c9bb586f99 (patch)
treedf56dcaa628b6936fc853f1d69caccaecf966546
parentb3634ff0763a7c33093c9dbd7ce0e2c53b65c2b6 (diff)
OBP support 'auto', 'force-bypass' and 'force-pass'; Optimize the signal handling function.
-rw-r--r--service/CMakeLists.txt2
-rw-r--r--service/include/olp_dev.h5
-rw-r--r--service/src/core.c71
-rw-r--r--service/src/olp.c8
-rw-r--r--service/src/olp_6500.c300
-rw-r--r--service/test/TestOLP.cc60
6 files changed, 291 insertions, 155 deletions
diff --git a/service/CMakeLists.txt b/service/CMakeLists.txt
index 51080fd..e283869 100644
--- a/service/CMakeLists.txt
+++ b/service/CMakeLists.txt
@@ -19,7 +19,7 @@ target_include_directories(mrzcpd INTERFACE ${SYSTEMD_INCLUDE_DIRS})
install(TARGETS mrzcpd RUNTIME DESTINATION ${MR_INSTALL_BINDIR_RELATIVE_PATH} COMPONENT Program)
-add_executable(TestOLP test/TestOLP.cc src/olp_6500.c )
+add_executable(TestOLP test/TestOLP.cc src/olp_6500.c)
target_link_libraries(TestOLP gtest_main MESA_prof_load_static ${SYSTEMD_LIBRARIES} ${DPDK_LIBRARY})
target_link_libraries(TestOLP rt pthread dl infra z elf)
target_include_directories(TestOLP PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include/")
diff --git a/service/include/olp_dev.h b/service/include/olp_dev.h
index 406ff26..0fe195a 100644
--- a/service/include/olp_dev.h
+++ b/service/include/olp_dev.h
@@ -29,9 +29,9 @@ enum olp_used_state
enum olp_channel_state
{
- OLP_CHANNEL_STATE_FORCE_INLINE,
+ OLP_CHANNEL_STATE_AUTO,
+ OLP_CHANNEL_STATE_FORCE_PASS,
OLP_CHANNEL_STATE_FORCE_BYPASS,
- OLP_CHANNEL_STATE_TAP,
};
enum olp_channel_heartbeat
@@ -49,6 +49,7 @@ enum olp_channel_nonrevertive_mode
struct olp_channel_timer
{
int enable;
+ int fd;
};
struct channel_runtime
diff --git a/service/src/core.c b/service/src/core.c
index eb9ad94..e1e4059 100644
--- a/service/src/core.c
+++ b/service/src/core.c
@@ -9,6 +9,7 @@
#include <rte_service_component.h>
#include <rte_version.h>
#include <signal.h>
+#include <sys/signalfd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/prctl.h>
@@ -113,6 +114,7 @@ const char service_git_version[] = "";
#define MR_SERVICE_DEFAULT_PKT_LATENCY 0
#endif
+int mr_config_init_ready = 0;
unsigned int g_logger_to_stdout = 1;
unsigned int g_logger_level = LOG_DEBUG;
unsigned int g_monit_interval = 1;
@@ -873,10 +875,70 @@ __rte_unused static void signal_handler(int signum)
g_keep_running = 0;
}
-__rte_unused static void config_reload_handler(int signum)
+void * config_reload_handler(void * arg)
{
- olp_config_reload(g_sc_main);
- return;
+ ssize_t s;
+ uintptr_t sfd = (uintptr_t)arg;
+ struct signalfd_siginfo fdsi;
+
+ pthread_detach(pthread_self());
+
+ while (!mr_config_init_ready)
+ {
+ sleep(1);
+ }
+
+ while(1)
+ {
+ s = read(sfd, &fdsi, sizeof(fdsi));
+ if (s != sizeof(fdsi))
+ {
+ continue;
+ }
+
+ if (fdsi.ssi_signo != SIGHUP)
+ {
+ continue;
+ }
+
+ olp_config_reload(g_sc_main);
+ }
+
+ close(sfd);
+ return (void *)NULL;
+}
+
+int config_reload_thread()
+{
+ int sfd;
+ int ret = 0;
+ sigset_t mask;
+ pthread_t thread_id;
+
+ sigemptyset(&mask);
+ sigaddset(&mask, SIGHUP);
+
+ if (sigprocmask(SIG_BLOCK, &mask, NULL) == -1)
+ {
+ MR_ERROR("SIGHUP: sigprocmask failed : %s", strerror(errno));
+ return RT_ERR;
+ }
+
+ sfd = signalfd(-1, &mask, 0);
+ if (sfd == -1)
+ {
+ MR_ERROR("SIGHUP: signalfd failed : %s", strerror(errno));
+ return RT_ERR;
+ }
+
+ ret = pthread_create(&thread_id, NULL, config_reload_handler, (void *)(uintptr_t)sfd);
+ if (ret < 0)
+ {
+ MR_ERROR("config reload thread failed : %s", strerror(errno));
+ return RT_ERR;
+ }
+
+ return RT_SUCCESS;
}
extern int hwinfo_init(struct sc_main * sc);
@@ -989,7 +1051,7 @@ int main(int argc, char * argv[])
/* Exegesis the singnal for fast stop */
// signal(SIGINT, signal_handler);
// signal(SIGTERM, signal_handler);
- signal(SIGHUP, config_reload_handler);
+ config_reload_thread();
if (devmgr_early_init(sc) != RT_SUCCESS)
{
@@ -1221,6 +1283,7 @@ int main(int argc, char * argv[])
/* 采用NOTIFY方式启动,通知操作系统完成了初始化 */
if (__check_is_notify())
sd_notify(0, "READY=1");
+ mr_config_init_ready = 1;
sleep(1);
/* 死锁检测 */
diff --git a/service/src/olp.c b/service/src/olp.c
index e2b8438..57f6a26 100644
--- a/service/src/olp.c
+++ b/service/src/olp.c
@@ -31,12 +31,11 @@
#include <olp_dev.h>
struct olp_manager_main * g_olp_mgr_main;
-extern int g_olp6500_config_ready;
-int olp6500_init(struct olp_manager_main * olp_mgr_main, char * cfgfile);
+int olp6500_init(struct olp_manager_main * olp_mgr_main, char * local_cfgfile);
cJSON * olp6500_monit_loop(struct sc_main * sc_main);
int olp6500_set_used_state(struct olp_device * olp_dev, char * dev_sym, uint32_t channel_id);
-int olp6500_config_reload();
+int olp6500_set_reload_flag();
cJSON * olp_manager_monit_loop(struct sc_main * sc_main)
{
@@ -47,14 +46,13 @@ cJSON * olp_manager_monit_loop(struct sc_main * sc_main)
int olp_config_reload(struct sc_main * sc_main)
{
- olp6500_config_reload();
+ olp6500_set_reload_flag();
return RT_SUCCESS;
}
int olp_set_used(char * dev_sym, uint32_t channel_id)
{
olp6500_set_used_state(g_olp_mgr_main->olp6500_main, dev_sym, channel_id);
- __atomic_exchange_n(&g_olp6500_config_ready, 1, __ATOMIC_SEQ_CST);
return RT_SUCCESS;
}
diff --git a/service/src/olp_6500.c b/service/src/olp_6500.c
index 47d0198..a2c5f4f 100644
--- a/service/src/olp_6500.c
+++ b/service/src/olp_6500.c
@@ -42,15 +42,21 @@
#define OLP6500_CHANNEL_INFO_OBJECT (0x0200)
#define OLP6500_CHANNEL_CONF_OBJECT (0x0501)
-#define LINE_STATUS_INLINE (0x30)
-#define LINE_STATUS_BYPASS (0xc0)
+#define OLP6500_SET_LINE_INLINE (0x30)
+#define OLP6500_SET_LINE_BYPASS (0xc0)
-#define OLP6500_TIMER_ONE_CYCLE_US 5000
-#define OLP6500_RELOAD_CONFIG_CYCLE_US 1000
+#define OLP6500_LINE_STATUS_INLINE (0x03)
+#define OLP6500_LINE_STATUS_BYPASS (0x0c)
+
+#define OLP6500_TIMER_ONE_CYCLE_US 1000
+#define OLP6500_RELOAD_CONFIG_CYCLE_US 1000
#define OLP6500_LOAD_CONFIG_NOT_READY 0
#define OLP6500_LOAD_CONFIG_READY 1
+#define OLP6500_WORK_MODE_MANUL 1
+#define OLP6500_WORK_MODE_AUTO 2
+
enum
{
OLP_TIMER_DISABLE,
@@ -88,6 +94,7 @@ enum
OLP_ERR_CODE_HB_COUNT_INCONSISTENT = 5,
OLP_ERR_CODE_WORK_LINE_INCONSISTENT = 6,
OLP_ERR_CODE_SW_BACK_INCONSISTENT = 7,
+ OLP_ERR_CODE_WORK_MODE_INCONSISTENT = 8,
};
/*
@@ -242,10 +249,9 @@ struct olp6500_packet
};
}__attribute__((packed));
-char *g_cfgfile;
-int g_olp6500_config_ready;
+static char *g_dynamic_cfgfile;
int g_olp6500_config_reload;
-struct olp_device * g_olp6500_dev;
+pthread_mutex_t g_olp6500_lock;
uint16_t olp6500_object_map[OLP_OBJECT_MAX] = {
[OLP_SET_HEARTBEAT_SWITCH] = OLP6500_HEARTBEAT_SWITCH_OBJECT,
[OLP_SET_WORK_MODE] = OLP6500_WORK_MODE_OBJECT,
@@ -256,12 +262,7 @@ uint16_t olp6500_object_map[OLP_OBJECT_MAX] = {
[OLP_GET_CHANNEL_CONF] = OLP6500_CHANNEL_CONF_OBJECT,
};
-// void * heartbeat_recv_thread(void * args)
-// {
-// return NULL;
-// }
-
-char * str_olp_device_type(enum olp_device_type device_type)
+static char * str_olp_device_type(enum olp_device_type device_type)
{
switch(device_type)
{
@@ -274,7 +275,7 @@ char * str_olp_device_type(enum olp_device_type device_type)
}
}
-char * str_olp_connect_type(enum olp_connect_type conn_type)
+static char * str_olp_connect_type(enum olp_connect_type conn_type)
{
switch(conn_type)
{
@@ -289,22 +290,22 @@ char * str_olp_connect_type(enum olp_connect_type conn_type)
}
}
-char * str_olp_workline(enum olp_channel_state state)
+static char * str_olp_workmode(enum olp_channel_state state)
{
switch(state)
{
- case OLP_CHANNEL_STATE_FORCE_INLINE:
- return "INLINE";
+ case OLP_CHANNEL_STATE_AUTO:
+ return "AUTO";
+ case OLP_CHANNEL_STATE_FORCE_PASS:
+ return "FORCE-PASS";
case OLP_CHANNEL_STATE_FORCE_BYPASS:
- return "BYPASS";
- case OLP_CHANNEL_STATE_TAP:
- return "TAP";
+ return "FORCE-BYPASS";
default:
return "";
}
}
-char * str_olp_enable_or_disable(uint32_t value)
+static char * str_olp_enable_or_disable(uint32_t value)
{
if (value)
return "ENABLE";
@@ -312,7 +313,7 @@ char * str_olp_enable_or_disable(uint32_t value)
return "DISABLE";
}
-void olp6500_device_dump_one(struct olp_dev_desc * dev_desc, uint32_t channel_id)
+static void olp6500_device_dump_one(struct olp_dev_desc * dev_desc, uint32_t channel_id)
{
struct olp_channel * channel = NULL;
char str_ip_addr[INET_ADDRSTRLEN] = {0};
@@ -332,7 +333,7 @@ void olp6500_device_dump_one(struct olp_dev_desc * dev_desc, uint32_t channel_id
channel = &dev_desc->channels[channel_id];
MR_INFO("\tchannel_id:\t\t\t\t\t%u", channel->olp_channel_id);
MR_INFO("\t\tused:\t\t\t\t\t%d", channel->used);
- MR_INFO("\t\tworkline:\t\t\t\t%s", str_olp_workline(channel->state));
+ MR_INFO("\t\tworkmode:\t\t\t\t%s", str_olp_workmode(channel->state));
MR_INFO("\t\theartbeat_mode:\t\t\t\t%s", str_olp_enable_or_disable(channel->en_heartbeat));
MR_INFO("\t\theartbeat_send_interval_in_ms:\t\t%u", channel->heartbeat_send_interval_in_ms);
MR_INFO("\t\theartbeat_timeout_interval_in_ms:\t%u", channel->heartbeat_timeout_interval_in_ms);
@@ -340,7 +341,7 @@ void olp6500_device_dump_one(struct olp_dev_desc * dev_desc, uint32_t channel_id
MR_INFO("\t\tnonrevertive_mode:\t\t\t%s", str_olp_enable_or_disable(channel->nonrevertive_mode));
}
-void olp6500_device_dump(struct olp_device * olp_dev)
+__rte_unused static void olp6500_device_dump(struct olp_device * olp_dev)
{
struct olp_dev_desc * olp_dev_desc = NULL;
struct olp_channel * channel = NULL;
@@ -370,7 +371,7 @@ void olp6500_device_dump(struct olp_device * olp_dev)
}
MR_INFO("\tchannel_id:\t\t\t\t\t%u", channel->olp_channel_id);
MR_INFO("\t\tused:\t\t\t\t\t%d", channel->used);
- MR_INFO("\t\tworkline:\t\t\t\t%s", str_olp_workline(channel->state));
+ MR_INFO("\t\tworkmode:\t\t\t\t%s", str_olp_workmode(channel->state));
MR_INFO("\t\theartbeat_mode:\t\t\t\t%s", str_olp_enable_or_disable(channel->en_heartbeat));
MR_INFO("\t\theartbeat_send_interval_in_ms:\t\t%u", channel->heartbeat_send_interval_in_ms);
MR_INFO("\t\theartbeat_timeout_interval_in_ms:\t%u", channel->heartbeat_timeout_interval_in_ms);
@@ -380,7 +381,7 @@ void olp6500_device_dump(struct olp_device * olp_dev)
}
}
-struct olp_dev_desc * olp6500_find_device_by_symbol(struct olp_device * olp_dev, char * olp_dev_sym)
+static struct olp_dev_desc * olp6500_find_device_by_symbol(struct olp_device * olp_dev, char * olp_dev_sym)
{
struct olp_dev_desc * dev_desc = NULL;
@@ -396,7 +397,7 @@ struct olp_dev_desc * olp6500_find_device_by_symbol(struct olp_device * olp_dev,
return NULL;
}
-char *olp6500_str_object(uint16_t object)
+static char *olp6500_str_object(uint16_t object)
{
switch(object)
{
@@ -438,11 +439,10 @@ int olp6500_check_recv_data(char * buff, uint16_t object)
return RT_SUCCESS;
}
-int olp6500_send_command_over_network_sync(struct olp_dev_desc * dev_desc, char * send_buff, int send_len, char * recv_buff, int recv_len)
+static int olp6500_send_command_over_network_sync(struct olp_dev_desc * dev_desc, char * send_buff, int send_len, char * recv_buff, int recv_len)
{
int ret = 0;
int length = 0;
- // char str_ip_addr[INET_ADDRSTRLEN] = {0};
struct sockaddr_in addr = dev_desc->network.addr;
struct timeval timeout;
@@ -464,8 +464,6 @@ int olp6500_send_command_over_network_sync(struct olp_dev_desc * dev_desc, char
if (ret == -1)
{
- // inet_ntop(AF_INET, &(addr.sin_addr), str_ip_addr, INET_ADDRSTRLEN);
- // MR_ERROR("send request to [%s] fail: %s", str_ip_addr, strerror(errno));
goto errout;
}
@@ -475,8 +473,6 @@ int olp6500_send_command_over_network_sync(struct olp_dev_desc * dev_desc, char
if (length <= 0)
{
- // inet_ntop(AF_INET, &(addr.sin_addr), str_ip_addr, INET_ADDRSTRLEN);
- // MR_ERROR("recv from [%s] fail : %s", str_ip_addr, strerror(errno));
goto errout;
}
close(sock);
@@ -486,7 +482,7 @@ errout:
return RT_ERR;
}
-int olp6500_send_command_sync(struct olp_dev_desc * dev_desc, uint16_t object, char * send_buff, int send_len, char * recv_buff, int recv_len)
+static int olp6500_send_command_sync(struct olp_dev_desc * dev_desc, uint16_t object, char * send_buff, int send_len, char * recv_buff, int recv_len)
{
int length = 0;
@@ -509,7 +505,7 @@ int olp6500_send_command_sync(struct olp_dev_desc * dev_desc, uint16_t object, c
return olp6500_check_recv_data(recv_buff, object);
}
-int olp6500_construct_packet(struct olp_channel * channel, int object, char * buff)
+int olp6500_packet_construct(struct olp_channel * channel, int object, char * buff)
{
int length = 0;
struct olp6500_packet * pkt = (struct olp6500_packet *)buff;
@@ -546,18 +542,18 @@ int olp6500_construct_packet(struct olp_channel * channel, int object, char * bu
pkt->port = 0;
pkt->len = 1;
- if (channel->en_heartbeat == OLP_CHANNEL_HEARTBEAT_DISABLE)
+ if (channel->state == OLP_CHANNEL_STATE_AUTO)
{
- pkt->work_mode.mode = 1;
+ pkt->work_mode.mode = 2;
}
else
{
- pkt->work_mode.mode = 2;
+ pkt->work_mode.mode = 1;
}
length = 7;
break;
case OLP_SET_WORK_LINE:
- if (channel->en_heartbeat == OLP_CHANNEL_HEARTBEAT_DISABLE)
+ if (channel->state != OLP_CHANNEL_STATE_AUTO)
{
pkt->action = OLP_CONFIG_SET;
pkt->slot = channel->olp_channel_id;
@@ -565,13 +561,13 @@ int olp6500_construct_packet(struct olp_channel * channel, int object, char * bu
pkt->port = 0;
pkt->len = 1;
- if (channel->state == OLP_CHANNEL_STATE_FORCE_INLINE)
+ if (channel->state == OLP_CHANNEL_STATE_FORCE_PASS)
{
- pkt->work_line.line_status = LINE_STATUS_INLINE;
+ pkt->work_line.line_status = OLP6500_SET_LINE_INLINE;
}
else if (channel->state == OLP_CHANNEL_STATE_FORCE_BYPASS)
{
- pkt->work_line.line_status = LINE_STATUS_BYPASS;
+ pkt->work_line.line_status = OLP6500_SET_LINE_BYPASS;
}
else
{
@@ -618,7 +614,40 @@ out:
return length;
}
-void olp6500_send_heartbeat_handler(int socket, struct olp_channel * channel)
+static void * olp6500_recv_heartbeat_handler(void * args)
+{
+ pthread_detach(pthread_self());
+
+ struct olp_channel * channel = (struct olp_channel *)args;
+ struct olp_dev_desc * dev_desc = channel->dev_desc;
+ int len = 0;
+ int sock = channel->timer.fd;
+ char buff[BUFF_MAX] = {0};
+
+ __atomic_fetch_add(&dev_desc->refcnt, 1, __ATOMIC_RELAXED);
+ while(__atomic_load_n(&channel->timer.enable, __ATOMIC_RELAXED) == OLP_TIMER_ENABLE)
+ {
+ usleep(OLP6500_TIMER_ONE_CYCLE_US);
+ len = recvfrom(sock, buff, BUFF_MAX-1, 0, NULL, 0);
+ if (len == -1)
+ {
+ continue;
+ }
+
+ struct olp6500_packet * pkt = (struct olp6500_packet *)buff;
+ if (pkt->object != htons(OLP6500_HEARTBEAT_PACKET_OBJECT))
+ {
+ continue;
+ }
+ struct timespec last_active_time;
+ clock_gettime(CLOCK_REALTIME, &last_active_time);
+ channel->runtime.last_active_time = last_active_time;
+ }
+ __atomic_fetch_sub(&dev_desc->refcnt, 1, __ATOMIC_RELAXED);
+ return NULL;
+}
+
+static void olp6500_send_heartbeat(int socket, struct olp_channel * channel)
{
int ret = 0;
int pkt_len = 0;
@@ -626,7 +655,7 @@ void olp6500_send_heartbeat_handler(int socket, struct olp_channel * channel)
struct olp_dev_desc * dev_desc = channel->dev_desc;
struct sockaddr_in * addr = &dev_desc->network.addr;
- pkt_len = olp6500_construct_packet(channel, OLP_HEARTBEAT_PACKET, buff);
+ pkt_len = olp6500_packet_construct(channel, OLP_HEARTBEAT_PACKET, buff);
if (pkt_len <= 0)
{
return;
@@ -646,7 +675,7 @@ void olp6500_send_heartbeat_handler(int socket, struct olp_channel * channel)
return;
}
-void * olp6500_cycle_send_heartbeat(void * args)
+static void * olp6500_send_heartbeat_handler(void * args)
{
pthread_detach(pthread_self());
@@ -656,9 +685,11 @@ void * olp6500_cycle_send_heartbeat(void * args)
struct timespec send_pkt_last_time;
struct timespec interval_time;
struct timeval timeout;
+ pthread_t tid;
+ int ret = 0;
+
timeout.tv_sec = 5;
timeout.tv_usec = 0;
-
memset(&send_pkt_last_time, 0, sizeof(send_pkt_last_time));
int sock = socket(AF_INET, SOCK_DGRAM, 0);
@@ -670,6 +701,14 @@ void * olp6500_cycle_send_heartbeat(void * args)
setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout));
setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));
+ channel->timer.fd = sock;
+ ret = pthread_create(&tid, NULL, olp6500_recv_heartbeat_handler, (void *)channel);
+ if (ret < 0)
+ {
+ MR_ERROR("OLP_6500 create receive heartbeat packet thread failed : %s", strerror(errno));
+ return NULL;
+ }
+
__atomic_fetch_add(&dev_desc->refcnt, 1, __ATOMIC_RELAXED);
while(__atomic_load_n(&channel->timer.enable, __ATOMIC_RELAXED) == OLP_TIMER_ENABLE)
{
@@ -677,11 +716,8 @@ void * olp6500_cycle_send_heartbeat(void * args)
timespec_diff(&send_pkt_last_time, &current_time, &interval_time);
if ((interval_time.tv_sec * 1000 + interval_time.tv_nsec/1000/1000) >= channel->heartbeat_send_interval_in_ms)
{
+ olp6500_send_heartbeat(sock, channel);
send_pkt_last_time = current_time;
- struct timespec last_active_time;
- clock_gettime(CLOCK_REALTIME, &last_active_time);
- olp6500_send_heartbeat_handler(sock, channel);
- channel->runtime.last_active_time = last_active_time;
}
usleep(OLP6500_TIMER_ONE_CYCLE_US);
}
@@ -690,7 +726,7 @@ void * olp6500_cycle_send_heartbeat(void * args)
return NULL;
}
-int olp6500_create_thread_send_heartbeat(struct olp_channel * channel)
+static int olp6500_heartbeat_thread_create(struct olp_channel * channel)
{
int ret = 0;
pthread_t tid;
@@ -701,7 +737,7 @@ int olp6500_create_thread_send_heartbeat(struct olp_channel * channel)
}
__atomic_exchange_n(&channel->timer.enable, OLP_TIMER_ENABLE, __ATOMIC_SEQ_CST);
- ret = pthread_create(&tid, NULL, olp6500_cycle_send_heartbeat, (void *)channel);
+ ret = pthread_create(&tid, NULL, olp6500_send_heartbeat_handler, (void *)channel);
if (ret < 0)
{
MR_ERROR("OLP_6500 create send heartbeat packet thread failed : %s", strerror(errno));
@@ -720,21 +756,21 @@ int olp6500_apply_control_command_to_peer(struct olp_dev_desc * dev_desc, uint32
channel = &dev_desc->channels[channel_id];
- pkt_len = olp6500_construct_packet(channel, OLP_SET_HEARTBEAT_SWITCH, buff);
+ pkt_len = olp6500_packet_construct(channel, OLP_SET_HEARTBEAT_SWITCH, buff);
ret = olp6500_send_command_sync(dev_desc, OLP_SET_HEARTBEAT_SWITCH, buff, pkt_len, buff, BUFF_MAX);
if (ret != RT_SUCCESS)
{
goto errout;
}
- pkt_len = olp6500_construct_packet(channel, OLP_SET_WORK_MODE, buff);
+ pkt_len = olp6500_packet_construct(channel, OLP_SET_WORK_MODE, buff);
ret = olp6500_send_command_sync(dev_desc, OLP_SET_WORK_MODE, buff, pkt_len, buff, BUFF_MAX);
if (ret != RT_SUCCESS)
{
goto errout;
}
- pkt_len = olp6500_construct_packet(channel, OLP_SET_WORK_LINE, buff);
+ pkt_len = olp6500_packet_construct(channel, OLP_SET_WORK_LINE, buff);
if (pkt_len > 0)
{
ret = olp6500_send_command_sync(dev_desc, OLP_SET_WORK_LINE, buff, pkt_len, buff, BUFF_MAX);
@@ -744,14 +780,14 @@ int olp6500_apply_control_command_to_peer(struct olp_dev_desc * dev_desc, uint32
}
}
- pkt_len = olp6500_construct_packet(channel, OLP_SET_SWITCHBACK_MODE, buff);
+ pkt_len = olp6500_packet_construct(channel, OLP_SET_SWITCHBACK_MODE, buff);
ret = olp6500_send_command_sync(dev_desc, OLP_SET_SWITCHBACK_MODE, buff, pkt_len, buff, BUFF_MAX);
if (ret != RT_SUCCESS)
{
goto errout;
}
- olp6500_create_thread_send_heartbeat(channel);
+ olp6500_heartbeat_thread_create(channel);
channel->runtime.errcode = OLP_SUCCESS;
return RT_SUCCESS;
errout:
@@ -768,23 +804,24 @@ errout:
return RT_ERR;
}
-void * _olp6500_retry_apply_control_command(void * args)
+static void * _olp6500_retry_apply_control_command(void * args)
{
+ struct olp_manager_main * olp_mgr_main = (struct olp_manager_main *)args;
struct olp_dev_desc * dev_desc = NULL;
struct olp_channel * channel = NULL;
+ struct olp_device * olp_dev = NULL;
+
+ pthread_detach(pthread_self());
while(1)
{
sleep(10);
- if (__atomic_load_n(&g_olp6500_config_ready, __ATOMIC_RELAXED) == OLP6500_LOAD_CONFIG_NOT_READY)
- {
- continue;
- }
-
- for (uint32_t i = 0; i < g_olp6500_dev->nr_olp_dev_descs; i++)
+ pthread_mutex_lock(&g_olp6500_lock);
+ olp_dev = olp_mgr_main->olp6500_main;
+ for (uint32_t i = 0; i < olp_dev->nr_olp_dev_descs; i++)
{
- dev_desc = g_olp6500_dev->olp_dev_descs[i];
+ dev_desc = olp_dev->olp_dev_descs[i];
__atomic_fetch_add(&dev_desc->refcnt, 1, __ATOMIC_RELAXED);
if (dev_desc->type != OLP_DEVICE_TYPE_OLP_6500 || dev_desc->used != OLP_STATE_USED)
@@ -806,22 +843,23 @@ void * _olp6500_retry_apply_control_command(void * args)
}
}
- for (uint32_t i = 0; i < g_olp6500_dev->nr_olp_dev_descs; i++)
+ for (uint32_t i = 0; i < olp_dev->nr_olp_dev_descs; i++)
{
- dev_desc = g_olp6500_dev->olp_dev_descs[i];
+ dev_desc = olp_dev->olp_dev_descs[i];
__atomic_fetch_sub(&dev_desc->refcnt, 1, __ATOMIC_RELAXED);
}
+ pthread_mutex_unlock(&g_olp6500_lock);
}
return NULL;
}
-int olp6500_retry_apply_control_command()
+static int olp6500_retry_apply_control_command(struct olp_manager_main * olp_mgr_main)
{
int ret = 0;
pthread_t tid;
- ret = pthread_create(&tid, NULL, _olp6500_retry_apply_control_command, NULL);
+ ret = pthread_create(&tid, NULL, _olp6500_retry_apply_control_command, olp_mgr_main);
if (ret < 0)
{
MR_ERROR("OLP_6500 create retry apply control command thread failed : %s", strerror(errno));
@@ -889,7 +927,7 @@ static int olp6500_channel_config_load(struct olp_dev_desc * olp_dev_desc, char
* in_addr = 1.1.1.1
* port = 6800
*/
-int olp6500_config_load(struct olp_device * olp_dev, char * cfgfile)
+static int olp6500_config_load(struct olp_device * olp_dev, char * cfgfile)
{
int ret = 0;
@@ -969,7 +1007,7 @@ int olp6500_set_used_state(struct olp_device * olp_dev, char * dev_sym, uint32_t
return RT_SUCCESS;
}
-int olp6500_copy_device_state(struct olp_device * src, struct olp_device * dst)
+static int olp6500_copy_device_state(struct olp_device * src, struct olp_device * dst)
{
struct olp_channel * channel = NULL;
struct olp_dev_desc * src_dev_desc = NULL;
@@ -1008,7 +1046,7 @@ int olp6500_copy_device_state(struct olp_device * src, struct olp_device * dst)
return RT_SUCCESS;
}
-int olp6500_get_optical_power( char * buff, struct olp_channel * channel)
+static int olp6500_get_optical_power( char * buff, struct olp_channel * channel)
{
struct olp6500_packet * pkt = (struct olp6500_packet *)buff;
if (pkt->object != htons(OLP6500_CHANNEL_INFO_OBJECT) || pkt->len != 17)
@@ -1029,7 +1067,7 @@ int olp6500_get_optical_power( char * buff, struct olp_channel * channel)
return RT_SUCCESS;
}
-int olp6500_check_channel_config(struct olp_channel * channel, char * buff, char *str_err_reason, int sz_err_reason)
+static int olp6500_check_channel_config(struct olp_channel * channel, char * buff, char *str_err_reason, int sz_err_reason)
{
struct olp6500_packet * pkt = (struct olp6500_packet *)buff;
struct olp_dev_desc * dev_desc = channel->dev_desc;
@@ -1064,9 +1102,9 @@ int olp6500_check_channel_config(struct olp_channel * channel, char * buff, char
if (pkt->channel_conf.heart_interval != (channel->heartbeat_timeout_interval_in_ms/20))
{
snprintf(str_err_reason, sz_err_reason, "The current device[%s:%u] configuration[heartbeat_timeout_interval_in_ms:%u] is inconsistent with the administrator's settings[heartbeat_timeout_interval_in_ms:%d].",
- dev_desc->devsym,
- channel->olp_channel_id,
- pkt->channel_conf.heart_interval*20,
+ dev_desc->devsym,
+ channel->olp_channel_id,
+ pkt->channel_conf.heart_interval*20,
channel->heartbeat_timeout_interval_in_ms);
if (channel->runtime.errcode != OLP_ERR_CODE_HB_INTERVAL_INCONSISTENT)
{
@@ -1099,23 +1137,62 @@ int olp6500_check_channel_config(struct olp_channel * channel, char * buff, char
return RT_ERR;
}
}
+
+ uint8_t channel_work_mode = 0;
+ if (channel->state == OLP_CHANNEL_STATE_AUTO)
+ {
+ channel_work_mode = OLP6500_WORK_MODE_AUTO;
+ }
else
{
- uint8_t channel_work_line = channel->state == OLP_CHANNEL_STATE_FORCE_INLINE ? 0x03 : 0x0c;
+ channel_work_mode = OLP6500_WORK_MODE_MANUL;
+ }
+
+ if (pkt->channel_conf.work_mode != channel_work_mode)
+ {
+ snprintf(str_err_reason, sz_err_reason, "The current device[%s:%u] configuration[workmode:%s] is inconsistent with the administrator's settings[workmode:%s].",
+ dev_desc->devsym,
+ channel->olp_channel_id,
+ pkt->channel_conf.work_mode==OLP6500_WORK_MODE_AUTO?"auto":"manual",
+ channel_work_mode==OLP6500_WORK_MODE_AUTO?"auto":"manual");
+ if (channel->runtime.errcode != OLP_ERR_CODE_WORK_MODE_INCONSISTENT)
+ {
+ MR_ERROR("The current device[%s:%u] configuration[workmode:%s] is inconsistent with the administrator's settings[workmode:%s].",
+ dev_desc->devsym,
+ channel->olp_channel_id,
+ pkt->channel_conf.work_mode==OLP6500_WORK_MODE_AUTO?"auto":"manual",
+ channel_work_mode==OLP6500_WORK_MODE_AUTO?"auto":"manual");
+ }
+ channel->runtime.errcode = OLP_ERR_CODE_WORK_MODE_INCONSISTENT;
+ return RT_ERR;
+ }
+
+ if (channel->state != OLP_CHANNEL_STATE_AUTO)
+ {
+ uint8_t channel_work_line = 0;
+ if (channel->state == OLP_CHANNEL_STATE_FORCE_PASS)
+ {
+ channel_work_line = OLP6500_LINE_STATUS_INLINE;
+ }
+ else if (channel->state == OLP_CHANNEL_STATE_FORCE_BYPASS)
+ {
+ channel_work_line = OLP6500_LINE_STATUS_BYPASS;
+ }
+
if (pkt->channel_conf.work_line != channel_work_line)
{
snprintf(str_err_reason, sz_err_reason, "The current device[%s:%u] configuration[workline:%s] is inconsistent with the administrator's settings[workline:%s].",
dev_desc->devsym,
channel->olp_channel_id,
- pkt->channel_conf.work_line==0x03?"inline":"bypass",
- channel_work_line==0x03?"inline":"bypass");
+ pkt->channel_conf.work_line==OLP6500_LINE_STATUS_INLINE?"inline":"bypass",
+ channel_work_line==OLP6500_LINE_STATUS_INLINE?"inline":"bypass");
if (channel->runtime.errcode != OLP_ERR_CODE_WORK_LINE_INCONSISTENT)
{
MR_ERROR("The current device[%s:%u] configuration[workline:%s] is inconsistent with the administrator's settings[workline:%s].",
dev_desc->devsym,
channel->olp_channel_id,
- pkt->channel_conf.work_line==0x03?"inline":"bypass",
- channel_work_line==0x03?"inline":"bypass");
+ pkt->channel_conf.work_line==OLP6500_LINE_STATUS_INLINE?"inline":"bypass",
+ channel_work_line==OLP6500_LINE_STATUS_INLINE?"inline":"bypass");
}
channel->runtime.errcode = OLP_ERR_CODE_WORK_LINE_INCONSISTENT;
return RT_ERR;
@@ -1155,17 +1232,14 @@ cJSON * olp6500_monit_loop(struct sc_main * sc_main)
char str_optical_power[16] = {0};
struct olp_dev_desc * dev_desc = NULL;
struct olp_channel * channel = NULL;
- struct olp_device * olp_dev = sc_main->olp_mgr_main->olp6500_main;
+ struct olp_device * olp_dev = NULL;
cJSON * j_obp_device = NULL;
cJSON * j_channel = NULL;
struct cJSON * j_obp_device_array = cJSON_CreateArray();
struct cJSON * j_channel_array = NULL;
- if (__atomic_load_n(&g_olp6500_config_ready, __ATOMIC_RELAXED) == OLP6500_LOAD_CONFIG_NOT_READY)
- {
- goto end;
- }
-
+ pthread_mutex_lock(&g_olp6500_lock);
+ olp_dev = sc_main->olp_mgr_main->olp6500_main;
for (int index = 0; index < olp_dev->nr_olp_dev_descs; index++)
{
dev_desc = olp_dev->olp_dev_descs[index];
@@ -1200,7 +1274,7 @@ cJSON * olp6500_monit_loop(struct sc_main * sc_main)
continue;
}
- pkt_len = olp6500_construct_packet(channel, OLP_GET_CHANNEL_INFO, buff);
+ pkt_len = olp6500_packet_construct(channel, OLP_GET_CHANNEL_INFO, buff);
ret = olp6500_send_command_sync(dev_desc, OLP_GET_CHANNEL_INFO, buff, pkt_len, buff, BUFF_MAX);
if (ret != RT_SUCCESS)
{
@@ -1229,10 +1303,10 @@ cJSON * olp6500_monit_loop(struct sc_main * sc_main)
cJSON_AddNumberToObject(j_channel, "channel_id", channel->olp_channel_id);
switch (channel->runtime.workline)
{
- case 0x03:
+ case OLP6500_LINE_STATUS_INLINE:
cJSON_AddStringToObject(j_channel, "workline", "inline");
break;
- case 0x0c:
+ case OLP6500_LINE_STATUS_BYPASS:
cJSON_AddStringToObject(j_channel, "workline", "bypass");
break;
default:
@@ -1250,7 +1324,7 @@ cJSON * olp6500_monit_loop(struct sc_main * sc_main)
snprintf(str_time, sizeof(str_time), "%ld", channel->runtime.last_active_time.tv_sec);
cJSON_AddStringToObject(j_channel, "last_active_time", str_time);
- pkt_len = olp6500_construct_packet(channel, OLP_GET_CHANNEL_CONF, buff);
+ pkt_len = olp6500_packet_construct(channel, OLP_GET_CHANNEL_CONF, buff);
ret = olp6500_send_command_sync(dev_desc, OLP_GET_CHANNEL_CONF, buff, pkt_len, buff, BUFF_MAX);
if (ret == RT_SUCCESS)
{
@@ -1272,7 +1346,8 @@ cJSON * olp6500_monit_loop(struct sc_main * sc_main)
dev_desc = olp_dev->olp_dev_descs[index];
__atomic_fetch_sub(&dev_desc->refcnt, 1, __ATOMIC_RELAXED);
}
-end:
+
+ pthread_mutex_unlock(&g_olp6500_lock);
return j_obp_device_array;
}
@@ -1303,7 +1378,7 @@ int olp6500_destroy_timer(struct olp_device * olp_dev)
return RT_SUCCESS;
}
-int olp6500_device_deinit(struct olp_device * olp_dev)
+static int olp6500_device_deinit(struct olp_device * olp_dev)
{
struct olp_dev_desc * dev_desc = NULL;
@@ -1326,28 +1401,25 @@ int olp6500_device_deinit(struct olp_device * olp_dev)
return RT_SUCCESS;
}
-int olp6500_config_reload()
+int olp6500_set_reload_flag()
{
__atomic_exchange_n(&g_olp6500_config_reload, 1, __ATOMIC_SEQ_CST);
return RT_SUCCESS;
}
-void * _olp6500_config_reload(void * args)
+static void * olp6500_config_reload(void * args)
{
int ret = 0;
struct olp_manager_main * olp_mgr_main = (struct olp_manager_main *)args;
struct olp_device * olp_dev_old = NULL;
struct olp_device * olp_dev_new = NULL;
+ pthread_detach(pthread_self());
+
while(1)
{
usleep(OLP6500_RELOAD_CONFIG_CYCLE_US);
- if (__atomic_load_n(&g_olp6500_config_ready, __ATOMIC_RELAXED) == OLP6500_LOAD_CONFIG_NOT_READY)
- {
- continue;
- }
-
if (__atomic_load_n(&g_olp6500_config_reload, __ATOMIC_RELAXED) == 0)
{
continue;
@@ -1359,27 +1431,21 @@ void * _olp6500_config_reload(void * args)
olp_dev_new = ZMALLOC(sizeof(struct olp_device));
MR_VERIFY_MALLOC(olp_dev_new);
- __atomic_exchange_n(&g_olp6500_config_ready, OLP6500_LOAD_CONFIG_NOT_READY, __ATOMIC_SEQ_CST);
-
- ret = olp6500_config_load(olp_dev_new, g_cfgfile);
+ ret = olp6500_config_load(olp_dev_new, g_dynamic_cfgfile);
if (ret != RT_SUCCESS)
{
goto errout;
}
+ pthread_mutex_lock(&g_olp6500_lock);
olp6500_copy_device_state(olp_dev_old, olp_dev_new);
-
olp6500_destroy_timer(olp_dev_old);
olp_mgr_main->olp6500_main = olp_dev_new;
- g_olp6500_dev = olp_mgr_main->olp6500_main;
-
- __atomic_exchange_n(&g_olp6500_config_ready, OLP6500_LOAD_CONFIG_READY, __ATOMIC_SEQ_CST);
olp6500_device_deinit(olp_dev_old);
+ pthread_mutex_unlock(&g_olp6500_lock);
continue;
errout:
- g_olp6500_dev = olp_mgr_main->olp6500_main;
- __atomic_exchange_n(&g_olp6500_config_ready, OLP6500_LOAD_CONFIG_READY, __ATOMIC_SEQ_CST);
olp6500_device_deinit(olp_dev_new);
continue;
}
@@ -1387,12 +1453,12 @@ void * _olp6500_config_reload(void * args)
return NULL;
}
-int olp6500_create_thread_config_reload(struct olp_manager_main * olp_mgr_main)
+static int olp6500_create_thread_config_reload(struct olp_manager_main * olp_mgr_main)
{
int ret = 0;
pthread_t tid;
- ret = pthread_create(&tid, NULL, _olp6500_config_reload, olp_mgr_main);
+ ret = pthread_create(&tid, NULL, olp6500_config_reload, olp_mgr_main);
if (ret < 0)
{
MR_ERROR("OLP_6500 create config reload thread failed : %s", strerror(errno));
@@ -1401,25 +1467,27 @@ int olp6500_create_thread_config_reload(struct olp_manager_main * olp_mgr_main)
return RT_SUCCESS;
}
-int olp6500_init(struct olp_manager_main * olp_mgr_main, char * cfgfile)
+int olp6500_init(struct olp_manager_main * olp_mgr_main, char * local_cfgfile)
{
int ret = 0;
- g_cfgfile = cfgfile;
+ g_dynamic_cfgfile = local_cfgfile;
+ pthread_mutex_init(&g_olp6500_lock, NULL);
struct olp_device * olp_dev = ZMALLOC(sizeof(struct olp_device));
MR_VERIFY_MALLOC(olp_dev);
- ret = olp6500_config_load(olp_dev, cfgfile);
+ ret = olp6500_config_load(olp_dev, local_cfgfile);
if (ret != RT_SUCCESS)
{
MR_ERROR("load OLP_6500 config failed. ");
goto errout;
}
+ pthread_mutex_lock(&g_olp6500_lock);
olp_mgr_main->olp6500_main = olp_dev;
- g_olp6500_dev = olp_dev;
- olp6500_retry_apply_control_command();
+ olp6500_retry_apply_control_command(olp_mgr_main);
olp6500_create_thread_config_reload(olp_mgr_main);
+ pthread_mutex_unlock(&g_olp6500_lock);
return RT_SUCCESS;
errout:
return RT_ERR;
diff --git a/service/test/TestOLP.cc b/service/test/TestOLP.cc
index c00c68c..77b5bc9 100644
--- a/service/test/TestOLP.cc
+++ b/service/test/TestOLP.cc
@@ -39,11 +39,10 @@ uint8_t g_ctrlzone_id = 0;
extern "C"
{
-extern int olp6500_construct_packet(struct olp_channel * channel, int type, char *buff);
+extern int olp6500_packet_construct(struct olp_channel * channel, int type, char *buff);
extern int olp6500_check_recv_data(char * buff, uint16_t object);
extern int olp6500_apply_control_command_to_peer(struct olp_dev_desc * dev_desc, uint32_t channel_id);
extern int olp6500_destroy_timer(struct olp_device * olp_dev);
-extern int olp6500_device_deinit(struct olp_device * olp_dev);
}
void olp_dev_desc_init(struct olp_dev_desc *dev_desc, struct olp_channel *channel)
@@ -52,7 +51,7 @@ void olp_dev_desc_init(struct olp_dev_desc *dev_desc, struct olp_channel *channe
dev_desc->type = OLP_DEVICE_TYPE_OLP_6500;
channel->olp_channel_id = 1;
- channel->state = OLP_CHANNEL_STATE_FORCE_INLINE;
+ channel->state = OLP_CHANNEL_STATE_FORCE_PASS;
channel->en_heartbeat = 1;
channel->heartbeat_timeout_interval_in_ms = 60;
channel->heartbeat_send_interval_in_ms = 60;
@@ -75,7 +74,7 @@ TEST(OLP_PACKET, OLP_SET_HEARTBEAT_SWITCH)
olp_dev_desc_init(&dev_desc, &dev_channel);
- pkt_len = olp6500_construct_packet(&dev_desc.channels[0], OLP_SET_HEARTBEAT_SWITCH, buff);
+ pkt_len = olp6500_packet_construct(&dev_desc.channels[0], OLP_SET_HEARTBEAT_SWITCH, buff);
EXPECT_TRUE(pkt_len == 10);
EXPECT_TRUE(buff[0] == 0x01);
EXPECT_TRUE(buff[1] == 0x01);
@@ -101,7 +100,7 @@ TEST(OLP_PACKET, OLP_SET_WORK_MODE)
olp_dev_desc_init(&dev_desc, &dev_channel);
- pkt_len = olp6500_construct_packet(&dev_desc.channels[0], OLP_SET_WORK_MODE, buff);
+ pkt_len = olp6500_packet_construct(&dev_desc.channels[0], OLP_SET_WORK_MODE, buff);
EXPECT_TRUE(pkt_len == 7);
EXPECT_TRUE(buff[0] == 0x01);
EXPECT_TRUE(buff[1] == 0x01);
@@ -109,7 +108,7 @@ TEST(OLP_PACKET, OLP_SET_WORK_MODE)
EXPECT_TRUE(buff[3] == 0x10);
EXPECT_TRUE(buff[4] == 0x00);
EXPECT_TRUE(buff[5] == 0x01);
- EXPECT_TRUE(buff[6] == 0x02);
+ EXPECT_TRUE(buff[6] == 0x01);
}
TEST(OLP_PACKET, OLP_SET_WORK_LINE)
@@ -124,8 +123,15 @@ TEST(OLP_PACKET, OLP_SET_WORK_LINE)
olp_dev_desc_init(&dev_desc, &dev_channel);
- pkt_len = olp6500_construct_packet(&dev_desc.channels[0], OLP_SET_WORK_LINE, buff);
- EXPECT_TRUE(pkt_len == 0);
+ pkt_len = olp6500_packet_construct(&dev_desc.channels[0], OLP_SET_WORK_LINE, buff);
+ EXPECT_TRUE(pkt_len == 7);
+ EXPECT_TRUE(buff[0] == 0x01);
+ EXPECT_TRUE(buff[1] == 0x01);
+ EXPECT_TRUE(buff[2] == 0x10);
+ EXPECT_TRUE(buff[3] == 0x70);
+ EXPECT_TRUE(buff[4] == 0x00);
+ EXPECT_TRUE(buff[5] == 0x01);
+ EXPECT_TRUE(buff[6] == 0x30);
}
TEST(OLP_PACKET, OLP_SET_SWITCHBACK_MODE)
@@ -140,7 +146,7 @@ TEST(OLP_PACKET, OLP_SET_SWITCHBACK_MODE)
olp_dev_desc_init(&dev_desc, &dev_channel);
- pkt_len = olp6500_construct_packet(&dev_desc.channels[0], OLP_SET_SWITCHBACK_MODE, buff);
+ pkt_len = olp6500_packet_construct(&dev_desc.channels[0], OLP_SET_SWITCHBACK_MODE, buff);
EXPECT_TRUE(pkt_len == 7);
EXPECT_TRUE(buff[0] == 0x01);
EXPECT_TRUE(buff[1] == 0x01);
@@ -163,7 +169,7 @@ TEST(OLP_PACKET, OLP_HEARTBEAT_PACKET)
olp_dev_desc_init(&dev_desc, &dev_channel);
- pkt_len = olp6500_construct_packet(&dev_desc.channels[0], OLP_HEARTBEAT_PACKET, buff);
+ pkt_len = olp6500_packet_construct(&dev_desc.channels[0], OLP_HEARTBEAT_PACKET, buff);
EXPECT_TRUE(pkt_len == 6);
EXPECT_TRUE(buff[0] == 0x00);
EXPECT_TRUE(buff[1] == 0x01);
@@ -185,7 +191,7 @@ TEST(OLP_PACKET, OLP_GET_CHANNEL_INFO)
olp_dev_desc_init(&dev_desc, &dev_channel);
- pkt_len = olp6500_construct_packet(&dev_desc.channels[0], OLP_GET_CHANNEL_INFO, buff);
+ pkt_len = olp6500_packet_construct(&dev_desc.channels[0], OLP_GET_CHANNEL_INFO, buff);
EXPECT_TRUE(pkt_len == 6);
EXPECT_TRUE(buff[0] == 0x00);
EXPECT_TRUE(buff[1] == 0x01);
@@ -207,7 +213,7 @@ TEST(OLP_PACKET, OLP_GET_CHANNEL_CONF)
olp_dev_desc_init(&dev_desc, &dev_channel);
- pkt_len = olp6500_construct_packet(&dev_desc.channels[0], OLP_GET_CHANNEL_CONF, buff);
+ pkt_len = olp6500_packet_construct(&dev_desc.channels[0], OLP_GET_CHANNEL_CONF, buff);
EXPECT_TRUE(pkt_len == 6);
EXPECT_TRUE(buff[0] == 0x00);
EXPECT_TRUE(buff[1] == 0x01);
@@ -344,7 +350,7 @@ TEST(OLP_CONTROL_COMMAND, CHANNEL_1)
channel->olp_channel_id = 1;
channel->used = OLP_STATE_USED;
- channel->state = OLP_CHANNEL_STATE_FORCE_INLINE;
+ channel->state = OLP_CHANNEL_STATE_FORCE_PASS;
channel->en_heartbeat = 1;
channel->heartbeat_timeout_interval_in_ms = 60;
channel->heartbeat_send_interval_in_ms = 60;
@@ -387,7 +393,7 @@ TEST(OLP_CONTROL_COMMAND, CHANNEL_2)
channel->olp_channel_id = 2;
channel->used = OLP_STATE_USED;
- channel->state = OLP_CHANNEL_STATE_FORCE_INLINE;
+ channel->state = OLP_CHANNEL_STATE_FORCE_PASS;
channel->en_heartbeat = 1;
channel->heartbeat_timeout_interval_in_ms = 60;
channel->heartbeat_send_interval_in_ms = 60;
@@ -430,7 +436,7 @@ TEST(OLP_CONTROL_COMMAND, CHANNEL_3)
channel->olp_channel_id = 3;
channel->used = OLP_STATE_USED;
- channel->state = OLP_CHANNEL_STATE_FORCE_INLINE;
+ channel->state = OLP_CHANNEL_STATE_FORCE_PASS;
channel->en_heartbeat = 1;
channel->heartbeat_timeout_interval_in_ms = 60;
channel->heartbeat_send_interval_in_ms = 60;
@@ -473,7 +479,7 @@ TEST(OLP_CONTROL_COMMAND, CHANNEL_4)
channel->olp_channel_id = 4;
channel->used = OLP_STATE_USED;
- channel->state = OLP_CHANNEL_STATE_FORCE_INLINE;
+ channel->state = OLP_CHANNEL_STATE_FORCE_PASS;
channel->en_heartbeat = 0;
channel->heartbeat_timeout_interval_in_ms = 60;
channel->heartbeat_send_interval_in_ms = 60;
@@ -559,7 +565,7 @@ TEST(OLP_CONTROL_COMMAND, CHANNEL_6)
channel->olp_channel_id = 6;
channel->used = OLP_STATE_USED;
- channel->state = OLP_CHANNEL_STATE_FORCE_INLINE;
+ channel->state = OLP_CHANNEL_STATE_FORCE_PASS;
channel->en_heartbeat = 1;
channel->heartbeat_timeout_interval_in_ms = 60;
channel->heartbeat_send_interval_in_ms = 60;
@@ -602,7 +608,7 @@ TEST(OLP_CONTROL_COMMAND, CHANNEL_7)
channel->olp_channel_id = 7;
channel->used = OLP_STATE_USED;
- channel->state = OLP_CHANNEL_STATE_FORCE_INLINE;
+ channel->state = OLP_CHANNEL_STATE_FORCE_PASS;
channel->en_heartbeat = 1;
channel->heartbeat_timeout_interval_in_ms = 60;
channel->heartbeat_send_interval_in_ms = 60;
@@ -645,7 +651,7 @@ TEST(OLP_CONTROL_COMMAND, CHANNEL_8)
channel->olp_channel_id = 8;
channel->used = OLP_STATE_USED;
- channel->state = OLP_CHANNEL_STATE_FORCE_INLINE;
+ channel->state = OLP_CHANNEL_STATE_FORCE_PASS;
channel->en_heartbeat = 1;
channel->heartbeat_timeout_interval_in_ms = 60;
channel->heartbeat_send_interval_in_ms = 60;
@@ -688,7 +694,7 @@ TEST(OLP_CONTROL_COMMAND, CHANNEL_9)
channel->olp_channel_id = 9;
channel->used = OLP_STATE_USED;
- channel->state = OLP_CHANNEL_STATE_FORCE_INLINE;
+ channel->state = OLP_CHANNEL_STATE_FORCE_PASS;
channel->en_heartbeat = 1;
channel->heartbeat_timeout_interval_in_ms = 60;
channel->heartbeat_send_interval_in_ms = 60;
@@ -731,7 +737,7 @@ TEST(OLP_CONTROL_COMMAND, CHANNEL_10)
channel->olp_channel_id = 10;
channel->used = OLP_STATE_USED;
- channel->state = OLP_CHANNEL_STATE_FORCE_INLINE;
+ channel->state = OLP_CHANNEL_STATE_FORCE_PASS;
channel->en_heartbeat = 1;
channel->heartbeat_timeout_interval_in_ms = 60;
channel->heartbeat_send_interval_in_ms = 60;
@@ -774,7 +780,7 @@ TEST(OLP_CONTROL_COMMAND, CHANNEL_11)
channel->olp_channel_id = 11;
channel->used = OLP_STATE_USED;
- channel->state = OLP_CHANNEL_STATE_FORCE_INLINE;
+ channel->state = OLP_CHANNEL_STATE_FORCE_PASS;
channel->en_heartbeat = 1;
channel->heartbeat_timeout_interval_in_ms = 60;
channel->heartbeat_send_interval_in_ms = 60;
@@ -817,7 +823,7 @@ TEST(OLP_CONTROL_COMMAND, CHANNEL_12)
channel->olp_channel_id = 12;
channel->used = OLP_STATE_USED;
- channel->state = OLP_CHANNEL_STATE_FORCE_INLINE;
+ channel->state = OLP_CHANNEL_STATE_FORCE_PASS;
channel->en_heartbeat = 1;
channel->heartbeat_timeout_interval_in_ms = 60;
channel->heartbeat_send_interval_in_ms = 60;
@@ -860,7 +866,7 @@ TEST(OLP_CONTROL_COMMAND, CHANNEL_13)
channel->olp_channel_id = 13;
channel->used = OLP_STATE_USED;
- channel->state = OLP_CHANNEL_STATE_FORCE_INLINE;
+ channel->state = OLP_CHANNEL_STATE_FORCE_PASS;
channel->en_heartbeat = 1;
channel->heartbeat_timeout_interval_in_ms = 60;
channel->heartbeat_send_interval_in_ms = 60;
@@ -903,7 +909,7 @@ TEST(OLP_CONTROL_COMMAND, CHANNEL_14)
channel->olp_channel_id = 14;
channel->used = OLP_STATE_USED;
- channel->state = OLP_CHANNEL_STATE_FORCE_INLINE;
+ channel->state = OLP_CHANNEL_STATE_FORCE_PASS;
channel->en_heartbeat = 1;
channel->heartbeat_timeout_interval_in_ms = 60;
channel->heartbeat_send_interval_in_ms = 60;
@@ -946,7 +952,7 @@ TEST(OLP_CONTROL_COMMAND, CHANNEL_15)
channel->olp_channel_id = 15;
channel->used = OLP_STATE_USED;
- channel->state = OLP_CHANNEL_STATE_FORCE_INLINE;
+ channel->state = OLP_CHANNEL_STATE_FORCE_PASS;
channel->en_heartbeat = 1;
channel->heartbeat_timeout_interval_in_ms = 60;
channel->heartbeat_send_interval_in_ms = 60;
@@ -989,7 +995,7 @@ TEST(OLP_CONTROL_COMMAND, CHANNEL_16)
channel->olp_channel_id = 16;
channel->used = OLP_STATE_USED;
- channel->state = OLP_CHANNEL_STATE_FORCE_INLINE;
+ channel->state = OLP_CHANNEL_STATE_FORCE_PASS;
channel->en_heartbeat = 1;
channel->heartbeat_timeout_interval_in_ms = 60;
channel->heartbeat_send_interval_in_ms = 60;