void get_cam_keyword_log_pre_translate(UserOperate_t* user_op, ResultContext_t *result_context ) { WS_ENV* ws_env; int * my_data = NULL; (void)ResultContext__getWsEnv(result_context, &ws_env); my_data = (int*)ws_malloc(ws_env, sizeof(int)); memset(my_data, 0, sizeof(int)); UserOperate__setUserData(user_op, my_data); }
/***************************************************************************** 函 数 名 : route_list_pre_translate 功能描述 : route list 预处理 输入参数 : user_op ---- user_opetate结构 result_context ---- 结果集 输出参数: 无 返 回 值: WS_OK,执行成功 -------------------------------------------------------------------------------- 最近一次修改记录: 修改作者: zhuliying 修改目的: 创建新函数 修改日期: 2009年12月14日 *****************************************************************************/ void route_list_pre_translate(UserOperate_t* user_op, ResultContext_t *result_context ) { WS_ENV* ws_env; struct uo_route_list_t *my_data; (void)ResultContext__getWsEnv(result_context, &ws_env); my_data = ws_malloc(ws_env, sizeof(struct uo_route_list_t)); memset(my_data, 0, sizeof(struct uo_route_list_t)); UserOperate__setUserData(user_op, my_data); }
void userdef_pro_rule_list_pre_translate(UserOperate_t* user_op, ResultContext_t *result_context ) { WS_ENV* ws_env; struct uo_userdef_proto_audit_rule_list_t * my_data = NULL; (void)ResultContext__getWsEnv(result_context, &ws_env); my_data = (struct uo_userdef_proto_audit_rule_list_t*)ws_malloc(ws_env, sizeof(struct uo_userdef_proto_audit_rule_list_t)); memset(my_data, 0, sizeof(struct uo_userdef_proto_audit_rule_list_t)); UserOperate__setUserData(user_op, my_data); }
void search_session_ctl_pre_translate(UserOperate_t* user_op, ResultContext_t *result_context ) { WS_ENV* ws_env; struct uo_session_ctl_t * my_data = NULL; (void)ResultContext__getWsEnv(result_context, &ws_env); my_data = (struct uo_session_ctl_t*)ws_malloc(ws_env, sizeof(struct uo_session_ctl_t)); memset(my_data, 0, sizeof(struct uo_session_ctl_t)); UserOperate__setUserData(user_op, my_data); }
void cam_log_pre_translate(UserOperate_t* user_op, ResultContext_t *result_context) { WS_ENV* ws_env; struct uo_cam_log_t * my_data = NULL; (void)ResultContext__getWsEnv(result_context, &ws_env); my_data = (struct uo_cam_log_t*)ws_malloc(ws_env, sizeof(struct uo_cam_log_t)); memset(my_data, 0, sizeof(struct uo_cam_log_t)); my_data->mCamLogId = 0; UserOperate__setUserData(user_op, my_data); }
/******************************************************************************* 函数名称 : netaddr_group_pre_translate 功能描述 : 地址配置的导出 输入参数 : user_op ---- user_opetate结构 result_context ---- 结果集 输出参数 : 无 返 回 值 : 无 -------------------------------------------------------------------------------- 最近一次修改记录: 修改作者 : 张发奇 修改目的 : 整改 修改日期 : 2012年2月19日 *******************************************************************************/ void netaddr_group_pre_translate(UserOperate_t* user_op, ResultContext_t *result_context ) { WS_ENV* ws_env; struct uo_netadr_export * my_data = NULL; (void)ResultContext__getWsEnv(result_context, &ws_env); my_data = (struct uo_netadr_export*)ws_malloc(ws_env, sizeof(struct uo_netadr_export)); memset(my_data, 0, sizeof(struct uo_netadr_export)); UserOperate__setUserData(user_op, my_data); }
void ip6addr_obj_pre_translate(UserOperate_t* user_op, ResultContext_t *result_context ) { WS_ENV* ws_env; struct uo_ip6addr_info* my_data = NULL; (void)ResultContext__getWsEnv(result_context, &ws_env); my_data = (struct uo_ip6addr_info*)ws_malloc(ws_env, sizeof(struct uo_ip6addr_info)); memset(my_data, 0, sizeof(struct uo_ip6addr_info)); UserOperate__setUserData(user_op, my_data); }
void *ws_memdup(const void *ptr, size_t size) { unsigned char *data = ws_malloc(size + 1); if (data == NULL) return NULL; memcpy(data, ptr, size); data[size] = '\0'; return data; }
/***************************************************************************** 函 数 名 : ws__getPoeIlimit 功能描述 : 获取poe设备的电流信息 输入参数 : ws_env ---- web service执行环境 输出参数 : ret ---- 得到poe 设备信息 返 回 值 : ERROR_SUCCESS ---- 执行成功 ws_new_soap_fault---- 执行失败 ----------------------------------------------------------------------------- 最近一次修改记录: 修改作者: ninglijun 修改目的: 生成新函数 修改日期: 2012年09月14日 *****************************************************************************/ int ws__getPoeIlimit(WS_ENV* ws_env, struct ws__getPoeIlimitResponse * ret) { drv_poe_dev_info_s * dev_info = NULL; struct PoeIlimit * wspoeilimit = NULL; s32 res,i,num; s8 buff[32]; dev_info = (drv_poe_dev_info_s*)ws_malloc(ws_env, sizeof(drv_poe_dev_info_s)); if (NULL == dev_info) { return ws_send_soap_error(ws_env, poe_error_str(ERR_POE_FAIL_MALLOC)); } res = poe_syscall_get_poe_dev_info(dev_info); if(ERROR_SUCCESS != res) { return ws_send_soap_error(ws_env, poe_error_str(ERR_POE_FAIL_SYSCALL)); } num = dev_info->poe_port_cust_ilimit_valid_num; ret->ret.sum = dev_info->poe_port_cust_ilimit_valid_num; ret->ret.res_USCOREcount = dev_info->poe_port_cust_ilimit_valid_num; ret->ret.__size = dev_info->poe_port_cust_ilimit_valid_num; wspoeilimit = (struct PoeIlimit *)ws_malloc(ws_env, num * sizeof(struct PoeIlimit)); if (NULL == wspoeilimit) { return ws_send_soap_error(ws_env, poe_error_str(ERR_POE_FAIL_MALLOC)); } for(i = 0 ; i < num ; i++) { snprintf(buff,sizeof(buff),"%d",(dev_info->poe_port_cust_ilimit_value[i] / 1000)); wspoeilimit[i].poeIlimitVlaue= ws_strdup(ws_env, buff); wspoeilimit[i].count = i; } ret->ret.__ptrres = wspoeilimit; return ERROR_SUCCESS; }
s32 ws__getAvSigsType(WS_ENV *soap, struct ws__getAvSigsListType *ret) { sqlite3 *dba_con = NULL; sqlite3_res dba_res = NULL; u32 count = 0; u32 i = 0; s8 *tmp = NULL; struct AvSigsType *Info = NULL; dba_con = sqlite3_open_ex(1, AV_DESC_DBFILE); if (NULL == dba_con) { return WS_OK; } snprintf(g_sqlite_sql_buf, sizeof(g_sqlite_sql_buf), "SELECT COUNT(*) AS count FROM tb_av_description_category;"); sqlite3_exec_query_ex(dba_con, g_sqlite_sql_buf, &dba_res); sqlite3_get_u32_ex(dba_res, 0, "count", &count); ret->ret.sum = (s32)count; ret->ret.res_USCOREcount = ret->ret.__size = (s32)count; if(0 == count) { goto label_ret; } Info = (struct AvSigsType *)ws_malloc(soap, count * sizeof(struct AvSigsType)); if(NULL == Info) { goto label_ret; } ret->ret.__ptrres = Info; sqlite3_res_free_ex(dba_res); dba_res = NULL; snprintf(g_sqlite_sql_buf, sizeof(g_sqlite_sql_buf), "SELECT * FROM tb_av_description_category;"); sqlite3_exec_query_ex(dba_con, g_sqlite_sql_buf, &dba_res); for(i = 0; i < count; i++) { sqlite3_get_s32_ex(dba_res, (s32)i, "category_id", &Info[i].value); sqlite3_get_str_ex(dba_res, (s32)i, "category_name", &tmp); Info[i].name= ws_strdup(soap, tmp); } label_ret: sqlite3_res_free_ex(dba_res); dba_res = NULL; sqlite3_close_ex(dba_con); dba_con = NULL; return WS_OK; }
/****************************************************************************** 函数名称: ws__mldEnableIfGet 功能描述: 取得mld显示信息 输入参数: ret:结果集 输出参数: ret:结果集 返 回 值: 0表示返回成功 -------------------------------------------------------------------------------- 最近一次修改记录 : 修改作者: 刘晓贺 修改目的: 新生成函数 修改日期: 2011-2-14 *******************************************************************************/ s32 ws__mldEnableIfGet(WS_ENV * ws_env, struct ws__getIp6McastMldEnableIfResponse *ret) { s32 i = 0; s32 num = 0; s8 *ifname = NULL; s32 result = 0; sqlite3 *db = NULL; sqlite3_res res = NULL; struct Ip6McastMldEnableIf *data = NULL; db = sqlite3_open_ex(1, IP_MC_CFG_DB); if(NULL == db) { return ws_send_soap_error(ws_env, "open basic db failed!"); } result = sqlite3_exec_query_ex(db, "select count(*) as count from tb_basic_interface_info;", &res); if(SQLITE_OK != result) { sqlite3_close_ex(db); return ws_send_soap_error(ws_env, "sqlite3_exec_query_ex error!"); } /*获取当前数据库中的记录数*/ sqlite3_get_s32_ex(res, 0, "count", &num); /*释放结果集,多次查询时,每次都需要释放*/ sqlite3_res_free_ex(res); res = NULL; data = (struct Ip6McastMldEnableIf *)ws_malloc(ws_env, num * sizeof(struct Ip6McastMldEnableIf)); result = sqlite3_exec_query_ex(db, "select * from tb_basic_interface_info;", &res); if(SQLITE_OK != result) { sqlite3_close_ex(db); return ws_send_soap_error(ws_env, "sqlite3_exec_query_ex error!"); } for(i = 0; i < num; i++) { sqlite3_get_str_ex(res, i, "ifname", &ifname); data[i].ifname = ws_strdup(ws_env, ifname); } /*释放结果集,多次查询时,每次都需要释放*/ sqlite3_res_free_ex(res); res = NULL; sqlite3_close_ex(db); ret->ret.sum = num; ret->ret.res_USCOREcount = num; ret->ret.__size = num; ret->ret.__ptrres = data; return SQLITE_OK; }
/* 最近日志、操作日志查询共用 */ void netctrlmsg_pre_translate(UserOperate_t* user_op, ResultContext_t *result_context ) { WS_ENV* ws_env; struct uo_netctrlmsg_t *my_data; (void)ResultContext__getWsEnv(result_context, &ws_env); my_data = (struct uo_netctrlmsg_t*)ws_malloc(ws_env, sizeof(struct uo_netctrlmsg_t)); memset(my_data, 0, sizeof(struct uo_netctrlmsg_t)); UserOperate__setUserData(user_op, my_data); my_data->rowid = 1; }
/***************************************************************************** 函 数 名: ws__setLevelEnable 功能描述: 下发优先级开关 输入参数: ws_env ---- web service执行环境 levelEnable ----优先级开关 输出参数: 返 回 值: ERR_OK ---- 执行成功 ws_new_soap_fault---- 执行失败 ----------------------------------------------------------------------------- 最近一次修改记录: 修改作者: ninglijun 修改目的: 生成新函数 修改日期: 2012年10月9日 *****************************************************************************/ int ws__setLevelEnable(WS_ENV* ws_env,xsd__int levelEnable ,xsd__int* ret) { s32 res; u32 enable; poe_config_s * poe_config = NULL; u32 num; /*从数据库中取值*/ res = poe_dba_get_level_enable(&enable); if(levelEnable != enable) { /*更新数据库*/ res = poe_dba_update_poe_level_enable(levelEnable); if (ERROR_SUCCESS != res) { return ws_send_soap_error(ws_env, poe_error_str(ERR_POE_FAIL_UPDATE_DBA)); } if(UNENABLE == levelEnable) { system("/bin/kill -9 `/sbin/pidof poe_bin`"); res = poe_dba_get_poe_config_count(&num);//获取端口数 if(ERROR_SUCCESS != res) { return ws_send_soap_error(ws_env, poe_error_str(ERR_POE_FAIL_GET_DBA)); } poe_config = (poe_config_s *)ws_malloc(ws_env, num * sizeof(poe_config_s)); if (NULL == poe_config) { return ws_send_soap_error(ws_env, poe_error_str(ERR_POE_FAIL_MALLOC)); } res = poe_dba_get_poe_config(poe_config , num);//从数据库中提取配置信息 if(ERROR_SUCCESS != res) { return ws_send_soap_error(ws_env, poe_error_str(ERR_POE_FAIL_GET_DBA)); } res = poe_syscall_port_power_on(num,poe_config); if(ERROR_SUCCESS != res) { return ws_send_soap_error(ws_env, poe_error_str(ERR_POE_FAIL_SYSCALL)); } } else { system("/usr/bin/poe_bin"); } } return ERROR_SUCCESS; }
/******************************************************************************* 函数名称 : ip6_pf_export_pre_translate 功能描述 : 地址配置的导出 输入参数 : user_op ---- user_opetate结构 result_context ---- 结果集 输出参数 : 无 返 回 值 : 无 -------------------------------------------------------------------------------- 最近一次修改记录: 修改作者 : 吕进 修改目的 : 新添加函数 修改日期 : 2010.9.13 *******************************************************************************/ void ip6_pf_export_pre_translate(UserOperate_t* user_op, ResultContext_t *result_context ) { WS_ENV* ws_env; struct uo_pf_policy_export * my_data = NULL; LONGIN_USER_INFO user; u32 count = 0; sqlite3 *db; sqlite3_res res; (void)ResultContext__getWsEnv(result_context, &ws_env); my_data = (struct uo_pf_policy_export*)ws_malloc(ws_env, sizeof(struct uo_pf_policy_export)); memset((void *)my_data, 0, sizeof(struct uo_pf_policy_export)); /*初始化数据*/ server_set_type_octet(); server_set_download_filename("ip6_pf_export.csv"); /*要打开下载的文件*/ /*取当前用户信息*/ if(OK == login_get_current_user_info(&user)) /*获取用户信息*/ { my_data->language = user.language; } else { my_data->language = LANGUAGE_ENGLISH; } db = sqlite3_open_ex(1, IP6_PF_DB); if ( SQLITE_OK != sqlite3_exec_query_ex(db, "select count(*) AS count FROM "IP6_PF_POLICY_TABLE, &res)) { goto label_ret; } if ( SQLITE_OK != sqlite3_get_u32_ex(res, 0, "count", &count)) { goto label_ret; } server_set_length(count * 1000 * 2); my_data->offset = 0; my_data->count = -1; label_ret: sqlite3_res_free_ex(res); /* 关闭数据库连接 */ sqlite3_close_ex(db); UserOperate__setUserData(user_op, my_data); }
s32 ws__getweekinfo(WS_ENV * soap,struct ws__weektimeinfo *ret) { time_t timestart; time_t timeend; struct tm tm; struct week_info * info; s32 i = 0; s8 tmp[40]; ret->ret.sum=0; ret->ret.__size=0; ret->ret.res_USCOREcount=0; ret->ret.__ptrres=NULL; info = ws_malloc(soap,sizeof(struct week_info)*SAVEWEEK); if(NULL == info) { return WS_OK; } time(×tart); localtime_r(×tart,&tm); timestart = timestart - tm.tm_wday * DAY_TO_SEC; timestart = timestart/DAY_TO_SEC*DAY_TO_SEC; for(i = 0;i <SAVEWEEK;i++) { localtime_r(×tart,&tm); info[i].weeknum = tm.tm_yday/WEEK_DAYS + 1; info[i].weekyear=tm.tm_year+1900; strftime(tmp,sizeof(tmp),"%Y-%m-%d",&tm); info[i].weekstart = ws_strdup(soap,tmp); timeend = timestart + (WEEK_DAYS-1)* DAY_TO_SEC; localtime_r(&timeend,&tm); strftime(tmp,sizeof(tmp),"%Y-%m-%d",&tm); info[i].weekend = ws_strdup(soap,tmp); info[i].timestart = timestart; timestart-=WEEK_DAYS*DAY_TO_SEC; } ret->ret.sum=SAVEWEEK; ret->ret.__size=SAVEWEEK; ret->ret.res_USCOREcount=SAVEWEEK; ret->ret.__ptrres=info; return WS_OK; }
/***************************************************************************** 函 数 名: ws__setPoeInfo 功能描述: 将页面poe数据信息下发到数据库 输入参数: ws_env ---- web service执行环境 portLevel0 ----优先级为0的端口索引 portLevel1 ----优先级为1的端口索引 portLevel2 ----优先级为2的端口索引 输出参数: 返 回 值: ERR_OK ---- 执行成功 ws_new_soap_fault---- 执行失败 ----------------------------------------------------------------------------- 最近一次修改记录: 修改作者: ninglijun 修改目的: 生成新函数 修改日期: 2012年8月30日 *****************************************************************************/ int ws__setPoeInfo(WS_ENV* ws_env,xsd__string portLevelIfname0, xsd__string portLevelIfname1,xsd__string portLevelIfname2,xsd__int* ret) { s32 res; poe_msg_s data; poe_info_s * poe_info = NULL; poe_info = (poe_info_s*)ws_malloc(ws_env, sizeof(poe_info_s)); if (NULL == poe_info) { return ws_send_soap_error(ws_env, poe_error_str(ERR_POE_FAIL_MALLOC)); } /*从数据库端口poe索引信息 ,然后显示到页面*/ res = poe_dba_get_poe_info(poe_info); if(ERROR_SUCCESS != res) { return ws_send_soap_error(ws_env, poe_error_str(ERR_POE_FAIL_GET_DBA)); } if((strcmp (poe_info->portLevelIfname0, portLevelIfname0) != 0)|| (strcmp (poe_info->portLevelIfname1, portLevelIfname1) != 0)|| (strcmp (poe_info->portLevelIfname2, portLevelIfname2) != 0)) { /*更新数据库*/ res = poe_dba_update_poe_info_level(0, portLevelIfname0); if (ERROR_SUCCESS != res) { return ws_send_soap_error(ws_env, poe_error_str(ERR_POE_FAIL_UPDATE_DBA)); } res = poe_dba_update_poe_info_level(1, portLevelIfname1); if (ERROR_SUCCESS != res) { return ws_send_soap_error(ws_env, poe_error_str(ERR_POE_FAIL_UPDATE_DBA)); } res = poe_dba_update_poe_info_level(2, portLevelIfname2); if (ERROR_SUCCESS != res) { return ws_send_soap_error(ws_env, poe_error_str(ERR_POE_FAIL_UPDATE_DBA)); } /*给deamon进程发cmd ,重新创建list*/ data.msg_cmd = MSG_POE_HAVE_SENDED; res = poe_list_send(&data); if (ERROR_SUCCESS != res) { return ws_send_soap_error(ws_env, poe_error_str(ERR_POE_FAIL_SEND_DATA)); } } return ERROR_SUCCESS; }
s32 ws__getBgpAggInfo(WS_ENV * ws_env,s32 afi, s32 safi, s32 nstart, s32 nsize, struct BgpAggInfoRespone * ret ) { struct BgpAggInfo * out = NULL; web_bgp_aggregate_info_t * info = (void*)buff; s32 count ,i ; s32 sum = 0 , max = 0; u8 iptrans[INET6_ADDRSTRLEN]; u8 *ipret=NULL; if( socket_api_write(WEB_BGP_APICMD_GET_AGG,NULL,0) < 0 ) return ws_send_soap_error(ws_env,"send command error!"); do{ count = socket_api_read(WEB_BGP_APICMD_GET_AGG,info,SOCKET_API_BUFFER_SIZE); if( count <= 0 ) { break; } if( max < sum + count ) { void * tmp = ws_malloc(ws_env,(sum + count)*sizeof(struct BgpAggInfo)); if( out != NULL ) { memcpy(tmp,out,sum * sizeof(struct BgpAggInfo)); ws_free(ws_env,out); } out = tmp ; max = sum + count ; } for(i=0;i<count;i++) { ipret = (u8*)inet_ntop((s32)info[i].p.family,(void*)&info[i].p.u,(s8*)iptrans,INET6_ADDRSTRLEN); if( ipret == NULL ) continue; out[sum].addr = ws_strdup(ws_env,(s8*)ipret); out[sum].mask = info[i].p.prefixlen; out[sum].sonly= info[i].summary_only; out[sum].asset=info[i].as_set; sum++; } }while( ! socket_api_check_flag(SOCKET_API_FLAG_LASTONE) ); ret->ret.sum = sum ; ret->ret.__ptrres = out ; ret->ret.__size = sum ; ret->ret.res_USCOREcount = sum ; return WS_OK; }
/******************************************************************************* 函数名称 : menu_pre_translate 功能描述 : 动态替换预处理 输入参数 : user_op ---- user_opetate结构 输出参数 : 无 返 回 值 : 无 -------------------------------------------------------------------------------- 最近一次修改记录 : 修改作者 : 聂耀龙 修改目的 : 兼容radius认证 修改日期 : 2010年6月24日 *******************************************************************************/ void menu_pre_translate(struct UserOperate* user_op, ResultContext_t *result_context) { WS_ENV* ws_env; MENU_TRANS * my_data = NULL; LONGIN_USER_INFO current_user; char file[256] = {0}; (void)ResultContext__getWsEnv(result_context, &ws_env); my_data = (MENU_TRANS *) ws_malloc(ws_env, sizeof(MENU_TRANS)); if(NULL == my_data) { return; } if(OK != login_get_current_user_info(¤t_user)) { /*获取当前用户信息失败,退出*/ return; } my_data->usergroup = current_user.group; memset(my_data->res_current, 0, sizeof(my_data->res_current)); memset(my_data->pos_current, 0, sizeof(my_data->pos_current)); memset(my_data->id_parent, 0, sizeof(my_data->id_parent)); my_data->id_parent[0] = "0";/*顶层节点的父节点定义*/ if(GROUP_IS_DEFAULT(my_data->usergroup)) { my_data->tablename = "tb_sys_group_menu"; } else { my_data->tablename = "tb_user_group_menu"; } if( 0 == login_get_current_user_vfw_id()) { snprintf(file, sizeof(file),"%s/menu.sql.%d_%d_%d", CACHE_FILE_PATH, current_user.group, current_user.language, 0); } else { snprintf(file, sizeof(file),"%s/menu.sql.%d_%d_%d", CACHE_FILE_PATH, current_user.group, current_user.language, 1); } UserOperate__setUserData(user_op, my_data); UserOperate__setCacheFile(user_op, file); return; }
void rule_new_export_pre_translate(UserOperate_t* user_op, ResultContext_t *result_context ) { WS_ENV* ws_env; struct uo_policy_list_t *my_data; (void)ResultContext__getWsEnv(result_context, &ws_env); my_data = (struct uo_policy_list_t*)ws_malloc(ws_env, sizeof(struct uo_policy_list_t)); memset((void *)my_data, 0, sizeof(struct uo_policy_list_t)); server_set_type_octet(); server_set_download_filename("rule_new.csv"); UserOperate__setUserData(user_op, my_data); }
/******************************************************************************* 函数名称 : local_user_info_pre_translate 功能描述 : 本地用户信息的导出 输入参数 : user_op ---- user_opetate结构 result_context ---- 结果集 输出参数 : 无 返 回 值 : 无 -------------------------------------------------------------------------------- 最近一次修改记录: 修改作者 :仇俊杰 修改目的 :新添加函数 修改日期 :2010.12.26 *******************************************************************************/ void local_user_info_pre_translate(UserOperate_t* user_op, ResultContext_t *result_context ) { WS_ENV* ws_env; struct uo_local_user_export * my_data = NULL; s8 sql_query_count[128]; s32 ret = 0; u32 count = 0; sqlite3_res res = NULL; sqlite3 *db; (void)ResultContext__getWsEnv(result_context, &ws_env); my_data = (struct uo_local_user_export*)ws_malloc(ws_env, sizeof(struct uo_local_user_export)); memset((void *)my_data, 0, sizeof(struct uo_local_user_export)); /*初始化数据*/ server_set_type_octet(); server_set_download_filename("local_user_info_export.csv"); /*要打开下载的文件*/ db = sqlite3_open_ex(1, LOCAL_USER_INFO_DB); snprintf(sql_query_count, sizeof(sql_query_count), "select count(*) AS count FROM tb_pam_user;"); ret = sqlite3_exec_query_ex(db, sql_query_count, &res); if ( SQLITE_OK != ret ) { goto label_ret; } if ( SQLITE_OK != (ret = sqlite3_get_u32_ex(res, 0, "count", &count)) ) { goto label_ret; } server_set_length(count * LOCAL_USER_EXPORT_PER_USER_LENGTH); my_data->offset = 0; my_data->count = count; label_ret: /* 释放结果集 */ sqlite3_res_free_ex(res); res = NULL; /* 关闭数据库连接 */ sqlite3_close_ex(db); UserOperate__setUserData(user_op, my_data); }
s32 ws__showBgpNeighbor(WS_ENV * ws_env,s32 afi, s32 safi,s32 nstart, s32 nsize,struct BgpShowNeighborResponse * ret) { s8 temp[SU_ADDRSTRLEN]; s32 count = 0 , i = 0; s32 sum = 0 ; s32 max = 0; struct BgpShowNeighbor * out = NULL; web_bgp_neighbor_show_info_t * info = (void*)buff; if( socket_api_write(WEB_BGP_APICMD_SHOW_NBR,NULL,0) < 0 ) return ws_send_soap_error(ws_env,"send command error!"); do{ count = socket_api_read(WEB_BGP_APICMD_SHOW_NBR,info,SOCKET_API_BUFFER_SIZE); if( count <= 0 ) { break; } if( max < sum + count ) { void * tmp = ws_malloc(ws_env,(sum + count)*sizeof(struct BgpShowNeighbor)); if( out != NULL ) { memcpy(tmp,out,sum * sizeof(struct BgpShowNeighbor)); ws_free(ws_env,out); } out = tmp ; max = sum + count ; } for(i=0;i<count;i++) { out[sum].hostip = ws_strdup(ws_env, sockunion2str(&(info[i].su), temp, SU_ADDRSTRLEN) ) ; out[sum].asid = info[i].asid ; out[sum].hostid = ws_strdup(ws_env,inet_ntoa(info[i].id)); out[sum].state = ws_strdup(ws_env,bgp_status_msg[(s32)info[i].state]); out[sum].localinterface = ws_strdup(ws_env,inet_ntoa(info[i].nexthop)); out[sum].uptime = ws_strdup(ws_env,web_time_dump(info[i].t_uptime)); out[sum].overtime = ws_strdup(ws_env,web_time_dump(info[i].t_dead)); sum++; } }while( ! socket_api_check_flag(SOCKET_API_FLAG_LASTONE) ); ret->ret.sum = sum ; ret->ret.__ptrres = out ; ret->ret.__size = sum ; ret->ret.res_USCOREcount = sum ; return WS_OK; }
/***************************************************************************** 函 数 名 : ws__delMonitorLink 功能描述 : 删除一条smartlink信息 输入参数 : uplinkPort ---- 上行端口字符串 输出参数 : 返 回 值 : WS_OK ---- 执行成功 else ---- 执行失败 ----------------------------------------------------------------------------- 最近一次修改记录: 修改作者: wuyang 修改目的: 生成新函数 修改日期: 2011年09月19日 *****************************************************************************/ int ws__delMonitorLink(WS_ENV* soap, xsd__string uplinkPort, xsd__int* ret) { u32 sys_error_code; u32 ul_str_len; s32 i; s32 ul_count = 0; s8* solo_str; s8* saveptr; s32* port_list; sys_error_code = smart_link_dba_del_monitor_link(uplinkPort); DEBUG_F("db del, ret:%d.\n",sys_error_code); if (ERROR_SUCCESS != sys_error_code) { return ws_send_soap_error(soap, smart_link_error_str(sys_error_code)); } ul_str_len = strlen(uplinkPort); for (solo_str = strtok_r(uplinkPort, ",", &saveptr); NULL != solo_str; solo_str = strtok_r(NULL, ",", &saveptr)) { ul_count++; } port_list = (s32*)ws_malloc(soap, sizeof(s32)*(ul_count)); if (NULL == port_list) { return ws_send_soap_error(soap, smart_link_error_str(ERR_SMART_LINK_FAIL_MALLOC)); } for (i = 0; i < ul_str_len; i++) { if (uplinkPort[i] == '\0') { uplinkPort[i] = ','; } } for (solo_str = strtok_r(uplinkPort, ",", &saveptr), i = 0; NULL != solo_str; solo_str = strtok_r(NULL, ",", &saveptr), i++) { port_list[i] = atoi(solo_str); } sys_error_code = smart_link_del_monitor_link(port_list, ul_count); DEBUG_F("kernel del, ret:%d.\n",sys_error_code); if (ERROR_SUCCESS != sys_error_code) { return ws_send_soap_error(soap, smart_link_error_str(sys_error_code)); } return WS_OK; }
/***************************************************************************** �� �� �� : macauth_user_info_pre_translate �������� : Ԥ���� ������� : user_op ---- user_opetate�ṹ result_context ---- ����� ������� : �� �� �� ֵ : ERROR_SUCCESS,ִ�гɹ� -------------------------------------------------------------------------------- ���һ���ļ�¼: ������: ��Ⱥ ��Ŀ��: �����º��� ������: 2011-8-30 *****************************************************************************/ void macauth_user_info_pre_translate(UserOperate_t* user_op, ResultContext_t *result_context ) { WS_ENV* ws_env; struct local_user_search_name *my_data; (void)ResultContext__getWsEnv(result_context, &ws_env); /*��ʼ������*/ server_set_type_octet(); my_data = ws_malloc(ws_env, sizeof(struct macauth_user_search_name)); memset(my_data, 0, sizeof(struct macauth_user_search_name)); server_set_download_filename("mac_auth_user_info_export.csv"); /*Ҫ�����ص��ļ�*/ UserOperate__setUserData(user_op, my_data); }
/***************************************************************************** 函 数 名 : systeminfo_pre_translate 功能描述 : systeminfo预定义 输入参数 : user_op ---- user_opetate结构 result_context ---- 结果集 输出参数 : 无 返 回 值 : WS_OK ---- 执行成功 调用函数 : 被调函数 : ============================================================================ 修改历史 : 1.日 期 : 2008年8月8日 修改内容 : 新生成函数 *****************************************************************************/ void systeminfo_pre_translate(UserOperate_t* user_op, ResultContext_t *result_context ) { WS_ENV* ws_env; struct uo_systeminfo_t * my_data = NULL; time_t timebegin; (void)ResultContext__getWsEnv(result_context, &ws_env); my_data = (struct uo_systeminfo_t*)ws_malloc(ws_env, sizeof(struct uo_systeminfo_t)); memset(my_data, 0, sizeof(struct uo_systeminfo_t)); UserOperate__setUserData(user_op, my_data); flux_option_init(&my_data->flux_opt); time(&timebegin); my_data->time=timebegin-TIME_BUF_NUM*SSA_FIRSTPAGE_INTERVAL_TIME; }
void vsm_pre_translate(UserOperate_t* user_op, ResultContext_t *result_context ) { WS_ENV* ws_env; struct uo_vsm_info_t* my_data; u32 dev_vsm_id; s32 sys_error_code; (void)ResultContext__getWsEnv(result_context, &ws_env); my_data = (struct uo_vsm_info_t*)ws_malloc(ws_env, sizeof(struct uo_vsm_info_t)); UserOperate__setUserData(user_op, my_data); /*得到当前状态的vsm id信息*/ sys_error_code = vsm_syscall_get_vsm_id(&dev_vsm_id); my_data->dev_vsm_id = dev_vsm_id; }
/******************************************************************************* 函数名称 : addrpool_export_pre_translate 功能描述 : 地址池导出 输入参数 : user_op ---- user_opetate结构 result_context ---- 结果集 输出参数 : 无 返 回 值 : 无 -------------------------------------------------------------------------------- 最近一次修改记录: 修改作者 : 沈大铭 修改目的 : 新添加函数 修改日期 : 2012年2月27日 *******************************************************************************/ void addrpool_export_pre_translate(UserOperate_t* user_op, ResultContext_t *result_context) { WS_ENV* ws_env; struct uo_addrpool_export * my_data = NULL; LONGIN_USER_INFO user; s32 ret = 0; s32 count = 0; sqlite3 *db; (void)ResultContext__getWsEnv(result_context, &ws_env); my_data = (struct uo_addrpool_export*)ws_malloc(ws_env, sizeof(struct uo_addrpool_export)); memset((void *)my_data, 0, sizeof(struct uo_addrpool_export)); /*初始化数据*/ server_set_type_octet(); server_set_download_filename("addrpool.csv"); /*要打开下载的文件*/ /*取当前用户信息*/ if(OK == login_get_current_user_info(&user)) /*获取用户信息*/ { my_data->language = user.language; } else { my_data->language = LANGUAGE_ENGLISH; } db = sqlite3_open_ex(1,SQLITE_CONFIG_DIR"/addrpool_cfg.db"); if ( ERROR_SUCCESS != (ret = addrpool_get_db_value_s32(db,"select count(*) AS count FROM tb_nat_addrpool", "count", &count))) { goto label_ret; } server_set_length(count * 1000 * 2); my_data->offset = 0; my_data->count = -1; label_ret: /* 关闭数据库连接 */ sqlite3_close_ex(db); db = NULL; UserOperate__setUserData(user_op, my_data); }
/******************************************************************************* 函数名称 : vfwmode_pre_translate 功能描述 : vfw配置导出 输入参数 : user_op ---- user_opetate结构 result_context ---- 结果集 输出参数 : 无 返 回 值 : 无 -------------------------------------------------------------------------------- 最近一次修改记录: 修改作者 :wangchangtao 修改目的 :新添加函数 修改日期 :2012.2.2 *******************************************************************************/ void vfwmode_pre_translate(UserOperate_t* user_op, ResultContext_t *result_context ) { WS_ENV* ws_env; PAGECTRL *my_data = NULL; s8 sql_query_count[128]; s32 ret = 0; u32 count = 0; sqlite3_res res = NULL; sqlite3 *db; (void)ResultContext__getWsEnv(result_context, &ws_env); my_data = ( PAGECTRL *)ws_malloc(ws_env, sizeof( PAGECTRL)); memset((void *)my_data, 0, sizeof( PAGECTRL)); //初始化数据 server_set_type_octet(); server_set_download_filename("vfwmode_config_export.csv"); //要打开下载的文件 db = sqlite3_open_ex(1, "/config/db/vfw_cfg.db"); snprintf(sql_query_count, sizeof(sql_query_count), "select count(*) AS count FROM tb_vfw;"); ret = sqlite3_exec_query_ex(db, sql_query_count, &res); if ( SQLITE_OK != ret ) { goto label_ret; } if ( SQLITE_OK != (ret = sqlite3_get_u32_ex(res, 0, "count", &count)) ) { goto label_ret; } server_set_length(count * 16 * 1024); //保证足够空间导出每个虚拟防火墙里1024个接口名称。 label_ret: // 释放结果集 sqlite3_res_free_ex(res); res = NULL; // 关闭数据库连接 sqlite3_close_ex(db); UserOperate__setUserData(user_op, my_data); }
void session_keep_pre_translate(UserOperate_t* user_op, ResultContext_t *result_context ) { WS_ENV* ws_env; const char * para; struct uo_session_keep_t * my_data = NULL; (void)ResultContext__getWsEnv(result_context, &ws_env); my_data = (struct uo_session_keep_t*)ws_malloc(ws_env, sizeof(struct uo_session_keep_t)); memset(my_data, 0, sizeof(struct uo_session_keep_t)); if (HTTP_PARA_FOUND == http_parameter_get("nodeid", ¶)) { my_data->nodeid = (s32)atoi(para); } UserOperate__setUserData(user_op, my_data); }
void ping_pre_translate(UserOperate_t* user_op, ResultContext_t *result_context ) { WS_ENV* ws_env; const char * para; struct uo_net_tool_s *my_data = NULL; (void)ResultContext__getWsEnv(result_context, &ws_env); my_data = (struct uo_net_tool_s*)ws_malloc(ws_env, sizeof(struct uo_net_tool_s)); memset(my_data, 0, sizeof(struct uo_net_tool_s)); my_data->id = 0; if (HTTP_PARA_FOUND == http_parameter_get("vrflist", ¶)) { my_data->id = (s32)atoi(para); } UserOperate__setUserData(user_op, my_data); }
void *ws_f_malloc(WsFastMalloc *pool, size_t size) { unsigned char *result; /* Keep the blocks aligned, because this function is used to allocate * space for structures containing longs and such. */ if (size % sizeof(long) != 0) { size += sizeof(long) - (size % sizeof(long)); } if (pool->size < size) { size_t alloc_size; WsFastMallocBlock *b; /* Must allocate a fresh block. */ alloc_size = pool->block_size; if (alloc_size < size) alloc_size = size; /* Allocate the block and remember to add the header size. */ b = ws_malloc(alloc_size + sizeof(WsFastMallocBlock)); if (b == NULL) /* No memory available. */ return NULL; /* Add this block to the memory pool. */ b->next = pool->blocks; pool->blocks = b; pool->ptr = ((unsigned char *) b) + sizeof(WsFastMallocBlock); pool->size = alloc_size; } /* Now we can allocate `size' bytes of data from this pool. */ result = pool->ptr; pool->ptr += size; pool->size -= size; pool->user_bytes_allocated += size; return result; }