2019-08-19 08:18:47 +00:00
|
|
|
|
#include <unistd.h>
|
2019-08-20 07:46:36 +00:00
|
|
|
|
#include <arpa/inet.h>
|
2019-08-09 11:42:19 +00:00
|
|
|
|
#include "../include/parsefile.h"
|
|
|
|
|
#include "../include/configm.h"
|
|
|
|
|
#include "../../../netlink_uapi/libnetlinku.h"
|
2019-08-15 06:24:41 +00:00
|
|
|
|
#include "rpc.h"
|
2019-08-09 11:42:19 +00:00
|
|
|
|
#include "authfree.h"
|
2019-08-15 06:24:41 +00:00
|
|
|
|
#include "auth_parameters.h"
|
2019-08-09 11:42:19 +00:00
|
|
|
|
#include <cjson/cJSON.h>
|
2019-08-15 06:24:41 +00:00
|
|
|
|
#include "s2j/s2j.h"
|
|
|
|
|
#include "commuapinl.h"
|
|
|
|
|
#include "../Platform/common/database/database.h"
|
|
|
|
|
#include "include/user_authfree.h"
|
|
|
|
|
#include "config_manager.h"
|
2019-08-09 11:42:19 +00:00
|
|
|
|
|
|
|
|
|
/*定义结构体数组 存在免认证规则 */
|
|
|
|
|
freeauth_configure_t freeauth_array[RULE_MAX_NUM] = {0};
|
|
|
|
|
|
2019-08-15 06:24:41 +00:00
|
|
|
|
#define UNAMESIZE (127 + 1)
|
|
|
|
|
#define SPECHAR(element) (strpbrk((element), "~!@#$%^&*()_+{}|:\"<>?\\,./;\'[]-=`")) //校验特殊字符
|
2019-08-09 11:42:19 +00:00
|
|
|
|
|
|
|
|
|
#ifdef FREEAUTH_ACK_COOKIES
|
|
|
|
|
#define CFG_FREEAUTH_ACK_COOKIES
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* 判断IPv4格式是否正确*/
|
|
|
|
|
int isIpV4Addr(const char *ipAddr)
|
|
|
|
|
{
|
2019-08-20 07:46:36 +00:00
|
|
|
|
unsigned char buf[sizeof(struct sockaddr_in)];
|
|
|
|
|
|
|
|
|
|
if((NULL == ipAddr) || (0 == strlen(ipAddr))) {
|
2019-08-09 11:42:19 +00:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(inet_pton(AF_INET, ipAddr, buf) == 1) {
|
|
|
|
|
return 0;
|
2019-08-09 11:42:19 +00:00
|
|
|
|
}
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
2019-08-09 11:42:19 +00:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-15 06:24:41 +00:00
|
|
|
|
/*下发配置到内核态 */
|
2019-08-09 11:42:19 +00:00
|
|
|
|
int set_freeauthcfg_waitack(freeauth_configure_t *struct_freeauth)
|
|
|
|
|
{
|
|
|
|
|
int freeauth_len = 0;
|
|
|
|
|
struct nlmsghdr *ack = NULL;
|
2019-08-15 06:24:41 +00:00
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
struct {
|
2019-08-09 11:42:19 +00:00
|
|
|
|
struct nlmsghdr n;
|
|
|
|
|
char buf[1024];
|
2019-08-15 06:24:41 +00:00
|
|
|
|
} req = {
|
2019-08-09 11:42:19 +00:00
|
|
|
|
.n.nlmsg_len = NLMSG_LENGTH(0),
|
|
|
|
|
#ifdef CFG_FREEAUTH_ACK_COOKIES
|
2019-08-15 06:24:41 +00:00
|
|
|
|
.n.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK, /*set NLM_F_ACK:use kernel auto ack*/
|
2019-08-09 11:42:19 +00:00
|
|
|
|
#else
|
|
|
|
|
.n.nlmsg_flags = NLM_F_REQUEST, /*not use kernel auto ack */
|
|
|
|
|
#endif
|
|
|
|
|
.n.nlmsg_type = FREEAUTH_CFG,
|
|
|
|
|
.n.nlmsg_pid = getpid(),
|
2019-08-15 06:24:41 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*判断要发送的数据是否为NULL,不为NULL,打印出来 */
|
2019-08-20 07:46:36 +00:00
|
|
|
|
if(struct_freeauth == NULL) {
|
2019-08-15 06:24:41 +00:00
|
|
|
|
printf("set_freeauthcfg_waitack is error: input struct_freeauth is NULL.\r\n");
|
|
|
|
|
return -1;
|
2019-08-20 07:46:36 +00:00
|
|
|
|
} else {
|
|
|
|
|
unsigned char str[INET_ADDRSTRLEN];
|
|
|
|
|
unsigned char dtr[INET_ADDRSTRLEN];
|
|
|
|
|
|
|
|
|
|
memset(str, 0, INET_ADDRSTRLEN);
|
|
|
|
|
inet_ntop(AF_INET, (void *)&struct_freeauth->sip, str, INET_ADDRSTRLEN);
|
|
|
|
|
|
|
|
|
|
memset(dtr, 0, INET_ADDRSTRLEN);
|
|
|
|
|
inet_ntop(AF_INET, (void *)&struct_freeauth->dip, dtr, INET_ADDRSTRLEN);
|
|
|
|
|
|
2019-08-15 06:24:41 +00:00
|
|
|
|
printf("set_freeauthcfg_waitack :name %s sip %s dip %s dport %d\n",
|
2019-08-20 07:46:36 +00:00
|
|
|
|
struct_freeauth->name, str, dtr,
|
2019-08-15 06:24:41 +00:00
|
|
|
|
struct_freeauth->dport);
|
|
|
|
|
}
|
2019-08-09 11:42:19 +00:00
|
|
|
|
|
|
|
|
|
/*计算需要发送的数据的长度 */
|
|
|
|
|
freeauth_len = sizeof(freeauth_configure_t);
|
|
|
|
|
|
|
|
|
|
/*可选属性 */
|
|
|
|
|
commnl_addattr_l(&req.n, sizeof(req), 1, struct_freeauth, freeauth_len);
|
2019-08-15 06:24:41 +00:00
|
|
|
|
|
2019-08-09 11:42:19 +00:00
|
|
|
|
/*发送组装好的netlink消息 */
|
2019-08-20 07:46:36 +00:00
|
|
|
|
if(pdeliv_talk(1, &req.n, &ack) < 0) {
|
2019-08-09 11:42:19 +00:00
|
|
|
|
printf("set_user_freeauth_waitack rcv ack msg faild.\r\n");
|
|
|
|
|
return -2;
|
2019-08-20 07:46:36 +00:00
|
|
|
|
} else {
|
2019-08-09 11:42:19 +00:00
|
|
|
|
printf("set_user_freeauth_waitack rcv ack msg success.\r\n");
|
|
|
|
|
}
|
2019-08-15 06:24:41 +00:00
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
if(ack != NULL) {
|
2019-08-15 06:24:41 +00:00
|
|
|
|
printf("set_user_freeauth_waitack rcv answer.\r\n");
|
2019-08-20 07:46:36 +00:00
|
|
|
|
} else {
|
2019-08-15 06:24:41 +00:00
|
|
|
|
printf("set_user_freeauth_waitack rcv answer error.\r\n");
|
|
|
|
|
return -3;
|
|
|
|
|
}
|
2019-08-09 11:42:19 +00:00
|
|
|
|
|
|
|
|
|
#ifdef CFG_FREEAUTH_ACK_COOKIES
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
2019-08-15 06:24:41 +00:00
|
|
|
|
/*recv answer*/
|
2019-08-20 07:46:36 +00:00
|
|
|
|
if(ack->nlmsg_type == NLMSG_ERROR) {
|
|
|
|
|
nl_debugfs_extack(ack);
|
2019-08-15 06:24:41 +00:00
|
|
|
|
}
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
2019-08-09 11:42:19 +00:00
|
|
|
|
#else
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
2019-08-15 06:24:41 +00:00
|
|
|
|
/*recv answer*/
|
2019-08-20 07:46:36 +00:00
|
|
|
|
if(ack->nlmsg_type == FREEAUTH_CFG) {
|
|
|
|
|
nl_debugfs(ack);
|
2019-08-15 06:24:41 +00:00
|
|
|
|
}
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
2019-08-09 11:42:19 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
if(ack) {
|
|
|
|
|
free(ack);
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-15 06:24:41 +00:00
|
|
|
|
return 0;
|
2019-08-09 11:42:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-19 08:18:47 +00:00
|
|
|
|
|
|
|
|
|
/*获取json串类型*/
|
|
|
|
|
ret_code freeauth_config_json_type(pointer input, uint *conf_type)
|
|
|
|
|
{
|
2019-08-20 07:46:36 +00:00
|
|
|
|
const char *pString = (char *)input;
|
2019-08-19 08:18:47 +00:00
|
|
|
|
cJSON *cjson, *type;
|
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
if(!pString) {
|
|
|
|
|
return RET_INPUTERR;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-19 08:18:47 +00:00
|
|
|
|
printf("json:[%s]\n", pString);
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
2019-08-19 08:18:47 +00:00
|
|
|
|
/*JSON字符串到JSON格式 */
|
|
|
|
|
cjson = cJSON_Parse(input);
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(!cjson) {
|
|
|
|
|
return RET_INPUTERR;
|
2019-08-19 08:18:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*获取操作类型 add、mod、del */
|
|
|
|
|
type = cJSON_GetObjectItem(cjson, "type");
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(!type) {
|
2019-08-19 08:18:47 +00:00
|
|
|
|
cJSON_Delete(cjson);
|
2019-08-20 07:46:36 +00:00
|
|
|
|
return RET_INPUTERR;
|
2019-08-19 08:18:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
if(conf_type) {
|
|
|
|
|
*conf_type = type->valueint;
|
|
|
|
|
}
|
2019-08-19 08:18:47 +00:00
|
|
|
|
|
|
|
|
|
cJSON_Delete(cjson);
|
|
|
|
|
return RET_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*json字符串转为结构体*/
|
|
|
|
|
/*iuput格式:{"type": 0, "data": {"rule_priority": 1, "name": "armink","sip": 1027824,"dip": 103427824,"dport": 24, "flag":0}}*/
|
2019-08-09 11:42:19 +00:00
|
|
|
|
ret_code freeauth_config_json_parse(pointer input, uint *conf_type, freeauth_configure_t *freeauth_buff)
|
|
|
|
|
{
|
2019-08-20 07:46:36 +00:00
|
|
|
|
const char *pString = (char *)input;
|
2019-08-09 11:42:19 +00:00
|
|
|
|
cJSON *cjson, *type, *data;
|
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
if(!pString) {
|
|
|
|
|
return RET_INPUTERR;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-15 06:24:41 +00:00
|
|
|
|
printf("json:[%s]\n", pString);
|
2019-08-09 11:42:19 +00:00
|
|
|
|
/*JSON字符串到JSON格式 */
|
2019-08-15 06:24:41 +00:00
|
|
|
|
cjson = cJSON_Parse(pString);
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(!cjson) {
|
|
|
|
|
return RET_INPUTERR;
|
2019-08-09 11:42:19 +00:00
|
|
|
|
}
|
2019-08-15 06:24:41 +00:00
|
|
|
|
|
2019-08-09 11:42:19 +00:00
|
|
|
|
/*获取操作类型 add、mod、del */
|
|
|
|
|
type = cJSON_GetObjectItem(cjson, "type");
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(!type) {
|
2019-08-09 11:42:19 +00:00
|
|
|
|
cJSON_Delete(cjson);
|
2019-08-20 07:46:36 +00:00
|
|
|
|
return RET_INPUTERR;
|
2019-08-09 11:42:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
if(conf_type) {
|
|
|
|
|
*conf_type = type->valueint;
|
|
|
|
|
}
|
2019-08-09 11:42:19 +00:00
|
|
|
|
|
|
|
|
|
/*获取免认证规则的data部分 */
|
|
|
|
|
data = cJSON_GetObjectItem(cjson, "data");
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(!data) {
|
2019-08-09 11:42:19 +00:00
|
|
|
|
cJSON_Delete(cjson);
|
2019-08-20 07:46:36 +00:00
|
|
|
|
return RET_INPUTERR;
|
2019-08-09 11:42:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*创建freeauth_configure_t结构体对象 */
|
|
|
|
|
s2j_create_struct_obj(struct_freeauth, freeauth_configure_t);
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(struct_freeauth == NULL) {
|
2019-08-09 11:42:19 +00:00
|
|
|
|
cJSON_Delete(cjson);
|
|
|
|
|
return RET_NOMEM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*反序列化数据到freeauth_configure_t结构体对象 */
|
2019-08-19 08:18:47 +00:00
|
|
|
|
s2j_struct_get_basic_element(struct_freeauth, data, int, rule_priority);
|
2019-08-09 11:42:19 +00:00
|
|
|
|
s2j_struct_get_basic_element(struct_freeauth, data, string, name);
|
|
|
|
|
s2j_struct_get_basic_element(struct_freeauth, data, int, sip);
|
|
|
|
|
s2j_struct_get_basic_element(struct_freeauth, data, int, dip);
|
|
|
|
|
s2j_struct_get_basic_element(struct_freeauth, data, int, dport);
|
2019-08-19 08:18:47 +00:00
|
|
|
|
s2j_struct_get_basic_element(struct_freeauth, data, int, flag);
|
2019-08-09 11:42:19 +00:00
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
if(freeauth_buff) {
|
|
|
|
|
memset(freeauth_buff, 0, sizeof(freeauth_configure_t));
|
|
|
|
|
freeauth_buff->rule_priority = struct_freeauth->rule_priority;
|
|
|
|
|
strncpy(freeauth_buff->name, struct_freeauth->name, 31);
|
|
|
|
|
freeauth_buff->sip = struct_freeauth->sip;
|
|
|
|
|
freeauth_buff->dip = struct_freeauth->dip;
|
|
|
|
|
freeauth_buff->dport = struct_freeauth->dport;
|
|
|
|
|
freeauth_buff->flag = struct_freeauth->flag;
|
|
|
|
|
}
|
2019-08-19 08:18:47 +00:00
|
|
|
|
|
|
|
|
|
cJSON_Delete(cjson);
|
2019-08-20 07:46:36 +00:00
|
|
|
|
s2j_delete_struct_obj(struct_freeauth);
|
2019-08-19 08:18:47 +00:00
|
|
|
|
|
|
|
|
|
return RET_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*iuput格式:
|
|
|
|
|
{
|
|
|
|
|
"type": 0,
|
|
|
|
|
"data": [
|
|
|
|
|
{"rule_priority": 1,"name": "cary","sip": 2323790,"dip": 13546465478,"dport": 120, "flag":0},
|
|
|
|
|
{"rule_priority": 2,"name": "nicole","sip": 2323790,"dip": 13546465478,"dport": 130, "flag":0},
|
|
|
|
|
{"rule_priority": 3,"name": "arwrgmink","sip": 2323790,"dip": 13546465478,"dport": 90, "flag":0}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
ret_code authpara_config_json_parse_array(pointer input, uint *conf_type, freeauth_configure_t **fb, int *cnt)
|
|
|
|
|
{
|
2019-08-20 07:46:36 +00:00
|
|
|
|
cJSON *cjson, *data, *rule_priority, *name, *sip, *dip, *dport, *flag;
|
|
|
|
|
freeauth_configure_t *freeauth_buff = *fb;
|
2019-08-19 08:18:47 +00:00
|
|
|
|
int iCount = 0, i = 0;
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
*fb = NULL;
|
2019-08-19 08:18:47 +00:00
|
|
|
|
/*JSON字符串到JSON格式 */
|
|
|
|
|
cjson = cJSON_Parse(input);
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(!cjson) {
|
|
|
|
|
return RET_INPUTERR;
|
2019-08-19 08:18:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rpc_log_info("json input:%s \n", cJSON_Print(cjson));
|
|
|
|
|
|
|
|
|
|
/*获取免认证规则的data部分 */
|
|
|
|
|
data = cJSON_GetObjectItem(cjson, "data");
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(!data) {
|
2019-08-19 08:18:47 +00:00
|
|
|
|
cJSON_Delete(cjson);
|
2019-08-20 07:46:36 +00:00
|
|
|
|
return RET_INPUTERR;
|
2019-08-19 08:18:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*获取数组长度*/
|
|
|
|
|
iCount = cJSON_GetArraySize(data);
|
2019-08-20 07:46:36 +00:00
|
|
|
|
printf("iCount=[%d]\n", iCount);
|
|
|
|
|
|
|
|
|
|
freeauth_buff = (freeauth_configure_t *)malloc(sizeof(freeauth_configure_t) * iCount);
|
2019-08-19 08:18:47 +00:00
|
|
|
|
|
|
|
|
|
if(!freeauth_buff) {
|
|
|
|
|
cJSON_Delete(cjson);
|
2019-08-20 07:46:36 +00:00
|
|
|
|
return RET_NOMEM;
|
2019-08-19 08:18:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memset(freeauth_buff, 0, sizeof(freeauth_configure_t) * iCount);
|
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
for(i = 0; i < iCount; i++) {
|
|
|
|
|
|
|
|
|
|
cJSON *pArrayItem = cJSON_GetArrayItem(data, i);
|
|
|
|
|
|
|
|
|
|
if(pArrayItem) {
|
2019-08-19 08:18:47 +00:00
|
|
|
|
/*获取未认证权限优先级键值对*/
|
|
|
|
|
rule_priority = cJSON_GetObjectItem(pArrayItem, "rule_priority");
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(rule_priority) {
|
|
|
|
|
freeauth_buff->rule_priority = rule_priority->valueint;
|
2019-08-19 08:18:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*未认证权限名称*/
|
|
|
|
|
name = cJSON_GetObjectItem(pArrayItem, "name");
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(name) {
|
|
|
|
|
strncpy(freeauth_buff->name, name->valuestring, 31);
|
2019-08-19 08:18:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*源IP地址*/
|
|
|
|
|
sip = cJSON_GetObjectItem(pArrayItem, "sip");
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(sip) {
|
|
|
|
|
freeauth_buff->sip = sip->valueint;
|
2019-08-19 08:18:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*目的IP地址*/
|
|
|
|
|
dip = cJSON_GetObjectItem(pArrayItem, "dip");
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(dip) {
|
|
|
|
|
freeauth_buff->dip = dip->valueint;
|
2019-08-19 08:18:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*目的端口号*/
|
|
|
|
|
dport = cJSON_GetObjectItem(pArrayItem, "dport");
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(dport) {
|
|
|
|
|
freeauth_buff->dport = dport->valueint;
|
2019-08-19 08:18:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*状态标志位*/
|
|
|
|
|
flag = cJSON_GetObjectItem(pArrayItem, "flag");
|
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
if(flag) {
|
|
|
|
|
freeauth_buff->flag = flag->valueint;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
2019-08-19 08:18:47 +00:00
|
|
|
|
printf("freeauth_buff->name = %p\n", &freeauth_buff->name);
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < iCount; j++)
|
|
|
|
|
{
|
|
|
|
|
printf("[%d %s %d %d %d %d]\n",pbuf[j].rule_priority, pbuf[j].name, pbuf[j].sip,
|
|
|
|
|
pbuf[j].dip, pbuf[j].dport, pbuf[j].flag);
|
|
|
|
|
}
|
2019-08-20 07:46:36 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2019-08-19 08:18:47 +00:00
|
|
|
|
freeauth_buff++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
if(cnt) {
|
|
|
|
|
*cnt = iCount;
|
2019-08-19 08:18:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-09 11:42:19 +00:00
|
|
|
|
cJSON_Delete(cjson);
|
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
*fb = freeauth_buff;
|
2019-08-09 11:42:19 +00:00
|
|
|
|
return RET_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
ret_code authpara_config_json_parse_del_array(pointer input, uint *conf_type, freeauth_configure_t **fb, int *cnt)
|
|
|
|
|
{
|
|
|
|
|
return authpara_config_json_parse_array(input, conf_type, fb, cnt);
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-19 08:18:47 +00:00
|
|
|
|
|
2019-08-15 06:24:41 +00:00
|
|
|
|
/*chk data格式 */
|
|
|
|
|
ret_code freeauth_config_chk(uint source, uint *config_type,
|
|
|
|
|
pointer input, int *input_len,
|
|
|
|
|
pointer output, int *output_len)
|
|
|
|
|
{
|
|
|
|
|
ret_code ret = RET_OK;
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
/*增加未认证权限规则*/
|
2019-08-15 06:24:41 +00:00
|
|
|
|
ret_code freeauth_config_add_proc(uint source, uint config_type,
|
|
|
|
|
pointer input, int input_len,
|
|
|
|
|
pointer output, int *output_len)
|
2019-08-09 11:42:19 +00:00
|
|
|
|
{
|
2019-08-15 06:24:41 +00:00
|
|
|
|
int i;
|
2019-08-20 07:46:36 +00:00
|
|
|
|
cJSON *res;
|
|
|
|
|
freeauth_configure_t *freeauth_configure;
|
|
|
|
|
uint conf_type = FREEAUTH_CONFIG_GET;
|
|
|
|
|
char *ret_char = NULL;
|
|
|
|
|
unsigned int ret_int = 0;
|
|
|
|
|
authfree_result_t authfree_result;
|
2019-08-09 11:42:19 +00:00
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
freeauth_configure = (freeauth_configure_t *)malloc(sizeof(freeauth_configure_t));
|
2019-08-15 06:24:41 +00:00
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
if(freeauth_configure == NULL) {
|
|
|
|
|
return RET_NOMEM;
|
2019-08-15 06:24:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
freeauth_config_json_parse(input, &conf_type, freeauth_configure);
|
2019-08-15 06:24:41 +00:00
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
/*校验用户名长度*/
|
|
|
|
|
if(input_len != sizeof(freeauth_configure_t) || NULL == freeauth_configure->name ||
|
|
|
|
|
(UNAMESIZE) < strlen(freeauth_configure->name) || 0 == strlen(freeauth_configure->name)) {
|
|
|
|
|
free(freeauth_configure);
|
|
|
|
|
return RET_INPUTERR;
|
2019-08-09 11:42:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
/* 校验用户名中不含特殊字符 */
|
|
|
|
|
if(SPECHAR(freeauth_configure->name)) {
|
|
|
|
|
free(freeauth_configure);
|
|
|
|
|
return RET_INPUTERR;
|
2019-08-09 11:42:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
if((freeauth_configure->dport < DPORT_MIN_NUM) || (freeauth_configure->dport > DPORT_MAX_NUM)) {
|
|
|
|
|
free(freeauth_configure);
|
|
|
|
|
return RET_IPINVALID;
|
2019-08-09 11:42:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-15 06:24:41 +00:00
|
|
|
|
/*查找要增加的未认证权限是否重名 该名字已存在 则退出程序 */
|
2019-08-20 07:46:36 +00:00
|
|
|
|
for(i = 0; i < RULE_MAX_NUM; i++) {
|
2019-08-15 06:24:41 +00:00
|
|
|
|
/*两个字符串相等 strcmp值为0*/
|
2019-08-20 07:46:36 +00:00
|
|
|
|
if(0 == strcmp(freeauth_array[i].name, freeauth_configure->name)) {
|
2019-08-15 06:24:41 +00:00
|
|
|
|
printf("%s(%d) freeauth_array[%d] = %p\n", __FUNCTION__, __LINE__, i, &freeauth_array[i]);
|
2019-08-20 07:46:36 +00:00
|
|
|
|
free(freeauth_configure);
|
|
|
|
|
return RET_EXIST;
|
2019-08-15 06:24:41 +00:00
|
|
|
|
}
|
2019-08-09 11:42:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-15 06:24:41 +00:00
|
|
|
|
/*数据库修改 存入全局变量*/
|
2019-08-19 08:18:47 +00:00
|
|
|
|
add_authfree(freeauth_configure->rule_priority, freeauth_configure->name, freeauth_configure->sip, freeauth_configure->dip,
|
2019-08-20 07:46:36 +00:00
|
|
|
|
freeauth_configure->dport, freeauth_configure->flag, &authfree_result);
|
2019-08-09 11:42:19 +00:00
|
|
|
|
|
2019-08-15 06:24:41 +00:00
|
|
|
|
#if 0
|
2019-08-09 11:42:19 +00:00
|
|
|
|
/*用户态下发到内核态auth_hook */
|
|
|
|
|
int r = -1;
|
|
|
|
|
printf("cfgchannel main begin:\r\n");
|
|
|
|
|
|
|
|
|
|
/*创建通道 */
|
|
|
|
|
r = commcfgnl_open();
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(r < 0) {
|
2019-08-09 11:42:19 +00:00
|
|
|
|
printf(" pdlivnl_open fail, exit.\r\n");
|
|
|
|
|
return RET_ERR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*下发配置到内核态 */
|
|
|
|
|
r = set_freeauthcfg_waitack(freeauth_configure);
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(r < 0) {
|
2019-08-09 11:42:19 +00:00
|
|
|
|
printf("set_cfg_debug_waitack failed.\r\n");
|
|
|
|
|
return RET_ERR;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
/*关闭netlink通道 */
|
2019-08-09 11:42:19 +00:00
|
|
|
|
commcfgnl_close();
|
|
|
|
|
printf("cfgchannel main exit!\r\n");
|
2019-08-15 06:24:41 +00:00
|
|
|
|
#endif
|
2019-08-09 11:42:19 +00:00
|
|
|
|
|
|
|
|
|
/*创建json对象 */
|
|
|
|
|
res = cJSON_CreateObject();
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(!res) {
|
2019-08-09 11:42:19 +00:00
|
|
|
|
free(freeauth_configure);
|
2019-08-20 07:46:36 +00:00
|
|
|
|
return RET_ERR;
|
2019-08-09 11:42:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*将json对象转换成json字符串 返回处理结果*/
|
2019-08-20 07:46:36 +00:00
|
|
|
|
cJSON_AddNumberToObject(res, "resultcode", authfree_result.resultcode);
|
|
|
|
|
cJSON_AddStringToObject(res, "message", authfree_result.message);
|
2019-08-09 11:42:19 +00:00
|
|
|
|
ret_char = cJSON_PrintUnformatted(res);
|
|
|
|
|
ret_int = strlen(ret_char);
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(output_len) {
|
2019-08-09 11:42:19 +00:00
|
|
|
|
*output_len = ret_int;
|
|
|
|
|
}
|
2019-08-15 06:24:41 +00:00
|
|
|
|
|
2019-08-09 11:42:19 +00:00
|
|
|
|
/*超出2k的内存,报错 */
|
2019-08-20 07:46:36 +00:00
|
|
|
|
if(ret_int >= 1024 * 2) {
|
2019-08-09 11:42:19 +00:00
|
|
|
|
free(ret_char);
|
2019-08-20 07:46:36 +00:00
|
|
|
|
free(freeauth_configure);
|
2019-08-09 11:42:19 +00:00
|
|
|
|
cJSON_Delete(res);
|
|
|
|
|
return RET_NOMEM;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-15 06:24:41 +00:00
|
|
|
|
memcpy(output, ret_char, ret_int + 1);
|
2019-08-09 11:42:19 +00:00
|
|
|
|
|
|
|
|
|
free(ret_char);
|
|
|
|
|
cJSON_Delete(res);
|
2019-08-20 07:46:36 +00:00
|
|
|
|
free(freeauth_configure);
|
|
|
|
|
|
2019-08-15 06:24:41 +00:00
|
|
|
|
return RET_OK;
|
2019-08-09 11:42:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ret_code freeauth_config_mod_proc(uint source, uint config_type,
|
2019-08-15 06:24:41 +00:00
|
|
|
|
pointer input, int input_len,
|
|
|
|
|
pointer output, int *output_len)
|
2019-08-09 11:42:19 +00:00
|
|
|
|
{
|
2019-08-15 06:24:41 +00:00
|
|
|
|
int i;
|
2019-08-19 08:18:47 +00:00
|
|
|
|
int cnt;
|
2019-08-20 07:46:36 +00:00
|
|
|
|
cJSON *res;
|
|
|
|
|
authfree_result_t authfree_result;
|
|
|
|
|
freeauth_configure_t *freeauth_configure = NULL;
|
|
|
|
|
uint conf_type = FREEAUTH_CONFIG_GET;
|
|
|
|
|
char *ret_char = NULL;
|
|
|
|
|
unsigned int ret_int = 0;
|
2019-08-09 11:42:19 +00:00
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
authpara_config_json_parse_array(input, &conf_type, &freeauth_configure, &cnt);
|
2019-08-15 06:24:41 +00:00
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
if(input_len != sizeof(freeauth_configure_t)) {
|
|
|
|
|
return RET_INPUTERR;
|
2019-08-19 08:18:47 +00:00
|
|
|
|
}
|
2019-08-15 06:24:41 +00:00
|
|
|
|
|
2019-08-19 08:18:47 +00:00
|
|
|
|
/*查找要修改的免认证规则名字,不存在则退出程序 */
|
2019-08-20 07:46:36 +00:00
|
|
|
|
for(i = 0; i < RULE_MAX_NUM; i++) {
|
2019-08-19 08:18:47 +00:00
|
|
|
|
/*两个字符串相等 strcmp值为0*/
|
2019-08-20 07:46:36 +00:00
|
|
|
|
for(int j = 0; j < cnt; j++) {
|
|
|
|
|
|
|
|
|
|
if(0 == strcmp(freeauth_array[i].name, freeauth_configure[j].name)) {
|
2019-08-19 08:18:47 +00:00
|
|
|
|
printf("%s %d\n", freeauth_array[i].name, i);
|
|
|
|
|
printf("%s %d\n", freeauth_configure[j].name, j);
|
|
|
|
|
printf("%s(%d) freeauth_array[%d] = %p\n", __FUNCTION__, __LINE__, i, &freeauth_array[j]);
|
|
|
|
|
/*数据库修改 存入全局变量*/
|
2019-08-20 07:46:36 +00:00
|
|
|
|
mod_authfree(freeauth_configure[j].rule_priority, freeauth_configure[j].name, freeauth_configure[j].sip, freeauth_configure[j].dip,
|
|
|
|
|
freeauth_configure[j].dport, freeauth_configure[j].flag, &authfree_result);
|
2019-08-19 08:18:47 +00:00
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
#if 0
|
2019-08-19 08:18:47 +00:00
|
|
|
|
/*用户态下发到内核态auth_hook */
|
|
|
|
|
int r = -1;
|
|
|
|
|
printf("cfgchannel main begin:\r\n");
|
|
|
|
|
|
|
|
|
|
/*创建通道 */
|
|
|
|
|
r = commcfgnl_open();
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(r < 0) {
|
2019-08-19 08:18:47 +00:00
|
|
|
|
printf(" pdlivnl_open fail, exit.\r\n");
|
|
|
|
|
return RET_ERR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*下发配置到内核态 */
|
|
|
|
|
r = set_freeauthcfg_waitack(freeauth_configure);
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(r < 0) {
|
2019-08-19 08:18:47 +00:00
|
|
|
|
printf("set_cfg_debug_waitack failed.\r\n");
|
|
|
|
|
return RET_ERR;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
/*关闭netlink通道 */
|
2019-08-19 08:18:47 +00:00
|
|
|
|
commcfgnl_close();
|
|
|
|
|
printf("cfgchannel main exit!\r\n");
|
2019-08-20 07:46:36 +00:00
|
|
|
|
#endif
|
2019-08-19 08:18:47 +00:00
|
|
|
|
|
|
|
|
|
/*创建json对象 */
|
|
|
|
|
res = cJSON_CreateObject();
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(!res) {
|
|
|
|
|
return RET_ERR;
|
2019-08-19 08:18:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*将json对象转换成json字符串 返回处理结果*/
|
2019-08-20 07:46:36 +00:00
|
|
|
|
cJSON_AddNumberToObject(res, "resultcode", authfree_result.resultcode);
|
|
|
|
|
cJSON_AddStringToObject(res, "message", authfree_result.message);
|
2019-08-19 08:18:47 +00:00
|
|
|
|
ret_char = cJSON_PrintUnformatted(res);
|
|
|
|
|
ret_int = strlen(ret_char);
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(output_len) {
|
2019-08-19 08:18:47 +00:00
|
|
|
|
*output_len = ret_int;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*超出2k的内存,报错 */
|
2019-08-20 07:46:36 +00:00
|
|
|
|
if(ret_int >= 1024 * 2) {
|
2019-08-19 08:18:47 +00:00
|
|
|
|
free(ret_char);
|
|
|
|
|
cJSON_Delete(res);
|
|
|
|
|
return RET_NOMEM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memcpy(output, ret_char, ret_int + 1);
|
2019-08-15 06:24:41 +00:00
|
|
|
|
|
|
|
|
|
free(ret_char);
|
|
|
|
|
cJSON_Delete(res);
|
|
|
|
|
}
|
2019-08-20 07:46:36 +00:00
|
|
|
|
}
|
2019-08-19 08:18:47 +00:00
|
|
|
|
}
|
2019-08-15 06:24:41 +00:00
|
|
|
|
|
2019-08-19 08:18:47 +00:00
|
|
|
|
if(freeauth_configure) {
|
|
|
|
|
free(freeauth_configure);
|
2019-08-09 11:42:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-19 08:18:47 +00:00
|
|
|
|
return RET_OK;
|
|
|
|
|
|
2019-08-09 11:42:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-19 08:18:47 +00:00
|
|
|
|
|
2019-08-09 11:42:19 +00:00
|
|
|
|
ret_code freeauth_config_del_proc(uint source, uint config_type,
|
2019-08-15 06:24:41 +00:00
|
|
|
|
pointer input, int input_len,
|
|
|
|
|
pointer output, int *output_len)
|
2019-08-09 11:42:19 +00:00
|
|
|
|
{
|
2019-08-15 06:24:41 +00:00
|
|
|
|
int i;
|
2019-08-19 08:18:47 +00:00
|
|
|
|
int cnt;
|
2019-08-20 07:46:36 +00:00
|
|
|
|
cJSON *res;
|
|
|
|
|
authfree_result_t authfree_result;
|
|
|
|
|
freeauth_configure_t *freeauth_configure = NULL;
|
|
|
|
|
uint conf_type = FREEAUTH_CONFIG_GET;
|
|
|
|
|
char *ret_char = NULL;
|
|
|
|
|
unsigned int ret_int = 0;
|
2019-08-09 11:42:19 +00:00
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
#if 0
|
|
|
|
|
freeauth_configure = (freeauth_configure_t *)malloc(sizeof(freeauth_configure_t));
|
2019-08-09 11:42:19 +00:00
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
if(freeauth_configure == NULL) {
|
|
|
|
|
return RET_NAMEINVAL;
|
2019-08-09 11:42:19 +00:00
|
|
|
|
}
|
2019-08-15 06:24:41 +00:00
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
#endif
|
2019-08-15 06:24:41 +00:00
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
authpara_config_json_parse_del_array(input, &conf_type, &freeauth_configure, &cnt);
|
2019-08-15 06:24:41 +00:00
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
if(input_len != sizeof(freeauth_configure_t)) {
|
|
|
|
|
return RET_INPUTERR;
|
2019-08-19 08:18:47 +00:00
|
|
|
|
}
|
2019-08-15 06:24:41 +00:00
|
|
|
|
|
2019-08-19 08:18:47 +00:00
|
|
|
|
/*查找要修改的免认证规则名字,不存在则退出程序 */
|
2019-08-20 07:46:36 +00:00
|
|
|
|
for(i = 0; i < RULE_MAX_NUM; i++) {
|
2019-08-19 08:18:47 +00:00
|
|
|
|
/*两个字符串相等 strcmp值为0*/
|
2019-08-20 07:46:36 +00:00
|
|
|
|
for(int j = 0; j < cnt; j++) {
|
|
|
|
|
|
|
|
|
|
if(0 == strcmp(freeauth_array[i].name, freeauth_configure[j].name)) {
|
2019-08-19 08:18:47 +00:00
|
|
|
|
printf("%s %d\n", freeauth_array[i].name, i);
|
|
|
|
|
printf("%s %d\n", freeauth_configure[j].name, j);
|
|
|
|
|
printf("%s(%d) freeauth_array[%d] = %p\n", __FUNCTION__, __LINE__, i, &freeauth_array[j]);
|
|
|
|
|
/*数据库修改 存入全局变量*/
|
2019-08-20 07:46:36 +00:00
|
|
|
|
del_authfree(freeauth_configure[j].name, &authfree_result);
|
|
|
|
|
|
|
|
|
|
#if 0
|
2019-08-19 08:18:47 +00:00
|
|
|
|
/*用户态下发到内核态auth_hook */
|
|
|
|
|
int r = -1;
|
|
|
|
|
printf("cfgchannel main begin:\r\n");
|
|
|
|
|
|
|
|
|
|
/*创建通道 */
|
|
|
|
|
r = commcfgnl_open();
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(r < 0) {
|
2019-08-19 08:18:47 +00:00
|
|
|
|
printf(" pdlivnl_open fail, exit.\r\n");
|
|
|
|
|
return RET_ERR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*下发配置到内核态 */
|
|
|
|
|
r = set_freeauthcfg_waitack(freeauth_configure);
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(r < 0) {
|
2019-08-19 08:18:47 +00:00
|
|
|
|
printf("set_cfg_debug_waitack failed.\r\n");
|
|
|
|
|
return RET_ERR;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
/*关闭netlink通道 */
|
2019-08-19 08:18:47 +00:00
|
|
|
|
commcfgnl_close();
|
|
|
|
|
printf("cfgchannel main exit!\r\n");
|
2019-08-20 07:46:36 +00:00
|
|
|
|
#endif
|
2019-08-19 08:18:47 +00:00
|
|
|
|
|
|
|
|
|
/*创建json对象 */
|
|
|
|
|
res = cJSON_CreateObject();
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(!res) {
|
|
|
|
|
return RET_ERR;
|
2019-08-19 08:18:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*将json对象转换成json字符串 返回处理结果*/
|
2019-08-20 07:46:36 +00:00
|
|
|
|
cJSON_AddNumberToObject(res, "resultcode", authfree_result.resultcode);
|
|
|
|
|
cJSON_AddStringToObject(res, "message", authfree_result.message);
|
2019-08-19 08:18:47 +00:00
|
|
|
|
ret_char = cJSON_PrintUnformatted(res);
|
|
|
|
|
ret_int = strlen(ret_char);
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
if(output_len) {
|
2019-08-19 08:18:47 +00:00
|
|
|
|
*output_len = ret_int;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*超出2k的内存,报错 */
|
2019-08-20 07:46:36 +00:00
|
|
|
|
if(ret_int >= 1024 * 2) {
|
2019-08-19 08:18:47 +00:00
|
|
|
|
free(ret_char);
|
|
|
|
|
cJSON_Delete(res);
|
|
|
|
|
return RET_NOMEM;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memcpy(output, ret_char, ret_int + 1);
|
2019-08-15 06:24:41 +00:00
|
|
|
|
|
|
|
|
|
free(ret_char);
|
|
|
|
|
cJSON_Delete(res);
|
|
|
|
|
}
|
2019-08-20 07:46:36 +00:00
|
|
|
|
}
|
2019-08-19 08:18:47 +00:00
|
|
|
|
}
|
2019-08-15 06:24:41 +00:00
|
|
|
|
|
2019-08-19 08:18:47 +00:00
|
|
|
|
if(freeauth_configure) {
|
|
|
|
|
free(freeauth_configure);
|
2019-08-09 11:42:19 +00:00
|
|
|
|
}
|
2019-08-19 08:18:47 +00:00
|
|
|
|
|
|
|
|
|
return RET_OK;
|
2019-08-09 11:42:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-19 08:18:47 +00:00
|
|
|
|
|
2019-08-09 11:42:19 +00:00
|
|
|
|
ret_code freeauth_config_proc(uint source, uint config_type,
|
2019-08-15 06:24:41 +00:00
|
|
|
|
pointer input, int input_len,
|
|
|
|
|
pointer output, int *output_len)
|
2019-08-09 11:42:19 +00:00
|
|
|
|
{
|
|
|
|
|
ret_code ret = RET_OK;
|
2019-08-15 06:24:41 +00:00
|
|
|
|
freeauth_configure_t freeauth_configure = {0};
|
|
|
|
|
int config_len = sizeof(freeauth_configure_t);
|
|
|
|
|
uint conf_type = FREEAUTH_CONFIG_GET;
|
|
|
|
|
char *ret_char = NULL;
|
|
|
|
|
unsigned int ret_int = 0;
|
2019-08-09 11:42:19 +00:00
|
|
|
|
int r = -1;
|
|
|
|
|
cJSON *res;
|
2019-08-15 06:24:41 +00:00
|
|
|
|
int code = 0;
|
2019-08-09 11:42:19 +00:00
|
|
|
|
|
2019-08-19 08:18:47 +00:00
|
|
|
|
freeauth_config_json_type(input, &conf_type);
|
|
|
|
|
rpc_log_info("config type is %d\n", conf_type);
|
2019-08-09 11:42:19 +00:00
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
switch(conf_type) {
|
|
|
|
|
case FREEAUTH_CONFIG_ADD:
|
|
|
|
|
ret = freeauth_config_add_proc(source, conf_type,
|
|
|
|
|
input, input_len,
|
|
|
|
|
output, output_len);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case FREEAUTH_CONFIG_MOD:
|
|
|
|
|
ret = freeauth_config_mod_proc(source, conf_type,
|
|
|
|
|
input, input_len,
|
|
|
|
|
output, output_len);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case FREEAUTH_CONFIG_DEL:
|
|
|
|
|
ret = freeauth_config_del_proc(source, conf_type,
|
|
|
|
|
input, input_len,
|
|
|
|
|
output, output_len);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
ret = RET_NOTSUPPORT;
|
2019-08-15 06:24:41 +00:00
|
|
|
|
}
|
2019-08-09 11:42:19 +00:00
|
|
|
|
|
2019-08-15 06:24:41 +00:00
|
|
|
|
return RET_OK;
|
|
|
|
|
}
|
2019-08-09 11:42:19 +00:00
|
|
|
|
|
|
|
|
|
|
2019-08-19 08:18:47 +00:00
|
|
|
|
|
2019-08-20 07:46:36 +00:00
|
|
|
|
|
|
|
|
|
|