This commit is contained in:
zhanglianghy 2019-08-28 10:51:46 +08:00
commit 63f527b079
31 changed files with 1002 additions and 387 deletions

View File

@ -119,8 +119,8 @@ LINUX_KERNEL := $(HUACHENG_LINUX_KERNEL)
endif
# 设置 ARM64 平台 SDK 头文件和库文件路径
ARM64_SDK_INCLUDE := $(SDKTARGETSYSROOT)/include
ARM64_SDK_LIBDIR := $(SDKTARGETSYSROOT)
ARM64_SDK_INCLUDE := $(SDKTARGETSYSROOT)/usr/include
ARM64_SDK_LIBDIR := $(SDKTARGETSYSROOT)/usr/lib
# 设置平台安装子目录
CPU_ARM64_DIR := ARM64

View File

@ -47,6 +47,7 @@
#define AUTHFREE_CONFIG (uint64)((uint64)LOCALAUTH_CONFIG_MODULE<<32|1)
#define FREEPARAMETERS_CONFIG (uint64)((uint64)LOCALAUTH_CONFIG_MODULE<<32|2)
#define AUTH_CONFIG_RECOVER (uint64)((uint64)LOCALAUTH_CONFIG_MODULE<<32|3)
#define LOG_CONFIG_CONSOLE (uint64)((uint64)LOG_CONFIG_MODULE<<32|1)

View File

@ -26,9 +26,7 @@ module device-status {
container memory-infos {
description "内存的状态信息";
leaf memory-total {
type int16 {
range "0..100";
}
type int64 ;
}
leaf usage-rate {
type int16 {

View File

@ -8,6 +8,7 @@
package com.cmcc.cmhi.huawei.impl;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.MountPointService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -16,13 +17,15 @@ public class HuaweiDriverProvider {
private static final Logger LOG = LoggerFactory.getLogger(HuaweiDriverProvider.class);
private final DataBroker dataBroker;
private final MountPointService mountService;
private HuaweiDriverRegister register = null;
private HuaweiNetconfSpeaker netconfSpeaker = null;
public HuaweiDriverProvider(final DataBroker dataBroker) {
public HuaweiDriverProvider(final DataBroker dataBroker, final MountPointService mountService) {
this.dataBroker = dataBroker;
this.mountService = mountService;
this.register = new HuaweiDriverRegister(this.dataBroker);
this.netconfSpeaker = new HuaweiNetconfSpeaker(this.dataBroker);
this.netconfSpeaker = new HuaweiNetconfSpeaker(this.dataBroker, this.mountService);
}
/**

View File

@ -52,12 +52,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev15
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
@ -75,7 +77,7 @@ import static org.opendaylight.controller.md.sal.binding.api.DataObjectModificat
public class HuaweiNetconfSpeaker implements DataTreeChangeListener<ConnectorInfo>,
BindingAwareProvider, AutoCloseable {
AutoCloseable {
private final ListenerRegistration<HuaweiNetconfSpeaker> configurationReg;
private MountPointService mountService;
@ -93,8 +95,9 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener<ConnectorInf
private ThreadFactory timeThreadFactory = new ThreadFactoryBuilder().setNameFormat("huawei-pool-%d").setDaemon(true).build();
public HuaweiNetconfSpeaker(DataBroker dataBroker) {
public HuaweiNetconfSpeaker(DataBroker dataBroker, MountPointService mountService) {
this.dataBroker = dataBroker;
this.mountService = mountService;
InstanceIdentifier<ConnectorInfo> connectPath = InstanceIdentifier.create(ConnectorInfo.class);
final DataTreeIdentifier<ConnectorInfo> dataTreeIdentifier = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, connectPath);
configurationReg = dataBroker.registerDataTreeChangeListener(dataTreeIdentifier, this);
@ -131,7 +134,7 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener<ConnectorInf
.build();
final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
transaction.put(LogicalDatastoreType.CONFIGURATION, NetconfIidFactory.netconfNodeIid(nodeId.getValue()), node);
transaction.put(LogicalDatastoreType.CONFIGURATION, NetconfIidFactory.netconfNodeIid(nodeId.getValue()), node, true);
Futures.addCallback(transaction.submit(), new FutureCallback<Void>() {
@ -143,7 +146,7 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener<ConnectorInf
@Override
public void onSuccess(Void avoid) {
LOG.debug("NetconfNode={} created successfully", netconfNode);
LOG.info("NetconfNode={} created successfully", netconfNode);
startTask(connectDevice.getId().getValue());
}
});
@ -172,22 +175,22 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener<ConnectorInf
configurationReg.close();
}
/**
* A method called when the session to MD-SAL is established. It initializes
* references to MD-SAL services needed throughout the lifetime of the
* huawei netconf application and registers its RPC implementation and Data change
* Listener with the MD-SAL
* <p>
* The skeleton for this method was generated with the MD-SAL application
* archetype.
*
* @param session Reference to the established MD-SAL session
*/
@Override
public void onSessionInitiated(BindingAwareBroker.ProviderContext session) {
LOG.info("HuaweiNetconfSpeaker Session Initiated");
this.mountService = session.getSALService(MountPointService.class);
}
// /**
// * A method called when the session to MD-SAL is established. It initializes
// * references to MD-SAL services needed throughout the lifetime of the
// * huawei netconf application and registers its RPC implementation and Data change
// * Listener with the MD-SAL
// * <p>
// * The skeleton for this method was generated with the MD-SAL application
// * archetype.
// *
// * @param session Reference to the established MD-SAL session
// */
// @Override
// public void onSessionInitiated(BindingAwareBroker.ProviderContext session) {
// LOG.info("HuaweiNetconfSpeaker Session Initiated");
// this.mountService = session.getSALService(MountPointService.class);
// }
@Override
@ -261,8 +264,12 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener<ConnectorInf
ScheduledExecutorService pool = new ScheduledThreadPoolExecutor(2, timeThreadFactory,
new ThreadPoolExecutor.AbortPolicy());
pool.scheduleAtFixedRate(() -> {
try {
readInfoFromDevice(nodeId);
}, 0, 10000, TimeUnit.MILLISECONDS);
} catch (Exception e) {
LOG.error("捕获一个异常:{}", e);
}
}, 180000, 10000, TimeUnit.MILLISECONDS);
if (Objects.nonNull(threads.get(nodeId))) {
LOG.info("remove exist pool in thread map");
if (!threads.get(nodeId).isShutdown()) {
@ -285,13 +292,15 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener<ConnectorInf
}
private void readInfoFromDevice(String nodeId) {
LOG.info("开始向华为设备获取cpu信息");
final Optional<MountPoint> hwNodeOptional = mountService.getMountPoint(NETCONF_TOPO_IID
.child(Node.class, new NodeKey(new NodeId(nodeId))));
LOG.info("开始向华为设备获取cpu信息2");
Preconditions.checkArgument(hwNodeOptional.isPresent(),
"Unable to locate mountpoint: %s, not mounted yet or not configured",
nodeId);
final MountPoint hwNode = hwNodeOptional.get();
LOG.info("Get the DataBroker for the mounted node ");
// Get the DataBroker for the mounted node
final DataBroker hwNodeBroker = hwNode.getService(DataBroker.class).get();
@ -308,7 +317,7 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener<ConnectorInf
InstanceIdentifier<CpuInfos> iid =
InstanceIdentifier.create(Devm.class).child(CpuInfos.class);
Optional<CpuInfos> cupInfos;
LOG.info("开始向华为设备获取cpu信息");
LOG.info("开始向华为设备读取cupInfos");
try {
// Read from a transaction is asynchronous, but a simple
// get/checkedGet makes the call synchronous
@ -331,9 +340,10 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener<ConnectorInf
iid, nodeId);
}
//write cpu information to layer
InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.cmcc.cmhi.adaptation.layer.device.status.rev190809.cpu.status.CpuInfos> cpuIid = NETCONF_TOPO_IID.child(Node.class).
augmentation(NodeCpu.class).
child(org.opendaylight.yang.gen.v1.urn.cmcc.cmhi.adaptation.layer.device.status.rev190809.cpu.status.CpuInfos.class);
InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.cmcc.cmhi.adaptation.layer.device.status.rev190809.cpu.status.CpuInfos> cpuIid = NETCONF_TOPO_IID
.child(Node.class, new NodeKey(new NodeId(nodeId)))
.augmentation(NodeCpu.class)
.child(org.opendaylight.yang.gen.v1.urn.cmcc.cmhi.adaptation.layer.device.status.rev190809.cpu.status.CpuInfos.class);
for (int i = 0; i < ifcList.size(); i++) {
final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
writeTransaction.put(LogicalDatastoreType.OPERATIONAL, cpuIid, ifcList.get(i));
@ -369,7 +379,8 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener<ConnectorInf
LOG.info("Show memory with serial {},cpu usage is {} ",
memoryInfo.getKey().getPosition(), memoryInfo.getDoMemoryUsage());
MemoryInfosBuilder builder = new MemoryInfosBuilder();
org.opendaylight.yang.gen.v1.urn.cmcc.cmhi.adaptation.layer.device.status.rev190809.mem.status.MemoryInfos temp = builder.setMemoryTotal(memoryInfo.getOsMemoryTotal().shortValue()).
LOG.info("Huawei Device {} OsMemoryTotal is: {}", nodeId, memoryInfo.getOsMemoryTotal());
org.opendaylight.yang.gen.v1.urn.cmcc.cmhi.adaptation.layer.device.status.rev190809.mem.status.MemoryInfos temp = builder.setMemoryTotal(memoryInfo.getOsMemoryTotal()).
setUsageRate(memoryInfo.getOsMemoryUsage().shortValue()).build();
memoryList.add(temp);
@ -380,9 +391,10 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener<ConnectorInf
}
//write memory information to layer
InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.cmcc.cmhi.adaptation.layer.device.status.rev190809.mem.status.MemoryInfos> customMemoryIID = NETCONF_TOPO_IID.child(Node.class).
augmentation(NodeMemory.class).
child(org.opendaylight.yang.gen.v1.urn.cmcc.cmhi.adaptation.layer.device.status.rev190809.mem.status.MemoryInfos.class);
InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.cmcc.cmhi.adaptation.layer.device.status.rev190809.mem.status.MemoryInfos> customMemoryIID = NETCONF_TOPO_IID
.child(Node.class, new NodeKey(new NodeId(nodeId)))
.augmentation(NodeMemory.class)
.child(org.opendaylight.yang.gen.v1.urn.cmcc.cmhi.adaptation.layer.device.status.rev190809.mem.status.MemoryInfos.class);
for (int i = 0; i < memoryList.size(); i++) {
final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
writeTransaction.put(LogicalDatastoreType.OPERATIONAL, customMemoryIID, memoryList.get(i));
@ -433,9 +445,11 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener<ConnectorInf
//write interface information to layer
InstanceIdentifier<TpInfos> tpinfosIID = NETCONF_TOPO_IID.child(Node.class).
child(TerminationPoint.class).augmentation(TpExt.class).child(TpInfos.class);
for (int i = 0; i < tpInfosList.size(); i++) {
InstanceIdentifier<TpInfos> tpinfosIID = NETCONF_TOPO_IID
.child(Node.class, new NodeKey(new NodeId(nodeId)))
.child(TerminationPoint.class, new TerminationPointKey(new TpId(tpInfosList.get(i).getTpName())))
.augmentation(TpExt.class).child(TpInfos.class);
final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
writeTransaction.put(LogicalDatastoreType.OPERATIONAL, tpinfosIID, tpInfosList.get(i));
Futures.addCallback(writeTransaction.submit(), new FutureCallback<Void>() {

View File

@ -14,11 +14,14 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
<reference id="dataBroker"
interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
odl:type="default"/>
<reference id="mountService"
interface="org.opendaylight.controller.md.sal.binding.api.MountPointService" />
<bean id="provider"
class="com.cmcc.cmhi.huawei.impl.HuaweiDriverProvider"
init-method="init" destroy-method="close">
<argument ref="dataBroker"/>
<argument ref="mountService"/>
</bean>
</blueprint>

View File

@ -33,7 +33,7 @@ COMMON_SRCS = configserver.c \
netconfig/bridge/libbridge/libbridge_if.c netconfig/bridge/libbridge/libbridge_init.c netconfig/bridge/libbridge/libbridge_devif.c\
web_config/config-adm/user_authpara.c \
web_config/config-adm/user_authfree.c \
web_config/authfree.c web_config/auth_parameters.c\
web_config/authfree.c web_config/auth_parameters.c web_config/auth_recover_config.c \
user_manager_config/user_recover_config.c user_manager_config/user_group_config.c user_manager_config/user_account_config.c user_manager_config/usermanager-server/array_index.c \
user_manager_config/usermanager-server/user_group.c user_manager_config/usermanager-server/user_mod.c user_manager_config/usermanager-server/user.c \
log_config/log_config_console.c log_config/log_config_init.c log_config/log_config_cm.c log_config/log_config_monitor.c log_config/log_config_remote.c log_config/log_config_file.c \

View File

@ -11,6 +11,7 @@
#include "log_config.h"
#include "../web_config/authfree.h"
#include "../web_config/auth_parameters.h"
#include "../web_config/auth_recover_config.h"
#include "natconfig.h"
#include "vlan_config.h"
@ -118,6 +119,15 @@
NULL, \
NULL \
},\
{\
AUTH_CONFIG_RECOVER, \
CONFIG_FROM_RECOVER1, \
TRUE, \
auth_recover_chk, \
auth_recover_proc, \
auth_recover_get, \
auth_recover_get_all \
},\
{\
USER_MANAGER_CONFIG_USER, \
CONFIG_FROM_WEB, \

View File

@ -4,6 +4,8 @@
#include "rpc_server.h"
#include "rpc_client.h"
int access(const char *pathname, int mode);
ret_code log_rpc_exec(char* service_name, char* method_name, pointer input, int input_len, int last_lenth)
{
if ((input == NULL)

View File

@ -147,7 +147,7 @@ ret_code log_remote_level_config_getall(uint source,
/* *.=emerg;*.=alert;*.=crit;*.=err;*.=warn;*.=notice;*.=info @1.1.1.1:514:RFC3164fmt
* *.=emerg;*.=alert;*.=crit;*.=err;*.=warn;*.=notice;*.=info @@1.1.1.2:514:RFC5424fmt */
static ret_code cm_log_prase_host_from_str(const char *input_str, log_remote_host_x_t *ret_host)
static ret_code cm_log_prase_host_from_str(char *const input_str, log_remote_host_x_t *ret_host)
{
char *pos = NULL;
char *pos2 = NULL;
@ -336,7 +336,7 @@ static ret_code cm_log_get_host_from_file_by_addr(const char *file_str, const ch
while ((getline(&line, &n, fp)) != -1)
{
memset(tmp_str, 0, sizeof(tmp_str));
snprintf(tmp_str, "@%s:", addr_str);
sprintf(tmp_str, "@%s:", addr_str);
if (NULL == strstr(line, tmp_str))
{
continue;

View File

@ -1824,6 +1824,7 @@ ret_code vid_value_chk(int vid)
ret_code vid_num_chk(char *if_name, operation_type op_type, int num)
{
int ifnode = -1;
int total = 0;
if(!if_name){
printf("[vlan]vid_num_chk: if_name is null.\n");
return RET_NULLP;
@ -1831,13 +1832,15 @@ ret_code vid_num_chk(char *if_name, operation_type op_type, int num)
printf("[vlan]vid_num_chk: if_name=%s, op_type=%d, num=%d\n", if_name, op_type, num);
ifnode = get_ifnode_from_global(if_name);
if(ifnode == -1){
printf("[vlan]vid_num_chk: get ifnode empty, return\n");
return RET_OK;
total = num;
printf("[vlan]vid_num_chk: get ifnode empty, total = %d\n", total);
}
if(op_type == OP_ADD &&
g_if_vlan_info[ifnode].vidcnt + num > EACH_PORT_MAX_VLAN_NUM){
printf("[vlan]vid_num_chk: ADD operation's vid num(%d+%d=%d) > EACH_PORT_MAX_VLAN_NUM\n",
g_if_vlan_info[ifnode].vidcnt, num, g_if_vlan_info[ifnode].vidcnt + num);
else{
total = g_if_vlan_info[ifnode].vidcnt + num;
printf("[vlan]vid_num_chk: total = %d + %d = %d\n", g_if_vlan_info[ifnode].vidcnt, num, total);
}
if(op_type == OP_ADD && total > EACH_PORT_MAX_VLAN_NUM){
printf("[vlan]vid_num_chk: ADD operation's total vid num > EACH_PORT_MAX_VLAN_NUM\n");
return RET_INPUTERR;
}
@ -2105,12 +2108,16 @@ ret_code vlan_config_get_chk(uint source, pointer input)
printf("[vlan]vlan_config_get_chk: get json parse failed(%d).\n", ret);
return ret;
}
#if 0
for(i = 0; i < MAX_INTERFACES; i++){
if(interface[i] == 1){
printf("[vlan]find a node[%d]\n", i);
return RET_OK;
}
}
return RET_INPUTERR;
#endif
return RET_OK;
}
/************************************************************
@ -2148,7 +2155,7 @@ ret_code vlan_config_chk(uint source,uint *config_type,
if(ret != RET_OK){
goto out;
}
*config_type = oper_type;
//*config_type = oper_type;
printf("[vlan]vlan_config_chk: operate_type=%d\n", oper_type);
if(oper_type == CM_CONFIG_SET){
printf("[vlan]vlan_config_chk: SET chk\n");

View File

@ -0,0 +1,321 @@
#include "auth_recover_config.h"
#include <cjson/cJSON.h>
#include "../include/parsefile.h"
#include "../include/configm.h"
#include "rpc.h"
#include "s2j/s2j.h"
#include "commuapinl.h"
#include "../Platform/common/database/database.h"
#include "config_manager.h"
#include "authfree.h"
#include "auth_parameters.h"
#include "include/user_authfree.h"
#include "include/user_authpara.h"
#include "include/auth_common.h"
void * auth_hdbc = NULL; //认证数据库连接句柄
extern freeauth_configure_t freeauth_array[];
extern auth_parameters_t *auth_para;
/*数据库重连*/
void db_connect()
{
if(NULL == auth_hdbc)
{
auth_hdbc = connect_database(AUTHRECOVER_DATABASE_ID);
}
}
/* 查询未认证权限恢复 */
void auth_getrule_db(char ** rule_db)
{
int num = 0;
int size = 0;
char *ret_authrule = NULL;
/*数据库重连*/
db_connect();
if(NULL == auth_hdbc)
{
return;
}
char *select_sql = "SELECT rule_priority, name, sip, dip, dport, flag FROM `authfree`";
ret_authrule = select_datebase_by_number(AUTHRECOVER_DATABASE_ID, auth_hdbc, "authfree", select_sql, 1, 0, &num, 0);
if(0 == num || NULL == ret_authrule)
{
return;
}
size = strlen(ret_authrule)+1;
char * point = (char*)malloc(size);
if(NULL == point)
{
return;
}
memset(point, 0, size);
memcpy(point, ret_authrule, size);
*rule_db = point; //在函数外面释放
return;
}
/* 查询认证参数恢复 */
void auth_getpara_db(char ** parameters_db)
{
int num = 0;
int size = 0;
char *ret_parameters = NULL;
/*数据库重连*/
db_connect();
if(NULL == auth_hdbc)
{
return;
}
char *select_sql = "SELECT port, timehorizon, failcount, dip, locktime, aging_time FROM `authparas`";
ret_parameters = select_datebase_by_number(AUTHRECOVER_DATABASE_ID, auth_hdbc, "authparas", select_sql, 1, 0, &num, 0);
if(0 == num || NULL == ret_parameters)
{
return;
}
size = strlen(ret_parameters)+1;
char * point = (char*)malloc(size);
if(NULL == point)
{
return;
}
memset(point, 0, size);
memcpy(point, ret_parameters, size);
*parameters_db = point; //在函数外面释放
return;
}
ret_code auth_recover_chk(uint source, uint *config_type,
pointer input, int *input_len,
pointer output, int *output_len)
{
ret_code ret = RET_OK;
return ret;
}
ret_code auth_recover_proc(uint source, uint config_type,
pointer input, int input_len,
pointer output, int *output_len)
{
ret_code ret = RET_OK;
return ret;
}
ret_code auth_recover_get(uint source,
pointer input, int input_len,
pointer output, int *output_len)
{
ret_code ret = RET_OK;
return ret;
}
/*配置恢复未认证权限、认证参数*/
ret_code auth_recover_get_all(uint source,
pointer output, int *output_len)
{
ret_code ret = RET_OK;
char *rule_db = NULL;
char *parameters_db = NULL;
if(CONFIG_FROM_RECOVER1 != source)
{
return ret;
}
auth_hdbc = connect_database(AUTHRECOVER_DATABASE_ID);
if(NULL == auth_hdbc)
{
return RET_SYSERR;
}
/*初始化认证参数结构体指针*/
authparInit();
auth_getrule_db(&rule_db);
if(NULL != rule_db)
{
/*输出参数为json字符串*/
cJSON * cjson = cJSON_Parse(rule_db);
if(NULL == cjson)
{
free(rule_db);
ret = RET_ERR;
return ret;
}
cJSON * data = cJSON_GetObjectItem(cjson, "data");
if(NULL == data)
{
free(rule_db);
cJSON_Delete(cjson);
return RET_ERR;
}
int mun_rule = cJSON_GetArraySize(data);
if(0 == mun_rule)
{
free(rule_db);
cJSON_Delete(cjson);
return RET_ERR;
}
/*创建freeauth_configure_t结构体对象 */
s2j_create_struct_obj(freeauth_buff, freeauth_configure_t);
if(freeauth_buff == NULL) {
cJSON_Delete(cjson);
return RET_NOMEM;
}
for (int i = 0; i < mun_rule; i++)
{
cJSON *pArrayItem = cJSON_GetArrayItem(data, i);
if(pArrayItem) {
/*获取未认证权限优先级键值对*/
cJSON *rule_priority = cJSON_GetObjectItem(pArrayItem, "rule_priority");
if(rule_priority) {
freeauth_buff->rule_priority = rule_priority->valueint;
}
/*未认证权限名称*/
cJSON *name = cJSON_GetObjectItem(pArrayItem, "name");
if(name) {
strncpy(freeauth_buff->name, name->valuestring, 31);
}
/*源IP地址*/
cJSON *sip = cJSON_GetObjectItem(pArrayItem, "sip");
if(sip) {
freeauth_buff->sip = sip->valueint;
}
/*目的IP地址*/
cJSON *dip = cJSON_GetObjectItem(pArrayItem, "dip");
if(dip) {
freeauth_buff->dip = dip->valueint;
}
/*目的端口号*/
cJSON *dport = cJSON_GetObjectItem(pArrayItem, "dport");
if(dport) {
freeauth_buff->dport = dport->valueint;
}
/*状态标志位*/
cJSON *flag = cJSON_GetObjectItem(pArrayItem, "flag");
if(flag) {
freeauth_buff->flag = flag->valueint;
}
printf("freeauth_buff->name = %p %s\n", &freeauth_buff->name, freeauth_buff->name);
/*把数据库的内容读出来 然后加到全局变量里边去*/
for(i = 0; i < RULE_MAX_NUM; i++) {
printf("the name is :%s\n", freeauth_array[i].name);
/*两个字符串相等 strcmp值为0*/
int a = strlen(freeauth_array[i].name);
printf("%d\n", a);
if(0 == strlen(freeauth_array[i].name)) {
printf("%s(%d) freeauth_array[%d] = %p\n", __FUNCTION__, __LINE__, i, &freeauth_array[i]);
memset(&freeauth_array[i], 0, sizeof(freeauth_configure_t));
freeauth_array[i].rule_priority = freeauth_buff->rule_priority;
strncpy(freeauth_array[i].name, freeauth_buff->name, 32);
freeauth_array[i].sip = freeauth_buff->sip;
freeauth_array[i].dip = freeauth_buff->dip;
freeauth_array[i].dport = freeauth_buff->dport;
freeauth_array[i].flag = freeauth_buff->flag;
printf("[%d %s %d %d %d %d %d]\n", freeauth_array[i].rule_priority, freeauth_array[i].name, freeauth_array[i].sip,
freeauth_array[i].dip, freeauth_array[i].dport, freeauth_array[i].dport, i);
break;
}
}
freeauth_buff++;
}
}
s2j_delete_struct_obj(freeauth_buff);
free(rule_db);
return RET_OK;
}
auth_getpara_db(&parameters_db);
if(NULL != parameters_db)
{
/*输出参数为json字符串*/
cJSON * cjson_para = cJSON_Parse(parameters_db);
if(NULL == cjson_para)
{
free(parameters_db);
ret = RET_ERR;
return ret;
}
cJSON * data_para = cJSON_GetObjectItem(cjson_para, "data");
if(NULL == data_para)
{
free(parameters_db);
cJSON_Delete(cjson_para);
return RET_ERR;
}
/*创建freeauth_configure_t结构体对象 */
s2j_create_struct_obj(auth_parameters, auth_parameters_t);
if(auth_parameters == NULL) {
cJSON_Delete(cjson_para);
return RET_NOMEM;
}
/*反序列化数据到freeauth_configure_t结构体对象 */
s2j_struct_get_basic_element(auth_parameters, data_para, int, port);
s2j_struct_get_basic_element(auth_parameters, data_para, int, timehorizon);
s2j_struct_get_basic_element(auth_parameters, data_para, int, failcount);
s2j_struct_get_basic_element(auth_parameters, data_para, int, locktime);
s2j_struct_get_basic_element(auth_parameters, data_para, int, aging_time);
/*将数据存入全局结构体指针*/
if(auth_para) {
auth_para->port = auth_parameters->port;
auth_para->timehorizon = auth_parameters->timehorizon;
auth_para->failcount = auth_parameters->failcount;
auth_para->locktime = auth_parameters->locktime;
auth_para->aging_time = auth_parameters->aging_time;
}
s2j_delete_struct_obj(auth_parameters);
cJSON_Delete(cjson_para);
}
return RET_OK;
}

View File

@ -0,0 +1,41 @@
#ifndef AUTH_RECOVER_H_
#define AUTH_RECOVER_H_
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include "rpc_common.h"
/*数据库重连*/
void db_connect();
/* 查询未认证权限恢复 */
void auth_getrule_db(char ** rule_db);
/* 查询认证参数恢复 */
void auth_getpara_db(char ** parameters_db);
ret_code auth_recover_chk(uint source, uint *config_type,
pointer input, int *input_len,
pointer output, int *output_len);
ret_code auth_recover_proc(uint source, uint config_type,
pointer input, int input_len,
pointer output, int *output_len);
ret_code auth_recover_get(uint source,
pointer input, int input_len,
pointer output, int *output_len);
/*配置恢复未认证权限、认证参数*/
ret_code auth_recover_get_all(uint source,
pointer output, int *output_len);
#endif

View File

@ -3,11 +3,10 @@
#include "../Platform/common/database/database.h"
#include "../include/user_authfree.h"
#include "string.h"
#define AUTHFREE_DATABASE_ID (16)
#define AUTHFREE_TABLE "authfree"
#include "../include/auth_common.h"
extern freeauth_configure_t freeauth_array[];
extern void * auth_hdbc;
static char *authfreemes[] = {"addrule success", "addrule fail", "rule existed", "modrule success",
"modrule failure", "rule not found", "delrule success", "delrule fail", "rulenum exceed maxnum",
@ -37,7 +36,7 @@ static int is_rule_full(void)
/*增加未认证权限规则*/
void add_authfree(int rule_priority, char *name, uint32_t sip, uint32_t dip, int dport, int flag, authfree_result_t *authfree_result)
{
void *authfree_hdbc;
//void *authfree_hdbc;
char *ret_sql = NULL;
int ret_add;
int ret;
@ -55,9 +54,8 @@ void add_authfree(int rule_priority, char *name, uint32_t sip, uint32_t dip, int
return;
}
printf("开始连接数据库\n");
/* 连接数据库 */
#if 0
authfree_hdbc = connect_database(AUTHFREE_DATABASE_ID);
if(NULL == authfree_hdbc) {
@ -67,7 +65,10 @@ void add_authfree(int rule_priority, char *name, uint32_t sip, uint32_t dip, int
/*长整型bigint 浮点型double 字符串character(10)*/
printf("authfree_hdbc = %p\n", authfree_hdbc);
ret = create_database_table(AUTHFREE_DATABASE_ID, authfree_hdbc, "authfree", "create table authfree(rule_priority bigint, name character(32), sip bigint, dip bigint, dport bigint, flag bigint)");
#endif
/*建表*/
ret = create_database_table(AUTHRECOVER_DATABASE_ID, auth_hdbc, "authfree", "create table authfree(rule_priority bigint, name character(32), sip bigint, dip bigint, dport bigint, flag bigint)");
printf("%d \n", ret);
#if 0
@ -89,7 +90,7 @@ void add_authfree(int rule_priority, char *name, uint32_t sip, uint32_t dip, int
/* 根据指定信息查询数据库的获取的结果的条目数 条目数大于10 则不能再添加 */
char *select_num = "SELECT rule_priority, name, sip, dip, dport, flag FROM `authfree`";
ret = get_select_datebase_number(AUTHFREE_DATABASE_ID, authfree_hdbc, "authfree", select_num, &num_sql, 6,
ret = get_select_datebase_number(AUTHRECOVER_DATABASE_ID, auth_hdbc, "authfree", select_num, &num_sql, 6,
DB_DATA_INT_TYPE, sizeof(rule_priority), rule_priority,
DB_DATA_STRING_TYPE, strlen(name) + 1, name,
DB_DATA_INT_TYPE, sizeof(sip), sip,
@ -109,7 +110,7 @@ void add_authfree(int rule_priority, char *name, uint32_t sip, uint32_t dip, int
/* 向authfree表中添加未认证权限名称、内部源IP地址、目的IP地址、目的端口号 */
char *addfree_sql = "INSERT INTO `authfree` SET rule_priority = ?, name = ?, sip = ?, dip = ?, dport = ?, flag = ?";
ret_add = update_database(AUTHFREE_DATABASE_ID, authfree_hdbc, DB_OP_INSERT, AUTHFREE_TABLE, addfree_sql, 6,
ret_add = update_database(AUTHRECOVER_DATABASE_ID, auth_hdbc, DB_OP_INSERT, AUTHFREE_TABLE, addfree_sql, 6,
DB_DATA_INT_TYPE, sizeof(rule_priority), rule_priority,
DB_DATA_STRING_TYPE, strlen(name) + 1, name,
DB_DATA_INT_TYPE, sizeof(sip), sip,
@ -167,7 +168,7 @@ void add_authfree(int rule_priority, char *name, uint32_t sip, uint32_t dip, int
/*修改未认证权限*/
void mod_authfree(int rule_priority, char *name, uint32_t sip, uint32_t dip, int dport, int flag, authfree_result_t *authfree_result)
{
void *authfree_hdbc;
//void *authfree_hdbc;
char *ret_sql = NULL;
int ret_mod;
int ret;
@ -180,8 +181,9 @@ void mod_authfree(int rule_priority, char *name, uint32_t sip, uint32_t dip, int
printf("开始连接数据库\n");
#if 0
/* 连接数据库 */
authfree_hdbc = connect_database(AUTHFREE_DATABASE_ID);
authfree_hdbc = connect_database(AUTHRECOVER_DATABASE_ID);
if(NULL == authfree_hdbc) {
printf("connetc failure\n");
@ -190,7 +192,10 @@ void mod_authfree(int rule_priority, char *name, uint32_t sip, uint32_t dip, int
/*长整型bigint 浮点型double 字符串character(10)*/
printf("authfree_hdbc = %p\n", authfree_hdbc);
ret = create_database_table(AUTHFREE_DATABASE_ID, authfree_hdbc, "authfree", "create table authfree(name character(32), sip bigint, dip bigint, dport bigint)");
#endif
/*建表*/
ret = create_database_table(AUTHRECOVER_DATABASE_ID, auth_hdbc, "authfree", "create table authfree(name character(32), sip bigint, dip bigint, dport bigint)");
printf("%d \n", ret);
#if 0
@ -211,7 +216,7 @@ void mod_authfree(int rule_priority, char *name, uint32_t sip, uint32_t dip, int
/*修改authfree表中内部源IP地址、目的IP地址、目的端口号 未认证权限名称不能修改 */
char *modfree_sql = "UPDATE `authfree` SET rule_priority = ?, sip = ?, dip = ?, dport = ? ,flag = ? WHERE name = ?";
ret_mod = update_database(AUTHFREE_DATABASE_ID, authfree_hdbc, DB_OP_UPDATE, AUTHFREE_TABLE, modfree_sql, 6,
ret_mod = update_database(AUTHRECOVER_DATABASE_ID, auth_hdbc, DB_OP_UPDATE, AUTHFREE_TABLE, modfree_sql, 6,
DB_DATA_INT_TYPE, sizeof(rule_priority), rule_priority,
DB_DATA_INT_TYPE, sizeof(sip), sip,
DB_DATA_INT_TYPE, sizeof(dip), dip,
@ -262,7 +267,7 @@ void mod_authfree(int rule_priority, char *name, uint32_t sip, uint32_t dip, int
/*删除未认证权限*/
void del_authfree(char *name, authfree_result_t *authfree_result)
{
void *authfree_hdbc;
//void *authfree_hdbc;
char *ret_sql = NULL;
int ret_del;
int ret;
@ -273,8 +278,7 @@ void del_authfree(char *name, authfree_result_t *authfree_result)
return;
}
printf("开始连接数据库\n");
#if 0
/* 连接数据库 */
authfree_hdbc = connect_database(AUTHFREE_DATABASE_ID);
@ -285,7 +289,10 @@ void del_authfree(char *name, authfree_result_t *authfree_result)
/*长整型bigint 浮点型double 字符串character(10)*/
printf("authfree_hdbc = %p\n", authfree_hdbc);
ret = create_database_table(AUTHFREE_DATABASE_ID, authfree_hdbc, "authfree", "create table authfree(name character(32), sip bigint, dip bigint, dport bigint)");
#endif
/*建表*/
ret = create_database_table(AUTHRECOVER_DATABASE_ID, auth_hdbc, "authfree", "create table authfree(name character(32), sip bigint, dip bigint, dport bigint)");
printf("%d \n", ret);
@ -308,7 +315,7 @@ void del_authfree(char *name, authfree_result_t *authfree_result)
/*删除authfree表中未认证权限名称、内部源IP地址、目的IP地址、目的端口号 */
char *delfree_sql = "DELETE FROM authfree WHERE name = ?";
ret_del = update_database(AUTHFREE_DATABASE_ID, authfree_hdbc, DB_OP_DEL, AUTHFREE_TABLE, delfree_sql, 1,
ret_del = update_database(AUTHRECOVER_DATABASE_ID, auth_hdbc, DB_OP_DEL, AUTHFREE_TABLE, delfree_sql, 1,
DB_DATA_STRING_TYPE, strlen(name) + 1, name);
printf("the value of ret:%d\n", ret_del);

View File

@ -8,11 +8,11 @@
#include "../../../../../Common/commuapinl.h"
#include "../auth_parameters.h"
#include "../Platform/common/database/database.h"
#define AUTHPARA_DATABASE_ID 15
#define AUTHPARA_TABLE "authparas"
#include "../include/user_authpara.h"
#include "../include/auth_common.h"
extern auth_parameters_t *auth_para;
extern void * auth_hdbc;
char * mes[]={"mod success", "mod failure"};
@ -20,7 +20,7 @@ char * mes[]={"mod success", "mod failure"};
void mod_authpara(int port, int timehorizon, int failcount, int locktime, int aging_time, configure_result_t *configure_result)
{
authparInit();
void * authpara_hdbc;
//void * authpara_hdbc;
char * ret_sql = NULL;
int ret;
int num;
@ -31,6 +31,7 @@ void mod_authpara(int port, int timehorizon, int failcount, int locktime, int ag
return;
}
#if 0
printf("开始连接数据库\n");
/* 连接数据库 */
@ -43,15 +44,18 @@ void mod_authpara(int port, int timehorizon, int failcount, int locktime, int ag
/*长整型bigint 浮点型double 字符串character(10)*/
printf("authpara_hdbc = %p\n", authpara_hdbc);
ret = create_database_table(AUTHPARA_DATABASE_ID, authpara_hdbc, "authparas", "create table authparas(port bigint, timehorizon bigint, failcount bigint, locktime bigint, aging_time bigint)");
#endif
/*建表*/
ret = create_database_table(AUTHRECOVER_DATABASE_ID, auth_hdbc, "authparas", "create table authparas(port bigint, timehorizon bigint, failcount bigint, locktime bigint, aging_time bigint)");
printf("%d \n",ret);
/* 存authpara表 默认值 */
char *user1_authpara = "INSERT INTO `authparas` SET port = 8080, timehorizon = 1, failcount = 5, locktime = 10, aging_time = 10";
int ret_addauthpara = update_database(AUTHPARA_DATABASE_ID, authpara_hdbc, DB_OP_INSERT, AUTHPARA_TABLE, user1_authpara, 0);
int ret_addauthpara = update_database(AUTHRECOVER_DATABASE_ID, auth_hdbc, DB_OP_INSERT, AUTHPARA_TABLE, user1_authpara, 0);
if(0 != ret_addauthpara)
{
disconnect_database(AUTHPARA_DATABASE_ID , authpara_hdbc); // ret_release记录日志
disconnect_database(AUTHRECOVER_DATABASE_ID , auth_hdbc); // ret_release记录日志
configure_result->resultcode = 1;
configure_result->message = mes[configure_result->resultcode];
return;
@ -59,7 +63,7 @@ void mod_authpara(int port, int timehorizon, int failcount, int locktime, int ag
char *user_authpara = "UPDATE `authparas` SET port = ?, timehorizon = ?, failcount = ?, locktime = ?, aging_time = ?";
ret = update_database(AUTHPARA_DATABASE_ID, authpara_hdbc, DB_OP_UPDATE, AUTHPARA_TABLE, user_authpara, 5,
ret = update_database(AUTHRECOVER_DATABASE_ID, auth_hdbc, DB_OP_UPDATE, AUTHPARA_TABLE, user_authpara, 5,
DB_DATA_INT_TYPE, sizeof(port), port,
DB_DATA_INT_TYPE, sizeof(timehorizon), timehorizon,
DB_DATA_INT_TYPE, sizeof(failcount), failcount,

View File

@ -0,0 +1,9 @@
#ifndef AUTH_COMMON_H_
#define AUTH_COMMON_H_
#define AUTHPARA_TABLE "authparas"
#define AUTHFREE_TABLE "authfree"
#define AUTHRECOVER_DATABASE_ID (15)
#endif

View File

@ -11,7 +11,6 @@
#define DELAUTHFREE_FAIL_DATABASE (7) //删除未认证权限失败
#define RULENUM_EXCEED (8) //未认证权限数量超过最大值
typedef enum {
ADD_RULE_OK = 0,
ADD_RULE_ERR = 1,

View File

@ -4,7 +4,6 @@
#include <stdint.h>
#include "../Platform/user/configm/config-server/web_config/auth_parameters.h"
#define ADDUSER_FAIL_NAMEDUP 4 //用户名重名
#define MODAUTHPARA_SUCCESS 0 //修改认证信息成功

View File

@ -16,7 +16,7 @@ int conf_file(cJSON *json_obj, int argc, char **argv)
log_file_t log_file_out = {0};
int level = LOG_INFO;
uint config_type = CM_CONFIG_SET;
cJSON *json_output = NULL;
char *json_output = NULL;
log_file.is_compress = LOG_UNCOMPRESS;

View File

@ -28,7 +28,7 @@ static log_rfc_t get_rfc_by_name(const char *name)
static int conf_remote_by_config_id(cJSON *json_obj, const char *host, const u16 port, const log_rfc_t rfc, uint64 config_id)
{
log_remote_host_x_t remote = {0};
cJSON *json_output = NULL;
char *json_output = NULL;
int config_type = CM_CONFIG_SET;
if (LOG_CONFIG_REMOTE_GET_HOST == config_id)
@ -141,7 +141,7 @@ int conf_remote_level(cJSON *json_obj, int argc, char **argv)
log_remote_level_t log_level = {0};
log_remote_level_t log_level_out = {0};
uint config_type = CM_CONFIG_SET;
cJSON *json_output = NULL;
char*json_output = NULL;
if (argc < 3) {
ULOG_WARNING(g_log, "Not input log level");

View File

@ -7,7 +7,7 @@
int set_log_conf(uint config_type, cJSON *json_obj, uint64 config_id, cJSON **json_output)
int set_log_conf(uint config_type, cJSON *json_obj, uint64 config_id, char **json_output)
{
int ret = -1;
char *output;
@ -48,7 +48,7 @@ int set_log_conf(uint config_type, cJSON *json_obj, uint64 config_id, cJSON **js
}
int logging_terminal_json_parse(pointer input, pointer config_buff, int conf_id)
int logging_terminal_json_parse(pointer input, pointer config_buff, uint64 conf_id)
{
cJSON *json_obj = NULL;

View File

@ -13,15 +13,15 @@
extern ulog_t *g_log;
int set_log_conf(uint config_type, cJSON *json_obj, uint64 config_id, cJSON **json_output);
int logging_terminal_json_parse(pointer input, pointer config_buff, int conf_id);
int set_log_conf(uint config_type, cJSON *json_obj, uint64 config_id, char **json_output);
int logging_terminal_json_parse(pointer input, pointer config_buff, uint64 conf_id);
#define CONF_TERMINAL(type, config_type, json_obj, str_level, on, module_name, conf_id) { \
type terminal = {0}; \
type terminal_out = {0}; \
int level; \
cJSON *json_output = NULL; \
char *json_output = NULL; \
\
if ((level = log_str_to_level(str_level)) < 0) { \
ULOG_WARNING(g_log, "Unknown log level:%s", str_level); \

View File

@ -134,7 +134,7 @@ static int trace_recv_handle(struct pdelivnl_ctrl_data *ctrl,
case TRACE_CFG_POLICY_REPLY:
reply = (trace_reply_t *)NLMSG_DATA(n);
if (sizeof(*reply) < (n->nlmsg_len - NLMSG_HDRLEN)) {
SYSLOG_WARN("The length of the reply message is required to be %u, but fact length is %u",
SYSLOG_WARN("The length of the reply message is required to be %ld, but fact length is %u",
sizeof(*reply), (n->nlmsg_len - NLMSG_HDRLEN));
break;
}
@ -187,9 +187,9 @@ static trace_ret_t cfg_channel_send(const uint32_t seq, const trace_policy_t *p
SYSLOG_DEBUG("Send hdr: is_reply:%d, seq:%u, ver:%u", req.hdr.is_reply, req.hdr.seq, req.hdr.ver);
SYSLOG_DEBUG("Send policy:");
SYSLOG_DEBUG(" src family:%u, src ip:%02x, sport:%u",
req.policy.src.family, req.policy.src.addr.ip4, req.policy.sport);
req.policy.src.family, req.policy.src.addr.ip4.s_addr, req.policy.sport);
SYSLOG_DEBUG(" dst family:%u, dst ip:%02x, dport:%u",
req.policy.dst.family, req.policy.dst.addr.ip4, req.policy.dport);
req.policy.dst.family, req.policy.dst.addr.ip4.s_addr, req.policy.dport);
SYSLOG_DEBUG(" protocol:%u, app_type:%u", req.policy.protocol, req.policy.app_type);
/*发送组装好的netlink消息*/

View File

@ -7,6 +7,7 @@
#include "ulog.h"
#include "log_common.h"
#include "ulog_in.h"
#include "sev_sched.h"
#define FILTER_CONTENT ":msg,contains,\""MODULE_FMT"\"\n"
#define DEFAULT_CONFIG_FILE_TMP "/etc/log-sched.conf.tmp"

View File

@ -15,7 +15,7 @@
#define REDIRECT_SEPERATE " "
typedef int (*rpc_cb)(pointer *input, const void *arg, char *str_err, int str_len);
typedef int (*rpc_cb)(pointer input, const void *arg, char *str_err, int str_len);
extern ulog_t *g_log;
extern FILE *g_conf_fp;

View File

@ -347,7 +347,7 @@ static int __rpc_conf_log_remote(pointer input, const void *arg, char *str_err,
log_op_t op;
memcpy(&op, arg, sizeof(op));
int ret = config_log_remote_host(op, (const log_remote_level_t *)input);
int ret = config_log_remote_host(op, (const log_remote_host_t *)input);
if (ret < 0) {
strncpy(str_err, "Configuring remote of log is faiure", str_len);
}

View File

@ -5,6 +5,8 @@
#include "log_common.h"
#include "ulog_api.h"
#include <unistd.h>
#define SEV_TIMEOUT 1
#define SEV_CMD "systemctl restart rsyslog"

111
libs/files/log/deal_logfiles.sh Executable file
View File

@ -0,0 +1,111 @@
#!/bin/bash
# 本脚本功能:
# 1. 从logrotate配置文件中取出日志文件的路径所有日志文件均以logrotate配置文件中第一行指示的路径为前缀
# 2. 从log_sched配置文件中取出日志文件大小上限
# 3. 计算步骤1指示的日志文件的总大小检测日志总大小是否超出上限若超出则删除所有日志文件
function deal_logs ()
{
# logrotate配置文件路径
logrotate_log_file="/etc/logrotate.d/log-syslog"
#log_sched配置文件路径
log_sched_file="/etc/log-sched.conf"
# 日志文件前缀
prefix=
# 日志大小上限
size_max=0
echo "**********************************************************"
echo " logrotate_cfg: $logrotate_log_file"
echo " log_sched_cfg: $log_sched_file"
echo "**********************************************************"
echo ""
# logrotate配置文件判空
if [ ! -e $logrotate_log_file ] ; then
return
fi
# 从logrotate配置文件中第一行有效行中读取出日志文件前缀
while read line
do
if [ -z $line ] ; then
continue
fi
prefix=$line;
echo "**********************************************************"
echo " get log-file-prefix: $prefix"
echo "**********************************************************"
echo ""
break
done < $logrotate_log_file
if [ -z $prefix ] ; then
echo "get log file failed"
return
fi
# log_sched配置文件判空
if [ ! -e $log_sched_file ] ; then
return
fi
#从log_sched配置文件中读取出日志大小上限值
while read line
do
tmpkey="file.max_size="
if [[ $line = *$tmpkey* ]] ; then
if [[ $line = $tmpkey ]] ; then
echo "size_max is empty, do nothing and return"
return
fi
size_max=${line#$tmpkey}
echo "**********************************************************"
echo " get size_max: $size_max"
echo "**********************************************************"
echo ""
break
fi
done < $log_sched_file
if [ $size_max -eq 0 ] ; then
echo "size_max is 0, do nothing and return"
return
fi
#定期检查日志总大小是否超限
path=$prefix*
echo " get path: $path"
folder_size=$(wc -c $path|grep total |awk '{print $1}')
if [ -z $folder_size ] ; then
folder_size=0
fi
echo "cursize: $folder_size"
echo "maxsize: $size_max"
if [ $folder_size -gt $size_max ] ; then
echo "flush folder $path"
rm -rf $path
sync
fi
}
deal_logs $@

64
libs/files/log/rsyslog.conf Executable file
View File

@ -0,0 +1,64 @@
# /etc/rsyslog.conf Configuration file for rsyslog.
#
# For more information see
# /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html
#
# Default logging rules can be found in /etc/rsyslog.d/50-default.conf
#################
#### MODULES ####
#################
module(load="imuxsock") # provides support for local system logging
#module(load="immark") # provides --MARK-- message capability
# provides UDP syslog reception
#module(load="imudp")
#input(type="imudp" port="514")
# provides TCP syslog reception
#module(load="imtcp")
#input(type="imtcp" port="514")
# provides kernel logging support and enable non-kernel klog messages
module(load="imklog" permitnonkernelfacility="on")
###########################
#### GLOBAL DIRECTIVES ####
###########################
#
# Use traditional timestamp format.
# To enable high precision timestamps, comment out the following line.
#
template(name="RFC3164fmt" type="string" string="<%PRI%>%timestamp:::date-rfc3164% %hostname% %syslogtag%%msg%\n")
template(name="RFC5424fmt" type="string" string="<%PRI%>%protocol-version% %timestamp:::date-rfc3339% %hostname% %app-name% %procid% %structured-data% %msgid%%msg%\n")
$ActionFileDefaultTemplate RFC5424fmt
# Filter duplicated messages
$RepeatedMsgReduction on
#
# Set the default permissions for all log files.
#
$FileOwner syslog
$FileGroup adm
$FileCreateMode 0640
$DirCreateMode 0755
$Umask 0022
$PrivDropToUser syslog
$PrivDropToGroup syslog
#
# Where to place spool and state files
#
$WorkDirectory /var/spool/rsyslog
#
# Include all config files in /etc/rsyslog.d/
#
$IncludeConfig /etc/rsyslog.d/*.conf

View File

@ -38,6 +38,8 @@ typedef enum { WEBM_HANDLE_INVALID_INDEX = -1,
WEBM_HANDLE_CONFIG_UUID_USER,
WEBM_HANDLE_CONFIG_DETAIL_USER,
WEBM_HANDLE_CONFIG_IPV4,
WEBM_HANDLE_CONFIG_VLAN_SET,
WEBM_HANDLE_CONFIG_VLAN_GET,
WEBM_HANDLE_MAX
} webm_handle_index;
@ -169,6 +171,20 @@ extern int webm_config_send_proc(server *srv, uint32_t config_type, uint64 confg
CM_CONFIG_SET, \
IPCONFIG_V4, \
webm_config_send_proc \
}, \
{\
WEBM_HANDLE_CONFIG_VLAN_SET, \
"/FSG-CF/setvlan", \
CM_CONFIG_SET, \
VLAN_CONFIG, \
webm_config_send_proc \
}, \
{\
WEBM_HANDLE_CONFIG_VLAN_GET, \
"/FSG-GF/getvlan", \
CM_CONFIG_GET, \
VLAN_CONFIG, \
webm_config_send_proc \
} \
\
}

View File

@ -17,15 +17,18 @@ if(PLAT_ARM64)
SET(CMAKE_SYSTEM_NAME Linux)
#this one not so much
SET(CMAKE_SYSTEM_VERSION 1)
# this is install root directory
SET(CMAKE_INSTALL_PREFIX /usr)
# specify the cross compiler
SET(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
SET(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
SET(CMAKE_STRIP aarch64-fsl-linux-strip)
SET(CMAKE_STRIP aarch64-linux-gnu-strip)
# specify the cross compile and link flags
# set(CMAKE_C_FLAGS "--sysroot=$ENV{SDKTARGETSYSROOT}")
# set(CMAKE_SHARED_LINKER_FLAGS "--sysroot=$ENV{SDKTARGETSYSROOT}")
set(CMAKE_C_FLAGS "--sysroot=$ENV{SDKTARGETSYSROOT}")
set(CMAKE_SHARED_LINKER_FLAGS "--sysroot=$ENV{SDKTARGETSYSROOT}")
SET(CMAKE_LIBRARY_PATH $ENV{SDKTARGETSYSROOT}/usr/lib)
# where is the target environment
SET(CMAKE_FIND_ROOT_PATH ${SDKTARGETSYSROOT})