secgateway/Platform/user/configm/config-server/web_config/authfree.h

97 lines
3.2 KiB
C
Raw Normal View History

#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
#define FREEAUTH_CONFIG_MOD 1
#define FREEAUTH_CONFIG_DEL 2
#define FREEAUTH_CONFIG_GET 3
/*配置消息 */
typedef struct {
int rule_priority; /*未认证权限优先级*/
char name[32]; /*未认证权限名称*/
uint32_t sip; /*未认证权限源IP地址*/
uint32_t dip; /*未认证权限目的IP地址*/
int dport; /*未认证权限目的端口号*/
int flag; /*状态标志位0表示状态启动1表示状态禁用*/
}freeauth_configure_t;
typedef struct {
int resultcode;
char *message;
}authfree_result_t;
/* 判断IPv4格式是否正确*/
int isIpV4Addr(const char *ipAddr);
/*下发配置到内核态 */
int set_freeauthcfg_waitack(freeauth_configure_t *struct_freeauth);
/*获取json串类型*/
ret_code freeauth_config_json_type(pointer input, uint *conf_type);
/*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);
/*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);
ret_code authpara_config_json_parse_del_array(pointer input, uint *conf_type, freeauth_configure_t **fb, int *cnt);
/*chk data格式 */
ret_code freeauth_config_chk(uint source, uint *config_type,
pointer input, int *input_len,
pointer output, int *output_len);
/*增加未认证权限规则 */
ret_code freeauth_config_add_proc(uint source, uint config_type,
pointer input, int input_len,
pointer output, int *output_len);
/*修改未认证权限规则 */
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_del_proc(uint source, uint config_type,
pointer input, int input_len,
pointer output, int *output_len);
ret_code freeauth_config_proc(uint source, uint config_type,
pointer input, int input_len,
pointer output, int *output_len);
#endif