2019-08-09 11:42:19 +00:00
|
|
|
|
#ifndef FREEAUTH_H_
|
|
|
|
|
#define FREEAUTH_H_
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.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 "../../../../common/rpc/rpc_common.h"
|
|
|
|
|
|
|
|
|
|
#define DPORT_MIN_NUM 0
|
|
|
|
|
#define DPORT_MAX_NUM 65535
|
|
|
|
|
#define RULE_MAX_NUM 10
|
|
|
|
|
|
|
|
|
|
#define FREEAUTH_CONFIG_ADD 0
|
2019-09-02 03:24:08 +00:00
|
|
|
|
#define FREEAUTH_CONFIG_MOV 1
|
2019-08-15 06:24:41 +00:00
|
|
|
|
#define FREEAUTH_CONFIG_DEL 2
|
2019-09-02 03:24:08 +00:00
|
|
|
|
#define FREEAUTH_CONFIG_MOD 3
|
|
|
|
|
#define FREEAUTH_CONFIG_GET 4
|
2019-08-09 11:42:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*配置消息 */
|
|
|
|
|
typedef struct {
|
2019-08-19 08:18:47 +00:00
|
|
|
|
int rule_priority; /*未认证权限优先级*/
|
|
|
|
|
char name[32]; /*未认证权限名称*/
|
|
|
|
|
uint32_t sip; /*未认证权限源IP地址*/
|
|
|
|
|
uint32_t dip; /*未认证权限目的IP地址*/
|
|
|
|
|
int dport; /*未认证权限目的端口号*/
|
|
|
|
|
int flag; /*状态标志位,0表示状态启动,1表示状态禁用*/
|
|
|
|
|
|
2019-08-09 11:42:19 +00:00
|
|
|
|
}freeauth_configure_t;
|
|
|
|
|
|
2019-09-02 03:24:08 +00:00
|
|
|
|
/*修改权限消息*/
|
|
|
|
|
typedef struct {
|
|
|
|
|
char name[32];
|
|
|
|
|
int after;
|
|
|
|
|
}rule_mod_t;
|
|
|
|
|
|
2019-08-15 06:24:41 +00:00
|
|
|
|
typedef struct {
|
|
|
|
|
int resultcode;
|
|
|
|
|
char *message;
|
|
|
|
|
}authfree_result_t;
|
|
|
|
|
|
2019-08-09 11:42:19 +00:00
|
|
|
|
|
|
|
|
|
/* 判断IPv4格式是否正确*/
|
|
|
|
|
int isIpV4Addr(const char *ipAddr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*下发配置到内核态 */
|
|
|
|
|
int set_freeauthcfg_waitack(freeauth_configure_t *struct_freeauth);
|
|
|
|
|
|
2019-08-19 08:18:47 +00:00
|
|
|
|
/*获取json串类型*/
|
|
|
|
|
ret_code freeauth_config_json_type(pointer input, uint *conf_type);
|
2019-08-09 11:42:19 +00:00
|
|
|
|
|
2019-09-02 03:24:08 +00:00
|
|
|
|
/*修改json字符串转为结构体 把未认证权限名称为name的序号移动到序号3前面*/
|
|
|
|
|
/*iuput格式:{"type": 1, "data": {"name": "armink", "after": 3}}*/
|
|
|
|
|
ret_code freeauth_mov_json_parse(pointer input, uint *conf_type, rule_mod_t *rule_mod);
|
|
|
|
|
|
|
|
|
|
|
2019-08-19 08:18:47 +00:00
|
|
|
|
/*json字符串转为结构体*/
|
|
|
|
|
/*iuput格式:{"type": 0, "data": {"rule_priority": 1, "name": "armink","sip": 1027824,"dip": 103427824,"dport": 24, "flag":0}}*/
|
|
|
|
|
ret_code freeauth_config_json_parse(pointer input, uint *conf_type, freeauth_configure_t *freeauth_buff);
|
2019-08-09 11:42:19 +00:00
|
|
|
|
|
|
|
|
|
|
2019-08-19 08:18:47 +00:00
|
|
|
|
/*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}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
*/
|
2019-09-02 03:24:08 +00:00
|
|
|
|
ret_code authfree_config_json_parse_array(pointer input, uint *conf_type, freeauth_configure_t **fb, int *cnt);
|
2019-08-09 11:42:19 +00:00
|
|
|
|
|
|
|
|
|
|
2019-08-19 08:18:47 +00:00
|
|
|
|
/*chk data格式 */
|
|
|
|
|
ret_code freeauth_config_chk(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-19 08:18:47 +00:00
|
|
|
|
/*增加未认证权限规则 */
|
2019-08-09 11:42:19 +00:00
|
|
|
|
ret_code freeauth_config_add_proc(uint source, uint config_type,
|
2019-08-19 08:18:47 +00:00
|
|
|
|
pointer input, int input_len,
|
|
|
|
|
pointer output, int *output_len);
|
2019-08-09 11:42:19 +00:00
|
|
|
|
|
2019-09-02 03:24:08 +00:00
|
|
|
|
/*移动未认证权限规则 */
|
|
|
|
|
ret_code freeauth_config_mov_proc(uint source, uint config_type,
|
2019-08-19 08:18:47 +00:00
|
|
|
|
pointer input, int input_len,
|
|
|
|
|
pointer output, int *output_len);
|
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-19 08:18:47 +00:00
|
|
|
|
pointer input, int input_len,
|
|
|
|
|
pointer output, int *output_len);
|
2019-08-09 11:42:19 +00:00
|
|
|
|
|
2019-09-02 03:24:08 +00:00
|
|
|
|
/*修改未认证权限规则*/
|
|
|
|
|
ret_code freeauth_config_mod_proc(uint source, uint config_type,
|
|
|
|
|
pointer input, int input_len,
|
|
|
|
|
pointer output, int *output_len);
|
|
|
|
|
|
|
|
|
|
/*查询未认证权限*/
|
|
|
|
|
ret_code freeauth_config_get_proc(uint source, uint config_type,
|
|
|
|
|
pointer input, int input_len,
|
|
|
|
|
pointer output, int *output_len);
|
|
|
|
|
|
2019-08-09 11:42:19 +00:00
|
|
|
|
ret_code freeauth_config_proc(uint source, uint config_type,
|
2019-08-19 08:18:47 +00:00
|
|
|
|
pointer input, int input_len,
|
|
|
|
|
pointer output, int *output_len);
|
|
|
|
|
|
2019-08-09 11:42:19 +00:00
|
|
|
|
|
|
|
|
|
#endif
|