secgateway/Platform/user/configm/config-server/include/brconfig.h

181 lines
5.3 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef BRCONFIG_H_
#define BRCONFIG_H_
#include "list.h"
#define BR_NAMSIZ INTERFACE_NAMSIZ
#define MAC_STRSIZ 32
#define LOCAL_STRSIZ 16
#define TIME_STRSIZ 16
#define MAC_MAXIZS 1024
#define FDB_CHUNK 128
typedef enum {
BR_CREATE_EVENT = 1,
BR_DELETE_EVENT,
BR_CREATE_EVENT_PRE,
BR_DELETE_EVENT_PRE,
BR_IF_JOIN_EVENT,
BR_IF_LEAVE_EVENT,
BR_IF_JOIN_EVENT_PRE,
BR_IF_LEAVE_EVENT_PRE,
BR_EVENT_INVALID
} BR_EVENT_TYPE;
/************************************************************/
/* 结构体 */
/************************************************************/
/* 事件通知数据结构 */
struct _br_event {
char *br_name;
char *if_name;
};
typedef struct _br_event br_event_t;
typedef int (*BR_EVENT_FUNC)(BR_EVENT_TYPE event_type,
br_event_t event_arg);
struct _br_event_node {
struct hlist_node list;
BR_EVENT_TYPE br_event;
BR_EVENT_FUNC event_func;
};
typedef struct _br_event_node br_event_node_t;
struct _br_event_head {
struct hlist_head head;
pthread_mutex_t lock;
boolean init;
};
typedef struct _br_event_head br_event_head_t;
/* 临时数据结构 */
struct _br_temp {
char *br_name;
boolean result;
};
typedef struct _br_temp br_temp_t;
/* 配置消息数据结构 */
struct _br_config {
char br_name[BR_NAMSIZ];
int port_num;
char **ports;
};
typedef struct _br_config br_config_t;
struct _br_fdb_config {
char br_name[BR_NAMSIZ];
};
typedef struct _br_fdb_config br_fdb_config_t;
/* json解析数据结构 */
struct _br_config_string {
int config_type;
char br_name[BR_NAMSIZ];
};
typedef struct _br_config_string br_config_string_t;
struct _br_if_config_string {
int config_type;
char br_name[BR_NAMSIZ];
char **ports;
};
typedef struct _br_if_config_string br_if_config_string_t;
struct _br_fdb_string{
int config_type;
char br_name[BR_NAMSIZ];
};
typedef struct _br_fdb_string br_fdb_string_t;
/* 状态数据结构 */
struct _br_fdb_info{
char mac_addr[MAC_STRSIZ];
char port[INTERFACE_NAMSIZ];
char local[LOCAL_STRSIZ];
char time[TIME_STRSIZ];
};
typedef struct _br_fdb_info fdb_info_t;
struct _br_fdb_status{
char br_name[BR_NAMSIZ];
int fdb_num;
fdb_info_t fdb_info[MAC_MAXIZS];
};
typedef struct _br_fdb_status br_fdb_status_t;
/* **********************************************************/
/* 提供给其他模块调用的函数 */
/************************************************************/
/* 添加桥sys_err 表示内核返回的系统错误码*/
ret_code br_bridge_add(char *br_name, int *sys_err);
/* 删除桥sys_err 表示内核返回的系统错误码 */
ret_code br_bridge_del(char * br_name, int *sys_err);
/* 通过接口名获取所在桥名 */
ret_code br_if_bridge_get(char *port_name , char *br_name);
/* 向桥中添加接口 */
ret_code br_if_bridge_add(char *br_name, char *port_list,
int cnt, int *sys_err);
/* 删除桥中的接口 */
ret_code br_if_bridge_del(char *br_name, char *port_list,
int cnt, int *sys_err);
/* 获取桥中接口数量 */
int br_if_bridge_num(char *br_name);
/* 注册桥事件通知函数 */
ret_code br_event_register(BR_EVENT_TYPE event_type,
BR_EVENT_FUNC event_func);
/* 去注册桥事件通知函数 */
ret_code br_event_unregister(BR_EVENT_TYPE event_type,
BR_EVENT_FUNC event_func);
/* **********************************************************/
/* 配置管理注册函数 */
/************************************************************/
/* 桥配置 */
ret_code br_config_chk(uint source,uint *config_type,
pointer input, int *input_len,
pointer output, int *output_len);
ret_code br_config_proc(uint source, uint config_type,
pointer input, int input_len,
pointer output, int *output_len);
/* 桥接口配置 */
ret_code br_if_config_chk(uint source,uint *config_type,
pointer input, int *input_len,
pointer output, int *output_len);
ret_code br_if_config_proc(uint source, uint config_type,
pointer input, int input_len,
pointer output, int *output_len);
ret_code br_if_config_get(uint source,
pointer input, int input_len,
pointer output, int *output_len);
ret_code br_if_config_get_all(uint source,
pointer output, int *output_len);
/* 桥fdb配置 */
ret_code br_fdb_config_chk(uint source,uint *config_type,
pointer input, int *input_len,
pointer output, int *output_len);
ret_code br_fdb_config_get(uint source,
pointer input, int input_len,
pointer output, int *output_len);
/* 模块初始化 */
ret_code br_bridge_init();
#endif