#ifndef BRCONFIG_H_ #define BRCONFIG_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_IF_JOIN_EVENT, BR_IF_LEAVE_EVENT, BR_EVENT_INVALID } BR_EVENT_TYPE; typedef int (*BR_EVENT_FUNC)(BR_EVENT_TYPE event_type, br_event_t event_arg); /************************************************************/ /* 结构体 */ /************************************************************/ /* 事件通知数据结构 */ struct _br_event { char *br_name; char *if_name; }; typedef struct _br_event br_event_t; 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 _brif_temp { int index; char *if_list; }; typedef struct _brif_temp br_if_temp_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; /* **********************************************************/ /* 提供给其他模块调用的函数 */ /************************************************************/ /* 通过接口名获取所在桥名 */ int 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_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); #endif